Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
379,900
def Dropout(p=0, per_channel=False, name=None, deterministic=False, random_state=None): if ia.is_single_number(p): p2 = iap.Binomial(1 - p) elif ia.is_iterable(p): ia.do_assert(len(p) == 2) ia.do_assert(p[0] < p[1]) ia.do_assert(0 <= p[0] <= 1.0) ia.do_assert(0 <= p[...
Augmenter that sets a certain fraction of pixels in images to zero. dtype support:: See ``imgaug.augmenters.arithmetic.MultiplyElementwise``. Parameters ---------- p : float or tuple of float or imgaug.parameters.StochasticParameter, optional The probability of any pixel being dropped...
379,901
def display_files(self, pcs_files): tree_iters = [] for pcs_file in pcs_files: path = pcs_file[] pixbuf, type_ = self.app.mime.get(path, pcs_file[], icon_size=self.ICON_SIZE) name = os.path.split(path)[NAME_COL] ...
重新格式化一下文件列表, 去除不需要的信息 这一操作主要是为了便于接下来的查找工作. 文件的path都被提取出来, 然后放到了一个list中.
379,902
def from_tuples(cls, tups): ivs = [Interval(*t) for t in tups] return IntervalTree(ivs)
Create a new IntervalTree from an iterable of 2- or 3-tuples, where the tuple lists begin, end, and optionally data.
379,903
def local_lru(obj): @wraps(obj) def memoizer(*args, **kwargs): instance = args[0] lru_size = instance._cache_size if lru_size: cache = instance._cache key = str((args, kwargs)) try: r = cache.pop(key) cache[key] = r...
Property that maps to a key in a local dict-like attribute. self._cache must be an OrderedDict self._cache_size must be defined as LRU size .. class Foo(object): def __init__(self, cache_size=5000): self._cache = OrderedDict() self._cache_size...
379,904
def _deallocator(self): lookup = { "c_bool": "logical", "c_double": "double", "c_double_complex": "complex", "c_char": "char", "c_int": "int", "c_float": "float", "c_short": "short", "c_long": "long" ...
Returns the name of the subroutine in ftypes_dealloc.f90 that can deallocate the array for this Ftype's pointer. :arg ctype: the string c-type of the variable.
379,905
def get_querystring(self): to_remove = self.get_querystring_parameter_to_remove() query_string = urlparse(self.request.get_full_path()).query query_dict = parse_qs(query_string.encode()) for arg in to_remove: if arg in query_dict: del query_dict[arg] ...
Clean existing query string (GET parameters) by removing arguments that we don't want to preserve (sort parameter, 'page')
379,906
def run(self, deploy_attempted=False): stdout = stderr = retcode = None if self.opts.get(, False): cmd_str = .join([self._escape_arg(arg) for arg in self.argv]) stdout, stderr, retcode = self.shell.exec_cmd(cmd_str) elif self.fun in self.wfuncs or self.mine: ...
Execute the routine, the routine can be either: 1. Execute a raw shell command 2. Execute a wrapper func 3. Execute a remote Salt command If a (re)deploy is needed, then retry the operation after a deploy attempt Returns tuple of (stdout, stderr, retcode)
379,907
def get_fresh_primary_tumors(biospecimen): df = biospecimen num_before = len(df.index) df = df.loc[~df[]] logger.info( , num_before - len(df.index), num_before) num_before = len(df.index) df = df.loc[df[] == ] logger.info( , ...
Filter biospecimen data to only keep non-FFPE primary tumor samples. Parameters ---------- biospecimen : `pandas.DataFrame` The biospecimen data frame. This type of data frame is returned by :meth:`get_biospecimen_data`. Returns ------- `pandas.DataFrame` The fi...
379,908
def do_loop_turn(self): if not self.is_master: logger.debug("Waiting for my master death...") self.wait_for_master_death() return if self.loop_count % self.alignak_monitor_period == 1: self.get_alignak_status(details=True) ...
Loop turn for Arbiter If not a master daemon, wait for my master death... Else, run: * Check satellites are alive * Check and dispatch (if needed) the configuration * Get broks and external commands from the satellites * Push broks and external commands to the satellites...
379,909
def load(self, name): try: return self._factories[name]() except KeyError: raise ValueError( "no %s factory registered under name %r, options are: %r" % (self.interface.__name__, name, sorted(self._factories)), )
Construct an object from a registered factory. Parameters ---------- name : str Name with which the factory was registered.
379,910
def show_firmware_version_output_show_firmware_version_node_info_firmware_version_info_secondary_version(self, **kwargs): config = ET.Element("config") show_firmware_version = ET.Element("show_firmware_version") config = show_firmware_version output = ET.SubElement(show_firmware...
Auto Generated Code
379,911
def load_extracted(src_dir: str, patterns="*.npy", vars_in_cols: bool = True, index: pd.Series = None): def _load(path, index): if index is None: arr = np.load(str(path)) else: arr = np.load(str(path), mmap_mode="r...
Load data extracted and stored by :py:func:`extract` Arguments: src_dir {str} -- The directory where the data is stored. Keyword Arguments: patterns {str, or list of str} -- A pattern (str) or list of patterns (list) to identify the variables to be loaded. The default l...
379,912
def dad_status_output_dad_status_entries_message(self, **kwargs): config = ET.Element("config") dad_status = ET.Element("dad_status") config = dad_status output = ET.SubElement(dad_status, "output") dad_status_entries = ET.SubElement(output, "dad-status-entries") ...
Auto Generated Code
379,913
def get_space(self, space_key, expand=): url = .format(space_key=space_key, expand=expand) return self.get(url)
Get information about a space through space key :param space_key: The unique space key name :param expand: OPTIONAL: additional info from description, homepage :return: Returns the space along with its ID
379,914
def client_id(self, client): params = { "name": client } response = self._get(url.clients, params=params) self._check_response(response, 200) return self._create_response(response).get("client_id")
Get a client's ID. Uses GET to /clients?name=<client> interface. :Args: * *client*: (str) Client's name :Returns: (str) Client id
379,915
def df2chucks(din,chunksize,outd,fn,return_fmt=,force=False): from os.path import exists from os import makedirs din.index=range(0,len(din),1) chunkrange=list(np.arange(0,len(din),chunksize)) chunkrange=list(zip([c+1 if ci!=0 else 0 for ci,c in enumerate(chunkrange)],chunkrange[1:]+[len(din)-1...
:param return_fmt: '\t': tab-sep file, lly, '.', 'list': returns a list
379,916
def load(cosmicFiles, tag=None, sat_id=None): import netCDF4 num = len(cosmicFiles) if num != 0: output = pysat.DataFrame(load_files(cosmicFiles, tag=tag, sat_id=sat_id)) output.index = pysat.utils.create_datetime_index(year=output.year, month...
cosmic data load routine, called by pysat
379,917
def split_task_parameters(line): if line is None: result = [] else: result = [parameter.strip() for parameter in line.split(",")] return result
Split a string of comma separated words.
379,918
def add_field(self, fieldname, fieldspec=whoosh_module_fields.TEXT): self._whoosh.add_field(fieldname, fieldspec) return self._whoosh.schema
Add a field in the index of the model. Args: fieldname (Text): This parameters register a new field in specified model. fieldspec (Name, optional): This option adds various options as were described before. Returns: TYPE: The new schema after deleted is returned.
379,919
def _desy_bookkeeping(self, key, value): return { : normalize_date(value.get()), : force_single_element(value.get()), : value.get(), }
Populate the ``_desy_bookkeeping`` key.
379,920
def safe_join(directory, *pathnames): parts = [directory] for filename in pathnames: if filename != "": filename = posixpath.normpath(filename) for sep in _os_alt_seps: if sep in filename: return None if os.path.isabs(filename) or filename == ...
Safely join `directory` and one or more untrusted `pathnames`. If this cannot be done, this function returns ``None``. :param directory: the base directory. :param pathnames: the untrusted pathnames relative to that directory.
379,921
def get_transform(offset, scale): return pd.DataFrame([[scale, 0, offset.x], [0, scale, offset.y], [0, 0, 1]], index=[, , ])
Parameters ---------- offset : pandas.Series Cartesian ``(x, y)`` coordinate of offset origin. scale : pandas.Series Scaling factor for ``x`` and ``y`` dimensions. Returns ------- pandas.DataFrame 3x3 transformation matrix resulting in specified `x/y` offset and ...
379,922
def setex(self, name, time, value): if isinstance(time, datetime.timedelta): time = int(time.total_seconds()) return self.execute_command(, name, time, value)
Set the value of key ``name`` to ``value`` that expires in ``time`` seconds. ``time`` can be represented by an integer or a Python timedelta object.
379,923
def expand_item(self, item, open_all=True): self.expand_row(self._view_path_for(item), open_all)
Display a node as expanded :param item: The item to show expanded :param open_all: Whether all child nodes should be recursively expanded.
379,924
def addChromosome( self, chrom, tax_id, tax_label=None, build_id=None, build_label=None): family = Family(self.graph) chr_id = makeChromID(str(chrom), tax_id) if tax_label is not None: chr_label = makeChromLabel(chrom, tax_label) else: ...
if it's just the chromosome, add it as an instance of a SO:chromosome, and add it to the genome. If a build is included, punn the chromosome as a subclass of SO:chromsome, and make the build-specific chromosome an instance of the supplied chr. The chr then becomes part of the build or ge...
379,925
def gen_round_trip_stats(round_trips): stats = {} stats[] = agg_all_long_short(round_trips, , PNL_STATS) stats[] = agg_all_long_short(round_trips, , SUMMARY_STATS) stats[] = agg_all_long_short(round_trips, , DURAT...
Generate various round-trip statistics. Parameters ---------- round_trips : pd.DataFrame DataFrame with one row per round trip trade. - See full explanation in round_trips.extract_round_trips Returns ------- stats : dict A dictionary where each value is a pandas DataFram...
379,926
def build_rrule(count=None, interval=None, bysecond=None, byminute=None, byhour=None, byweekno=None, bymonthday=None, byyearday=None, bymonth=None, until=None, bysetpos=None, wkst=None, byday=None, freq=None): result = {} if count is not None: result...
Build rrule dictionary for vRecur class. :param count: int :param interval: int :param bysecond: int :param byminute: int :param byhour: int :param byweekno: int :param bymonthday: int :param byyearday: int :param bymonth: int :param until: datetime :param bysetpos: int ...
379,927
def connect(self, recver): r1 = recver m1 = r1.middle s2 = self m2 = self.middle r2 = self.other r2.middle = m1 del m2.sender del m2.recver del m1.recver m1.recver = weakref.ref(r2, m1.on_abandoned) m1.recver_current = m2...
Rewire: s1 -> m1 <- r1 --> s2 -> m2 <- r2 To: s1 -> m1 <- r2
379,928
def raw_datastream_old(request, pid, dsid, type=None, repo=None, headers=None, accept_range_request=False, as_of_date=None, streaming=False): DISABLED if repo is None: repo = Repository() if headers is None: headers = {} get_obj_opts = {} ...
.. NOTE:: This version of :meth:`raw_datastream` is deprecated, and you should update to the new :meth:`raw_datastream`. This version is still available if you are using a version of Fedora prior to 3.7 and need the additional functionality. View to display a raw datastream that b...
379,929
def get_gradient_y(shape, py): import scipy.sparse height, width = shape rows = [] empty = scipy.sparse.dia_matrix((width, width)) identity = scipy.sparse.identity(width) for n in range(py): row = [empty]*n row += [-identity, identity] row += [empty]*(height-n...
Calculate the gradient in the y direction to the line at py The y gradient operator is a block matrix, where each block is the size of the image width. The matrix itself is made up of (img_height x img_height) blocks, most of which are all zeros.
379,930
def loadSenderKey(self, senderKeyName): q = "SELECT record FROM sender_keys WHERE group_id = ? and sender_id = ?" cursor = self.dbConn.cursor() cursor.execute(q, (senderKeyName.getGroupId(), senderKeyName.getSender().getName())) result = cursor.fetchone() if not result:...
:type senderKeyName: SenderKeyName
379,931
def p_for_stmt(p): if len(p) == 8: if not isinstance(p[2], node.ident): raise_exception(SyntaxError, "Not implemented: for loop", new_lexer) p[2].props = "I" p[0] = node.for_stmt(ident=p[2], expr=p[4], stmt_list=p[6])
for_stmt : FOR ident EQ expr SEMI stmt_list END_STMT | FOR LPAREN ident EQ expr RPAREN SEMI stmt_list END_STMT | FOR matrix EQ expr SEMI stmt_list END_STMT
379,932
def mp2q(p, q): p, q = flatten(p), flatten(q) entropy_dist = 1 / len(p) return sum(entropy_dist * np.nan_to_num((p ** 2) / q * np.log(p / q)))
Compute the MP2Q measure. Args: p (np.ndarray): The unpartitioned repertoire q (np.ndarray): The partitioned repertoire
379,933
def _generate_subscribe_headers(self): headers =[] headers.append((, self.eventhub_client.zone_id)) token = self.eventhub_client.service._get_bearer_token() headers.append((, self._config.subscriber_name)) headers.append((, token[(token.index() + 1):])) if self...
generate the subscribe stub headers based on the supplied config :return: i
379,934
def authorize_handler(self, f): @wraps(f) def decorated(*args, **kwargs): server = self.server uri, http_method, body, headers = extract_params() if request.method in (, ): redirect_uri = request.args.get(, self.error_uri) ...
Authorization handler decorator. This decorator will sort the parameters and headers out, and pre validate everything:: @app.route('/oauth/authorize', methods=['GET', 'POST']) @oauth.authorize_handler def authorize(*args, **kwargs): if request.method...
379,935
def do_run_one(self, args): work_spec_names = args.from_work_spec or None worker = SingleWorker(self.config, task_master=self.task_master, work_spec_names=work_spec_names, max_jobs=args.max_jobs) worker.register() rc = False starttime = time.time() count = 0 ...
run a single job
379,936
def format_rst(self): res = num_cols = len(self.header) col_width = 25 for _ in range(num_cols): res += .join([ for _ in range(col_width - 1)]) + res += for c in self.header: res += c.ljust(col_width) res += for _ in ...
return table in RST format
379,937
def preserve_set_th1_add_directory(state=True): with LOCK: status = ROOT.TH1.AddDirectoryStatus() try: ROOT.TH1.AddDirectory(state) yield finally: ROOT.TH1.AddDirectory(status)
Context manager to temporarily set TH1.AddDirectory() state
379,938
def get_lldp_neighbor_detail_output_lldp_neighbor_detail_remaining_life(self, **kwargs): config = ET.Element("config") get_lldp_neighbor_detail = ET.Element("get_lldp_neighbor_detail") config = get_lldp_neighbor_detail output = ET.SubElement(get_lldp_neighbor_detail, "output") ...
Auto Generated Code
379,939
def unique_slugify(instance, value, slug_field_name=, queryset=None, slug_separator=): slug_field = instance._meta.get_field(slug_field_name) slug = getattr(instance, slug_field.attname) slug_len = slug_field.max_length slug = slugify(value) if slug_len: slug =...
Calculates and stores a unique slug of ``value`` for an instance. ``slug_field_name`` should be a string matching the name of the field to store the slug in (and the field to check against for uniqueness). ``queryset`` usually doesn't need to be explicitly provided - it'll default to using the ``.all(...
379,940
def remove_volatile(type_): nake_type = remove_alias(type_) if not is_volatile(nake_type): return type_ else: if isinstance(nake_type, cpptypes.array_t): is_c = is_const(nake_type) if is_c: base_type_ = nake_type.base.base.base else: ...
removes volatile from the type definition If type is not volatile type, it will be returned as is
379,941
def data_received(self, data): self.tokenizer.feed(data) while self.tokenizer.has_tokens(): raw = self.tokenizer.get_next_token() frame = frame_from_raw(raw) if frame is not None: self.frame_received_cb(frame)
Handle data received.
379,942
def target(self): task = yield self.task() if not task: yield defer.succeed(None) defer.returnValue(None) defer.returnValue(task.target)
Find the target name for this build. :returns: deferred that when fired returns the build task's target name. If we could not determine the build task, or the task's target, return None.
379,943
def hpss_demo(input_file, output_harmonic, output_percussive): print(, input_file) y, sr = librosa.load(input_file) print() y_harmonic, y_percussive = librosa.effects.hpss(y) print(, output_harmonic) librosa.output.write_wav(output_harmonic, y_harmonic, sr) print(, o...
HPSS demo function. :parameters: - input_file : str path to input audio - output_harmonic : str path to save output harmonic (wav) - output_percussive : str path to save output harmonic (wav)
379,944
def flexifunction_directory_send(self, target_system, target_component, directory_type, start_index, count, directory_data, force_mavlink1=False): return self.send(self.flexifunction_directory_encode(target_system, target_component, directory_type, start_index, count, directory_data), f...
Acknowldge sucess or failure of a flexifunction command target_system : System ID (uint8_t) target_component : Component ID (uint8_t) directory_type : 0=inputs, 1=outputs (uint8_t) start_index : index of first...
379,945
def colorize(self, colormap): if self.mode not in ("L", "LA"): raise ValueError("Image should be grayscale to colorize") if self.mode == "LA": alpha = self.channels[1] else: alpha = None self.channels = colormap.colorize(self.channels[0]) ...
Colorize the current image using *colormap*. Works only on"L" or "LA" images.
379,946
def find(node, filter_=None, stop=None, maxlevel=None): return _find(node, filter_=filter_, stop=stop, maxlevel=maxlevel)
Search for *single* node matching `filter_` but stop at `maxlevel` or `stop`. Return matching node. Args: node: top node, start searching. Keyword Args: filter_: function called with every `node` as argument, `node` is returned if `True`. stop: stop iteration at `node` if `stop` f...
379,947
def combine_metadata(*metadata_objects, **kwargs): average_times = kwargs.get(, True) shared_keys = None info_dicts = [] for metadata_object in metadata_objects: if isinstance(metadata_object, dict): metadata_dict = metadata_object elif hasattr(metadata_object, "a...
Combine the metadata of two or more Datasets. If any keys are not equal or do not exist in all provided dictionaries then they are not included in the returned dictionary. By default any keys with the word 'time' in them and consisting of datetime objects will be averaged. This is to handle cases where...
379,948
def enable(self): ret = self.get() if ret is None: return False else: return ret.lower().startswith()
Return True|False if the AMP is enabled in the configuration file (enable=true|false).
379,949
def entrez_sets_of_results(url, retstart=False, retmax=False, count=False) -> Optional[List[requests.Response]]: if not retstart: retstart = 0 if not retmax: retmax = 500 if not count: count = retmax retmax = 500 while retstart < count: diff = count - retsta...
Gets sets of results back from Entrez. Entrez can only return 500 results at a time. This creates a generator that gets results by incrementing retstart and retmax. Parameters ---------- url : str The Entrez API url to use. retstart : int Return values starting at this index. ...
379,950
def _checkstatus(status, line): newstatus = 0 if status == 0: if _islinetype(line, GRPSTART): newstatus = 1 elif _isfinal(line): newstatus = 4 elif status == 1: if _islinetype(line, GRPSTART): newstatus = 1 e...
Returns state/status after reading the next line. The status codes are:: LE07_clip_L1TP_039027_20150529_20160902_01_T1_B1.TIF - BEGIN parsing; 1 - ENTER METADATA GROUP, 2 - READ METADATA LINE, 3 - END METDADATA GROUP, 4 - END PARSING Permitted Transitions:: LE07_clip_L1TP_039027_20150529...
379,951
def get_bucket(self, hash_name, bucket_key): results = [] for row in self._get_bucket_rows(hash_name, bucket_key): val_dict = pickle.loads(row) if in val_dict: row = [] col = [] data = [] ...
Returns bucket content as list of tuples (vector, data).
379,952
def _add_grid_attributes(self, ds): for name_int, names_ext in self._grid_attrs.items(): ds_coord_name = set(names_ext).intersection(set(ds.coords) | set(ds.data_vars)) model_attr = getattr(self.model, name_int, None) ...
Add model grid attributes to a dataset
379,953
def straddle(self, strike, expiry): _rows = {} _prices = {} for _opttype in _constants.OPTTYPES: _rows[_opttype] = _relevant_rows(self.data, (strike, expiry, _opttype,), "No key for {} strike {} {}".format(expiry, strike, _opttype)) _prices[_o...
Metrics for evaluating a straddle. Parameters ------------ strike : numeric Strike price. expiry : date or date str (e.g. '2015-01-01') Expiration date. Returns ------------ metrics : DataFrame Metrics for evaluating straddle.
379,954
def stream(self, from_=values.unset, to=values.unset, date_created_on_or_before=values.unset, date_created_after=values.unset, limit=None, page_size=None): limits = self._version.read_limits(limit, page_size) page = self.page( from_=from_, ...
Streams FaxInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode from_: Retrieve only those faxes sent...
379,955
def create_app(debug=False): app = Flask(__name__) app.secret_key = str(uuid.uuid4()) app.json_encoder = DateTimeEncoder app.register_blueprint(page) Bower(app) api = Api(app) api.add_resource( PluginListAPI, api_path + "plugins/", endpoint="APIPlugins" ) ...
Create the flask app :param debug: Use debug mode :type debug: bool :return: Created app :rtype: flask.Flask
379,956
def make_url(path, protocol=None, hosts=None): protocol = if not protocol else protocol host = hosts[random.randrange(len(hosts))] if hosts else return protocol + host + path.strip()
Make an URL given a path, and optionally, a protocol and set of hosts to select from randomly. :param path: The Archive.org path. :type path: str :param protocol: (optional) The HTTP protocol to use. "https://" is used by default. :type protocol: str :param hosts: (option...
379,957
def get_users_for_assigned_to(): User = get_user_model() return User.objects.filter(is_active=True, is_staff=True)
Return a list of users who can be assigned to workflow states
379,958
def get_by_name(self, name): san_managers = self._client.get_all() result = [x for x in san_managers if x[] == name] return result[0] if result else None
Gets a SAN Manager by name. Args: name: Name of the SAN Manager Returns: dict: SAN Manager.
379,959
def get_currency(self, code): for currency in self.currencies: if currency[] == code: return currency raise RuntimeError("%s: %s not found" % (self.name, code))
Helper function Returns a dict containing: shortname (the code) longname users - a comma separated list of countries/regions/cities that use it alternatives - alternative names, e.g. ewro, Quid, Buck symbol - e.g. £, $ highlight - ?
379,960
def _replace_with_specific_page(page, menu_item): if type(page) is Page: page = page.specific if isinstance(menu_item, MenuItem): menu_item.link_page = page else: menu_item = page return page, menu_item
If ``page`` is a vanilla ``Page` object, replace it with a 'specific' version of itself. Also update ``menu_item``, depending on whether it's a ``MenuItem`` object or a ``Page`` object.
379,961
def get_attributes(self, dataset): attributes = self.attributes(dataset) attr_ = [ (k, v[0]) for k, v in attributes.items()] return pd.DataFrame(attr_, columns=["Attribute","Description"])
Get available attritbutes from dataset you've selected
379,962
def _insert_html(self, cursor, html): cursor.beginEditBlock() cursor.insertHtml(html) cursor.movePosition(QtGui.QTextCursor.Left, QtGui.QTextCursor.KeepAnchor) if cursor.selection().toPlainText() == : cursor.removeSelectedText() ...
Inserts HTML using the specified cursor in such a way that future formatting is unaffected.
379,963
def on_startup(self, callback: callable, polling=True, webhook=True): self._check_frozen() if not webhook and not polling: warn(, UserWarning) return if isinstance(callback, (list, tuple, set)): for cb in callback: self.on_startup(cb,...
Register a callback for the startup process :param callback: :param polling: use with polling :param webhook: use with webhook
379,964
def price_unit(self): currency = self.currency consumption_unit = self.consumption_unit if not currency or not consumption_unit: _LOGGER.error("Could not find price_unit.") return " " return currency + "/" + consumption_unit
Return the price unit.
379,965
def sample(self, bqm, num_reads=10): values = tuple(bqm.vartype.value) def _itersample(): for __ in range(num_reads): sample = {v: choice(values) for v in bqm.linear} energy = bqm.energy(sample) yield sample, energy samples,...
Give random samples for a binary quadratic model. Variable assignments are chosen by coin flip. Args: bqm (:obj:`.BinaryQuadraticModel`): Binary quadratic model to be sampled from. num_reads (int, optional, default=10): Number of reads. ...
379,966
def plot_welch_perdiogram(x, fs, nperseg): import scipy.signal import numpy N = len(x) time = numpy.arange(N) / fs f, Pxx_den = scipy.signal.welch(x, fs, nperseg=nperseg) plt.semilogy(f, Pxx_den) plt.ylim([0.5e-3, 1]) plt.xlabel() plt.ylabel() plt.show() ...
Plot Welch perdiogram Args ---- x: ndarray Signal array fs: float Sampling frequency nperseg: float Length of each data segment in PSD
379,967
def _account_table(accounts): accountmap = {} for acc in accounts: accountmap[acc.address] = acc for alias in acc.aliases: accountmap[alias] = acc return accountmap
creates a lookup table (emailaddress -> account) for a given list of accounts :param accounts: list of accounts :type accounts: list of `alot.account.Account` :returns: hashtable :rvalue: dict (str -> `alot.account.Account`)
379,968
def fetch_url(url): with closing(urllib.urlopen(url)) as f: if f.code is 200: response = f.read() return strip_formfeeds(response).decode(ENCODING)
Fetch the given url, strip formfeeds and decode it into the defined encoding
379,969
def _readClusterSettings(self): instanceMetaData = get_instance_metadata() region = zoneToRegion(self._zone) conn = boto.ec2.connect_to_region(region) instance = conn.get_all_instances(instance_ids=[instanceMetaData["instance-id"]])[0].instances[0] self.clusterName = str...
Reads the cluster settings from the instance metadata, which assumes the instance is the leader.
379,970
def exec_(self, columns=(), by=(), where=(), **kwds): return self._seu(, columns, by, where, kwds)
exec from self >>> t = q('([]a:1 2 3; b:10 20 30)') >>> t.exec_('a', where='b > 10').show() 2 3
379,971
def kube_pod_status_phase(self, metric, scraper_config): metric_name = scraper_config[] + status_phase_counter = Counter() for sample in metric.samples: tags = [ self._label_to_tag(, sample[self.SAMPLE_LABELS], scraper_config), ...
Phase a pod is in.
379,972
def _extract_html_hex(string): try: hex_string = string and _hex_regexp().search(string).group(0) or except AttributeError: return None if len(hex_string) == 3: hex_string = hex_string[0] * 2 + hex_string[1] * 2 + hex_string[2] * 2 return hex_string
Get the first 3 or 6 hex digits in the string
379,973
def is_prime(n, mr_rounds=25): if n <= first_primes[-1]: return n in first_primes for p in first_primes: if n % p == 0: return False return miller_rabin(n, mr_rounds)
Test whether n is probably prime See <https://en.wikipedia.org/wiki/Primality_test#Probabilistic_tests> Arguments: n (int): the number to be tested mr_rounds (int, optional): number of Miller-Rabin iterations to run; defaults to 25 iterations, which is what the GMP library uses ...
379,974
def cancel_signature_request(self, signature_request_id): request = self._get_request() request.post(url=self.SIGNATURE_REQUEST_CANCEL_URL + signature_request_id, get_json=False)
Cancels a SignatureRequest Cancels a SignatureRequest. After canceling, no one will be able to sign or access the SignatureRequest or its documents. Only the requester can cancel and only before everyone has signed. Args: signing_request_id (str): The id of the signature r...
379,975
def sortby(self, variables, ascending=True): from .dataarray import DataArray if not isinstance(variables, list): variables = [variables] else: variables = variables variables = [v if isinstance(v, DataArray) else self[v] for v in va...
Sort object by labels or values (along an axis). Sorts the dataset, either along specified dimensions, or according to values of 1-D dataarrays that share dimension with calling object. If the input variables are dataarrays, then the dataarrays are aligned (via left-join) to th...
379,976
def _gdcm_to_numpy(self, image): gdcm_typemap = { gdcm.PixelFormat.INT8: numpy.int8, gdcm.PixelFormat.UINT8: numpy.uint8, gdcm.PixelFormat.UINT16: numpy.uint16, gdcm.PixelFormat.INT16: numpy.int16, gdcm.PixelFormat.UINT32: numpy....
Converts a GDCM image to a numpy array. :param image: GDCM.ImageReader.GetImage()
379,977
def reset(self): "Initialises all needed variables to default values" self.metadata = {} self.items = [] self.spine = [] self.guide = [] self.pages = [] self.toc = [] self.bindings = [] self.IDENTIFIER_ID = self.FOLDER_NAME = s...
Initialises all needed variables to default values
379,978
def ParseFromString(self, text, message): if not isinstance(text, str): text = text.decode() return self.ParseLines(text.split(), message)
Parses a text representation of a protocol message into a message.
379,979
def update(self, x, w=1): self.n += w if len(self) == 0: self._add_centroid(Centroid(x, w)) return S = self._find_closest_centroids(x) while len(S) != 0 and w > 0: j = choice(list(range(len(S)))) c_j = S[j] q = self...
Update the t-digest with value x and weight w.
379,980
def parseValue(self, value): if self.isVector(): return list(map(self._pythonType, value.split())) if self.typ == : return _parseBool(value) return self._pythonType(value)
Parse the given value and return result.
379,981
def get_routers(self, context, router_ids=None, hd_ids=None): cctxt = self.client.prepare(version=) return cctxt.call(context, , host=self.host, router_ids=router_ids, hosting_device_ids=hd_ids)
Make a remote process call to retrieve the sync data for routers. :param context: session context :param router_ids: list of routers to fetch :param hd_ids: hosting device ids, only routers assigned to these hosting devices will be returned.
379,982
def key(self, key, strictkey=None): return self._select(self._pointer.key(key, strictkey))
Return a chunk referencing a key in a mapping with the name 'key'.
379,983
def set_attributes(self, doc, fields, parent_type=None, catch_all_field=None): if parent_type: assert isinstance(parent_type, Union) super(Union, self).set_attributes(doc, fields, parent_type) self.catch_all_field = catch_all_field self.parent_type = ...
:param UnionField catch_all_field: The field designated as the catch-all. This field should be a member of the list of fields. See :meth:`Composite.set_attributes` for parameter definitions.
379,984
def insert_many(self, rows, chunk_size=1000, ensure=None, types=None): chunk = [] for row in rows: row = self._sync_columns(row, ensure, types=types) chunk.append(row) if len(chunk) == chunk_size: chunk = pad_chunk_columns(chunk) ...
Add many rows at a time. This is significantly faster than adding them one by one. Per default the rows are processed in chunks of 1000 per commit, unless you specify a different ``chunk_size``. See :py:meth:`insert() <dataset.Table.insert>` for details on the other parameters....
379,985
def route(self, fn, **kwargs): new_kwargs = fn(**kwargs) if not isinstance(new_kwargs, dict): return new_kwargs new_kwargs["url"] = kwargs return self.render(**new_kwargs)
Route helper : apply fn function but keep the calling object, *ie* kwargs, for other functions :param fn: Function to run the route with :type fn: function :param kwargs: Parsed url arguments :type kwargs: dict :return: HTTP Response with rendered template :rtype: flask....
379,986
def _formatFilepaths(self): likedir=self[][] self.likefile = join(likedir,self[][]) self.mergefile = join(likedir,self[][]) self.roifile = join(likedir,self[][]) searchdir=self[][] self.labelfile = join(searchdir,self[][]) self.objectfile = join(sear...
Join dirnames and filenames from config.
379,987
def platform_detect(): pi = pi_version() if pi is not None: return RASPBERRY_PI plat = platform.platform() if plat.lower().find() > -1: return BEAGLEBONE_BLACK elif plat.lower().find() > -1: return BEAGLEBONE_BLACK elif plat.lower().find() > -1: ...
Detect if running on the Raspberry Pi or Beaglebone Black and return the platform type. Will return RASPBERRY_PI, BEAGLEBONE_BLACK, or UNKNOWN.
379,988
def leave_scope(self): def entry_size(entry): if entry.scope == SCOPE.global_ or \ entry.is_aliased: return 0 if entry.class_ != CLASS.array: return entry.size return entry.memsize for v in...
Ends a function body and pops current scope out of the symbol table.
379,989
def buscar_healthchecks(self, id_ambiente_vip): url = + str(id_ambiente_vip) code, xml = self.submit(None, , url) return self.response(code, xml, [])
Search healthcheck ​by environmentvip_id :return: Dictionary with the following structure: :: {'healthcheck_opt': [{'name': <name>, 'id': <id>},...]} :raise InvalidParameterError: Environment VIP identifier is null and invalid. :raise EnvironmentVipNotFoundError: Environm...
379,990
def update_mode(arg_namespace): try: updater.update(custom_sources=arg_namespace.custom) except (PermissionError, FileNotFoundError) as exception: if isinstance(exception, PermissionError): print() if isinstance(exception, FileNotFoundError): print( ...
Check command line arguments and run update function.
379,991
def to_netjson(self, remove_block=True): result = OrderedDict() intermediate_data = list(self.intermediate_data[self.intermediate_key]) for index, block in enumerate(intermediate_data): if self.should_skip_block(block): continue ...
Converts the intermediate data structure (``self.intermediate_datra``) to a NetJSON configuration dictionary (``self.config``)
379,992
def update(self, num_iid, session, **kwargs): request = TOPRequest() request[] = num_iid for k, v in kwargs.iteritems(): if k not in (, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ) and v==None: continue if k == : k...
taobao.item.update 更新商品信息 根据传入的num_iid更新对应的商品的数据 传入的num_iid所对应的商品必须属于当前会话的用户 商品的属性和sku的属性有包含的关系,商品的价格要位于sku的价格区间之中(例如,sku价格有5元、10元两种,那么商品的价格就需要大于等于5元,小于等于10元,否则更新商品会失败) 商品的类目和商品的价格、sku的价格都有一定的相关性(具体的关系要通过类目属性查询接口获得) 当关键属性值更新为“其他”的时候,需要输入input_pids和input_str商品才能更新成功。
379,993
def add_auth(self, req, **kwargs): if in req.headers: del req.headers[] req.headers[] = formatdate(usegmt=True) req.headers[] = self._provider.security_token string_to_sign, headers_to_sign = self.string_to_sign(req) boto.log.debug( % strin...
Add AWS3 authentication to a request. :type req: :class`boto.connection.HTTPRequest` :param req: The HTTPRequest object.
379,994
def GetBalance(self, asset_id, watch_only=0): total = Fixed8(0) if type(asset_id) is NEP5Token.NEP5Token: return self.GetTokenBalance(asset_id, watch_only) for coin in self.GetCoins(): if coin.Output.AssetId == asset_id: if coin.State & CoinStat...
Get the balance of a specific token by its asset id. Args: asset_id (NEP5Token|TransactionOutput): an instance of type neo.Wallets.NEP5Token or neo.Core.TX.Transaction.TransactionOutput to get the balance from. watch_only (bool): True, to limit to watch only wallets. Returns: ...
379,995
def _build(self, src, path, dest, mtime): input_path = os.path.join(src, path) output_paths = [os.path.join(dest, output) for output in self._outputs(src, path)] if path in self.failures and mtime <= self.failures[path]: ret...
Calls `build` after testing that at least one output file (as returned by `_outputs()` does not exist or is older than `mtime`. If the build fails, the build time is recorded and no other builds will be attempted on `input` until this method is called with a larger mtime.
379,996
def pkg_blacklist(self): blacklist = BlackList() options = [ "-b", "--blacklist" ] flag = [ "--add", "--remove" ] command = ["list"] if (len(self.args) == 2 and self.args[0] in options and se...
Manage blacklist packages
379,997
def get_ntlm_response(self, flags, challenge, target_info=None, channel_binding=None): if flags & NegotiateFlag.NTLMSSP_NTLM2_KEY and self._lm_compatibility < 3: response, key = PasswordAuthentication.get_ntlm2_respon...
Computes the 24 byte NTLM challenge response given the 8 byte server challenge, along with the session key. If NTLMv2 is used, the TargetInfo structure must be supplied, the updated TargetInfo structure will be returned :param challenge: The 8-byte challenge message generated by the server :retu...
379,998
def _VarintBytes(value): pieces = [] _EncodeVarint(pieces.append, value) return b"".join(pieces)
Encode the given integer as a varint and return the bytes. This is only called at startup time so it doesn't need to be fast.
379,999
def find_one(self, cls, id): try: db_result = self.get_class_table(cls).lookup(id) except ItemNotFound: return obj
Required functionality.