code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def cosine_similarity(vect1, vect2): <NEW_LINE> <INDENT> return scalar_product(vect1, vect2) / (vect_abs(vect1) * vect_abs(vect2))
the scalar product of two vector from the same vector space is geometrically defined as u . v = cos(u, v) * |u| * |v| the cosine similarity extracts the cosine component from the scalar product divided by the product of the L2 norm of each vector
625941ceb7558d58953c5038
def quit(self): <NEW_LINE> <INDENT> pg.display.quit() <NEW_LINE> pg.quit()
quit the pygame instance Example: >>> img = Image("simplecv") >>> d = img.show() >>> time.sleep(5) >>> d.quit()
625941ce56ac1b37e62642f3
def nick(self, bot, msg): <NEW_LINE> <INDENT> oldnick = msg["host"].split("!")[0] <NEW_LINE> newnick = msg["arg"][1:] <NEW_LINE> if newnick in self.admins and oldnick not in self.admins: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if oldnick in self.admins: <NEW_LINE> <INDENT> self.admins[newnick] = self.admins[oldn...
Handles nickchanges
625941ce55399d3f055887d8
def remove_control_chart(s): <NEW_LINE> <INDENT> s = re.sub(r'\n', ' ', s) <NEW_LINE> s = s.replace('\xa0', '') <NEW_LINE> s = re.sub(r' +', ' ', s) <NEW_LINE> return to_string(s)
:param s: string that may not be utf-8 encode :return:
625941ce3539df3088e2e46f
def __init__(self): <NEW_LINE> <INDENT> WriterBase.__init__(self) <NEW_LINE> self.sub_sequence_count = 0
Initialize the class.
625941ce57b8e32f524835bf
def _query_selector(self, selector): <NEW_LINE> <INDENT> return self._bindings[selector]
Returns all the agents that match the selector
625941cee8904600ed9f2050
def create_subelement(self, parent, name, value=""): <NEW_LINE> <INDENT> se = ET.SubElement(parent, name) <NEW_LINE> se.text = value <NEW_LINE> return se
create subelement :param parent: parent element :param name : name of the element :param value : value to be assigned to the element :returns: element
625941cea219f33f34628a8e
def get_partSpeech(s): <NEW_LINE> <INDENT> pass
has to ask the user the part of speech and store it
625941ce31939e2706e4cf8e
def copy(self): <NEW_LINE> <INDENT> return _btk.SwigPyIterator_copy(self)
copy(self) -> SwigPyIterator
625941ce3cc13d1c6d3c749e
def match(self, datetime): <NEW_LINE> <INDENT> localtime = self._localtime(datetime) <NEW_LINE> return (self.matchers.minute(localtime.minute, localtime) and self.matchers.hour(localtime.hour, localtime) and self.matchers.day(localtime.day, localtime) and self.matchers.month(localtime.month, localtime) and self.matcher...
Determines whether the given datetime matches the scheduling rules stored in the class instance. The datetime is converted to the stored timezone, and then the components of the time are checked against the matchers in the CronTab superclass.
625941ce0a50d4780f666fb7
def p_lock_statement(p): <NEW_LINE> <INDENT> pass
lock_statement : LOCK LPAREN expression RPAREN embedded_statement
625941ce07d97122c41789b0
def determine_db_dir(): <NEW_LINE> <INDENT> if platform.system() == "Darwin": <NEW_LINE> <INDENT> return os.path.expanduser("~/Library/Application Support/NATU/") <NEW_LINE> <DEDENT> elif platform.system() == "Windows": <NEW_LINE> <INDENT> return os.path.join(os.environ['APPDATA'], "NATU") <NEW_LINE> <DEDENT> return os...
Return the default location of the natu data directory
625941ced58c6744b4257d84
def add_end_substation(self, substation: Substation) -> Circuit: <NEW_LINE> <INDENT> if self._validate_reference(substation, self.get_end_substation, "An Substation"): <NEW_LINE> <INDENT> return self <NEW_LINE> <DEDENT> self._end_substations = list() if self._end_substations is None else self._end_substations <NEW_LINE...
Associate an `zepben.evolve.cim.iec61970.base.core.substation.Substation` with this `Circuit` `substation` the `zepben.evolve.cim.iec61970.base.core.substation.Substation` to associate with this `Circuit`. Returns A reference to this `Circuit` to allow fluent use. Raises `ValueError` if another `Substation` with the s...
625941ce96565a6dacc8f7f0
def copy_committed_keys(self, diff, new_folder): <NEW_LINE> <INDENT> for buck, k in self._iter_keys(diff['bucket_keys_already_committed']): <NEW_LINE> <INDENT> new_key = os.path.join(new_folder, k.split('/')[-1]) <NEW_LINE> print("Copying {} to {}...".format(k, new_key)) <NEW_LINE> buck.copy_key(new_key, buck.name, k)
Given the diff from `diff_redshift_and_bucket`, copy the keys that have already been committed to a new bucket folder for later validation
625941ce090684286d50ee0a
def compute_tick_freq(self): <NEW_LINE> <INDENT> delta_t = (self.header['ScanEndTimeNTP'] - self.header['ScanStartTimeNTP']) <NEW_LINE> delta_ticks = self.header['StartAngle'] - self.header['EndAngle'] <NEW_LINE> tick_freq = (delta_ticks << 32)/ float(delta_t) <NEW_LINE> return int(tick_freq)
Compute the tick frequency from the start/end angles and times. This is typically within 1% of the nominal values. Note: we are using the device supplied tick resolution of 1/32nd degree @return: tickfrequency - a floating point number (ticks per second)
625941ced7e4931a7ee9e042
def test_accessible_ids_with_private_and_member(self): <NEW_LINE> <INDENT> user = self.create_user() <NEW_LINE> repository = self.create_repository(public=False) <NEW_LINE> repository.users.add(user) <NEW_LINE> self.assertIn( repository.pk, Repository.objects.accessible_ids(user, visible_only=True)) <NEW_LINE> self.ass...
Testing Repository.objects.accessible_ids with private repository and user is a member
625941ce925a0f43d2549f9c
def _Check2(): <NEW_LINE> <INDENT> self.assertEquals(long(os.path.getmtime(os.path.join(tmpdir, 'obj1'))), 5) <NEW_LINE> self.assertEquals(long(os.path.getmtime(os.path.join(tmpdir, '.obj2'))), 5) <NEW_LINE> self.assertEquals(long(os.path.getmtime(os.path.join(tmpdir, 'obj6'))), 50) <NEW_LINE> self.assertEquals(long(os...
Verify mtime was set for objects at destination.
625941ce99fddb7c1c9de4b5
def _fill_available_moves_cache( self, gameboard: SquareGameboard, start_cell: Cell, player_mark: PlayerMark, enemy_mark: PlayerMark, ) -> None: <NEW_LINE> <INDENT> for offset_coordinate, direction in gameboard.get_offsets( start_cell.coordinate ): <NEW_LINE> <INDENT> if gameboard[offset_coordinate].mark == enemy_mark:...
Fill cache with available moves. :param gameboard: The gameboard that will be checked. :param start_cell: The cell relative to which the directions will be checked. :param player_mark: The current player mark. :param enemy_mark: The mark to which all cells should have in checked directions between ``start_...
625941ce046cf37aa974ce6c
def __init__(self, source, dest, guard): <NEW_LINE> <INDENT> self.source = source <NEW_LINE> self.dest = dest <NEW_LINE> self.guard = guard
`source` from state `dest` to state `guard(Game)` true/false function evaluating the game to see if now is a valid time to take this transition
625941cea05bb46b383ec946
def testCreateGoalWithInValidDate(self): <NEW_LINE> <INDENT> response = Goal.create('test_title','test_description','test_user','test_prize',1,'test_goal_type', '500','dollars', '4/23/2005') <NEW_LINE> self.assertFalse(not response['errors'])
Test witih valid data
625941ced99f1b3c44c676b2
def __init__(self, config): <NEW_LINE> <INDENT> self.suffix = '.png' <NEW_LINE> self.config = config <NEW_LINE> self.train_filenames = get_files(config.train_file_path, self.suffix) <NEW_LINE> self.train_labels = get_labels(config.train_label_path, self.train_filenames) <NEW_LINE> self.eval_filenames = get_files(config...
config: data_paralle_size buffer: batch_size:
625941cebe8e80087fb20d67
@api_view(['GET', 'POST']) <NEW_LINE> def snippet_list(request, format=None): <NEW_LINE> <INDENT> if request.method == 'GET': <NEW_LINE> <INDENT> snippets = Snippet.objects.all() <NEW_LINE> serializer = SnippetSerializer(snippets, many=True) <NEW_LINE> return Response(serializer.data) <NEW_LINE> <DEDENT> elif request.m...
코드조각을 모두 보여주거나 새 코드 조각을 만든다
625941ce66656f66f7cbc2cf
def test_fail_must_login(self): <NEW_LINE> <INDENT> guest_obj = self._check_init() <NEW_LINE> msg = 'You need to login first' <NEW_LINE> with self.assertRaisesRegex(RuntimeError, msg): <NEW_LINE> <INDENT> guest_obj.hotplug(vols=[dict()]) <NEW_LINE> <DEDENT> with self.assertRaisesRegex(RuntimeError, msg): <NEW_LINE> <IN...
Verify that operations will fail if login was not initially performed.
625941ce31939e2706e4cf8f
def delete(self, group_name): <NEW_LINE> <INDENT> endpoint = "2.0/groups/delete" <NEW_LINE> data = json.dumps({'group_name': group_name}) <NEW_LINE> url = "%s%s" % (self.hostname, endpoint) <NEW_LINE> req = requests.post(url, headers=self.__headers, data=data) <NEW_LINE> objects = req.json() <NEW_LINE> return objects
Removes a group from this organization.
625941ce67a9b606de4a7fde
def is_folder(self, file): <NEW_LINE> <INDENT> return isinstance(file, FolderMetadata)
check if the file is a folder :param file: :return:
625941ce55399d3f055887d9
def visit_named_nodes( self, node: Union[AnyFunctionDef, ast.ClassDef, ast.ExceptHandler], ) -> None: <NEW_LINE> <INDENT> names = {node.name} if node.name else set() <NEW_LINE> self._scope(node, names, is_local=False) <NEW_LINE> self._outer_scope(node, names) <NEW_LINE> self.generic_visit(node)
Visits block nodes that have ``.name`` property.
625941ce4a966d76dd551134
def add_all_wordforms(self, lexeme): <NEW_LINE> <INDENT> for wf in lexeme.generate_wordforms(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.wfs[wf.wf].append(wf) <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> self.wfs[wf.wf] = [wf]
Add all the wordforms of a given lexeme to the list of pre-generated wordforms.
625941cebe383301e01b55aa
def test_create(self): <NEW_LINE> <INDENT> self.assertEqual(self.book_ode.active, True)
Test Books are active by default
625941ce63b5f9789fde720a
def execute(self): <NEW_LINE> <INDENT> if self.url is not None and self.core is not None: <NEW_LINE> <INDENT> if self.import_core is not None and self.import_core is True: <NEW_LINE> <INDENT> self.import_core_execution() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.row_count_execution() <NEW_LINE> <DEDENT> <DEDEN...
Executa uma funcao com base nos parametros :return:
625941ce3eb6a72ae02ec602
def poly_sturm(f, *symbols): <NEW_LINE> <INDENT> if not isinstance(f, Poly): <NEW_LINE> <INDENT> f = Poly(f, *symbols) <NEW_LINE> <DEDENT> elif symbols: <NEW_LINE> <INDENT> raise SymbolsError("Redundant symbols were given") <NEW_LINE> <DEDENT> if f.is_multivariate: <NEW_LINE> <INDENT> raise MultivariatePolyError(f) <NE...
Computes the Sturm sequence of a given polynomial. Given a univariate, square-free polynomial f(x) returns an associated Sturm sequence f_0(x), ..., f_n(x) defined by: f_0(x), f_1(x) = f(x), f'(x) f_n = -rem(f_{n-2}(x), f_{n-1}(x)) For more information on the implemented algorithm refer to: [1] J.H. Davenpo...
625941ce4f6381625f114b60
def event_register_int(self, bp_pid, bp_addr, sync): <NEW_LINE> <INDENT> msgtype = "EVENT_REGISTER" <NEW_LINE> submsg = self.vmmsg_helper(msgtype) <NEW_LINE> submsg.event_type = vmi_pb2.__getattribute__("F_INT") <NEW_LINE> submsg.sync_state = vmi_pb2.__getattribute__(sync) <NEW_LINE> submsg.bp_pid = bp_pid <NEW_LINE> s...
Internal use only. Performs event registration for breakpoints.
625941cecdde0d52a9e53158
def purge(self, targets=None): <NEW_LINE> <INDENT> if targets is None: <NEW_LINE> <INDENT> targets = set([]) <NEW_LINE> targets = targets.union([x for x in self.vertices if x.marked_for_cleanup]) <NEW_LINE> targets = targets.union([x for x in self.half_edges if x.marked_for_cleanup or x.is_infinite()]) <NEW_LINE> targe...
Run all purge methods in correct order
625941ce009cb60464c634d6
def list(self, filter=None, type=None, sort=None, limit=None, page=None, detailed=None): <NEW_LINE> <INDENT> schema = JobSchema() <NEW_LINE> resp = self.service.list(self.base, filter, type, sort, limit, page, detailed=detailed) <NEW_LINE> js, l = self.service.decode(schema, resp, many=True, links=True) <NEW_LINE> retu...
Get a list of jobs. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit returned list length. :param page: (optional) Page to return. :param detailed: (optional) Re...
625941ce435de62698dfdd71
def get_position(self): <NEW_LINE> <INDENT> return self.do(self.config['position'])
获取持仓
625941ce30dc7b7665901a8b
def prop_value(s1, val): <NEW_LINE> <INDENT> for pv in get_all_properties(): <NEW_LINE> <INDENT> if ' ' not in pv.strip(): <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> prop, value = pv.split() <NEW_LINE> if sub_string(value, val): <NEW_LINE> <INDENT> if sub_string(prop, s1): <NEW_LINE> <INDENT> yield '{0} {1}'.form...
Генератор возвращает свойства и значения разделённые пробелом Из всех свойств выбирает только с совпадающим порядком букв
625941ce26238365f5f0ef93
def _interface_selection(iface, packet ): <NEW_LINE> <INDENT> if iface is None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> iff = next(packet.__iter__()).route()[0] <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDENT> iff = None <NEW_LINE> <DEDENT> return iff or conf.iface <NEW_LINE> <DEDENT> return iface
Select the network interface according to the layer 3 destination
625941ce85dfad0860c3af80
def testDNNOnly(self): <NEW_LINE> <INDENT> cont_features = [ tf.contrib.layers.real_valued_column('feature', dimension=4)] <NEW_LINE> classifier = tf.contrib.learn.DNNLinearCombinedClassifier( n_classes=3, dnn_feature_columns=cont_features, dnn_hidden_units=[3, 3]) <NEW_LINE> classifier.fit(input_fn=_iris_input_multicl...
Tests that DNN-only instantiation works.
625941ce3317a56b86939d7d
@cmdline.subcommand() <NEW_LINE> @cmdline.no_output <NEW_LINE> def clear_flag(flag): <NEW_LINE> <INDENT> old_flags = get_flags() <NEW_LINE> unitdata.kv().unset('reactive.states.%s' % flag) <NEW_LINE> unitdata.kv().set('reactive.dispatch.removed_state', True) <NEW_LINE> if flag in old_flags: <NEW_LINE> <INDENT> tracer()...
Clear / deactivate a flag. :param str flag: Name of flag to set. .. note:: **Changes to flags are reset when a handler crashes.** Changes to flags happen immediately, but they are only persisted at the end of a complete and successful run of the reactive framework. All unpersisted changes are discarded when ...
625941ce379a373c97cfac6a
def __init__(self, tensors): <NEW_LINE> <INDENT> self.tensors = tensors
Args: tensors: list of tensorflow tensors with well defined shape.
625941ce3eb6a72ae02ec603
def _arguments(self, node): <NEW_LINE> <INDENT> if node.vararg or node.kwarg: <NEW_LINE> <INDENT> raise (Exception("Phylanx does not support *args and **kwargs")) <NEW_LINE> <DEDENT> defaults = tuple(map(self.apply_rule, node.defaults)) <NEW_LINE> result = tuple() <NEW_LINE> padded_defaults = (None,) * (len(node.args) ...
class arguments(args, vararg, kwonlyargs, kwarg, defaults, kw_defaults) The arguments for a function. `args` and `kwonlyargs` are lists of arg nodes. `vararg` and `kwarg` are single arg nodes, referring to the *args, **kwargs parameters. `defaults` is a list of default values for arguments that can be passed positiona...
625941ce21bff66bcd684a78
def get_recipe_matrix(loc='static'): <NEW_LINE> <INDENT> if loc == 'db': <NEW_LINE> <INDENT> recipe_ids, nut_dicts = [], [] <NEW_LINE> for food in Food.objects.all(): <NEW_LINE> <INDENT> recipe_ids.append(food.id_string) <NEW_LINE> nut_dicts.append(food.nutrients) <NEW_LINE> <DEDENT> recipe_matrix = np.zeros([len(recip...
Get a (foods, nutrients)-matrix from db or file.
625941ce01c39578d7e74f61
def put_Color(self, Color): <NEW_LINE> <INDENT> return super(IFormattedTextSymbol, self).put_Color(Color)
Method ITextSymbol.put_Color (from ITextSymbol) INPUT Color : IColor*
625941ce6fece00bbac2d864
def extract_circle(center, radius, coords): <NEW_LINE> <INDENT> return np.where(((coords - center) ** 2).sum(axis=-1) < radius ** 2)[0]
Extract the indices of coords which fall within a circle defined by center and radius Parameters ---------- center : float radius : float coords : array of float with shape (numpoints,2) Returns ------- output : 1-darray of integers index array referring to the coords array
625941cebe7bc26dc91cd725
def acquire(self, t, mode): <NEW_LINE> <INDENT> self._maintain_queue() <NEW_LINE> if t in self.holders: <NEW_LINE> <INDENT> if self._mode_accept(mode): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if self.mode is Mode.read and mode is Mode.write: <NEW_LINE> <INDENT> if len(self.holders) == 1: <NEW_LINE> <INDENT>...
Try to acquire the lock Following the rules that read locks are not exclusive, and FIFO. :param t: The transaction trying to acquire this lock :param mode: type of lock to acquire, read or write :return: True if success, the set of transactions to wait for if not success
625941ce4527f215b584c57c
def textblock(self, width, justification='C', lines=1): <NEW_LINE> <INDENT> assert justification in ['L','R','C','J'] <NEW_LINE> self.code += "^FB%i,%i,%i,%s,%i" % (width*self.dpmm, lines, 0, justification, 0)
new text block width of textblock in millimeters
625941ce23e79379d52ee689
def add_usage(self, usage, actions, groups, prefix=None): <NEW_LINE> <INDENT> self.sect << self._prog << self._format_actions_usage(listmap(FormatWrapper, actions), groups)
Formats the usage and appends it to the current section.
625941ce167d2b6e31218cbb
def color_headers(self, count): <NEW_LINE> <INDENT> self._reset_color_headers() <NEW_LINE> if self._editor_inst.color_style == ColorTheme.Softimage: <NEW_LINE> <INDENT> for index in range(count): <NEW_LINE> <INDENT> header_name = self.table_model.get_inf(index) <NEW_LINE> rgb = self._editor_inst.obj.inf_colors.get(head...
Resets the colors on the top headers. An active influence will be colored as blue. When using the Softimage theme, each header will be the color if its influence.
625941ceeab8aa0e5d26dc7d
def stack_recommendation(context): <NEW_LINE> <INDENT> stack_recommendation_on_space_page(context) <NEW_LINE> stack_reccomendation_on_pipepines_page(context)
Check the presence of stack recommendation on all relevant pages on OpenShift.io.
625941ceec188e330fd5a8c4
def p_instrution_2(p): <NEW_LINE> <INDENT> p[0] = [p[2]]
instrucion : G0 parameters
625941cecb5e8a47e48b7bd0
def rebuild_source(source, full_base_url): <NEW_LINE> <INDENT> source = source.replace('src="//', 'src="http://') <NEW_LINE> source = source.replace('src="/', 'src="%s' % full_base_url) <NEW_LINE> source = source.replace('src="../', 'src="%s' % full_base_url) <NEW_LINE> source = source.replace('src="./', 'src="%s' % fu...
Completes the links on a web page.
625941ceb57a9660fec339a9
@task <NEW_LINE> def rm(path): <NEW_LINE> <INDENT> bucket = utils.get_bucket(app_config.ASSETS_S3_BUCKET) <NEW_LINE> file_list = glob(path) <NEW_LINE> found_folder = True <NEW_LINE> while found_folder: <NEW_LINE> <INDENT> found_folder = False <NEW_LINE> for local_path in file_list: <NEW_LINE> <INDENT> if os.path.isdir(...
Remove an asset from s3 and locally
625941cef548e778e58cd6a3
def terminate(self, *, async_callback=None): <NEW_LINE> <INDENT> self.process.terminate() <NEW_LINE> return self._queue_termination(async_callback)
Terminate the engine. This is not an UCI command. It instead tries to terminate the engine on operating system level, like sending SIGTERM on Unix systems. If possible, first try the *quit* command. :return: The return code of the engine process (or a Future).
625941ce7047854f462a152f
def convert_bgr2gray(img): <NEW_LINE> <INDENT> img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) <NEW_LINE> return img
Convert to gray image Args: img: image to be converted in gray Returns: gray image
625941cecc0a2c11143dcfb6
def has_granted_affinities_to_choose(): <NEW_LINE> <INDENT> rank_ = get_last() <NEW_LINE> if rank_: <NEW_LINE> <INDENT> return len(rank_.affinities_to_choose) > 0 <NEW_LINE> <DEDENT> return False
return if the player can choose some skills or emphases
625941ce7d43ff24873a2dc6
def _save_cached_when_graph_building(self, file_prefix, object_graph_tensor, options, update_ckpt_state=False): <NEW_LINE> <INDENT> (named_saveable_objects, graph_proto, feed_additions, registered_savers) = self._gather_saveables( object_graph_tensor=object_graph_tensor) <NEW_LINE> def _run_save(): <NEW_LINE> <INDENT> ...
Create or retrieve save ops. Args: file_prefix: The prefix for saved checkpoint files. object_graph_tensor: A `Tensor` to which the current object graph will be fed. options: `CheckpointOptions` object. update_ckpt_state: Optional bool flag. Indiciate whether the internal checkpoint state needs to be u...
625941ce498bea3a759b9bd4
def models(self, cr, uid, context=None): <NEW_LINE> <INDENT> context = context or dict() <NEW_LINE> model_pool = self.pool.get('ir.model') <NEW_LINE> model_ids = model_pool.search( cr, uid, [('model', 'in', context.get("model_list", self._models))], order="name", context=context) <NEW_LINE> model_objs = model_pool.brow...
Get allowed models and their names. It searches for the models on the database, so if modules are not installed, models will not be shown.
625941cee1aae11d1e749ddd
def finished(self): <NEW_LINE> <INDENT> return self.step >= self.n_steps
Return the state of completion of current simulation
625941ce956e5f7376d70f93
def callstack_as_str(callstack: Sequence[CallItem], depth=-1) -> str: <NEW_LINE> <INDENT> short_stack = [] <NEW_LINE> anonymous_tail = True <NEW_LINE> for tag_name, _ in reversed(callstack): <NEW_LINE> <INDENT> if tag_name[:1] == ':': <NEW_LINE> <INDENT> if anonymous_tail and tag_name != ":Forward": <NEW_LINE> <INDENT>...
Returns a string representation of the callstack!
625941ce627d3e7fe0d68f75
def parse_args(self, argv): <NEW_LINE> <INDENT> from argparse import ArgumentParser <NEW_LINE> name = CCPluginNew.plugin_name() <NEW_LINE> category = CCPluginNew.plugin_category() <NEW_LINE> parser = ArgumentParser(prog="cocos %s" % self.__class__.plugin_name(), description=self.__class__.brief_description()) <NEW_LINE...
Custom and check param list.
625941ce8e05c05ec3eea49a
def connectionMade(self): <NEW_LINE> <INDENT> self.terminal.reset() <NEW_LINE> self._window = self._makeWindow()
Reset the terminal and create a UI for selecting an application to use.
625941ced268445f265b4f94
def manage_resetUsers(self, logins, RESPONSE=None): <NEW_LINE> <INDENT> for login in logins: <NEW_LINE> <INDENT> self.resetAttempts(login) <NEW_LINE> <DEDENT> message = "User reset" <NEW_LINE> if RESPONSE is not None: <NEW_LINE> <INDENT> RESPONSE.redirect( '%s/manage_users?manage_tabs_message=%s' % ( self.absolute_url(...
Reset lockout so user can login again
625941ce82261d6c526ab5c5
def authenticate(self, login, passcode): <NEW_LINE> <INDENT> return login in self.store and self.store[login] == passcode
Authenticate the login and passcode. @return: Whether provided login and password match values in store. @rtype: C{bool}
625941ce99cbb53fe6792d0c
def extract_iq(self, id): <NEW_LINE> <INDENT> self.items = ServiceDblink.query_intermediate_iq(id) <NEW_LINE> return self.toJson()
:param id: :return:
625941ce566aa707497f468e
def lines_length_check(self): <NEW_LINE> <INDENT> line_size = max([len(x) for x in self.result]) <NEW_LINE> temp = [] <NEW_LINE> for line in self.result: <NEW_LINE> <INDENT> if len(line) < line_size: <NEW_LINE> <INDENT> line += " "*(line_size-len(line)) <NEW_LINE> <DEDENT> temp.append(line) <NEW_LINE> <DEDENT> self.res...
This method adds extra spaces to all element .center() is sensible to the length of a str
625941ce8e71fb1e9831d8cf
def _validate_iterable( self, v: Any, values: Dict[str, Any], loc: 'LocStr', cls: Optional['ModelOrDc'] ) -> 'ValidateReturn': <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> iterable = iter(v) <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> return v, ErrorWrapper(errors_.IterableError(), loc) <NEW_LINE> <DEDENT...
Validate Iterables. This intentionally doesn't validate values to allow infinite generators.
625941ce236d856c2ad44901
def current_vm_status(self, vmstatus): <NEW_LINE> <INDENT> if vmstatus == 'up': <NEW_LINE> <INDENT> hrstatus = _('up') <NEW_LINE> <DEDENT> elif vmstatus == 'down': <NEW_LINE> <INDENT> hrstatus = _('down') <NEW_LINE> <DEDENT> elif vmstatus == 'powering_down': <NEW_LINE> <INDENT> hrstatus = _('powering_down') <NEW_LINE> ...
Description: Single translation between oVirt-like status to human-readable status Arguments: oVirt-like status Returns: Human-readable status
625941ce91f36d47f21ac619
def __init__(self, output): <NEW_LINE> <INDENT> self.output = output <NEW_LINE> self.parse_queue = {} <NEW_LINE> self.parsed = [] <NEW_LINE> self.director_config = False <NEW_LINE> self.sd_config = False <NEW_LINE> self.fd_config = False <NEW_LINE> return
Initialize the instance variables, and set the output device. There should probably be a default set here.
625941cecdde0d52a9e53159
def _get_common_headers(self): <NEW_LINE> <INDENT> return { 'X-User-Id': self.user_id, 'X-Device-Id': self.device_id, 'X-Client-Version': self.client_version, 'User-Agent': self.application_name + "/" + self.client_version, 'X-Application-Name': self.application_name, self.auth[0]: self.auth[1], 'Cache-Control': 'no-ca...
Headers to include in every HTTP requests Includes the authentication heads (token based or basic auth if no token). Also include an application name header to make it possible for the server to compute access statistics for various client types (e.g. browser vs devices).
625941ce26068e7796caee05
def _flatten_anchors(anchor_lists): <NEW_LINE> <INDENT> masks = [] <NEW_LINE> mask_count = 0 <NEW_LINE> for group in anchor_lists: <NEW_LINE> <INDENT> this_mask_set = [] <NEW_LINE> for _ in group: <NEW_LINE> <INDENT> this_mask_set.append(mask_count) <NEW_LINE> mask_count += 1 <NEW_LINE> <DEDENT> masks.append(this_mask_...
Return a flattened set of anchor boxes. Take an iterable of iterables (a list of anchor coordinates) and return (1) a flattened list of anchors and (2) lists of "mask" indices mapping the flattened anchor list onto the original list. Arguments: anchor_lists {iterable} -- list of lists of anchor bo...
625941ce26238365f5f0ef94
def bisect_le(yfunc, y, r): <NEW_LINE> <INDENT> lo, hi = 0, len(r) <NEW_LINE> found = None <NEW_LINE> while lo < hi: <NEW_LINE> <INDENT> mid = (lo + hi) // 2 <NEW_LINE> if yfunc(r[mid]) <= y: <NEW_LINE> <INDENT> found = mid <NEW_LINE> lo = mid + 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> hi = mid <NEW_LINE> <DEDEN...
Return last index from range `r` which: yfunc(r[i]) <= y || None :param yfunc: probed function as one arg callable :param y: value :param r: range with non-descending values :return: found value or None
625941ce004d5f362079a458
def handle_exception(self, e, operation=None): <NEW_LINE> <INDENT> if operation is not None: self.log.error("Failed to %s." % operation) <NEW_LINE> self.log.error(str(e)) <NEW_LINE> for error in e: <NEW_LINE> <INDENT> self.log.error(str(error)) <NEW_LINE> <DEDENT> self.log.error("Error: %s." % return_execution_error()[...
Handle an exception. INPUT e: the exception (from BaseException, e). operation: the action being attempted (that failed).
625941ce4f88993c3716c18c
def move_left(self): <NEW_LINE> <INDENT> pass
stub
625941ce596a897236089be6
def filter_property(self, value): <NEW_LINE> <INDENT> filter_field = self <NEW_LINE> filter_type = filter_field.filter_type <NEW_LINE> filter_value = filter_field.filter_value <NEW_LINE> filtered = True <NEW_LINE> WEEKDAY_INTS = { 'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'su...
Determine if passed value should be filtered or not
625941ce23849d37ff7b31b5
def __init_data(self): <NEW_LINE> <INDENT> self.CompactFlag = False <NEW_LINE> self.MainRow = [512, 512, 512, 512] <NEW_LINE> self.MainCol = 4 <NEW_LINE> self.PageRange = [] <NEW_LINE> for index in range(4): <NEW_LINE> <INDENT> self.PageRange.append([512*index, 512*(index+1)]) <NEW_LINE> <DEDENT> self.PreRegSpec = {"ES...
Declare initial data.
625941ce30c21e258bdfa5c3
def change_diva_path(p, set=None, split=None, ext=None, data_format=None): <NEW_LINE> <INDENT> if isinstance(p, str): <NEW_LINE> <INDENT> p = Path(p) <NEW_LINE> <DEDENT> if not split: <NEW_LINE> <INDENT> split = p.parents[DIVAPath.split].name <NEW_LINE> <DEDENT> if not data_format: <NEW_LINE> <INDENT> data_format = p.p...
Change diva path parameters: path/Set/data_format/split :param p: :param set: :param split: :param ext: :return:
625941ce4f88993c3716c18d
@click.command() <NEW_LINE> @click.option( "--day", type=click.DateTime(), required=True, help="The day to summarize" ) <NEW_LINE> def run_command(day): <NEW_LINE> <INDENT> print(f"downloading IFQ for {day}") <NEW_LINE> cmd = DownloadIFQ(day=day) <NEW_LINE> messagebus = bootstrap.for_cli() <NEW_LINE> messagebus.handle(...
Downloads the IFQ issue for a specific day
625941ce8a349b6b435e8299
def __init__(self, name, address, build_graph, payload=None, tags=None, description=None, **kwargs): <NEW_LINE> <INDENT> self.payload = payload or Payload() <NEW_LINE> self.payload.freeze() <NEW_LINE> self.name = name <NEW_LINE> self.address = address <NEW_LINE> self._tags = set(tags or []) <NEW_LINE> self._build_graph...
:param string name: The name of this target, which combined with this build file defines the target address. :param dependencies: Other targets that this target depends on. :type dependencies: list of target specs :param Address address: The Address that maps to this Target in the BuildGraph :param BuildGraph build_g...
625941ced164cc6175782e74
def get_axis(self, day): <NEW_LINE> <INDENT> day_delta = self.now.date() - timedelta(days=day) <NEW_LINE> day_from = int(day_delta.strftime('%s')) <NEW_LINE> day_until = int(day_delta.strftime('%s')) + 60 * 60 * 24 <NEW_LINE> day_rows = [i for i in self.rows if day_from < i[0] < day_until] <NEW_LINE> time_stamp = day_d...
get axis for day passed in
625941cecad5886f8bd270ff
def test_move_multi_threading_prevention(self): <NEW_LINE> <INDENT> self.robot.move(Ptp(goal=self.test_data.get_joints("ZeroPose", PLANNING_GROUP_NAME))) <NEW_LINE> rospy.loginfo("Step 1") <NEW_LINE> ptp = Ptp(goal=self.test_data.get_joints("PTPJointValid", PLANNING_GROUP_NAME), vel_scale=0.1) <NEW_LINE> move_thread = ...
Tests what happens if two move() are started in two threads. Test sequence: 1. Start a command in separate thread. 2. Start another command in main test thread. Test Results: 1. Robot starts moving. 2. Second move throws RobotMoveAlreadyRunningError. First move finishes successfully.
625941cee8904600ed9f2053
def concrete_items(self): <NEW_LINE> <INDENT> for field, _ in self._meta.get_concrete_fields_with_model(): <NEW_LINE> <INDENT> yield field.attname, getattr(self, field.attname)
Allow model to be used as a mapping: return key, value generator
625941ced10714528d5ffe09
def get_new_fig(fn, figsize=[9,9]): <NEW_LINE> <INDENT> fig1 = plt.figure(fn, figsize) <NEW_LINE> ax1 = fig1.gca() <NEW_LINE> ax1.cla() <NEW_LINE> return fig1, ax1
Init graphics
625941ceaad79263cf390b67
def set_type_alias_map(self, type_alias_map): <NEW_LINE> <INDENT> self.type_alias_map = type_alias_map
Sets the type alias map. :type type_alias_map: Dictionary :param type_alias_map: The type alias map.
625941cebf627c535bc132f5
def scalar_map(self, other): <NEW_LINE> <INDENT> relocated_scalars = [] <NEW_LINE> origin_coords = tuple(self.position_wrt(other).to_matrix(other)) <NEW_LINE> for i, x in enumerate(other.base_scalars()): <NEW_LINE> <INDENT> relocated_scalars.append(x - origin_coords[i]) <NEW_LINE> <DEDENT> vars_matrix = (self.rotation_...
Returns a dictionary which expresses the coordinate variables (base scalars) of this frame in terms of the variables of otherframe. Parameters ========== otherframe : CoordSysCartesian The other system to map the variables to. Examples ======== >>> from sympy.vector import CoordSysCartesian >>> from sympy impor...
625941ceec188e330fd5a8c5
def setModelData(self, editor: QComboBox, model: QAbstractTableModel, index: QModelIndex) -> None: <NEW_LINE> <INDENT> self.logger.debug("Updating model data for index [{}, {}]: {}". format(index.column(), index.row(), editor.currentText())) <NEW_LINE> if index.isValid() and index.column() == 1 and not self.__only_numb...
Update the model data at the given index from the editor value. Derived function. :param editor: data provider :param model: data storage :param index: index where data has to be updated :return: Nothing
625941ce091ae35668667084
def info(self, msg): <NEW_LINE> <INDENT> logging.info(msg)
Logs an info message Parameters ------------ msg Message
625941ce23e79379d52ee68a
def refresh_node_list(self): <NEW_LINE> <INDENT> self.get_node_types() <NEW_LINE> self.populate_node_list() <NEW_LINE> return None
clear and repopulate node type list
625941ce7b25080760e3957f
def __init__(self, layers, activation='tanh'): <NEW_LINE> <INDENT> if activation == 'sigmoid': <NEW_LINE> <INDENT> self.activation = sigmoid <NEW_LINE> self.activation_deriv = sigmoid_derivative <NEW_LINE> <DEDENT> elif activation == 'tanh': <NEW_LINE> <INDENT> self.activation = tanh <NEW_LINE> self.activation_deriv = ...
:param layers: 包含每一层的单元数 :param activation: 选择非线性函数是sigmoid还是tanh 并初始化权重
625941ce5fcc89381b1e17e5
def stat_attributs(attribut): <NEW_LINE> <INDENT> final = {} <NEW_LINE> for x in attribut : <NEW_LINE> <INDENT> for element in attribut[x] : <NEW_LINE> <INDENT> if not element in final: <NEW_LINE> <INDENT> final[element]=1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> final[element]+=1 <NEW_LINE> <DEDENT> <DEDENT> <DED...
va rendre un dictionnaire qui à chaque attribut (college, location, employer) renvoit le nombre de personnes le possedant input:dictionnaire associant à chaque user son attribut (ou pas) output:dictionnaire
625941ce07d97122c41789b2
def test_search_web_block(self): <NEW_LINE> <INDENT> pass
Test case for search_web_block # noqa: E501
625941ce6aa9bd52df036ecb
def swapPairs(self, head): <NEW_LINE> <INDENT> if not head: <NEW_LINE> <INDENT> return head <NEW_LINE> <DEDENT> if not head.next: <NEW_LINE> <INDENT> return head <NEW_LINE> <DEDENT> first = head <NEW_LINE> second = head.next <NEW_LINE> while first and second: <NEW_LINE> <INDENT> first.val, second.val = second.val, firs...
:type head: ListNode :rtype: ListNode
625941ce8da39b475bd6509a
def soup(): <NEW_LINE> <INDENT> page = requests.get("https://awcoupon.ca/en/register") <NEW_LINE> logger.info("======STARTING REGISTRATION======") <NEW_LINE> if page.status_code != 200: <NEW_LINE> <INDENT> logger.error("Cannot Locate the target coupon server") <NEW_LINE> print("Cannot Locate the target server") <NEW_L...
' This function represents the automated registration component of the application It will scrape the target webpage and will sign the user up for it while imitiating a browser. The scraper will pretent to be a browser by using a header that captures a session cookie and adds a token + session key to the payload Data t...
625941ced4950a0f3b08c475
def clean_excel(filepath, write_file='src/terrorism.csv', delimiter='\t', newline='\n'): <NEW_LINE> <INDENT> book = xlrd.open_workbook(filepath) <NEW_LINE> sheet = book.sheet_by_index(0) <NEW_LINE> f = open(write_file, 'w') <NEW_LINE> for row in range(sheet.nrows): <NEW_LINE> <INDENT> for column in range(sheet.ncols): ...
Clean the global terrorism database file and convert it into a csv @param filepath {String} - The path to the global database xlsx file @param write_file {String} - Path to the .csv output file @param delimiter {String} - Delimiter for the csv output file @param newline {String} - Newline string to use for csv output ...
625941ce8c0ade5d55d3eae1
def get_file_data(filename): <NEW_LINE> <INDENT> print("search file: ", filename) <NEW_LINE> if os.path.exists(filename): <NEW_LINE> <INDENT> file_data = ((open(filename, "rb")).read()) <NEW_LINE> return file_data <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return r"C:\webroot\index.html"
Get data from file
625941ce0383005118ecf709
@patch("efm8.hid", autospec=True) <NEW_LINE> def test_flash_error(hid): <NEW_LINE> <INDENT> hid.device().get_feature_report.return_value = [0] <NEW_LINE> with pytest.raises(efm8.BadResponse): <NEW_LINE> <INDENT> efm8.flash(1, 2, "3", efm8.to_frames([0])) <NEW_LINE> <DEDENT> hid.device().open.assert_called_once_with(1, ...
Check we handle a error case.
625941ce5fcc89381b1e17e6
def _sendBoxcar2(self, msg, title, accesstoken): <NEW_LINE> <INDENT> msg = msg.strip() <NEW_LINE> curUrl = API_URL <NEW_LINE> data = urllib.urlencode({ 'user_credentials': accesstoken, 'notification[title]': "SiCKRAGE : " + title + ' : ' + msg, 'notification[long_message]': msg, 'notification[sound]': "notifier-2" }) <...
Sends a boxcar2 notification to the address provided msg: The message to send title: The title of the message accesstoken: to send to this device returns: True if the message succeeded, False otherwise
625941ce92d797404e3042b0
def _is_valid_repo_file(s): <NEW_LINE> <INDENT> if not os.path.exists(s): <NEW_LINE> <INDENT> raise argparse.ArgumentTypeError('%s: file not found' % s) <NEW_LINE> <DEDENT> repos = [] <NEW_LINE> with open(s, 'r') as csvfile: <NEW_LINE> <INDENT> reader = csv.reader(csvfile) <NEW_LINE> for row in reader: <NEW_LINE> <INDE...
Argparse type helper - is passed file a valid list of repos.
625941ced6c5a10208144172
def check_type_str(value, allow_conversion=True, param=None, prefix=''): <NEW_LINE> <INDENT> if isinstance(value, string_types): <NEW_LINE> <INDENT> return value <NEW_LINE> <DEDENT> if allow_conversion: <NEW_LINE> <INDENT> return to_native(value, errors='surrogate_or_strict') <NEW_LINE> <DEDENT> msg = "'{0!r}' is not a...
Verify that the value is a string or convert to a string. Since unexpected changes can sometimes happen when converting to a string, ``allow_conversion`` controls whether or not the value will be converted or a TypeError will be raised if the value is not a string and would be converted :arg value: Value to validate ...
625941ce16aa5153ce36259f
def _writedata( self, aData ) : <NEW_LINE> <INDENT> self.dc(1) <NEW_LINE> self.cs(0) <NEW_LINE> self.spi.write(aData) <NEW_LINE> self.cs(1)
Write given data to the device. This may be either a single int or a bytearray of values.
625941ced10714528d5ffe0a
def checkYearsOrder(year, years = YEARS): <NEW_LINE> <INDENT> year = int(year) <NEW_LINE> available_years = list(map(int,years.split(","))) <NEW_LINE> if year not in available_years: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> orderOfChecks = [year] <NEW_LINE> i = 1 <NEW_LINE> while (min(available_years) not in...
Accepts a year in the range specified in YEARS in the API_Anrop file. Returns a permutation of the years from YEARS in which order to look for data, including the given year. Prioritizes data closer to the given year, and rather more recent years than not. Example: If YEARS are "2016,2017,2018,2019" and input is 2018 t...
625941ce460517430c3942ab
def count(tnode): <NEW_LINE> <INDENT> if tnode is None: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return (1 + count(treenode.get_left(tnode)) + count(treenode.get_right(tnode)))
-> <- @param: tnode -. @return:
625941ce15fb5d323cde0c37