Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
384,600
def flatten(iterable): if isiterable(iterable): flat = [] for item in list(iterable): item = flatten(item) if not isiterable(item): item = [item] flat += item return flat else: return iterable
convenience tool to flatten any nested iterable example: flatten([[[],[4]],[[[5,[6,7, []]]]]]) >>> [4, 5, 6, 7] flatten('hello') >>> 'hello' Parameters ---------- iterable Returns ------- flattened object
384,601
def break_edge(self, from_index, to_index, to_jimage=None, allow_reverse=False): existing_edges = self.graph.get_edge_data(from_index, to_index) existing_reverse = None if to_jimage is None: raise ValueError("Image must be supplied, to avoid ambiguity.") ...
Remove an edge from the StructureGraph. If no image is given, this method will fail. :param from_index: int :param to_index: int :param to_jimage: tuple :param allow_reverse: If allow_reverse is True, then break_edge will attempt to break both (from_index, to_index) and, failing...
384,602
def container_remove_objects(object_id, input_params={}, always_retry=False, **kwargs): return DXHTTPRequest( % object_id, input_params, always_retry=always_retry, **kwargs)
Invokes the /container-xxxx/removeObjects API method. For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Folders-and-Deletion#API-method%3A-%2Fclass-xxxx%2FremoveObjects
384,603
def _strip_zoom(input_string, strip_string): try: return int(input_string.strip(strip_string)) except Exception as e: raise MapcheteConfigError("zoom level could not be determined: %s" % e)
Return zoom level as integer or throw error.
384,604
def solar_position(moment, latitude, longitude, Z=0.0, T=298.15, P=101325.0, atmos_refract=0.5667): rs refraction changes how high it appears as though the sun is; so values are returned with an optional conversion to the aparent angle. This impacts only the zenith/elevation. ...
r'''Calculate the position of the sun in the sky. It is defined in terms of two angles - the zenith and the azimith. The azimuth tells where a sundial would see the sun as coming from; the zenith tells how high in the sky it is. The solar elevation angle is returned for convinience; it is the complimen...
384,605
def xpose6(m): m = stypes.toDoubleMatrix(m) mout = stypes.emptyDoubleMatrix(x=6, y=6) libspice.xpose6_c(m, mout) return stypes.cMatrixToNumpy(mout)
Transpose a 6x6 matrix http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/xpose6_c.html :param m: Matrix to be transposed :type m: list[6][6] :return: Transposed matrix :rtype: list[6][6]
384,606
def cumulative_window(group_by=None, order_by=None): return Window( preceding=None, following=0, group_by=group_by, order_by=order_by )
Create a cumulative window for use with aggregate window functions. All window frames / ranges are inclusive. Parameters ---------- group_by : expressions, default None Either specify here or with TableExpr.group_by order_by : expressions, default None For analytic functions requir...
384,607
def download_file(url, filename=None, show_progress=draw_pbar): s filename part) show_progress: callback function to update a progress bar the show_progress function shall take two parameters: `seen` and `size`, and return nothing. This function returns the filename it has written the result to. ...
Download a file and show progress url: the URL of the file to download filename: the filename to download it to (if not given, uses the url's filename part) show_progress: callback function to update a progress bar the show_progress function shall take two parameters: `seen` and `size`, and return...
384,608
def fix_config(self, options): options = super(InitStorageValue, self).fix_config(options) opt = "storage_name" if opt not in options: options[opt] = "unknown" if opt not in self.help: self.help[opt] = "The name of the storage value to delete (string)." ...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
384,609
def closeEvent(self, event): self.script_thread.quit() self.read_probes.quit() if self.config_filename: fname = self.config_filename self.save_config(fname) event.accept() print() print() print()
things to be done when gui closes, like save the settings
384,610
def set_send_enable(self, setting): self._pebble.send_packet(DataLogging(data=DataLoggingSetSendEnable(enabled=setting)))
Set the send enable setting on the watch
384,611
def make_headers(context: TraceContext) -> Headers: headers = { TRACE_ID_HEADER: context.trace_id, SPAN_ID_HEADER: context.span_id, FLAGS_HEADER: , SAMPLED_ID_HEADER: if context.sampled else , } if context.parent_id is not None: headers[PARENT_ID_HEADER] = conte...
Creates dict with zipkin headers from supplied trace context.
384,612
async def get_scene(self, scene_id, from_cache=True) -> Scene: if not from_cache: await self.get_scenes() for _scene in self.scenes: if _scene.id == scene_id: return _scene raise ResourceNotFoundException("Scene not found scene_id: {}".format(scen...
Get a scene resource instance. :raises a ResourceNotFoundException when no scene found. :raises a PvApiError when something is wrong with the hub.
384,613
def set_server(self, server_pos, key, value): if zeroconf_tag and self.zeroconf_enable_tag: self.listener.set_server(server_pos, key, value)
Set the key to the value for the server_pos (position in the list).
384,614
def cmprss(delim, n, instr, lenout=_default_len_out): delim = ctypes.c_char(delim.encode(encoding=)) n = ctypes.c_int(n) instr = stypes.stringToCharP(instr) output = stypes.stringToCharP(lenout) libspice.cmprss_c(delim, n, instr, lenout, output) return stypes.toPythonString(output)
Compress a character string by removing occurrences of more than N consecutive occurrences of a specified character. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cmprss_c.html :param delim: Delimiter to be compressed. :type delim: str :param n: Maximum consecutive occurrences of del...
384,615
def reset (): global __prefixes_suffixes, __suffixes_to_types, __types, __rule_names_to_types, __target_suffixes_cache __register_features () __prefixes_suffixes = [property.PropertyMap(), property.PropertyMap()] __suffixes_to_types = {} __types = {} ...
Clear the module state. This is mainly for testing purposes. Note that this must be called _after_ resetting the module 'feature'.
384,616
def get_subdomain_history_neighbors(self, cursor, subdomain_rec): hist = self.subdomain_db.get_subdomain_history(subdomain_rec.get_fqn(), include_unaccepted=True, start_sequence=subdomain_rec.n-1, end_sequence=subdomain_rec.n, cur=cursor) hist.sort(lambda h1, h2: -1 if h1.n < h2.n or (...
Given a subdomain record, get its neighbors. I.e. get all of the subdomain records with the previous sequence number, and get all of the subdomain records with the next sequence number Returns {'prev': [...blockchain order...], 'cur': [...blockchain order...], 'fut': [...blockchain order...]}
384,617
def getTransitionProbabilities(state, action): assert 0 <= action < ACTIONS if not isLegal(state, action): s1 = [convertTupleToIndex(state)] return(s1, [1], -10) state = list(state) state[action] = PLAYER if isWon(state, PLAYER): ...
Parameters ---------- state : tuple The state action : int The action Returns ------- s1, p, r : tuple of two lists and an int s1 are the next states, p are the probabilities, and r is the reward
384,618
def nuc_v(msg): tc = typecode(msg) if tc != 19: raise RuntimeError("%s: Not an airborne velocity message, expecting TC = 19" % msg) msgbin = common.hex2bin(msg) NUCv = common.bin2int(msgbin[42:45]) try: HVE = uncertainty.NUCv[NUCv][] VVE = uncertainty.NUCv[NUCv][] ...
Calculate NUCv, Navigation Uncertainty Category - Velocity (ADS-B version 1) Args: msg (string): 28 bytes hexadecimal message string, Returns: int or string: 95% Horizontal Velocity Error int or string: 95% Vertical Velocity Error
384,619
def clean_caches(path): for dirname, subdirlist, filelist in os.walk(path): for f in filelist: if f.endswith(): try: os.remove(os.path.join(dirname, f)) except FileNotFoundError: pass if dirname.endswith(): ...
Removes all python cache files recursively on a path. :param path: the path :return: None
384,620
def sync(to_install, to_uninstall, verbose=False, dry_run=False, install_flags=None): if not to_uninstall and not to_install: click.echo("Everything up-to-date") pip_flags = [] if not verbose: pip_flags += [] if to_uninstall: if dry_run: click.echo("Would unins...
Install and uninstalls the given sets of modules.
384,621
def user_data_dir(appname, appauthor=None, version=None, roaming=False): r if sys.platform.startswith("win"): if appauthor is None: raise AppDirsError("must specify on Windows") const = roaming and "CSIDL_APPDATA" or "CSIDL_LOCAL_APPDATA" path = os.path.join(_get_win_folder(...
r"""Return full path to the user-specific data dir for this application. "appname" is the name of application. "appauthor" (only required and used on Windows) is the name of the appauthor or distributing body for this application. Typically it is the owning company name. ...
384,622
def upgrade(): op.create_table( , sa.Column(, sa.Integer(), nullable=False), sa.Column(, sa.Integer(), nullable=False), sa.Column(, sa.String(length=255), nullable=False), sa.Column( , sqlalchemy_utils.JSONType(), nullable=False), ...
Upgrade database.
384,623
def build(self, pre=None, shortest=False): if pre is None: pre = [] res = deque() for value in self.values: try: res.append(utils.val(value, pre, shortest=shortest)) except errors.FlushGrams as e: prev = "".join(res) ...
Build this rule definition :param list pre: The prerequisites list :param bool shortest: Whether or not the shortest reference-chain (most minimal) version of the field should be generated.
384,624
def connect(self, name, func, sender=None, dispatch_uid=None): try: signal = self._registry[name] except KeyError: signal = self.register(name) signal.connect(func, sender=sender, dispatch_uid=dispatch_uid)
Connects a function to a hook.\ Creates the hook (name) if it does not exists :param str name: The hook name :param callable func: A function reference used as a callback :param class sender: Optional sender __class__ to which the\ func should respond. Default will match all ...
384,625
def pretty_size(value): exp = int(math.log(value, 1024)) if value > 0 else 0 unit = [exp] if exp == 0: return % (value, unit) unit_value = value / (1024.0 ** exp) places = int(math.log(unit_value, 10)) return % (2 - places, unit_value, unit)
Convert a number of bytes into a human-readable string. Output is 2...5 characters. Values >= 1000 always produce output in form: x.xxxU, xx.xxU, xxxU, xxxxU.
384,626
def _cmptimestamps(self, filest1, filest2): mtime_cmp = int((filest1.st_mtime - filest2.st_mtime) * 1000) > 0 if self._use_ctime: return mtime_cmp or \ int((filest1.st_ctime - filest2.st_mtime) * 1000) > 0 else: return mtime_cmp
Compare time stamps of two files and return True if file1 (source) is more recent than file2 (target)
384,627
def delete(self, id): map = self._delete_map_from_user_by_id(c.user, id) if map is None: abort(404) if os.path.exists(os.path.join(config[], map.filepath)): os.unlink(os.path.join(config[], map.filepath)) response.status = 204 return
DELETE /mapfiles/id: Delete an existing mapfile owned by the current user. Deletion of the map entry in db and remove mapfile from filesystem.
384,628
def _Open(self, path_spec, mode=): if not path_spec.HasParent(): raise errors.PathSpecError( ) range_offset = getattr(path_spec, , None) if range_offset is None: raise errors.PathSpecError( ) range_size = getattr(path_spec, , None) if range_size is None: ...
Opens the file system defined by path specification. Args: path_spec (PathSpec): a path specification. mode (Optional[str]): file access mode. The default is 'rb' which represents read-only binary. Raises: AccessError: if the access to open the file was denied. IOError: if th...
384,629
def file_delete(context, id, file_id): component.file_delete(context, id=id, file_id=file_id)
file_delete(context, id, path) Delete a component file >>> dcictl component-file-delete [OPTIONS] :param string id: ID of the component to delete file [required] :param string file_id: ID for the file to delete [required]
384,630
def build_path(graph, node1, node2, path=None): if path is None: path = [] if node1 is node2: return path path.append(node2) for pred in graph.all_preds(node2): if pred in path: continue build_path(graph, node1, pred, path) return path
Build the path from node1 to node2. The path is composed of all the nodes between node1 and node2, node1 excluded. Although if there is a loop starting from node1, it will be included in the path.
384,631
def attention_lm_base(): hparams = common_hparams.basic_params1() hparams.hidden_size = 1024 hparams.batch_size = 8192 hparams.max_length = 256 hparams.dropout = 0.0 hparams.clip_grad_norm = 0. hparams.optimizer_adam_epsilon = 1e-9 hparams.learning_rate_decay_scheme = "noam" hparams.learning_rate...
Set of hyperparameters.
384,632
def copy( self, name, start_codons=None, stop_codons=None, codon_table=None, codon_table_changes=None): new_start_codons = ( self.start_codons.copy() if start_codons is None else start_codons) ...
Make copy of this GeneticCode object with optional replacement values for all fields.
384,633
def usage(): global g_script_name print("") print("Usage: " + g_script_name + " [...options...]") print("") print(" --help print out this help menu and show all the valid flags and inputs.") print("") print(" --inputfileadd filename where the new java messages to ignore are...
Illustrate what the various input flags are and the options should be. :return: none
384,634
def _extract_symbols(self, symbols, default=None): to_ret = {} for symbol in symbols: symbolInfo = self.elf.symbol_decoder.get_symbol_for_name(symbol) if symbolInfo is None: if default is not None: to_ret[symbol] = default ...
! @brief Fill 'symbols' field with required flash algo symbols
384,635
def add_values_to_bundle_safe(connection, bundle, values): for value in values: try: connection.addValueToBundle(bundle, value) except YouTrackException as e: if e.response.status == 409: print("Value with name [ %s ] already exists in bundle [ %s ]" % ...
Adds values to specified bundle. Checks, whether each value already contains in bundle. If yes, it is not added. Args: connection: An opened Connection instance. bundle: Bundle instance to add values in. values: Values, that should be added in bundle. Raises: YouTrackException:...
384,636
def get(self, key): doc = self._collection.find_one({: key}) if doc: doc.pop() return doc
Get a document by id.
384,637
def infos(self): data = { "meta": { "description": self.meta_description, "lang": self.meta_lang, "keywords": self.meta_keywords, "favicon": self.meta_favicon, "canonical": self.canonical_link, "...
dict: The summation of all data available about the extracted article Note: Read only
384,638
def direction_vector(self, angle): s movement direction at a given (absolute) angle (in degrees). No check is made whether angle lies within the arcs span ) Returns a 2x1 numpy array. >>> a = Arc((0, 0), 1, 0, 90, True) >>> assert all(abs(a.direction_vector(0) - np.array...
Returns a unit vector, pointing in the arc's movement direction at a given (absolute) angle (in degrees). No check is made whether angle lies within the arc's span (the results for angles outside of the arc's span ) Returns a 2x1 numpy array. >>> a = Arc((0, 0), 1, 0, 90, True) ...
384,639
def pop(self, pair, default=None): return super(BaseKerning, self).pop(pair, default)
Removes the **pair** from the Kerning and returns the value as an ``int``. If no pair is found, **default** is returned. **pair** is a ``tuple`` of two :ref:`type-string`\s. This must return either **default** or a :ref:`type-int-float`. >>> font.kerning.pop(("A", "V")) ...
384,640
def char_between(lower, upper, func_name): function = register_function(func_name, lambda char: lower<=char<=upper) return char_on_predicate(function)
return current char and step if char is between lower and upper, where @test: a python function with one argument, which tests on one char and return True or False @test must be registered with register_function
384,641
def returnValueList(self, key_list, last=False): last=TrueJimLarry result = [] row = self.returnOneEntry(last=last) if not row: return None dict_row = internal.convert_to_dict(row) for field in key_list: result.append(dict_row.get(field, None)) ...
Return a list of key values for the first entry in the current list. If 'last=True', then the last entry is referenced." Returns None is the list is empty. If a key is missing, then that entry in the list is None. Example of use: >>> test = [ ... {"name": "Jim", "...
384,642
def apply_new_scoped_variable_type(self, path, new_variable_type_str): data_port_id = self.list_store[path][self.ID_STORAGE_ID] try: if self.model.state.scoped_variables[data_port_id].data_type.__name__ != new_variable_type_str: self.model.state.scoped_variables[data...
Applies the new data type of the scoped variable defined by path :param str path: The path identifying the edited variable :param str new_variable_type_str: New data type as str
384,643
def normalize_sort(sort=None): if not sort: return Null output = FlatList() for s in listwrap(sort): if is_text(s) or mo_math.is_integer(s): output.append({"value": s, "sort": 1}) elif not s.field and not s.value and s.sort==None: for n, v ...
CONVERT SORT PARAMETERS TO A NORMAL FORM SO EASIER TO USE
384,644
def zpk2tf(z, p, k): r import scipy.signal b, a = scipy.signal.zpk2tf(z, p, k) return b, a
r"""Return polynomial transfer function representation from zeros and poles :param ndarray z: Zeros of the transfer function. :param ndarray p: Poles of the transfer function. :param float k: System gain. :return: b : ndarray Numerator polynomial. a : ndarray Numerator and denominator ...
384,645
def start_trace(reset=True, filter_func=None, time_filter_func=None): global trace_filter global time_filter if reset: reset_trace() if filter_func: trace_filter = filter_func else: trace_filter = GlobbingFilter(exclude=[]) if time_filter_func: time_filter ...
Begins a trace. Setting reset to True will reset all previously recorded trace data. filter_func needs to point to a callable function that accepts the parameters (call_stack, module_name, class_name, func_name, full_name). Every call will be passed into this function and it is up to the function to dec...
384,646
def count_if(predicate, seq): f = lambda count, x: count + (not not predicate(x)) return reduce(f, seq, 0)
Count the number of elements of seq for which the predicate is true. >>> count_if(callable, [42, None, max, min]) 2
384,647
def _gather_all_deps(self, args, kwargs): depends = [] count = 0 for dep in args: if isinstance(dep, Future): if self.tasks[dep.tid][] not in FINAL_STATES: count += 1 depends.extend([dep]) for key...
Count the number of unresolved futures on which a task depends. Args: - args (List[args]) : The list of args list to the fn - kwargs (Dict{kwargs}) : The dict of all kwargs passed to the fn Returns: - count, [list of dependencies]
384,648
def register(self, what, obj): name = obj.name version = obj.version enable = obj.enable if enable == : return key = Key(name, version) self.plugins[what][key] = obj
Registering a plugin Params ------ what: Nature of the plugin (backend, instrumentation, repo) obj: Instance of the plugin
384,649
def validate_xml_text(text): bad_chars = __INVALID_XML_CHARS & set(text) if bad_chars: for offset,c in enumerate(text): if c in bad_chars: raise RuntimeError( + repr(c) + + str(offset))
validates XML text
384,650
def get_feature_by_path(self, locus, term, rank, accession, **kwargs): kwargs[] = True if kwargs.get(): return self.get_feature_by_path_with_http_info(locus, term, rank, accession, **kwargs) else: (data) = self.get_feature_by_path_with_http_info(locus, term, rank...
Retrieve an enumerated sequence feature This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(resp...
384,651
def _reaction_po_to_dict(tokens) -> Reaction: return Reaction( reactants=_reaction_part_po_to_dict(tokens[REACTANTS]), products=_reaction_part_po_to_dict(tokens[PRODUCTS]), )
Convert a reaction parse object to a DSL. :type tokens: ParseResult
384,652
def _radec(self,*args,**kwargs): lbd= self._lbd(*args,**kwargs) return coords.lb_to_radec(lbd[:,0],lbd[:,1],degree=True,epoch=None)
Calculate ra and dec
384,653
def configureIAMCredentials(self, AWSAccessKeyID, AWSSecretAccessKey, AWSSessionToken=""): iam_credentials_provider = IAMCredentialsProvider() iam_credentials_provider.set_access_key_id(AWSAccessKeyID) iam_credentials_provider.set_secret_access_key(AWSSecretAccessKey) iam_creden...
**Description** Used to configure/update the custom IAM credentials for Websocket SigV4 connection to AWS IoT. Should be called before connect. **Syntax** .. code:: python myAWSIoTMQTTClient.configureIAMCredentials(obtainedAccessKeyID, obtainedSecretAccessKey, obtainedSess...
384,654
def _invalid_implementation(self, t, missing, mistyped, mismatched): assert missing or mistyped or mismatched, "Implementation wasn't invalid." message = "\nclass {C} failed to implement interface {I}:".format( C=getname(t), I=getname(self), ) if missing...
Make a TypeError explaining why ``t`` doesn't implement our interface.
384,655
def redistribute_threads(blockdimx, blockdimy, blockdimz, dimx, dimy, dimz): while blockdimz > dimz: tmp = blockdimz // 2 if tmp < dimz: break blockdimy *= 2 blockdimz = tmp while blockdimy > dimy: tmp = blockdimy // 2 i...
Redistribute threads from the Z dimension towards the X dimension. Also clamp number of threads to the problem dimension size, if necessary
384,656
def set_dimmer_start_time(self, hour, minute): d1 = self._gateway.get_gateway_info().current_time d2 = dt.utcnow() diff = d1 - d2 newtime = dt(100, 1, 1, hour, minute, 00) - diff command = { ATTR_SMART_TASK_TRIGGER_TIME_INTERVAL: ...
Set start time for task (hh:mm) in iso8601. NB: dimmer starts 30 mins before time in app
384,657
def create(*context, **kwargs): items = context context = ContextStack() for item in items: if item is None: continue if isinstance(item, ContextStack): context._stack.extend(item._stack) else: context...
Build a ContextStack instance from a sequence of context-like items. This factory-style method is more general than the ContextStack class's constructor in that, unlike the constructor, the argument list can itself contain ContextStack instances. Here is an example illustrating various...
384,658
def _make_r_patches(data, K_g, critical_r, indices, approx): def append_components(means, covs, data, partition): subdata_start = 0 subdata_stop = partition[0] for len_subdata in partition: subdata = data[subdata_start:subdata_stop] means.append( _np.mean(subdat...
Helper function for :py:func:`.make_r_gaussmix` and :py:func:`.make_r_tmix`. Group the ``data`` according to the R value and split each group into ``K_g`` patches. Return the patch means and covariances. For details see the docstrings of the above mentioned functions.
384,659
def load(self, dump_fn=, prep_only=0, force_upload=0, from_local=0, name=None, site=None, dest_dir=None): r = self.database_renderer(name=name, site=site) r.env.dump_fn = self.get_default_db_fn(fn_template=dump_fn, dest_dir=dest_dir) from_local = int(from_local) pre...
Restores a database snapshot onto the target database server. If prep_only=1, commands for preparing the load will be generated, but not the command to finally load the snapshot.
384,660
def enter_eventloop(self): self.log.info("entering eventloop") signal(SIGINT, default_int_handler) while self.eventloop is not None: try: self.eventloop(self) except KeyboardInterrupt: self.log.error("Keyb...
enter eventloop
384,661
def cleanup_unreachable(rdf): all_subjects = set(rdf.subjects()) logging.debug("total subject resources: %d", len(all_subjects)) reachable = find_reachable(rdf, SKOS.Concept) nonreachable = all_subjects - reachable logging.debug("deleting %s non-reachable resources", len(nonreachable)) ...
Remove triples which cannot be reached from the concepts by graph traversal.
384,662
def resample_signal(self, data_frame): new_freq = np.round(1 / self.sampling_frequency, decimals=6) df_resampled = data_frame.resample(str(new_freq) + ).mean() logging.debug("resample signal") df_resampled = df_resampled.interpolate(...
Convenience method for frequency conversion and resampling of data frame. Object must have a DatetimeIndex. After re-sampling, this methods interpolate the time magnitude sum acceleration values and the x,y,z values of the data frame acceleration :param data_frame: the data frame ...
384,663
def _stripslashes(s): r = re.sub(r"\\(n|r)", "\n", s) r = re.sub(r"\\", "", r) return r
Removes trailing and leading backslashes from string
384,664
def _set_status(self, status, message=): message = message.strip() if message.startswith(): msg_id = message[1:] message = self.messages.get(msg_id, ) message = message.encode(, ) for func in self.set_status_funcs: func(s...
Updates the status and message on all supported IM apps. `status` Status type (See ``VALID_STATUSES``). `message` Status message.
384,665
def from_bytes(cls, b): hdr = None head_chunks = [] end = ("IEND", make_chunk("IEND", b"")) frame_chunks = [] frames = [] num_plays = 0 frame_has_head_chunks = False control = None for type_, data in parse_chunks(b): if type_ == "IHDR": hdr = data frame_chunks.append((type_, dat...
Create an APNG from raw bytes. :arg bytes b: The raw bytes of the APNG file. :rtype: APNG
384,666
def is_same(type1, type2): nake_type1 = remove_declarated(type1) nake_type2 = remove_declarated(type2) return nake_type1 == nake_type2
returns True, if type1 and type2 are same types
384,667
def _get_log_model_class(self): if self.log_model_class is not None: return self.log_model_class app_label, model_label = self.log_model.rsplit(, 1) self.log_model_class = apps.get_model(app_label, model_label) return self.log_model_class
Cache for fetching the actual log model object once django is loaded. Otherwise, import conflict occur: WorkflowEnabled imports <log_model> which tries to import all models to retrieve the proper model class.
384,668
def shelter_listbybreed(self, **kwargs): root = self._do_api_call("shelter.listByBreed", kwargs) shelter_ids = root.findall("shelterIds/id") for shelter_id in shelter_ids: yield shelter_id.text
shelter.listByBreed wrapper. Given a breed and an animal type, list the shelter IDs with pets of said breed. :rtype: generator :returns: A generator of shelter IDs that have breed matches.
384,669
def move(zone, zonepath): * ret = {: True} res = __salt__[](.format( zone=.format(zone) if _is_uuid(zone) else .format(zone), path=zonepath, )) ret[] = res[] == 0 ret[] = res[] if ret[] else res[] ret[] = ret[].replace(, ) if ret[] == : del ret[] return...
Move zone to new zonepath. zone : string name or uuid of the zone zonepath : string new zonepath CLI Example: .. code-block:: bash salt '*' zoneadm.move meave /sweetwater/meave
384,670
def get_profile(session): response = session.get(PROFILE_URL, allow_redirects=False) if response.status_code == 302: raise USPSError() parsed = BeautifulSoup(response.text, HTML_PARSER) profile = parsed.find(, {: }) data = {} for row in profile.find_all(): cells = row.find_a...
Get profile data.
384,671
def add_interactions_from(self, ebunch, t=None, e=None): if t is None: raise nx.NetworkXError( "The t argument must be a specified.") for ed in ebunch: self.add_interaction(ed[0], ed[1], t, e)
Add all the interaction in ebunch at time t. Parameters ---------- ebunch : container of interaction Each interaction given in the container will be added to the graph. The interaction must be given as as 2-tuples (u,v) or 3-tuples (u,v,d) where d is a dictio...
384,672
def imagecapture(self, window_name=None, x=0, y=0, width=None, height=None): if x or y or (width and width != -1) or (height and height != -1): raise LdtpServerException("Not implemented") if window_name: handle, name, app = self._get_window_handle(w...
Captures screenshot of the whole desktop or given window @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param x: x co-ordinate value @type x: int @param y: y co-ordinate value ...
384,673
def set_stack_address_mapping(self, absolute_address, region_id, related_function_address=None): if self._stack_region_map is None: raise SimMemoryError() self._stack_region_map.map(absolute_address, region_id, related_function_address=related_function_address)
Create a new mapping between an absolute address (which is the base address of a specific stack frame) and a region ID. :param absolute_address: The absolute memory address. :param region_id: The region ID. :param related_function_address: Related function address.
384,674
def s15f16l(s): n = len(s) // 4 t = struct.unpack( % n, s) return map((2**-16).__mul__, t)
Convert sequence of ICC s15Fixed16 to list of float.
384,675
def _get(self, key, what): if not self.runtime._ring: return None pos = self._get_pos(key) if what == : return pos nodename = self.runtime._ring[self.runtime._keys[pos]] if what in [, , , ]: return self.runtime._nodes[nodename][what]...
Generic getter magic method. The node with the nearest but not less hash value is returned. :param key: the key to look for. :param what: the information to look for in, allowed values: - instance (default): associated node instance - nodename: node name - p...
384,676
def checkBinary(name, bindir=None): if name == "sumo-gui": envName = "GUISIM_BINARY" else: envName = name.upper() + "_BINARY" env = os.environ join = os.path.join if envName in env and exeExists(env.get(envName)): return env.get(envName) if bindir is not None: ...
Checks for the given binary in the places, defined by the environment variables SUMO_HOME and <NAME>_BINARY.
384,677
def OnPadIntCtrl(self, event): self.attrs["pad"] = event.GetValue() post_command_event(self, self.DrawChartMsg)
Pad IntCtrl event handler
384,678
def _get_remote(self, cached=True): return self.m( , cmdd=dict( cmd= % ( if cached else ), cwd=self.local ), verbose=False )
Helper function to determine remote :param cached: Use cached values or query remotes
384,679
def from_conll(this_class, stream): stream = iter(stream) corpus = this_class() while 1: sentence = Sentence.from_conll(stream) if sentence: corpus.append(sentence) else: break return corpus
Construct a Corpus. stream is an iterable over strings where each string is a line in CoNLL-X format.
384,680
def remove(path): r = cpenv.resolve(path) if isinstance(r.resolved[0], cpenv.VirtualEnvironment): EnvironmentCache.discard(r.resolved[0]) EnvironmentCache.save()
Remove a cached environment. Removed paths will no longer be able to be activated by name
384,681
def sample_slice(args): (u, loglstar, axes, scale, prior_transform, loglikelihood, kwargs) = args rstate = np.random nonperiodic = kwargs.get(, None) n = len(u) slices = kwargs.get(, 5) nc = 0 nexpand = 0 ncontract = 0 fscale = [] axes = scale ...
Return a new live point proposed by a series of random slices away from an existing live point. Standard "Gibs-like" implementation where a single multivariate "slice" is a combination of `ndim` univariate slices through each axis. Parameters ---------- u : `~numpy.ndarray` with shape (npdim,) ...
384,682
def _execute(self, cursor, statements): payload = [{: s, : p, :[]} for (s, p) in statements] http_response = self._http_req("POST", self._tx, {: payload}) if self._tx == TX_ENDPOINT: self._tx = http_response.getheader() response = self._deserialize(http_response) ...
Executes a list of statements, returning an iterator of results sets. Each statement should be a tuple of (statement, params).
384,683
def list(self, search_opts=None): query = base.get_query_string(search_opts) return self._list( % query, )
Get a list of Plugins.
384,684
def get_ball_by_ball(self, match_key, over_key=None): if over_key: ball_by_ball_url = "{base_path}match/{match_key}/balls/{over_key}/".format(base_path=self.api_path, match_key=match_key, over_key=over_key) else: ball_by_ball_url = "{base_path}match/{match_key}/balls/"....
match_key: key of the match over_key : key of the over Return: json data:
384,685
def check_applied(result): try: applied = result.was_applied except Exception: applied = True if not applied: raise LWTException(result.one())
Raises LWTException if it looks like a failed LWT request. A LWTException won't be raised in the special case in which there are several failed LWT in a :class:`~cqlengine.query.BatchQuery`.
384,686
def updateSocialTone(user, socialTone, maintainHistory): currentSocial = [] currentSocialObject = [] for tone in socialTone[]: if tone[] >= SOCIAL_HIGH_SCORE_THRESHOLD: currentSocial.append(tone[].lower() + ) currentSocialObject.append({ : tone[].lo...
updateSocialTone updates the user with the social tones interpreted based on the specified thresholds @param user a json object representing user information (tone) to be used in conversing with the Conversation Service @param socialTone a json object containing the social tones in the payload retur...
384,687
def _set_system_description(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass(v,base=RestrictedClassType(base_type=unicode, restriction_dict={: [u]}), is_leaf=True, yang_name="system-description", rest_name="system-description", parent=self, path_helper=self._...
Setter method for system_description, mapped from YANG variable /protocol/lldp/system_description (string) If this variable is read-only (config: false) in the source YANG file, then _set_system_description is considered as a private method. Backends looking to populate this variable should do so via ca...
384,688
def mode(data): n = data.shape[0] iqr = np.percentile(data, 75)-np.percentile(data, 25) bin_size = 2 * iqr / n**(1/3) if bin_size == 0: return np.nan databin = np.round(data/bin_size)*bin_size + bin_size/2 u, indices = np.unique(databin, return_inverse=Tru...
Compute an intelligent value for the mode The most common value in experimental is not very useful if there are a lot of digits after the comma. This method approaches this issue by rounding to bin size that is determined by the Freedman–Diaconis rule. Parameters ---------- data: 1d ndarra...
384,689
def add_enclave_tag(self, report_id, name, enclave_id, id_type=None): params = { : id_type, : name, : enclave_id } resp = self._client.post("reports/%s/tags" % report_id, params=params) return str(resp.content)
Adds a tag to a specific report, for a specific enclave. :param report_id: The ID of the report :param name: The name of the tag to be added :param enclave_id: ID of the enclave where the tag will be added :param id_type: indicates whether the ID internal or an external ID provided by t...
384,690
def primary_avatar(user, size=AVATAR_DEFAULT_SIZE): alt = unicode(user) url = reverse(, kwargs={ : user, : size}) return % (url, alt, )
This tag tries to get the default avatar for a user without doing any db requests. It achieve this by linking to a special view that will do all the work for us. If that special view is then cached by a CDN for instance, we will avoid many db calls.
384,691
def delete(self, personId): check_type(personId, basestring, may_be_none=False) self._session.delete(API_ENDPOINT + + personId)
Remove a person from the system. Only an admin can remove a person. Args: personId(basestring): The ID of the person to be deleted. Raises: TypeError: If the parameter types are incorrect. ApiError: If the Webex Teams cloud returns an error.
384,692
def parse_args(self): self.tcex.log.info() Args(self.tcex.parser) self.args = self.tcex.args
Parse CLI args.
384,693
def send_data_to_server(self, data, time_out=5): if not data.endswith(self.__connection_end): data = "{0}{1}".format(data, foundations.strings.to_string(self.__connection_end).decode("string_escape")) connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) connectio...
Sends given data to the Server. :param data: Data to send. :type data: unicode :param time_out: Connection timeout in seconds. :type time_out: float :return: Method success. :rtype: bool
384,694
def terminate(self): terminate_function_name = self.spec.get() if not terminate_function_name: logger.error( , self.key) return None terminate_function = getattr(self.module, self.spec[]) if no...
Kills the work unit. This is called by the standard worker system, but only in response to an operating system signal. If the job does setup such as creating a child process, its terminate function should kill that child process. More specifically, this function requires the w...
384,695
def transformer_moe_base(): hparams = common_hparams.basic_params1() hparams.norm_type = "layer" hparams.hidden_size = 512 hparams.batch_size = 4096 hparams.max_length = 2001 hparams.max_input_seq_length = 2000 hparams.max_target_seq_length = 2000 hparams.dropout = 0.0 hparams.clip_grad_norm = 0. ...
Set of hyperparameters.
384,696
def field_value(key, label, color, padding): if not clr.has_colors and padding > 0: padding = 7 if color == "bright gray" or color == "dark gray": bright_prefix = "" else: bright_prefix = "bright " field = clr.stringc(key, "{0}{1}".format(bright_prefix, color)) field_l...
Print a specific field's stats.
384,697
def write_configuration(self, out, secret_attrs=False): key_order = [, , , , , , , , ] cd = self.get_configuration_dict(secret_attrs=secret_attrs) for k in key_order: if k in cd: out.write(.format(k, cd[k])) out.write() fo...
Generic configuration, may be overridden by type-specific version
384,698
def execute_cleanup_tasks(ctx, cleanup_tasks, dry_run=False): executor = Executor(cleanup_tasks, ctx.config) for cleanup_task in cleanup_tasks.tasks: print("CLEANUP TASK: %s" % cleanup_task) executor.execute((cleanup_task, dict(dry_run=dry_run)))
Execute several cleanup tasks as part of the cleanup. REQUIRES: ``clean(ctx, dry_run=False)`` signature in cleanup tasks. :param ctx: Context object for the tasks. :param cleanup_tasks: Collection of cleanup tasks (as Collection). :param dry_run: Indicates dry-run mode (bool)
384,699
def make_transformer(self, decompose=, decompose_by=50, tsne_kwargs={}): decompositions = { : TruncatedSVD, : PCA, } if decompose and decompose.lower() not in decompositions: raise YellowbrickValueError( " is not a ...
Creates an internal transformer pipeline to project the data set into 2D space using TSNE, applying an pre-decomposition technique ahead of embedding if necessary. This method will reset the transformer on the class, and can be used to explore different decompositions. Parameters ...