code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def test_class_map(): <NEW_LINE> <INDENT> make_class_map_data() <NEW_LINE> config_template_path = join(config_dir, 'test_class_map.template.cfg') <NEW_LINE> config_path = fill_in_config_paths(config_template_path) <NEW_LINE> run_configuration(config_path, quiet=True, local=True) <NEW_LINE> with open(join(output_dir, 't... | Test class maps | 625941dfd10714528d600038 |
def get_gps(): <NEW_LINE> <INDENT> return [6.928318, 79.8881236] | return gps value | 625941dfd4950a0f3b08c69c |
def add_child(self, new_segment): <NEW_LINE> <INDENT> new_polygon = new_segment.polygon <NEW_LINE> height = new_segment.height <NEW_LINE> leaf = InclusionTree(new_polygon, height) <NEW_LINE> self.children.append(leaf) <NEW_LINE> return leaf | "
add new child with polygon contained in provided segment. | 625941df4c3428357757c677 |
def parse_args(argv): <NEW_LINE> <INDENT> parser = build_parser(argv[0]) <NEW_LINE> if not parser: <NEW_LINE> <INDENT> return None, None <NEW_LINE> <DEDENT> (options, args) = parser.parse_args(argv[1:]) <NEW_LINE> gbp.log.setup(options.color, options.verbose, options.color_scheme) <NEW_LINE> if options.download: <NEW_L... | Parse commandline arguments | 625941dfff9c53063f47c543 |
def add_creatable(self, line: GenieGameEntityGroup) -> None: <NEW_LINE> <INDENT> if not self.contains_creatable(line.get_head_unit_id()): <NEW_LINE> <INDENT> self.creates.append(line) | Adds another line to the list of creatables.
:param line: The GenieBuildingLineGroup the villager produces. | 625941df287bf620b61d3db3 |
def calculate_total_playback(self): <NEW_LINE> <INDENT> if self.survey.get('survey_id') == self.qcas_survey_id: <NEW_LINE> <INDENT> all_acquisitions_questions = self.qcas_machinery_acquisitions_questions + self.qcas_other_acquisitions_questions <NEW_LINE> total_machinery_acquisitions = sum(Decimal(value) for q_code, va... | For QCAS:
Calculates the total value for both acquisitions and proceeds from disposals for machinery and equipment section
as well as all sections.
q_code - 692 - Total value of all acquisitions questions.
q_code - 693 - Total value of all disposals questions.
q_code - 714 - Total value of all acquisitions questions fo... | 625941df090684286d50f03b |
def OnOwnerChanged(self,*args): <NEW_LINE> <INDENT> pass | OnOwnerChanged(self: ToolStripItem,e: EventArgs)
Raises the System.Windows.Forms.ToolStripItem.OwnerChanged event.
e: An System.EventArgs that contains the event data. | 625941df8c3a87329515870f |
def resize_disabled(): <NEW_LINE> <INDENT> return getattr(project_settings, 'ALOHA_RESIZE_DISABLED', False) | return settings or default | 625941df851cf427c661a85e |
def set_pnp_id(self, pnp_id): <NEW_LINE> <INDENT> assert isinstance(pnp_id, PnpId) <NEW_LINE> value = pnp_id.encode().value <NEW_LINE> self.set(PnpIdCharacteristic, value) | :type pnp_id: PnpId | 625941dfcc0a2c11143dd1e2 |
def aggregate(self, alpha = []): <NEW_LINE> <INDENT> if len(alpha) < len(self.reg): <NEW_LINE> <INDENT> for i in range(len(self.reg)-len(alpha)): <NEW_LINE> <INDENT> alpha.append(1) <NEW_LINE> <DEDENT> <DEDENT> self.alpha = alpha <NEW_LINE> self.y_hat = [] <NEW_LINE> for i in range(len(self.X_test)): <NEW_LINE> <INDENT... | Ensembles (Weighted Bagging/Bootstrap-Aggregation) all the predictions | 625941df3617ad0b5ed68248 |
def un_re_say(self, irc, msg, regex): <NEW_LINE> <INDENT> text = regex["sentence"] <NEW_LINE> text = text.capitalize() + "!" <NEW_LINE> self.log.info(f'say: msg:|{msg}|, regex:|{regex}| -> |{text}|') <NEW_LINE> irc.reply(text, prefixNick=False) | ^say (?P<sentence>.*$) | 625941df4f6381625f114d8d |
def test_log_interp_vv_speed_and_space(self): <NEW_LINE> <INDENT> rr,pp = funct_log_mesh(1024, 0.01, 200.0) <NEW_LINE> lgi = log_interp_c(rr) <NEW_LINE> gcs = np.array([1.2030, 3.2030, 0.7, 10.0, 5.3]) <NEW_LINE> ff = np.array([[np.exp(-gc*r**2) for r in rr] for gc in gcs]) <NEW_LINE> rrs = np.linspace(0.05, 250.0, 200... | Test the interpolation facility for an array arguments from the class log_interp_c | 625941df3eb6a72ae02ec837 |
def add_message(self, msg, count): <NEW_LINE> <INDENT> keepers = {} <NEW_LINE> for header in self._keepers: <NEW_LINE> <INDENT> keepers[header] = msg.get_all(header, []) <NEW_LINE> <DEDENT> for header in msg.keys(): <NEW_LINE> <INDENT> del msg[header] <NEW_LINE> <DEDENT> for header in self._keepers: <NEW_LINE> <INDENT>... | Add the message to the digest. | 625941df1b99ca400220ae04 |
def action(self, colony): <NEW_LINE> <INDENT> if self.impostor == True: <NEW_LINE> <INDENT> self.reduce_armor(self.armor) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ThrowerAnt.action(self, colony) <NEW_LINE> if not isinstance(colony.queen, QueenPlace): <NEW_LINE> <INDENT> colony.queen = QueenPlace(colony.queen, self... | A queen ant throws a leaf, but also doubles the damage of ants
in her tunnel.
Impostor queens do only one thing: reduce their own armor to 0. | 625941df167d2b6e31218ee6 |
def main(argv): <NEW_LINE> <INDENT> parser = argparse.ArgumentParser(description='This script extracts visual features from given images') <NEW_LINE> parser.add_argument('-i', '--imageDir', help="Path to the images", required=False) <NEW_LINE> parser.add_argument('-dd', '--dataDir', help='Data directory where data will... | Main function for running extract features script | 625941df15baa723493c42c9 |
def copy_param(target_link, source_link): <NEW_LINE> <INDENT> target_params = dict(target_link.namedparams()) <NEW_LINE> for param_name, param in source_link.namedparams(): <NEW_LINE> <INDENT> target_params[param_name].data[:] = param.data <NEW_LINE> <DEDENT> target_links = dict(target_link.namedlinks()) <NEW_LINE> for... | Copy parameters of a link to another link. | 625941dfd164cc61757830a0 |
def raster_to_shape(raster): <NEW_LINE> <INDENT> left = raster.bounds.left <NEW_LINE> right = raster.bounds.right <NEW_LINE> top = raster.bounds.top <NEW_LINE> bottom = raster.bounds.bottom <NEW_LINE> top_left = (left, top) <NEW_LINE> top_right = (right, top) <NEW_LINE> bottom_left = (left, bottom) <NEW_LINE> bottom_ri... | Take a raster and return a polygon representing the outer edge. | 625941dfa219f33f34628cb7 |
def get_playload_from_cocktail(cocktail): <NEW_LINE> <INDENT> payload = {'data': []} <NEW_LINE> table_bottle_slot_dict = [] <NEW_LINE> for bottle in cocktail.bottles.all(): <NEW_LINE> <INDENT> info = Cocktailinfo.objects.get(bottle=bottle, cocktail=cocktail) <NEW_LINE> bottle_slot_dict = {'slot_id': bottle.slot, 'volum... | Create a JSON payload from a cocktail model object
:param cocktail: Cocktail model
:return: JSON payload | 625941dfbde94217f368313f |
def get_client_obj(nodeid, client_obj_list: List[Client]) -> Client: <NEW_LINE> <INDENT> for client_obj in client_obj_list: <NEW_LINE> <INDENT> if nodeid == client_obj.node.node_id: <NEW_LINE> <INDENT> return client_obj | Get the client object according to the node id
:param nodeid:
:param client_obj_list:
:return: | 625941dfc432627299f04f9a |
def _get_instances(self, **kwargs): <NEW_LINE> <INDENT> reservations = self.ec2_connection.describe_instances(**kwargs).get('Reservations') <NEW_LINE> instances = list() <NEW_LINE> for reservation in reservations: <NEW_LINE> <INDENT> for instance in reservation.get("Instances"): <NEW_LINE> <INDENT> instances.append( EC... | Gets instance reservations and parses instance objects | 625941dfd53ae8145f87a5bc |
def get_data_loaders(args, tokenizer): <NEW_LINE> <INDENT> personachat = get_dataset(tokenizer, args.dataset_path, args.dataset_cache) <NEW_LINE> logger.info("Build inputs and labels") <NEW_LINE> datasets = {"train": defaultdict(list), "valid": defaultdict(list)} <NEW_LINE> for dataset_name, dataset in personachat.item... | Prepare the dataset for training and evaluation | 625941df91af0d3eaac9bd6d |
def loss_and_gradients(x, y, params): <NEW_LINE> <INDENT> y_pred, aggregation, activation = hidden_layers(x, params) <NEW_LINE> loss = -np.log(y_pred[y]) <NEW_LINE> grads = [] <NEW_LINE> y_one_hot = one_hot_vector(y, len(y_pred)) <NEW_LINE> dz = y_pred - y_one_hot <NEW_LINE> g = dz <NEW_LINE> layer_number = len(params)... | params: a list as created by create_classifier(...)
returns:
loss,[gW1, gb1, gW2, gb2, ...]
loss: scalar
gW1: matrix, gradients of W1
gb1: vector, gradients of b1
gW2: matrix, gradients of W2
gb2: vector, gradients of b2
...
(of course, if we request a linear classifier (ie, params is of length 2),
you should no... | 625941df30c21e258bdfa7f1 |
def _set_node_ref(self, v, load=False): <NEW_LINE> <INDENT> parent = getattr(self, "_parent", None) <NEW_LINE> if parent is not None and load is False: <NEW_LINE> <INDENT> raise AttributeError("Cannot set keys directly when" + " within an instantiated list") <NEW_LINE> <DEDENT> if hasattr(v, "_utype"): <NEW_LINE> <INDE... | Setter method for node_ref, mapped from YANG variable /networks/network/node/supporting_node/node_ref (leafref)
If this variable is read-only (config: false) in the
source YANG file, then _set_node_ref is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_no... | 625941dfe64d504609d74b91 |
def test_add_cron_right(self): <NEW_LINE> <INDENT> if self.total == 0: <NEW_LINE> <INDENT> self.assertEqual(0, self.cron.priority) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.assertEqual(1, self.cron2.priority) | Testing that the added crons have the right initial priority | 625941df71ff763f4b5499e3 |
def _mel_to_linear_matrix(): <NEW_LINE> <INDENT> m = _linear_to_mel_matrix() <NEW_LINE> m_t = np.transpose(m) <NEW_LINE> p = np.matmul(m, m_t) <NEW_LINE> d = [1.0 / x if np.abs(x) > 1.0e-8 else x for x in np.sum(p, axis=0)] <NEW_LINE> return np.matmul(m_t, np.diag(d)) | Get the inverse mel transformation matrix. | 625941df4428ac0f6e5bab46 |
def decode_union(self, data_type, obj): <NEW_LINE> <INDENT> val = None <NEW_LINE> if isinstance(obj, six.string_types): <NEW_LINE> <INDENT> tag = obj <NEW_LINE> if data_type.definition._is_tag_present(tag, self.caller_permissions): <NEW_LINE> <INDENT> val_data_type = data_type.definition._get_val_data_type( tag, self.c... | The data_type argument must be a Union.
See json_compat_obj_decode() for argument descriptions. | 625941dfe1aae11d1e74a00c |
def add_column(self, columns): <NEW_LINE> <INDENT> for key in sorted(list(columns.keys())): <NEW_LINE> <INDENT> self.dataSet[key] = columns[key] | Add columns to self.dataSet
:param columns: {'key_1':[values],...,'key_n:[values]}
:return: None | 625941dfa8370b7717052bf0 |
def test_more_complex_mappings(self): <NEW_LINE> <INDENT> keys = [ "!#!@AB89.[],/-+", "2f0j20j0j", "13r2ffs,,,,,,", "-n339ghhss8898v", "d" ] <NEW_LINE> values = [ "13r \n\t \r doo bE B", "waka waka waka", "What's all the fuss?!", "(a=3.5, b=4.5, c=11.2)", "\"some quoted string\"" ] <NEW_LINE> assert len(keys) == len(va... | This test creates some crazy key-value pairs with random amounts of
whitespace between them, and verifies that str-to-dict works in both
directions. | 625941df8e05c05ec3eea6c9 |
def _get_first_event_with_attribute(self, events): <NEW_LINE> <INDENT> first_event_time = time.time() + 1 <NEW_LINE> first_account = None <NEW_LINE> first_jid = None <NEW_LINE> first_event = None <NEW_LINE> for account in events: <NEW_LINE> <INDENT> for jid in events[account]: <NEW_LINE> <INDENT> for event in events[ac... | Get the first event
events is in the form {account1: {jid1: [ev1, ev2], },. } | 625941dfa05bb46b383ecb71 |
def test_execute_empty_user_id_raises_value_error(self): <NEW_LINE> <INDENT> u = self.__get_user() <NEW_LINE> self.assertRaises(ValueError, self.__target.execute, u) | Test that calling AddUserInteractor.execute with a null user_id raises a ValueError | 625941df293b9510aa2c35e4 |
def user_create_command(self): <NEW_LINE> <INDENT> pass | base function
:return: | 625941dfd164cc61757830a1 |
def run(self) -> None: <NEW_LINE> <INDENT> self.f_cpp = open(self.filename, "r", encoding="UTF-8") <NEW_LINE> if self.name == "td": <NEW_LINE> <INDENT> self.f_define = open(f"{self.prefix}_{self.name}_data_constant.py", "w", encoding="UTF-8") <NEW_LINE> <DEDENT> self.f_typedef = open(f"{self.prefix}_{self.name}_data_ty... | 主函数 | 625941dfad47b63b2c50a2d0 |
def format_bytes_to_human(size, precision=2): <NEW_LINE> <INDENT> size = int(size) <NEW_LINE> fmt = '%%1.%df %%s' % precision <NEW_LINE> for unit in ['B', 'KB', 'MB', 'GB', 'TB']: <NEW_LINE> <INDENT> if size < 1024.0: <NEW_LINE> <INDENT> return fmt % (size, unit) <NEW_LINE> <DEDENT> size /= 1024.0 | Format a byte value to a human readable representation (B, KB, MB...).
.. versionadded:: 1.0.8
:Parameters:
`size`: int
Number that represents the bytes value
`precision`: int, defaults to 2
Precision after the comma
Examples::
>>> format_bytes_to_human(6463)
'6.31 KB'
>>> format... | 625941dfbe7bc26dc91cd94c |
def on_escape_press(self, event): <NEW_LINE> <INDENT> self.tm.process_event(Event.pause_event()) <NEW_LINE> print('SHOW DIALOG') <NEW_LINE> return 'break' | Pause and show dialog on ESC. | 625941dfdd821e528d63b4f9 |
def get_data(self): <NEW_LINE> <INDENT> return self._data | Get data object. | 625941df8a349b6b435e84c5 |
def random_filter(puzzle_d, n_fixed): <NEW_LINE> <INDENT> fixed = copy.deepcopy(puzzle_d) <NEW_LINE> keys = list(fixed.keys()) <NEW_LINE> random.shuffle(keys) <NEW_LINE> indices = keys[:len(keys) - n_fixed] <NEW_LINE> for i in indices: <NEW_LINE> <INDENT> del fixed[i] <NEW_LINE> <DEDENT> return fixed | A puzzle dictionary of a random Sudoku puzzle of 'fixed' size
based on the Sudoku 'puzzle' dictionary. | 625941df91f36d47f21ac848 |
@check_resp_pait(response_model_list=[FileRespModel]) <NEW_LINE> def file_response_route() -> Response: <NEW_LINE> <INDENT> file_content: str = "Hello Word!" <NEW_LINE> with NamedTemporaryFile(delete=True) as f: <NEW_LINE> <INDENT> f.write(file_content.encode()) <NEW_LINE> f.seek(0) <NEW_LINE> _, f_path, f_filename = f... | test return file response | 625941df460517430c3944cf |
def tap_key(self, character='', n=1, interval=0): <NEW_LINE> <INDENT> for i in xrange(n): <NEW_LINE> <INDENT> self.press_key(character) <NEW_LINE> self.release_key(character) <NEW_LINE> time.sleep(interval) | Press and release a given character key n times. | 625941df4f88993c3716c3b7 |
def unlock(self): <NEW_LINE> <INDENT> if self.locked: <NEW_LINE> <INDENT> self.dbfile.flush() <NEW_LINE> portalocker.unlock(self.dbfile) <NEW_LINE> self.locked = False <NEW_LINE> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | unlock file, platform independence
:return: | 625941df0a366e3fb873eb6f |
def add_contours(self, img, filled=False, **kwargs): <NEW_LINE> <INDENT> self._map_show(img, type='contour', **kwargs) <NEW_LINE> if filled: <NEW_LINE> <INDENT> colors = kwargs['colors'] <NEW_LINE> levels = kwargs['levels'] <NEW_LINE> if len(levels) <= 1: <NEW_LINE> <INDENT> levels.append(np.inf) <NEW_LINE> <DEDENT> al... | Contour a 3D map in all the views.
Parameters
-----------
img: Niimg-like object
See http://nilearn.github.io/manipulating_images/manipulating_images.html#niimg.
Provides image to plot.
filled: boolean, optional
If filled=True, contours are displayed with color fillings.
kwargs:
Extra keyword arguments... | 625941df7047854f462a1758 |
def create(self): <NEW_LINE> <INDENT> return run_state_change( CreateFilesystem( device=self.api.get_device_path(self.volume.blockdevice_id), filesystem=self.filesystem_type ), self.deployer, InMemoryStatePersister(), ) | Create a filesystem on this scenario's volume.
:return: A ``Deferred`` which fires when the filesystem has been
created. | 625941dff9cc0f698b14094b |
def serialize(self, buff): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> _x = self <NEW_LINE> buff.write(_struct_5d.pack(_x.origin_x, _x.origin_y, _x.origin_angRob, _x.dest_x, _x.dest_y)) <NEW_LINE> _x = self.sensorBool <NEW_LINE> length = len(_x) <NEW_LINE> if python3 or type(_x) == unicode: <NEW_LINE> <INDENT> _x = _x... | serialize message into buffer
:param buff: buffer, ``StringIO`` | 625941df0a50d4780f6671e7 |
def get_over_width(element: int) -> float: <NEW_LINE> <INDENT> pass | _summary_
Args:
element (int): _description_
Returns:
float: _description_ | 625941dfab23a570cc2504d7 |
def _ensure_unicode(msg): <NEW_LINE> <INDENT> if not isinstance(msg, six.text_type): <NEW_LINE> <INDENT> if isinstance(msg, six.binary_type): <NEW_LINE> <INDENT> msg = encodeutils.safe_decode( msg, incoming='utf-8', errors='xmlcharrefreplace', ) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> msg = six.text_type(msg) <NE... | Do our best to turn the input argument into a unicode object.
| 625941df956e5f7376d711be |
@compatibility(is_backward_compatible=False) <NEW_LINE> def chain(*op_support: OperatorSupportBase) -> OperatorSupportBase: <NEW_LINE> <INDENT> def _chain(submods, node) -> bool: <NEW_LINE> <INDENT> return all( x.is_node_supported(submods, node) for x in op_support ) <NEW_LINE> <DEDENT> return create_op_support(_chain) | Combines a sequence of `OperatorSupportBase` instances to form a single `OperatorSupportBase`
instance by evaluating each input `OperatorSupportBase` instance, and returns False if
any of it reports False. | 625941df73bcbd0ca4b2c3c9 |
def request_matches_minimal(self, match_ids): <NEW_LINE> <INDENT> return self.send_job(EDOTAGCMsg.EMsgClientToGCMatchesMinimalRequest, {'match_ids': match_ids}) | Request matches with only minimal data.
:param match_ids: match ids
:type match_ids: :class:`list`
:return: job event id
:rtype: :class:`str`
Response event: ``matches_minimal``
:param matches: list of `CMsgDOTAMatchMinimal <https://github.com/ValvePython/dota2/blob/ca75440adca20d852b9aec3917e4387466848d5b/protobuf... | 625941df4428ac0f6e5bab47 |
def pc_noutput_items_var(self): <NEW_LINE> <INDENT> return _COWN_swig.syncher2_sptr_pc_noutput_items_var(self) | pc_noutput_items_var(syncher2_sptr self) -> float | 625941df7d847024c06be611 |
def build_from_json(self, json): <NEW_LINE> <INDENT> enabled = True <NEW_LINE> self._action_id = json['id'] <NEW_LINE> self._name = json['name'] <NEW_LINE> self._primitive_counter = json['primitive_counter'] <NEW_LINE> for primitive in json['seq']: <NEW_LINE> <INDENT> if primitive.has_key('arm_target'): <NEW_LINE> <IND... | Fills out action using information using json from db
Args:
dict : json/dict retrieved from couchdb | 625941df293b9510aa2c35e5 |
def testJPEG2000PixelArray(self): <NEW_LINE> <INDENT> with self.assertRaises((NotImplementedError, )): <NEW_LINE> <INDENT> _ = self.jpeg_2k_lossless.pixel_array | JPEG2000: Now works | 625941df76e4537e8c3519c7 |
def test_0005_registration_using_invitation_code(self): <NEW_LINE> <INDENT> with Transaction().start(DB_NAME, USER, CONTEXT): <NEW_LINE> <INDENT> self.create_defaults() <NEW_LINE> app = self.get_app() <NEW_LINE> work, = self.Work.create([{ 'name': 'ABC', 'company': self.company.id, }]) <NEW_LINE> project, = self.Projec... | Check if user got registered and joined project when invitation
code is there | 625941dfd99f1b3c44c678dc |
def isfinished(self): <NEW_LINE> <INDENT> return self.status == SWOperation.ST_FINISHED | Checks if this software operation has been completed
Checks if the status of this software operation is set to
ST_FINISHED and returns True if so.
@return True if this software operation is finished, False otherwise | 625941df379a373c97cfae99 |
def testParseDateTimeValue(self): <NEW_LINE> <INDENT> parser = cups_ipp.CupsIppParser() <NEW_LINE> datetime_data = self._CreateDateTimeValueData(parser) <NEW_LINE> datetime_value = parser._ParseDateTimeValue(datetime_data, 0) <NEW_LINE> self.assertIsNotNone(datetime_value) <NEW_LINE> self.assertEqual(datetime_value.yea... | Tests the _ParseDateTimeValue function. | 625941df3cc13d1c6d3c76cc |
def del_edge(self, val1, val2): <NEW_LINE> <INDENT> if val2 in self._graph[val1]: <NEW_LINE> <INDENT> self._graph[val1].pop(val2) | Delete the edge between two nodes. | 625941df16aa5153ce3627cb |
def __init__(self, **kwargs): <NEW_LINE> <INDENT> parameters = Parameters_deMon(**kwargs) <NEW_LINE> command = parameters['command'] <NEW_LINE> if command is None: <NEW_LINE> <INDENT> command = os.environ.get('DEMON_COMMAND') <NEW_LINE> <DEDENT> if command is None: <NEW_LINE> <INDENT> mess = 'The "DEMON_COMMAND" enviro... | ASE interface to the deMon code.
The deMon2k code can be obtained from http://www.demon-software.com
The DEMON_COMMAND environment variable must be set to run the executable, in bash it would be set along the lines of
export DEMON_COMMAND="deMon.4.3.6.std > deMon_ase.out 2>&1"
Parameters:
label : str
relative p... | 625941df7cff6e4e81117cd8 |
def load_json(filename): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open(filename, 'rb') as fid: <NEW_LINE> <INDENT> data = json.load(fid) <NEW_LINE> <DEDENT> return data, None <NEW_LINE> <DEDENT> except Exception as err: <NEW_LINE> <INDENT> return None, str(err) | Load a json file as a dictionary | 625941df7c178a314d6ef7b7 |
def save_user(self): <NEW_LINE> <INDENT> User.user_list.append(self) | save_credential method save user object into user_list | 625941dffb3f5b602dac39e9 |
def str_enc_dec(val): <NEW_LINE> <INDENT> if isinstance(val, str): <NEW_LINE> <INDENT> val = bytes(val, 'utf-8') <NEW_LINE> <DEDENT> val = val.decode("utf-8", "replace") <NEW_LINE> return val | Handles encoding decoding for localized values. | 625941df8e05c05ec3eea6ca |
def persistent_clear(self, complete_name, callback=None): <NEW_LINE> <INDENT> element = self.toc.get_element_by_complete_name(complete_name) <NEW_LINE> if not element.is_persistent(): <NEW_LINE> <INDENT> raise AttributeError(f"Param '{complete_name}' is not persistent") <NEW_LINE> <DEDENT> def new_packet_cb(pk): <NEW_L... | Clear the current value of the specified persistent parameter from
eeprom. The supplied callback will be called with `True` as an
argument on success and with `False` as an argument on failure.
@param complete_name The 'group.name' name of the parameter to store
@param callback Optional callback should take `complete_... | 625941df76e4537e8c3519c8 |
def add_fake_accel(widget, accel): <NEW_LINE> <INDENT> if not hasattr(add_fake_accel, "_group"): <NEW_LINE> <INDENT> add_fake_accel._group = Gtk.AccelGroup() <NEW_LINE> <DEDENT> group = add_fake_accel._group <NEW_LINE> key, val = Gtk.accelerator_parse(accel) <NEW_LINE> assert key is not None <NEW_LINE> assert val is no... | Accelerators are only for window menus and global keyboard shortcuts.
Since we want to use them in context menus as well, to indicate which
key events the parent widget knows about, we use a global fake
accelgroup without any actions.. | 625941dff7d966606f6aa35b |
def resnet50(pretrained=False, **kwargs): <NEW_LINE> <INDENT> model = ResNet(Bottleneck, [3, 4, 6, 3], **kwargs) <NEW_LINE> if pretrained: <NEW_LINE> <INDENT> model.load_state_dict(torch.load(pretrained_model), strict=False) <NEW_LINE> <DEDENT> return model | Constructs a ResNet-50 model.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet | 625941dfa4f1c619b28b0385 |
def fill(self, value) -> 'InfluxQuerySet': <NEW_LINE> <INDENT> clone = self.clone() <NEW_LINE> clone.query.fill = value <NEW_LINE> return clone | Return a query set where time frames with no data will be filled with value.
:param value: | 625941df656771135c3ebbc5 |
def test_multiple_case_02(self): <NEW_LINE> <INDENT> self.pms_property2 = self.env["pms.property"].create( { "name": "Property 2", "company_id": self.company1.id, "default_pricelist_id": self.pricelist1.id, } ) <NEW_LINE> self.env["pms.room.type.class"].create( { "name": "Room type class 1", "default_code": "c1", "pms_... | Check that a room type class can be created with the same
code as another when one of them has pms_property_ids = False
----------
A room type class is created with code 'c1' for property 1(company1).
Another room type class is created with code 'c1' and the
properties set to False. Then the room_type with code 'c1'
in... | 625941dfd18da76e2353282c |
def get_word_vec(word, conn=ENGINE): <NEW_LINE> <INDENT> query = "SELECT * FROM words_w2v WHERE word = '{}'".format(word) <NEW_LINE> vector_df = pd.read_sql(query, conn, index_col='word') <NEW_LINE> if not vector_df.empty: <NEW_LINE> <INDENT> logger.debug( f'found exact match for query {word} in w2v') <NEW_LINE> return... | Load the word2vec vector for the given word from the database
Parameters
----------
word: str
A word to find word2vec representation for.
Returns
-------
pd.DataFrame
A dataframe containing the word2vec representation of the given word
Raises
------
UnknownWord
If the given word doesn't have a known word... | 625941df091ae356686672ac |
def _add_join_item_field(self, field, index): <NEW_LINE> <INDENT> name = "%sJ%d" % (field, index + 1) <NEW_LINE> trait = self._inputs.trait(field, False, True) <NEW_LINE> self._inputs.add_trait(name, trait) <NEW_LINE> return name | Add new join item fields qualified by the given index
Return the new field name | 625941dfd6c5a102081443a0 |
def __iter__(self): <NEW_LINE> <INDENT> self.execute() <NEW_LINE> return iter(self.results) | Allows iterating on the response. | 625941dfd7e4931a7ee9e272 |
def parse_reference_file(self, reference_file, encoding): <NEW_LINE> <INDENT> ref_file = codecs.open(reference_file, "r", encoding) <NEW_LINE> lines = ref_file.read().split("\n") <NEW_LINE> ref_dic = {} <NEW_LINE> ref_file.close() <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> if not line == "": <NEW_LINE> <INDENT> ... | Extracts the reference keyphrases from a given file.
@param reference_file: The path of the file containing all the reference
keyphrases of the analysed files.
@type reference_file: C{string}
@param encoding: The encoding of the reference files.
@type encoding: C{str... | 625941df283ffb24f3c55c51 |
def ApproxEqualPoints(p, q): <NEW_LINE> <INDENT> for i in range(len(p)): <NEW_LINE> <INDENT> if abs(p[i] - q[i]) > DISTTOL: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True | Return True if p and q are approximately the same points.
Args:
p: n-tuple of float
q: n-tuple of float
Returns:
bool - True if the 1-norm <= DISTTOL | 625941dfadb09d7d5db6cae0 |
def parse(uri): <NEW_LINE> <INDENT> scheme, netloc, path, query, frag = urlparse.urlsplit(uri, allow_fragments=False) <NEW_LINE> if '@' in netloc: <NEW_LINE> <INDENT> raise IOError('userinfo not allowed: ' + netloc) <NEW_LINE> <DEDENT> if netloc[-3:] == ':80': <NEW_LINE> <INDENT> netloc = netloc[:-3] <NEW_LINE> <DEDENT... | parse URI into host and path parts.
Normalize host to lower case and remove ':80' if present | 625941dfd268445f265b51c1 |
def fitnum(self): <NEW_LINE> <INDENT> self.refresh() <NEW_LINE> fnb = self.params['filenb'] <NEW_LINE> out(1, 'Begin numerical fit') <NEW_LINE> for i in range(fnb): <NEW_LINE> <INDENT> f = self.params['img_names'][i] <NEW_LINE> out(1, '===============', i+1, '/', fnb,'===============|') <NEW_LINE> out(1, 'Working on', ... | Fit a background model over the residuals of the Moffat fit | 625941df56b00c62f0f149ae |
def test_restart_policy(self): <NEW_LINE> <INDENT> policy = object() <NEW_LINE> volume_service = create_volume_service(self) <NEW_LINE> fake_docker = FakeDockerClient() <NEW_LINE> deployer = P2PNodeDeployer(u'example.com', volume_service, fake_docker) <NEW_LINE> application_name = u'site-example.com' <NEW_LINE> applica... | ``StartApplication.run()`` passes an ``Application``'s restart_policy
to ``DockerClient.add`` which is used when creating a Unit. | 625941df07d97122c4178be6 |
def name_fields(self, name): <NEW_LINE> <INDENT> parts = name.split() <NEW_LINE> first = parts[0] <NEW_LINE> if len(parts) > 2: <NEW_LINE> <INDENT> middle = parts[1] <NEW_LINE> last = ' '.join(parts[2:]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> middle = '' <NEW_LINE> last = ' '.join(parts[1:]) <NEW_LINE> <DEDE... | Returns a Dictionary containing expected name fields.
:param name: The display name to parse into fields | 625941df8da39b475bd652ca |
def load(self): <NEW_LINE> <INDENT> if type(self.source) == etree._ElementTree: <NEW_LINE> <INDENT> self.source = etree.tostring(self.source) <NEW_LINE> self.process() <NEW_LINE> return True <NEW_LINE> <DEDENT> elif self.source_filename is not None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.source = open(self.s... | Parses the source file into an etree object. | 625941dfcb5e8a47e48b7df9 |
def __init__(self, image, skin_mask, labeled_image, label_number, rectangle_slices): <NEW_LINE> <INDENT> self.region_skin_pixels = np.count_nonzero( labeled_image[rectangle_slices] == label_number ) <NEW_LINE> self.bounding_rectangle_size = ( rectangle_slices[1].start - rectangle_slices[0].start ) * ( rectan... | Creates a new skin region.
image: The entire image in YCrCb mode.
skin_mask: The entire image skin mask.
labeled_image: A matrix of the size of the image with the region
label in each position. See scipy.ndimage.measurements.label.
label_number: The label number of this skin region.
rectangle_slices: The slices to... | 625941dfa17c0f6771cbe3a3 |
def test_is_course_in_enterprise_catalog_for_available_course(self): <NEW_LINE> <INDENT> enterprise_catalog_id = 1 <NEW_LINE> self.mock_access_token_response() <NEW_LINE> self.mock_catalog_contains_endpoint( discovery_api_url=self.site_configuration.discovery_api_url, catalog_id=enterprise_catalog_id, course_run_ids=[s... | Verify that method "is_course_in_enterprise_catalog" returns True if
the provided course is available in the enterprise course catalog. | 625941dfd8ef3951e3243891 |
def SysLog(level, type, messageId, tranId, other): <NEW_LINE> <INDENT> if other == None: <NEW_LINE> <INDENT> message = 'COMPONENT = vHut_Agent\n' + 'MODULE = Hypervisor_Agent\n' + 'TRANSACTIONID = ' + tranId + '\n' + 'LEVEL = '+ level + '\n' + 'TYPE = ' + type + '\n' + 'MESSAGEID = ' + messageId + '\n' + 'MESSAGE = ' +... | WindowsイベントログにErrorログを出力する。
引数: level ログ出力レベル
message ログに埋め込むメッセージ
返り値: | 625941df26238365f5f0f1c6 |
def __init__(self, name, username, password, hostname, port, file_mask, local_dir, use_scp=False, fail_if_exists=True, setup_commands=[], on_fail_command=None, on_fail_delay=0, logger=None): <NEW_LINE> <INDENT> super(SshFileMonitor, self).__init__(name, logger) <NEW_LINE> self._file_mask = file_mask <NEW_LINE> self._lo... | :param name: name of the object
:param username: ssh login username
:param password: ssh login password
:param hostname: ssh server ip
:param port: ssh server port
:param file_mask: file_mask to fetch
:param local_dir: local_path to store fetched files
:param use_scp: use the SCP protocol for transferring files instead... | 625941df38b623060ff0b141 |
def lowest_common_multiple(numbers): <NEW_LINE> <INDENT> answer = 1 <NEW_LINE> complete = False <NEW_LINE> while complete == False: <NEW_LINE> <INDENT> complete = True <NEW_LINE> for x in numbers: <NEW_LINE> <INDENT> if x > answer: <NEW_LINE> <INDENT> complete = False <NEW_LINE> answer = x <NEW_LINE> break <NEW_LINE> <... | Return lowest common multiple of set of numbers in 'numbers' | 625941df57b8e32f524837f1 |
def open_connection(self, host, alias=None, port=22, timeout=None, newline=None, prompt=None, term_type=None, width=None, height=None, path_separator=None, encoding=None, proxy_uri=None): <NEW_LINE> <INDENT> timeout = timeout or self._config.timeout <NEW_LINE> newline = newline or self._config.newline <NEW_LINE> prompt... | Opens a new SSH connection to the given ``host`` and ``port``.
The new connection is made active. Possible existing connections
are left open in the background.
Note that on Jython this keyword actually opens a connection and
will fail immediately on unreachable hosts. On Python the actual
connection attempt will not... | 625941dfeab8aa0e5d26dead |
def test_str(self, rom256): <NEW_LINE> <INDENT> e = "ROM({})".format(repr(bytes256)) <NEW_LINE> assert str(rom256) == e | Unicode string representation | 625941df2eb69b55b151cc07 |
def memoize(f): <NEW_LINE> <INDENT> cache = {} <NEW_LINE> def cache_f(*args): <NEW_LINE> <INDENT> if args in cache: <NEW_LINE> <INDENT> return cache[args] <NEW_LINE> <DEDENT> rval = f(*args) <NEW_LINE> cache[args] = rval <NEW_LINE> return rval <NEW_LINE> <DEDENT> return cache_f | Simple decorator hashes *args to f, stores rvals in dict.
This simple decorator works in memory only, does not persist between
processes. | 625941dfbde94217f3683141 |
def horizontal_burning_area(vertical_distance, burning_length, spread_angle=35): <NEW_LINE> <INDENT> new_length = burning_length + 2 * vertical_distance * np.tan(spread_angle) <NEW_LINE> return new_length | Formula 9-1 from CHRISTIFIRE Phase 1 (NUREG/CR-7010, Vol. 1), p. 147
Calculates the burning rate by the burning surface area.
The fire is assumed to be distributed uniformly over the tray width and
spreads only along the tray, away from the fire seat. Due to preheating
of the upper trays, the burning area forms a V-sh... | 625941dfa934411ee37519e8 |
def is_finish(self): <NEW_LINE> <INDENT> if self.nb_module > 0: <NEW_LINE> <INDENT> if self.nb_module == len(self._module_status): <NEW_LINE> <INDENT> for ms in self._module_status: <NEW_LINE> <INDENT> if not ms.is_finish(): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> for m in self._extract_malware: <... | Check the state of malware
If all status are finished, the malware analysis is finish. | 625941dfff9c53063f47c546 |
def draw_coast(): <NEW_LINE> <INDENT> i = 0 <NEW_LINE> while i <= 600: <NEW_LINE> <INDENT> circle(screen, (233, 255, 0), (i, 309), 30) <NEW_LINE> circle(screen, (59, 56, 255), (i + 30, 257), 30) <NEW_LINE> i += 60 <NEW_LINE> <DEDENT> line(screen, (100, 100, 100), [0, 283], [600, 283], 1) | Функция рисует береговую линию
Returns
-------
None. | 625941df627d3e7fe0d691a5 |
def test_get_routes(self): <NEW_LINE> <INDENT> with patch.object(os.path, 'join', return_value='A'): <NEW_LINE> <INDENT> with patch.object(rh_ip, '_read_file', return_value='A'): <NEW_LINE> <INDENT> self.assertEqual(rh_ip.get_routes('iface'), 'A') | Test to return the contents of the interface routes script. | 625941df32920d7e50b28527 |
def move(self, direction): <NEW_LINE> <INDENT> if direction == 'UP': <NEW_LINE> <INDENT> if self.caract_y > 0: <NEW_LINE> <INDENT> if self.structure[self.caract_y - 1][self.caract_x] != 'T': <NEW_LINE> <INDENT> self.caract_y -= 1 <NEW_LINE> self.y = self.caract_y * SPRITE_SIZE <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> if d... | Method that manages player movements | 625941df99cbb53fe6792f3a |
def end_operation(self): <NEW_LINE> <INDENT> self.operation_complete.emit(self.clipboard_mode, self.clipboard) <NEW_LINE> self.in_transaction = False <NEW_LINE> if self.clipboard_mode == ClipboardMode.Cut: <NEW_LINE> <INDENT> self.clipboard = [] | Ends the current operation on the clipboard and raises the operation_complete signal.
Copy operations can be completed multiple times to perform multiple pastes with the same content.
If the current operation is a cut, the clipboard will be cleared.
If the current operation is a copy, the clipboard contents will remain... | 625941dfe64d504609d74b94 |
@pytest.fixture <NEW_LINE> def some_data(): <NEW_LINE> <INDENT> return 42 | Answer to ultimate question
:return: 42 | 625941df711fe17d825426b8 |
def exp(mat, out=None): <NEW_LINE> <INDENT> if out is None: <NEW_LINE> <INDENT> out = np.empty_like(mat) <NEW_LINE> <DEDENT> np.clip(mat, -np.inf, 100, out=out) <NEW_LINE> pyvml.Exp(out, out) <NEW_LINE> return out | A (hacky) safe exp that avoids overflowing
Input:
mat: the input ndarray
out: (optional) the output ndarray. Could be in-place.
Output:
out: the output ndarray | 625941df9b70327d1c4e112a |
def find(self, quality): <NEW_LINE> <INDENT> current_node = self.head <NEW_LINE> while current_node is not None: <NEW_LINE> <INDENT> if current_node.data == quality: <NEW_LINE> <INDENT> return current_node.data <NEW_LINE> <DEDENT> current_node = current_node.next <NEW_LINE> <DEDENT> return None | Return an item from this linked list satisfying the given quality.
TODO: Best case running time: O(???) Why and under what conditions?
TODO: Worst case running time: O(???) Why and under what conditions? | 625941df0a50d4780f6671e9 |
def test_update_properties(node, compute, project, async_run, controller): <NEW_LINE> <INDENT> response = MagicMock() <NEW_LINE> response.json = {"console": 2048} <NEW_LINE> compute.put = AsyncioMagicMock(return_value=response) <NEW_LINE> controller._notification = AsyncioMagicMock() <NEW_LINE> async_run(node.update(x=... | properties will be updated by the answer from compute | 625941dfe76e3b2f99f3ab5b |
def set_headers_and_charset(self, headers): <NEW_LINE> <INDENT> self.headers = headers <NEW_LINE> try: <NEW_LINE> <INDENT> self.charset = CHARSET_RE.search(headers['content-type']) <NEW_LINE> self.charset = self.charset.group('encoding') <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> self.charset = 'utf-8' | #### set_headers_and_charset()
***description***
Set up Response's header information and the charset.
***params***
headers: < dict >
The dictionary-type header data. | 625941df4e696a04525c97a1 |
def addToNode(self): <NEW_LINE> <INDENT> if self.haplogroup in SNP.tree.hg2nodeDict: <NEW_LINE> <INDENT> self.setSortVariables() <NEW_LINE> SNP.tree.hg2nodeDict[self.haplogroup].addDroppedMarker(self) <NEW_LINE> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | adds this dropped marker to the corresponding node, if it exists | 625941dfa8ecb033257d3420 |
def logout(self) -> None: <NEW_LINE> <INDENT> resp = self.send_and_wait(b"LOGOUT\n") <NEW_LINE> if resp != b"OK!\n": <NEW_LINE> <INDENT> raise InvalidResponse('expected "OK!\\n", got "{}"'.format(resp.decode())) | Log out of the server. | 625941df44b2445a339323e8 |
def applyPatches(self): <NEW_LINE> <INDENT> EmergeDebug.trace("SourceBase.applyPatches called", 0) <NEW_LINE> if self.subinfo.hasTarget() or self.subinfo.hasSvnTarget(): <NEW_LINE> <INDENT> patches = self.subinfo.patchesToApply() <NEW_LINE> if not isinstance(patches, list): <NEW_LINE> <INDENT> patches = list([patches])... | apply patches if available | 625941df283ffb24f3c55c52 |
def fetch_all_jornals() : <NEW_LINE> <INDENT> base_link = 'https://www.elsevier.com/catalog?page=' <NEW_LINE> start_rank = 1 <NEW_LINE> end_rank = 2 <NEW_LINE> step = 20 <NEW_LINE> data = [] <NEW_LINE> for i in range(start_rank, end_rank + 1, step): <NEW_LINE> <INDENT> link = base_link + str(i) <NEW_LINE> print ("[INFO... | This function is used to fetch all journal links from a page.
Elsevier returns only 20 journal links in a page.
start : http://www.elsevier.com/journals/title/all?start_rank=1
end : http://www.elsevier.com/journals/title/all?start_rank=3141
:return: list of links to pages containing links to journals | 625941df63b5f9789fde743a |
def __init__(self): <NEW_LINE> <INDENT> super(TerminalServerClientMRUEventData, self).__init__( data_type=self.DATA_TYPE) <NEW_LINE> self.entries = None <NEW_LINE> self.key_path = None | Initializes event data. | 625941df596a897236089e11 |
def construct_recurrence_coefficients( order, dist, recurrence_algorithm="stieltjes", rule="clenshaw_curtis", tolerance=1e-10, scaling=3, n_max=5000, ): <NEW_LINE> <INDENT> assert isinstance(dist, chaospy.Distribution), ( "%s is not a distribution" % str(dist)) <NEW_LINE> if len(dist) > 1: <NEW_LINE> <INDENT> orders = ... | Frontend wrapper for constructing *three terms recurrence* coefficients.
The algorithm for constructing recurrence coefficients can be specified
using the ``recurrence_algorithm`` flag. It accepts the strings:
``stieltjes``
Use the discretized Stieltjes algorithm for iterative estimate each
recurrence coeffic... | 625941df7b180e01f3dc4b4c |
@cli.command() <NEW_LINE> @click.argument('year') <NEW_LINE> def ily(year): <NEW_LINE> <INDENT> res = f"{year} is a leap year!" if utils.is_leap_year(year) else f"{year} is not a leap year :(" <NEW_LINE> print(res) | Checks if the supplied year is a leap year | 625941df462c4b4f79d1da25 |
def test_download(self): <NEW_LINE> <INDENT> f = self.resources.getfile("lena.png") <NEW_LINE> self.assertTrue(os.path.exists(f)) <NEW_LINE> di = self.resources.getdir("source.tar.gz") <NEW_LINE> for fi in di: <NEW_LINE> <INDENT> self.assertTrue(os.path.exists(fi)) | test the download from silx.org | 625941df30c21e258bdfa7f4 |
def has_edge(self, edge): <NEW_LINE> <INDENT> u,v = edge <NEW_LINE> return (u,v) in self.edge_properties and (v,u) in self.edge_properties | Return whether an edge exists.
@type edge: tuple
@param edge: Edge.
@rtype: boolean
@return: Truth-value for edge existence. | 625941df76e4537e8c3519c9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.