code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def unbind(self, format, ): <NEW_LINE> <INDENT> return utils.lib.zsock_unbind(self._p, format, ) | Unbind a socket from a formatted endpoint.
Returns 0 if OK, -1 if the endpoint was invalid or the function
isn't supported. | 625941ec66656f66f7cbc6c0 |
def clicked(self): <NEW_LINE> <INDENT> modifiers = QtGuiWidgets.QApplication.keyboardModifiers() <NEW_LINE> if modifiers == QtCore.Qt.ShiftModifier: <NEW_LINE> <INDENT> channel = self.sender().text() <NEW_LINE> if channel in self.shuffle_list: <NEW_LINE> <INDENT> self.shuffle_list.remove(channel) <NEW_LINE> self.sender... | Route click events based on key modifier. | 625941eccc40096d61595e61 |
def integer_id(self): <NEW_LINE> <INDENT> if self.__reference is None: <NEW_LINE> <INDENT> id = self.id() <NEW_LINE> if not isinstance(id, int): <NEW_LINE> <INDENT> id = None <NEW_LINE> <DEDENT> return id <NEW_LINE> <DEDENT> elem = self.__reference.path().element(-1) <NEW_LINE> return elem.id() or None | Return the integer id in the last (kind, id) pair, if any.
Returns:
An integer id, or None if the key has a string id or is incomplete. | 625941ecbe383301e01b598e |
def _build_flow_dict(G, R, capacity, weight): <NEW_LINE> <INDENT> inf = float('inf') <NEW_LINE> flow_dict = {} <NEW_LINE> if G.is_multigraph(): <NEW_LINE> <INDENT> for u in G: <NEW_LINE> <INDENT> flow_dict[u] = {} <NEW_LINE> for v, es in G[u].items(): <NEW_LINE> <INDENT> flow_dict[u][v] = dict( (k, (0 if (u != v or e.g... | Build a flow dictionary from a residual network.
| 625941ec435de62698dfe160 |
def get_entity(db: SQLAlchemy, id: str) -> EntityOut: <NEW_LINE> <INDENT> db_session = db.session_class() <NEW_LINE> entry = repository.get_entity(db_session, id) <NEW_LINE> if not entry: <NEW_LINE> <INDENT> raise exc.NotFound() <NEW_LINE> <DEDENT> return EntityOut(entry) | Get and entity by id. | 625941eca05bb46b383ecd2f |
def iterate_files(files, fast=False): <NEW_LINE> <INDENT> from json import loads <NEW_LINE> if fast: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> from ujson import loads <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> <DEDENT> if isinstance(files, str): <NEW_LINE> <INDENT> files = [files] <NEW_... | Loop over all the records of the provided Shodan output file(s). | 625941ec4527f215b584c965 |
def test_state_vector_single_time(requests_mock, params_sv, response_sv, results_sv): <NEW_LINE> <INDENT> sv = StateVector(**params_sv) <NEW_LINE> requests_mock.post(JPL_URL + '/calculation/new', json=response_sv) <NEW_LINE> requests_mock.get( JPL_URL + '/calculation/' + response_sv['calculationId'], json=response_sv) ... | Run state vector calculation on JPL API. | 625941eca05bb46b383ecd30 |
def proton_split(line): <NEW_LINE> <INDENT> result = [] <NEW_LINE> indqs = False <NEW_LINE> pending_comma = False <NEW_LINE> res = "" <NEW_LINE> for i in range(len(line)): <NEW_LINE> <INDENT> c = line[i] <NEW_LINE> if c == '\"': <NEW_LINE> <INDENT> if pending_comma: <NEW_LINE> <INDENT> res += ',' <NEW_LINE> pending_com... | Split a log line into fields.
* allow commas and spaces in quoted strings.
* split on ', ' and on ' '.
strip trailing commas between fields.
* quoted fields must have both quotes
:param line:
:return: | 625941ec3d592f4c4ed1d572 |
def _lcm(a: int, b: int) -> int: <NEW_LINE> <INDENT> return a * b // _gcd(a, b) | Return lowest common multiple. | 625941ecde87d2750b8602ab |
def replace(self, **kwargs): <NEW_LINE> <INDENT> return self._replace(**kwargs) | Exposes the underlying namedtuple replace. | 625941ecbf627c535bc136e2 |
def save_data(df, database_filename): <NEW_LINE> <INDENT> engine = create_engine('sqlite:///'+database_filename) <NEW_LINE> df.to_sql('dataset', engine, index=False) | save df into sqlite db
param: df
param: database_filename
return: None | 625941ecb5575c28eb68e518 |
def clean(self): <NEW_LINE> <INDENT> if len(self.recipient) <= 8: <NEW_LINE> <INDENT> self.recipient = '%s%s' % (DEFAULT_INTERNATIONAL_PREFIX, self.recipient) | Ensure the recipient has an international prefix. | 625941ec8a43f66fc4b54573 |
def exclude_vendors_with_high_minimums(self, choice_parts: "List[ChoicePart]", excluded_vendor_names: Dict[str, None], reduced_vendor_messages: List[str]) -> None: <NEW_LINE> <INDENT> order: Order = self <NEW_LINE> vendor_minimums: Dict[str, float] = order.vendor_minimums <NEW_LINE> tracing: str = tracing_get() <NEW_LI... | *Order*: Sweep through *choice* parts and figure out if the
vendors with large minimum orders can be dropped: | 625941ec293b9510aa2c37a4 |
def parse_rules(self, conf): <NEW_LINE> <INDENT> a_lst = [ "ipsec", "log", "action", "protocol", "fragment", "disable", "description", "icmp", ] <NEW_LINE> rule = self.parse_attr(conf, a_lst) <NEW_LINE> r_sub = { "p2p": self.parse_p2p(conf), "tcp": self.parse_tcp(conf, "tcp"), "icmp": self.parse_icmp(conf, "icmp"), "ti... | This function triggers the parsing of 'rule' attributes.
a_lst is a list having rule attributes which doesn't
have further sub attributes.
:param conf: configuration
:return: generated rule configuration dictionary. | 625941eca934411ee3751ba8 |
def __init__(self, mu, sigma, g, g_jac, h, h_jac, R=0., Q=0.): <NEW_LINE> <INDENT> self.mu = mu <NEW_LINE> self.sigma = sigma <NEW_LINE> self.mu_init = mu <NEW_LINE> self.sigma_init = sigma <NEW_LINE> self.g = g <NEW_LINE> self.g_jac = g_jac <NEW_LINE> self.R = R <NEW_LINE> self.h = h <NEW_LINE> self.h_jac = h_jac <NEW... | :param mu: prior mean
:param sigma: prior covariance
:param g: process function
:param g_jac: process function's jacobian
:param h: measurement function
:param h_jac: measurement function's jacobian
:param R: process noise
:param Q: measurement noise | 625941ec94891a1f4081bfbf |
def validate_response_format(self, expected, response): <NEW_LINE> <INDENT> JsonValidator(self._is_response).validate(expected, response) | Validates the response against the expected format
Args:
expected (dict): expected response format
response (dict): response of the endpoint | 625941ecbaa26c4b54cb162d |
def borrar_todos(self): <NEW_LINE> <INDENT> listSocio = self.todos() <NEW_LINE> if listSocio: <NEW_LINE> <INDENT> for i in listSocio: <NEW_LINE> <INDENT> self.baja(i.id) <NEW_LINE> <DEDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | Borra todos los socios de la base de datos.
Devuelve True si el borrado fue exitoso.
:rtype: bool | 625941ec283ffb24f3c55e0f |
def fsa_to_fst(fsa, separator=''): <NEW_LINE> <INDENT> retval = hfst.HfstBasicTransducer(fsa) <NEW_LINE> encoded_symbols = libhfst.StringSet() <NEW_LINE> for state in retval.states(): <NEW_LINE> <INDENT> arcs = retval.transitions(state) <NEW_LINE> for arc in arcs: <NEW_LINE> <INDENT> input = arc.get_input_symbol() <NEW... | (Experimental)
Decode an encoded automaton back into a transducer, i.e. create a
transducer where each transition <inSout:inSout> of *fsa*, where 'S' is
the first *separator* found in the compound symbol 'inSout', is replaced
with a transition <in:out>.
If no *separator* is found in the symbol, transition is copied a... | 625941ec1f037a2d8b946710 |
def get_values(self): <NEW_LINE> <INDENT> return self.cell_values | Returns a numpy array of cell values | 625941ec5fcc89381b1e1bd6 |
def normalize_gauss_global(co_occ): <NEW_LINE> <INDENT> mu = np.mean(co_occ) <NEW_LINE> sigma = np.std(co_occ) <NEW_LINE> if sigma != 0: <NEW_LINE> <INDENT> return (co_occ - mu)/sigma <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return co_occ - mu | Normalize the full matrix with respect to its global standard deviation and mean (X <- (X - mean) / std).
Args:
* ``co_occ`` (*ndarray*): input matrix.
Returns:
* ``normalized`` (*ndarray*): normalized matrix. | 625941ec23849d37ff7b359e |
def list(self, detailed=True, response_key = True, **kwargs): <NEW_LINE> <INDENT> if detailed is True: <NEW_LINE> <INDENT> if response_key : <NEW_LINE> <INDENT> return self._get("/snapshots/detail", "snapshots", **kwargs) <NEW_LINE> <DEDENT> else : <NEW_LINE> <INDENT> return self._get("/snapshots/detail", **kwargs) <NE... | Get a list of all snapshots.
:rtype: list of :class:`Snapshot` | 625941ec167d2b6e312190a8 |
def gene2ensembl(): <NEW_LINE> <INDENT> out = 'ncbi/gene2ensembl.gz' <NEW_LINE> out = io.get_output_path(out) <NEW_LINE> io.ensure_absence_of_file(out) <NEW_LINE> io.ensure_presence_of_directory(out) <NEW_LINE> stored_locations = downloader.download_data_set('gene2ensembl') <NEW_LINE> if len(stored_locations) == 1: <NE... | Will download gene2ensembl, and format it for further usage
- adhere to science of science naming conventions | 625941ec9f2886367277ad9c |
def _gt(self): <NEW_LINE> <INDENT> code = self._stack_to_D() <NEW_LINE> code += 'A=A-1'+'\n' <NEW_LINE> code += 'D=M-D'+'\n' <NEW_LINE> code += self._D_is_EGL_0('JGT') <NEW_LINE> code += '@SP'+'\n' <NEW_LINE> code += 'A=M-1'+'\n' <NEW_LINE> code += 'M=D'+'\n' <NEW_LINE> return code | Generates code for:
comparing two values from the stack, and
putting the result back on the stack.
The result is true (-1) if second is greater, false (0) otherwise.
output:
code in Hack Assembly | 625941ec004d5f362079a843 |
def has_flag(self, flagname): <NEW_LINE> <INDENT> import tempfile <NEW_LINE> with tempfile.NamedTemporaryFile('w', suffix='.cpp') as f: <NEW_LINE> <INDENT> f.write('int main (int argc, char **argv) { return 0; }') <NEW_LINE> try: <NEW_LINE> <INDENT> self.compile([f.name], extra_postargs=[flagname]) <NEW_LINE> <DEDENT> ... | Return whether a flag name is supported on the specified compiler. | 625941ec6aa9bd52df0372bb |
def _on_after_delete(self, **kwargs): <NEW_LINE> <INDENT> if self.has_field('images'): <NEW_LINE> <INDENT> for img in self.images: <NEW_LINE> <INDENT> img.delete() | Hook
| 625941ecc432627299f0515d |
def test_main_with_users(self): <NEW_LINE> <INDENT> add_user('john', 'john@doe.com', 'testingpassword') <NEW_LINE> add_user('michael', 'michael@montreal.com', 'testingpassword') <NEW_LINE> with self.client: <NEW_LINE> <INDENT> response = self.client.get('/') <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_L... | Ensure the main route behaves correctly when users have been
added to the database. | 625941ec60cbc95b062c6a57 |
def get_uint8(self, fail_value=0): <NEW_LINE> <INDENT> s = self.read_size(1) <NEW_LINE> return self._unpack('B', s) if s else fail_value | Extract and return a uint8_t from the current file position. | 625941ec4f6381625f114f4f |
def test_work_flow5(self): <NEW_LINE> <INDENT> pass | refund before shipping the product: create product order -> pay -> request refund -> provider ships the product (no refund) -buyer confirms
| 625941ec26068e7796caf1fb |
def delete_floating_ip(self, ip_id): <NEW_LINE> <INDENT> return self.call_nw_plugin_function('delete_floating_ip',{'ip_id':ip_id}) | Deletes the given floating IP
parameters
----------
ip_id : string
UUID of the floating IP
returns
-------
dictionary | 625941ec96565a6dacc8fbdd |
def setState(valueList, isCurrent, keyVar=None, stateWdg=stateWdg, timerWdg=timerWdg): <NEW_LINE> <INDENT> severity = { "Done": RO.Constants.sevNormal, "Moving": RO.Constants.sevWarning, "Homing": RO.Constants.sevWarning, "Failed": RO.Constants.sevError, "NotHomed": RO.Constants.sevError, None: RO.Constants.sevWarning,... | Callback for <mir>State; used to set state widgets for the appropriate mirror
| 625941ec15fb5d323cde102b |
def delete_vtep_endpoint(self, interface_uuid, mac_address): <NEW_LINE> <INDENT> self._execute_vtep_request( lambda: self.client.vxlan.remove(interface_uuid, mac_address)) | Sends a request to the vswitch requesting the deletion of a static
VTEP Endpoint entry. | 625941ec85dfad0860c3b370 |
def prune(self): <NEW_LINE> <INDENT> pass | Take some effort to optimize. Used before being
cached | 625941ec187af65679ca5633 |
def is_point_in_volumes(volumes, point): <NEW_LINE> <INDENT> for vol in volumes: <NEW_LINE> <INDENT> bb = bounding_box_world(vol[0]) <NEW_LINE> if is_point_in_bounding_box(bb,point): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> return False | Returns true if the point is in one of the volumes | 625941ec66673b3332b925a5 |
def rollback_cluster_upgrade( self, timeout=60, custom_headers=None, raw=False, **operation_config): <NEW_LINE> <INDENT> api_version = "6.0" <NEW_LINE> url = self.rollback_cluster_upgrade.metadata['url'] <NEW_LINE> query_parameters = {} <NEW_LINE> query_parameters['api-version'] = self._serialize.query("api_version", a... | Roll back the upgrade of a Service Fabric cluster.
Roll back the code or configuration upgrade of a Service Fabric
cluster.
:param timeout: The server timeout for performing the operation in
seconds. This timeout specifies the time duration that the client is
willing to wait for the requested operation to complete.... | 625941ecfbf16365ca6f66e2 |
def is_topbuttons_required(num): <NEW_LINE> <INDENT> if hasattr(settings, 'TOP_BUTTONS_REQUIRED'): <NEW_LINE> <INDENT> return num >= settings.TOP_BUTTONS_REQUIRED <NEW_LINE> <DEDENT> return False | Bridge templates and settings in terms if display top buttons | 625941ec6fb2d068a760f5b9 |
def test_023_message__name_get(self): <NEW_LINE> <INDENT> protected = {'jwk' : {'n' : 'n'}, 'url' : 'http://tester.local/acme/revokecert'} <NEW_LINE> self.message.dbstore.account_lookup.return_value = {'bar' : 'foo'} <NEW_LINE> self.assertEqual(None, self.message._name_get(protected)) | test Message.name_get() with 'jwk' and correct 'url' and wrong account lookup data | 625941ec99fddb7c1c9de8a2 |
def process_image(image): <NEW_LINE> <INDENT> pil_image = Image.open(image) <NEW_LINE> pil_image.load() <NEW_LINE> if pil_image.size[1] > pil_image.size[0]: <NEW_LINE> <INDENT> pil_image.thumbnail((256, 5000)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> pil_image.thumbnail((5000, 256)) <NEW_LINE> <DEDENT> size = pil_... | Takes a PIL input, makes some formatting changes and then converts it to a numpy array | 625941ecbaa26c4b54cb162e |
def is_valid_mirror(self, uri): <NEW_LINE> <INDENT> if uri == None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> elif re.match("^((ftp)|(http)|(file)|(rsync)|(https))://([a-z]|[A-Z]|[0-9]|:|/|\.|~)+$", uri) == None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return True | Check if a given uri is a vaild one | 625941ecdd821e528d63b6b8 |
def test_hls_video_with_youtube_delayed_response_time(self): <NEW_LINE> <INDENT> self.youtube_configuration.update({ 'time_to_response': 7.0, }) <NEW_LINE> self.metadata = self.metadata_for_mode('html5_and_hls', additional_data={'youtube_id_1_0': 'b7xgknqkQk8'}) <NEW_LINE> self.navigate_to_video() <NEW_LINE> self.asser... | Scenario: HLS video is rendered when the YouTube API response time is slow
Given the YouTube server response time is greater than 1.5 seconds
And the course has a Video component with Youtube, HTML5 and HLS sources available
Then the HLS video is rendered | 625941eccc0a2c11143dd3a5 |
def setNumBlocks(self, value): <NEW_LINE> <INDENT> self.paramMap[self.numUserBlocks] = value <NEW_LINE> self.paramMap[self.numItemBlocks] = value | Sets both :py:attr:`numUserBlocks` and :py:attr:`numItemBlocks` to the specific value. | 625941ec32920d7e50b286e8 |
def _GenerateProject(project, options, version, generator_flags): <NEW_LINE> <INDENT> default_config = _GetDefaultConfiguration(project.spec) <NEW_LINE> if default_config.get('msvs_existing_vcproj'): <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> return _GenerateMSBuildProject(project, options, version, generator_fl... | Generates a vcproj file.
Arguments:
project: the MSVSProject object.
options: global generator options.
version: the MSVSVersion object.
generator_flags: dict of generator-specific flags.
Returns:
A list of source files that cannot be found on disk. | 625941ec379a373c97cfb05b |
def handle_endtag(self, tag): <NEW_LINE> <INDENT> if tag == "script" and self.script_stack is not None: <NEW_LINE> <INDENT> self.script_stack = None <NEW_LINE> <DEDENT> elif tag in self.in_: <NEW_LINE> <INDENT> self.in_[tag.lower()] = False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> row = "</%s>" % tag <NEW_LINE> se... | Intercepts the end of a tag.
@param tag tag | 625941ec4f88993c3716c575 |
def is_number(x): <NEW_LINE> <INDENT> print (x) <NEW_LINE> amountOfDots = 0 <NEW_LINE> for n in x: <NEW_LINE> <INDENT> if n == ".": <NEW_LINE> <INDENT> amountOfDots +=1 <NEW_LINE> <DEDENT> if amountOfDots > 1: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> if x[0]=="-": <NEW_LINE> <INDENT> x = x[1:] <NEW... | Finding out if the input is a number | 625941ec656771135c3ebd89 |
def Learn(x): <NEW_LINE> <INDENT> if x>=4 and x<=5: <NEW_LINE> <INDENT> return "kindergarden" <NEW_LINE> <DEDENT> elif x>=6 and x<=14: <NEW_LINE> <INDENT> return "grade_school" <NEW_LINE> <DEDENT> elif x>=15 and x<=18: <NEW_LINE> <INDENT> return "grade_school" <NEW_LINE> <DEDENT> elif x>=19 and x<=21: <NEW_LINE> <INDEN... | This function get age of person and returns his status
for example: the age is 15 and the output is grade_school | 625941ecd18da76e235329f0 |
def get_speaker(self, speaker_url): <NEW_LINE> <INDENT> return self.api_request(speaker_url) | Given a speaker URL, return a dictionary containing
the speaker metadata.
:type speaker_url: String
:param speaker_url: the URL identifier of the speaker
:rtype: Dict
:returns: a dictionary containing the metadata fields describing
this speaker | 625941ec009cb60464c638c1 |
@pytest.mark.gen_test <NEW_LINE> def test_auth_admin_retained_if_unset(app): <NEW_LINE> <INDENT> name = 'kiwi' <NEW_LINE> user = add_user(app.db, app, name=name, admin=True) <NEW_LINE> assert user.admin is True <NEW_LINE> cookies = yield app.login_user(name) <NEW_LINE> assert user.admin is True | admin should be unchanged if authenticator doesn't return admin value | 625941ecb5575c28eb68e519 |
def _pause(self): <NEW_LINE> <INDENT> self._stop_button.state(['!pressed']) <NEW_LINE> self._pause_button.state(['pressed']) <NEW_LINE> self._play_button.state(['!pressed']) <NEW_LINE> self._stop_timer() <NEW_LINE> self._midi_player.pause() <NEW_LINE> self._update_playback_position() | Pause playback | 625941ec711fe17d82542873 |
def validate_configuration(configured_options): <NEW_LINE> <INDENT> required_options = [option for option, optionValue in config.config_options.iteritems() if optionValue["required"]] <NEW_LINE> if not all(rO in configured_options for rO in required_options): <NEW_LINE> <INDENT> Exception("Required options are not conf... | Reads user specified configurations, and determines if they've
configured all fields that are required. Otherwise the program will
throw an exception.
:param configured_options: The options that should be configured
for a particular playlist and subreddit.
:return: | 625941ec07f4c71912b11999 |
def get_parameters_N(): <NEW_LINE> <INDENT> rows_per_batch = 100 <NEW_LINE> num_servers = 9 <NEW_LINE> q = 6 <NEW_LINE> num_outputs = q <NEW_LINE> server_storage = 1/3 <NEW_LINE> num_partitions = 240 <NEW_LINE> num_outputs = 10*q <NEW_LINE> parameters = list() <NEW_LINE> for i in range(1, 11): <NEW_LINE> <INDENT> num_c... | Get a list of parameters for the N to n ratio plot. | 625941ecd7e4931a7ee9e433 |
def update(self, func: Callable) -> Callable: <NEW_LINE> <INDENT> def wrap(*args, **kwargs): <NEW_LINE> <INDENT> ret = func(*args, **kwargs) <NEW_LINE> if self.core: <NEW_LINE> <INDENT> self.core.doupdate() <NEW_LINE> <DEDENT> return ret <NEW_LINE> <DEDENT> return wrap | Decorator that only updates the screen | 625941ec4f88993c3716c576 |
def run_add_entry_process(): <NEW_LINE> <INDENT> add = Add_Menu() <NEW_LINE> add.show() <NEW_LINE> employee = get_employee() <NEW_LINE> clear_screen() <NEW_LINE> add.show() <NEW_LINE> date = get_date() <NEW_LINE> clear_screen() <NEW_LINE> add.show() <NEW_LINE> title = get_title() <NEW_LINE> clear_screen() <NEW_LINE> ad... | Creates new time entry and saves to database.
Obtains field information from user, creates new time entry object, and
then saves the entry's information into the database. | 625941eceab8aa0e5d26e06e |
def get_hack_mod(self, rank: Rank): <NEW_LINE> <INDENT> return rank.value * 0 | Returns zero for most clases | 625941ec097d151d1a22336b |
def encode_string(in_s, alphabet): <NEW_LINE> <INDENT> d1 = dict(enumerate(alphabet)) <NEW_LINE> d2 = {v: k for k, v in d1.items()} <NEW_LINE> return ( 'exec("".join(map(chr,[int("".join(str({}[i]) for i in x.split())) for x in\n' '"{}"\n.split(" ")])))\n'.format( pformat(d2), chunk_string( " ".join(" ".join(d1[int(i... | Convert input string to encoded output string with the given alphabet | 625941eccc40096d61595e62 |
def test_create_file(self): <NEW_LINE> <INDENT> workbook = Workbook(self.got_filename) <NEW_LINE> worksheet = workbook.add_worksheet() <NEW_LINE> chartsheet = workbook.add_chartsheet() <NEW_LINE> chart = workbook.add_chart({'type': 'bar'}) <NEW_LINE> chart.axis_ids = [61297792, 61299328] <NEW_LINE> data = [ [1, 2, 3, 4... | Test the worksheet properties of an XlsxWriter chartsheet file. | 625941ec7cff6e4e81117e99 |
def ComputeBoundingBox(self): <NEW_LINE> <INDENT> return _itkBoundingBoxPython.itkBoundingBoxUL3DMCULPD3_ComputeBoundingBox(self) | ComputeBoundingBox(self) -> bool | 625941ec0fa83653e46574cc |
def dehydrate(self, bundle): <NEW_LINE> <INDENT> if bundle.obj.point: <NEW_LINE> <INDENT> bundle.data['lat'] = bundle.obj.point.coords[1] <NEW_LINE> bundle.data['lon'] = bundle.obj.point.coords[0] <NEW_LINE> <DEDENT> bundle.data['image_uri'] = "/content/instance/%s-100x100.jpg" % bundle.data['uid'] <NEW_LINE> return bu... | Additional fields, not found in object, perhaps need some processing. | 625941ec7b25080760e3996a |
def test_show_event_closed_category_no_permission(self): <NEW_LINE> <INDENT> self.event.is_hidden = True <NEW_LINE> self.event.save() <NEW_LINE> self.override_acl({ 'can_hide_events': 1, 'can_close_threads': 0, }) <NEW_LINE> self.category.is_closed = True <NEW_LINE> self.category.save() <NEW_LINE> response = self.patch... | api show event in closed category with no permission fails | 625941ecd53ae8145f87a779 |
def run(self, spelling_query=None): <NEW_LINE> <INDENT> final_query = self.build_query() <NEW_LINE> kwargs = { 'start_offset': self.start_offset, } <NEW_LINE> if self.order_by: <NEW_LINE> <INDENT> kwargs['sort_by'] = self.order_by <NEW_LINE> <DEDENT> if self.end_offset is not None: <NEW_LINE> <INDENT> kwargs['end_offse... | Builds and executes the query. Returns a list of search results. | 625941ecfbf16365ca6f66e3 |
def key_sort_none(value: Optional[Any]) -> Any: <NEW_LINE> <INDENT> if value is None: <NEW_LINE> <INDENT> return MIN_VALUE <NEW_LINE> <DEDENT> return value | This function can be used as `key=` argument for sorted() and
.sort(), in order to sort values that can be of a certain type (e.g.,
str), or None, so that None is always lower.
We just need to replace None with MIN_VALUE, which is an object that
happily compares with anything, and is lower than anything. | 625941ecd99f1b3c44c67a99 |
def WriteData2(nn,aa,bb,output_file_path): <NEW_LINE> <INDENT> output_file = output_file_path.rstrip('\n') <NEW_LINE> outfile = open(output_file,"w") <NEW_LINE> for i in range (0, nn): <NEW_LINE> <INDENT> outfile.write(' %10.6e \t %8.4e \n' % (aa[i],bb[i])) <NEW_LINE> <DEDENT> outfile.close() | Write two columns of data to an external ASCII text file | 625941ec3539df3088e2e85f |
def turtlePlot(turtleCommands,color,system,iterations): <NEW_LINE> <INDENT> X0=np.array([0]) <NEW_LINE> Y0=np.array([0]) <NEW_LINE> d0=np.array([1,0]) <NEW_LINE> for i in range(np.size(turtleCommands)): <NEW_LINE> <INDENT> if i//2==i/2: <NEW_LINE> <INDENT> Li=turtleCommands[i] <NEW_LINE> if i==0: <NEW_LINE> <INDENT> Xi... | Takes an array of alternating lenghts and turns to plot a diagram
according to user defined colors, turtleCommands is an array of numbers,
color is a string, system is a string, iterations is an integer | 625941ecd53ae8145f87a77a |
def patch(self, body, raise_exc=True, headers=False): <NEW_LINE> <INDENT> return self._request(PATCH, body, raise_exc, headers) | Performs an HTTP PATCH to the server. This is a
non-idempotent call that may update all or a portion of the
resource this navigator is pointing to. The format of the
patch body is up to implementations.
`body` may either be a string or a dictionary representing json
`headers` are additional headers to send in the requ... | 625941ecb545ff76a8914329 |
def query_db_one(self, query, *args): <NEW_LINE> <INDENT> for e in self.conn.execute(query, tuple(args)): <NEW_LINE> <INDENT> if len(e) == 1: <NEW_LINE> <INDENT> return e[0] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return e <NEW_LINE> <DEDENT> break <NEW_LINE> <DEDENT> return None | Query the database and return one matching row as tuple or single object. | 625941ec3346ee7daa2b3284 |
def __init__(self, template, capacity, max_length, scope): <NEW_LINE> <INDENT> self._capacity = capacity <NEW_LINE> self._max_length = max_length <NEW_LINE> with tf.variable_scope(scope) as scope: <NEW_LINE> <INDENT> self._scope = scope <NEW_LINE> self._length = tf.Variable(tf.zeros(capacity, tf.int32), False) <NEW_LIN... | Create a memory that stores episodes.
Each transition tuple consists of quantities specified by the template.
These quantities would typically be be observartions, actions, rewards, and
done indicators.
Args:
template: List of tensors to derive shapes and dtypes of each transition.
capacity: Number of episodes, o... | 625941ecb57a9660fec33da0 |
def get_dates_wth_more_pct_errors(self, pct_errors): <NEW_LINE> <INDENT> dates = [] <NEW_LINE> with psycopg2.connect(dbname=self._dbname) as news_db: <NEW_LINE> <INDENT> with news_db.cursor() as cursor: <NEW_LINE> <INDENT> sql = DbReport._DATES_WITH_PCT_ERRORS_SQL <NEW_LINE> cursor.execute(sql, {"nok_pct": pct_errors})... | Report the dates which have more than the supplied percent of
response errors.
Returns a list of tuples in order of most error prone. The tuples
in the list contain date (as datetime), percentage of error requests
on that date, and total number of requests on that date.
Keyword arguments:
pct_errors -- the percentage... | 625941ecf8510a7c17cf9c14 |
def lowestCommonAncestor(self, root, p, q): <NEW_LINE> <INDENT> _,_,res = self.find(root, p, q) <NEW_LINE> return res | :type root: TreeNode
:type p: TreeNode
:type q: TreeNode
:rtype: TreeNode | 625941ecbd1bec0571d90b43 |
def test_should_be_resilient_to_empty_notebook(conf, work_dir): <NEW_LINE> <INDENT> output_path = join(work_dir, 'out.py') <NEW_LINE> notebook_path = gen_notebook(cells=[('code', 'print(\'poney\')')], tmp_dir=work_dir, file_name='test.ipynb', docstring=None) <NEW_LINE> export_to_script(input_notebook_path=notebook_path... | Test templating is resilient to empty Notebook, no exception. | 625941ec6fece00bbac2dc59 |
def get_or_create(self, index_name): <NEW_LINE> <INDENT> raise NotImplementedError | Get a Vertex Index or create it if it doesn't exist.
:param index_name: Index name.
:type index_name: str
:rtype: Index | 625941eccc0a2c11143dd3a6 |
def load_posts_reblogs(ids_with_reblogs, truncate_body=0): <NEW_LINE> <INDENT> post_ids = [r[0] for r in ids_with_reblogs] <NEW_LINE> reblog_by = dict(ids_with_reblogs) <NEW_LINE> posts = load_posts(post_ids, truncate_body=truncate_body) <NEW_LINE> for post in posts: <NEW_LINE> <INDENT> rby = set(reblog_by[post['post_i... | Given a list of (id, reblogged_by) tuples, return posts w/ reblog key. | 625941ec92d797404e3046a1 |
def to_dict(self, detail=False): <NEW_LINE> <INDENT> info = { 'bf_id': str(self.id), 'description': self.desc, 'participants': self.participants, 'status': self.status, 'winner': self.winner, 'time_left': self.time_left, 'fighters': [self.fighter0.to_dict(), self.fighter1.to_dict()], } <NEW_LINE> if detail: <NEW_LINE> ... | bf_id: 12345, //which battle field this is for
description: 'describe this battle field',
participants: 12300,
winner: 0/1,
time_left: 10800, // how many seconds this battle will be over
fighters: [{ // city 0
name: 'BJ',
current_photo: 'http://test.com/bj.jpg',
description: 'BJ is bla bla bla...',
blood: 10, // how m... | 625941ece5267d203edce1ab |
def __init__(self, hash_func, initsz=100, maxload=0.7): <NEW_LINE> <INDENT> self.cap = initsz <NEW_LINE> self.table = [None for _ in range(self.cap)] <NEW_LINE> self.numkeys = 0 <NEW_LINE> self.maxload = maxload <NEW_LINE> self.probes = 0 <NEW_LINE> self.collisions = 0 <NEW_LINE> self.hash_func = hash_func <NEW_LINE> s... | Creates an open-addressed hash map of given size and maximum load factor
:param initsz: Initial size (default 100)
:param maxload: Max load factor (default 0.7) | 625941ecbde94217f3683300 |
def test_set_price_per_kg_2(self): <NEW_LINE> <INDENT> argv = ['main.py', 'saopaulo', 'florianopolis', '50', '6'] <NEW_LINE> shipping = Shipping(TABLE1_NAME, argv) <NEW_LINE> shipping.kg = 'central' <NEW_LINE> set_price_per_kg = shipping.set_price_per_kg() <NEW_LINE> self.assertTrue(set_price_per_kg) | Shipping.set_price_per_kg should return True if any row matches the
following rule:
row['nome'] == self.kg
and float(row['inicial']) <= self.weight
and row['final'] != '' and self.weight < float(row['final']) | 625941ecf9cc0f698b140b0b |
def test_get_achievement_template(self): <NEW_LINE> <INDENT> pass | Test case for get_achievement_template
Get a single achievement template | 625941ec5166f23b2e1a566d |
def editevent (self, id, event, date = None, subject = None, usejournal = None, security = None, when = None, props = None): <NEW_LINE> <INDENT> self._logged_in () <NEW_LINE> assert type (event) == UnicodeType <NEW_LINE> assert subject is None or type (subject) == UnicodeType <NEW_LINE> args = self._required_headers (i... | editevent - Edit or delete a user's past journal entry
Modify an already created event. If fields are empty, it will delete
the event. | 625941ec1f037a2d8b946711 |
def _load_defaults(self): <NEW_LINE> <INDENT> defaults = None <NEW_LINE> if os.path.exists(os.path.join('policies', 'defaults.yml')): <NEW_LINE> <INDENT> defaults = self._read_file_yaml( os.path.join('policies', 'defaults.yml') ) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> paths = self._config.policy_source_paths <NEW... | Load a defaults.yml file from either the ``policies/`` subdirectory
or directories in the ``policy_source_paths`` configuration key. | 625941ecf8510a7c17cf9c15 |
def hasPermissionProject(user_id, project_id): <NEW_LINE> <INDENT> service = getAuthService() <NEW_LINE> try: <NEW_LINE> <INDENT> ret = service.auth.hasPermissionProject(project_id = project_id, user_id = user_id) <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> result = ret.ge... | 业务权限检查 | 625941ec63d6d428bbe44a05 |
@task <NEW_LINE> def lint(ctx): <NEW_LINE> <INDENT> print('Invoking :: PyLint :') <NEW_LINE> py_files = [] <NEW_LINE> for root, _, files in os.walk("."): <NEW_LINE> <INDENT> for file in files: <NEW_LINE> <INDENT> if file.endswith(".py"): <NEW_LINE> <INDENT> file_path = os.path.join(root, file) <NEW_LINE> py_files.appen... | Task to run PyLint over all python files within the project. | 625941ec6fb2d068a760f5ba |
def ebay(search_phrase, website='de', page=1): <NEW_LINE> <INDENT> options = webdriver.firefox.options.Options() <NEW_LINE> options.add_argument('-headless') <NEW_LINE> driver = webdriver.Firefox(options=options) <NEW_LINE> if page==1: <NEW_LINE> <INDENT> url = 'https://www.ebay.' + website + '/sch/i.html?_from=R40&_nk... | Gets all product images on website, calls exactly one page
Returns list containing dictionaries of image_id, image_url, thumbnail_url, image_name
:website: country identifier of url: de, com, co.uk.
:search_phrase: phrase that is entered on website for searching
:page: page of search results to crawl | 625941ec96565a6dacc8fbde |
def metropolis(population, n, p, c, Y): <NEW_LINE> <INDENT> fx = [0] * len(population) <NEW_LINE> fitness = [] <NEW_LINE> for i in range(len(population)): <NEW_LINE> <INDENT> fx[i], _ = total_benefit(population[i], n, p, c, Y) <NEW_LINE> <DEDENT> max_fx = max(fx) <NEW_LINE> avg_fx = mean(fx) <NEW_LINE> for i in range(l... | 适应度函数,构建目标函数和适应度值成正比的函数
:param population: 输入种群
:param n: 企业的个数
:param p: 企业间的收益情况
:param c: 企业加入平台的成本
:param Y: 补贴上限
:return: 返回种群的目标函数和适应度值 | 625941ece64d504609d74d54 |
def new_url(module): <NEW_LINE> <INDENT> url_base = "/axapi/v3/vcs-vblades/stat/{vblade-id}" <NEW_LINE> f_dict = {} <NEW_LINE> f_dict["vblade-id"] = "" <NEW_LINE> return url_base.format(**f_dict) | Return the URL for creating a resource | 625941ec287bf620b61d3f75 |
def theta_GMST1982(jd_ut1): <NEW_LINE> <INDENT> t = (jd_ut1 - T0) / 36525.0 <NEW_LINE> g = 67310.54841 + (8640184.812866 + (0.093104 + (-6.2e-6) * t) * t) * t <NEW_LINE> dg = 8640184.812866 + (0.093104 * 2.0 + (-6.2e-6 * 3.0) * t) * t <NEW_LINE> theta = (jd_ut1 % 1.0 + g * _second % 1.0) * tau <NEW_LINE> theta_dot = (1... | Return the angle of Greenwich Mean Standard Time 1982 given the JD.
This angle defines the difference between the idiosyncratic True
Equator Mean Equinox (TEME) frame of reference used by SGP4 and the
more standard Pseudo Earth Fixed (PEF) frame of reference.
From AIAA 2006-6753 Appendix C. | 625941ec4428ac0f6e5bad0b |
def new_url(**kwargs): <NEW_LINE> <INDENT> url_base = "/axapi/v3/debug/msg-proxy" <NEW_LINE> f_dict = {} <NEW_LINE> return url_base.format(**f_dict) | Return the URL for creating a resource | 625941ec4a966d76dd551529 |
def generate_samples(self): <NEW_LINE> <INDENT> filenames = glob_all(self.args.random_data_folder, '*.wav') <NEW_LINE> shuffle(filenames) <NEW_LINE> while True: <NEW_LINE> <INDENT> for fn in filenames: <NEW_LINE> <INDENT> for x, y in self.vectors_from_fn(fn): <NEW_LINE> <INDENT> yield x, y | Generate training samples (network inputs and outputs) | 625941ec2ae34c7f2600d645 |
def fallocate64(self, path, len): <NEW_LINE> <INDENT> return self.inner_cmd("fallocate64 %s %s" % (path, len)) | fallocate - preallocate a file in the guest filesystem
This command preallocates a file (containing zero bytes) named "path" of
size "len" bytes. If the file exists already, it is overwritten. | 625941ec38b623060ff0b302 |
def piptone(t, rt, Fs, F0, dBSPL, pip_dur, pip_start): <NEW_LINE> <INDENT> pip_pts = int(pip_dur * Fs) + 1 <NEW_LINE> pip_t = np.linspace(0, pip_dur, pip_pts) <NEW_LINE> pip = np.sqrt(2) * dbspl_to_pa(dBSPL) * np.sin(2*np.pi*F0*pip_t) <NEW_LINE> ramp_pts = int(rt * Fs) + 1 <NEW_LINE> ramp = np.sin(np.linspace(0, np.pi/... | Create a waveform with multiple sine-ramped tone pips. Output is in
Pascals.
Parameters
----------
t : array
array of time values
rt : float
ramp duration
Fs : float
sample rate
F0 : float
pip frequency
dBSPL : float
maximum sound pressure level of pip
pip_dur : float
duration of pip includin... | 625941ecc4546d3d9de72f4d |
def start(host="localhost", port=8080): <NEW_LINE> <INDENT> abs_app_dir_path = os.path.dirname(os.path.realpath(__file__)) <NEW_LINE> abs_views_path = os.path.join(abs_app_dir_path, "templates") <NEW_LINE> TEMPLATE_PATH.insert(0, abs_views_path) <NEW_LINE> run(host=host, port=port) <NEW_LINE> print(f"Running web-server... | Run the web server | 625941ec76e4537e8c351b8b |
def write_waveform_uint32( self, waveform_name: str, samples_to_write: int, data: [c_int32], check_error: bool = True ) -> int: <NEW_LINE> <INDENT> c_wvfm_name = c_char_p(waveform_name.encode('utf-8')) <NEW_LINE> error_code = self.hsdio.niHSDIO_WriteNamedWaveformU32( self.vi, c_wvfm_name, c_int32(samples_to_write), dat... | Transfers data from PC memory to the HSDIO's onboard memory.
Supported devices for this function depend on the data width of your device, not on the
number of assigned dynamic channels. This function may be used when the data width is 4.
If you specify a waveform_name not already allocated on the device, the appropr... | 625941ecd164cc6175783264 |
def fit(self, X, y): <NEW_LINE> <INDENT> X, y = check_X_y(X, y, dtype='float64') <NEW_LINE> (n_shapelets, window_sizes, window_steps, n_jobs, rng) = self._check_params(X, y) <NEW_LINE> X_new, scores, shapelets, indices = self._fit( X, y, n_shapelets, window_sizes, window_steps, self.remove_similar, n_jobs, rng ) <NEW_L... | Fit the model according to the given training data.
It finds the ``n_shapelets`` best shapelets in the training set.
Parameters
----------
X : array-like, shape = (n_samples, n_timestamps)
Univariate time series.
y : array-like, shape = (n_samples,)
Class labels for each data sample.
Returns
-------
self : ... | 625941ec851cf427c661aa1f |
def park(self): <NEW_LINE> <INDENT> logger.info("Parking the telescope") | Park the telescope | 625941ec31939e2706e4d377 |
def write_results(file_name, results): <NEW_LINE> <INDENT> with open(file_name, "a+") as f: <NEW_LINE> <INDENT> for result_i in results: <NEW_LINE> <INDENT> row_info = result_i[0] + " " + str(result_i[1]) <NEW_LINE> f.write(row_info) <NEW_LINE> f.write("\n") <NEW_LINE> <DEDENT> f.write("\n") | Opens the file and writes each result on a separate line
:inputs: file_name, results
:file_name: name of the file that the query is being written to
:results: the results from the query
:output: returns NONE | 625941ec7c178a314d6ef97d |
def input_date(self, name, var="", containers=None, pageId=None): <NEW_LINE> <INDENT> return self.input_line(name, 'string', var, containers, pageId=pageId) | Create a Date input field | 625941ec66656f66f7cbc6c2 |
def recalc_costs_losses(): <NEW_LINE> <INDENT> df['costs'] = float(0) <NEW_LINE> df['losses'] = float(0) <NEW_LINE> for r, c in df.iterrows(): <NEW_LINE> <INDENT> if c['capacity'] > 0: <NEW_LINE> <INDENT> hp_lab = c['hp_type'] <NEW_LINE> hp_p = df_hp[df_hp['label_3'] == hp_lab].squeeze() <NEW_LINE> if hp_p['nonconvex']... | Calculates the investment costs and thermal losses for each
pipeline of the district heating network.
(This recalculation could also serve as check for comparing the
total pipeline costs with the objective value of oemof.solph
optimisation model)
Note
----
With nonconvex investments (with binary variables) it could ha... | 625941ecbe383301e01b5990 |
@instances.command('start') <NEW_LINE> @click.option('--project', default=None, help="Only instances for project(tag project:<name>)") <NEW_LINE> def start_instances(project): <NEW_LINE> <INDENT> instances = filter_instances(project) <NEW_LINE> for i in instances: <NEW_LINE> <INDENT> print("Starting instance with id {0... | Start EC2 instances | 625941ec7047854f462a1918 |
def getListingEntry(self, width, currentTime, listingType): <NEW_LINE> <INDENT> return entries.ConnectionPanelLine.getListingEntry(self, width, currentTime, listingType) | Provides the [(msg, attr)...] listing for this relay in the circuilt
listing. Lines are composed of the following components:
<bracket> <dst> <etc> <placement label>
The dst and etc entries largely match their ConnectionEntry counterparts.
Arguments:
width - maximum length of the line
currentTime - the cu... | 625941ec56ac1b37e62646da |
@shared_task <NEW_LINE> def remove_old_periodic_data(): <NEW_LINE> <INDENT> now = datetime.utcnow() <NEW_LINE> expired = now - relativedelta(days=31) <NEW_LINE> TimeSeriesData.objects.filter(ts__lte=expired).delete() | Removes expired periodic_data from the db | 625941ecad47b63b2c50a494 |
def person_type(self): <NEW_LINE> <INDENT> return 'staff' | "Return a string representing the type of employee a person is this is | 625941ec7047854f462a1919 |
def test_empty_name(self): <NEW_LINE> <INDENT> data = { "name": "", "description": "some text", "expires_at": "12/12/2020 23:00", "max_messages": 1 } <NEW_LINE> form = CreateBoxForm(data) <NEW_LINE> self.assertEqual(form.is_valid(), False) | Name must be present | 625941ecbf627c535bc136e4 |
def labelize_data(y): <NEW_LINE> <INDENT> print("labelize_data") <NEW_LINE> i = 0 <NEW_LINE> numeric_labels = list() <NEW_LINE> for d in y: <NEW_LINE> <INDENT> if 'rndy' in d: <NEW_LINE> <INDENT> numeric_labels.append(1) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> numeric_labels.append(0) <NEW_LINE> <DEDENT> i += 1 <... | labellzza numericamente i nomi dei file
assegna 1 se è una caduta del manichino, 0 altrimenti
:param y:
:return: | 625941ecab23a570cc25069c |
def max_sharpe(self, solver=None, solver_options=None, verbose=True, risk_free_rate=0.02): <NEW_LINE> <INDENT> if solver_options == None: <NEW_LINE> <INDENT> solver_options = {} <NEW_LINE> <DEDENT> self.y = cp.Variable(shape=self.n) <NEW_LINE> self.k = cp.Variable() <NEW_LINE> self.objective = cp.quad_form(self.y, self... | Maximum Sharpe Ratio Optimisation
:param solver: type of cvxpy solver to use, default None
:type solver: str
:param solver_options: dict of solver options for cvxpy
:type solver_options: dict()
:param verbose: whether to print steps
:type verbose: boolean
:param risk_free_rate: risk free rate parameter, default to 0.0... | 625941ec6fece00bbac2dc5a |
def reselect(self, event=None): <NEW_LINE> <INDENT> if self.selIdx is not None: <NEW_LINE> <INDENT> self.dmListDisp.selection_set(self.selIdx) <NEW_LINE> self.dmListDisp.event_generate('<<ListboxSelect>>') | Return selection focus to a dm after an action is completed. | 625941ec94891a1f4081bfc1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.