Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
387,000
def forward_substitution(matrix_l, matrix_b): q = len(matrix_b) matrix_y = [0.0 for _ in range(q)] matrix_y[0] = float(matrix_b[0]) / float(matrix_l[0][0]) for i in range(1, q): matrix_y[i] = float(matrix_b[i]) - sum([matrix_l[i][j] * matrix_y[j] for j in range(0, i)]) matrix_y[i] /...
Forward substitution method for the solution of linear systems. Solves the equation :math:`Ly = b` using forward substitution method where :math:`L` is a lower triangular matrix and :math:`b` is a column matrix. :param matrix_l: L, lower triangular matrix :type matrix_l: list, tuple :param matrix_...
387,001
def _get_qvm_based_on_real_device(name: str, device: Device, noisy: bool, connection: ForestConnection = None, qvm_type: str = ): if noisy: noise_model = device.noise_model else: noise_model = None return _get_qvm_qc(na...
A qvm with a based on a real device. This is the most realistic QVM. :param name: The full name of this QVM :param device: The device from :py:func:`get_lattice`. :param noisy: Whether to construct a noisy quantum computer by using the device's associated noise model. :param connection: An...
387,002
def valuefrompostdata(self, postdata): if self.id in postdata and postdata[self.id] != : return int(postdata[self.id]) else: return None
This parameter method searches the POST data and retrieves the values it needs. It does not set the value yet though, but simply returns it. Needs to be explicitly passed to parameter.set()
387,003
def compute(cls, observation, prediction): assert isinstance(observation, dict) assert isinstance(prediction, dict) p_mean = prediction[] s = (((p_n-1)*(p_std**2) + (o_n-1)*(o_std**2))/(p_n+o_n-2))**0.5 except KeyError: s = (p_std**2 + o_std**2)**0.5 ...
Compute a Cohen's D from an observation and a prediction.
387,004
def _line_wrapper(self,diffs): for fromdata,todata,flag in diffs: if flag is None: yield fromdata,todata,flag continue (fromline,fromtext),(toline,totext) = fromdata,todata fromlist,toli...
Returns iterator that splits (wraps) mdiff text lines
387,005
def svd(g, svdcut=1e-12, wgts=False, add_svdnoise=False): if hasattr(g,): is_dict = True g = BufferDict(g) else: is_dict = False class svdarray(numpy.ndarray): def __new__(cls, inputarray): obj = numpy.array(g).view(cls) retur...
Apply SVD cuts to collection of |GVar|\s in ``g``. Standard usage is, for example, :: svdcut = ... gmod = svd(g, svdcut=svdcut) where ``g`` is an array of |GVar|\s or a dictionary containing |GVar|\s and/or arrays of |GVar|\s. When ``svdcut>0``, ``gmod`` is a copy of ``g`` whose |GVar...
387,006
def build_tensor_serving_input_receiver_fn(shape, dtype=tf.float32, batch_size=1): def serving_input_receiver_fn(): features = tf.placeholder( dtype=dtype, shape=[batch_size] + shape, name=) return tf.estimator.export.TensorServingInputReceiver( ...
Returns a input_receiver_fn that can be used during serving. This expects examples to come through as float tensors, and simply wraps them as TensorServingInputReceivers. Arguably, this should live in tf.estimator.export. Testing here first. Args: shape: list representing target size of a single example....
387,007
def walk(self, basedir): system_d = SitePackagesDir() filter_system_d = system_d and os.path.commonprefix([system_d, basedir]) != system_d for root, dirs, files in os.walk(basedir, topdown=True): dirs[:] = [d for d in dirs if d[0] != and d[0] != "_"] ...
Walk all the directories of basedir except hidden directories :param basedir: string, the directory to walk :returns: generator, same as os.walk
387,008
def on_play_speed(self, *args): Clock.unschedule(self.play) Clock.schedule_interval(self.play, 1.0 / self.play_speed)
Change the interval at which ``self.play`` is called to match my current ``play_speed``.
387,009
def NRTL(xs, taus, alphas): r gammas = [] cmps = range(len(xs)) Gs = [[exp(-alphas[i][j]*taus[i][j]) for j in cmps] for i in cmps] for i in cmps: tn1, td1, total2 = 0., 0., 0. for j in cmps: tn1 += xs[j]*taus[j][i]*Gs[j][i] td1 += xs[j]*Gs[j][i] ...
r'''Calculates the activity coefficients of each species in a mixture using the Non-Random Two-Liquid (NRTL) method, given their mole fractions, dimensionless interaction parameters, and nonrandomness constants. Those are normally correlated with temperature in some form, and need to be calculated separ...
387,010
def resolve_object(self, object_arg_name, resolver): def decorator(func_or_class): if isinstance(func_or_class, type): func_or_class._apply_decorator_to_methods(decorator) return func_or_class @wraps(func_or_clas...
A helper decorator to resolve object instance from arguments (e.g. identity). Example: >>> @namespace.route('/<int:user_id>') ... class MyResource(Resource): ... @namespace.resolve_object( ... object_arg_name='user', ... resolver=lambda kwargs: User.quer...
387,011
def _get(self, uri, params={}): if not uri.startswith(self.remote): uri = .format(self.remote, uri) return self._make_request(uri, params)
HTTP GET function :param uri: REST endpoint :param params: optional HTTP params to pass to the endpoint :return: list of results (usually a list of dicts) Example: ret = cli.get('/search', params={ 'q': 'example.org' })
387,012
def _parse_csv_col_rules(self): self.cols = self.csv_line.split() self.table = self.extract_col(0) self.column = self.extract_col(1) self.data_type = self.extract_col(2) self.aikif_map = self.extract_col(3) self.aikif_map_name = self.extract_col(4) self.e...
splits the CSV line of the current format and puts into local class variables - mainly for testing, though this is not the best method long term. (TODO - fix this)
387,013
def _join(segments): new = [] start = segments[0][0] end = segments[0][1] for i in range(len(segments)-1): if segments[i+1][0] != segments[i][1]: new.append((start, end)) start = segments[i+1][0] end = segments[i+1][1] new.append((start, end)) return ...
simply list by joining adjacent segments.
387,014
def timestr_mod24(timestr: str) -> int: try: hours, mins, secs = [int(x) for x in timestr.split(":")] hours %= 24 result = f"{hours:02d}:{mins:02d}:{secs:02d}" except: result = None return result
Given a GTFS HH:MM:SS time string, return a timestring in the same format but with the hours taken modulo 24.
387,015
def write_template(fn, lang="python"): with open(fn, "wb") as fh: if lang == "python": fh.write(PY_TEMPLATE) elif lang == "bash": fh.write(SH_TEMPLATE)
Write language-specific script template to file. Arguments: - fn(``string``) path to save the template to - lang('python', 'bash') which programming language
387,016
def fix_config(self, options): options = super(RenameRelation, self).fix_config(options) opt = "name" if opt not in options: options[opt] = "newname" if opt not in self.help: self.help[opt] = "The new relation name to use (string)." return optio...
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
387,017
def get_link_name (self, tag, attrs, attr): if tag == and attr == : data = self.parser.peek(MAX_NAMELEN) data = data.decode(self.parser.encoding, "ignore") name = linkname.href_name(data) if not name: name = attrs.get_true(, ...
Parse attrs for link name. Return name of link.
387,018
def memory_read16(self, addr, num_halfwords, zone=None): return self.memory_read(addr, num_halfwords, zone=zone, nbits=16)
Reads memory from the target system in units of 16-bits. Args: self (JLink): the ``JLink`` instance addr (int): start address to read from num_halfwords (int): number of half words to read zone (str): memory zone to read from Returns: List of halfwords...
387,019
def cli(env, identifier, name, all, note): vsi = SoftLayer.VSManager(env.client) vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, ) capture = vsi.capture(vs_id, name, all, note) table = formatting.KeyValueTable([, ]) table.align[] = table.align[] = table.add_row([, capture[...
Capture one or all disks from a virtual server to a SoftLayer image.
387,020
def _get_position(self, position, prev=False): if position == self.POSITION_LOADING: if prev: raise IndexError() else: return self._conversation.events[0].id_ else: ev = self._conversation.next_event(position, prev=prev) ...
Return the next/previous position or raise IndexError.
387,021
def store(self, deferred_result): self._counter += 1 self._stored[self._counter] = deferred_result return self._counter
Store a EventualResult. Return an integer, a unique identifier that can be used to retrieve the object.
387,022
def mean_abs_tree_shap(model, data): def f(X): v = TreeExplainer(model).shap_values(X) if isinstance(v, list): return [np.tile(np.abs(sv).mean(0), (X.shape[0], 1)) for sv in v] else: return np.tile(np.abs(v).mean(0), (X.shape[0], 1)) return f
mean(|TreeExplainer|) color = red_blue_circle(0.25) linestyle = solid
387,023
def changelist_view(self, request, extra_context=None): extra_context = extra_context or {} if in request.GET.keys(): value = request.GET[].split() content_type = get_object_or_404( ContentType, id=value[0], ) trac...
Get object currently tracked and add a button to get back to it
387,024
def resolve_redirects(self, resp, req, stream=False, timeout=None, verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs): hist = [] url = self.get_redirect_target(resp) while url: prepared_request = req.copy() ...
Receives a Response. Returns a generator of Responses or Requests.
387,025
def _initialize(self, chain, length): if self._getfunc is None: self._getfunc = self.db.model._funs_to_tally[self.name] try: self._shape = np.shape(self._getfunc()) except TypeError: self._shape = None self._vstr = .join(var_str(se...
Create an SQL table.
387,026
def _read_execute_info(path, parents): path = os.path.join(path, "StarCraft II/ExecuteInfo.txt") if os.path.exists(path): with open(path, "rb") as f: for line in f: parts = [p.strip() for p in line.decode("utf-8").split("=")] if len(parts) == 2 and parts[0] == "executable": ...
Read the ExecuteInfo.txt file and return the base directory.
387,027
def Clift(Re): r if Re < 0.01: return 24./Re + 3/16. elif Re < 20: return 24./Re*(1 + 0.1315*Re**(0.82 - 0.05*log10(Re))) elif Re < 260: return 24./Re*(1 + 0.1935*Re**(0.6305)) elif Re < 1500: return 10**(1.6435 - 1.1242*log10(Re) + 0.1558*(log10(Re))**2) elif Re ...
r'''Calculates drag coefficient of a smooth sphere using the method in [1]_ as described in [2]_. .. math:: C_D = \left\{ \begin{array}{ll} \frac{24}{Re} + \frac{3}{16} & \mbox{if $Re < 0.01$}\\ \frac{24}{Re}(1 + 0.1315Re^{0.82 - 0.05\log Re}) & \mbox{if $0.01 < Re < 20$}\\ \fra...
387,028
def list_clusters(self): resp = self._client.instance_admin_client.list_clusters(self.name) clusters = [Cluster.from_pb(cluster, self) for cluster in resp.clusters] return clusters, resp.failed_locations
List the clusters in this instance. For example: .. literalinclude:: snippets.py :start-after: [START bigtable_list_clusters_on_instance] :end-before: [END bigtable_list_clusters_on_instance] :rtype: tuple :returns: (clusters, failed_locations), whe...
387,029
def scaleToSeconds(requestContext, seriesList, seconds): for series in seriesList: series.name = "scaleToSeconds(%s,%d)" % (series.name, seconds) series.pathExpression = series.name factor = seconds * 1.0 / series.step for i, value in enumerate(series): series[i] = ...
Takes one metric or a wildcard seriesList and returns "value per seconds" where seconds is a last argument to this functions. Useful in conjunction with derivative or integral function if you want to normalize its result to a known resolution for arbitrary retentions
387,030
def get_pull_request_query(self, queries, repository_id, project=None): route_values = {} if project is not None: route_values[] = self._serialize.url(, project, ) if repository_id is not None: route_values[] = self._serialize.url(, repository_id, ) conte...
GetPullRequestQuery. [Preview API] This API is used to find what pull requests are related to a given commit. It can be used to either find the pull request that created a particular merge commit or it can be used to find all pull requests that have ever merged a particular commit. The input is a list of quer...
387,031
def punchcard(self, branch=, limit=None, days=None, by=None, normalize=None, ignore_globs=None, include_globs=None): ch = self.commit_history( branch=branch, limit=limit, days=days, ignore_globs=ignore_globs, include_globs=i...
Returns a pandas DataFrame containing all of the data for a punchcard. * day_of_week * hour_of_day * author / committer * lines * insertions * deletions * net :param branch: the branch to return commits for :param limit: (optional, default...
387,032
def __draw_cmp(self, obj1, obj2): if obj1.draw_order > obj2.draw_order: return 1 elif obj1.draw_order < obj2.draw_order: return -1 else: return 0
Defines how our drawable objects should be sorted
387,033
def destroy_iam(app=, env=, **_): session = boto3.Session(profile_name=env) client = session.client() generated = get_details(env=env, app=app) generated_iam = generated.iam() app_details = collections.namedtuple(, generated_iam.keys()) details = app_details(**generated_iam) LOG.debug...
Destroy IAM Resources. Args: app (str): Spinnaker Application name. env (str): Deployment environment, i.e. dev, stage, prod. Returns: True upon successful completion.
387,034
def undersampling(X, y, cost_mat=None, per=0.5): n_samples = X.shape[0] num_y1 = y.sum() num_y0 = n_samples - num_y1 filter_rand = np.random.rand(int(num_y1 + num_y0)) if num_y1 < num_y0: num_y0_new = num_y1 * 1.0 / per - num_y1 num_y0_new_per = num_y0_new * 1.0 / n...
Under-sampling. Parameters ---------- X : array-like of shape = [n_samples, n_features] The input samples. y : array-like of shape = [n_samples] Ground truth (correct) labels. cost_mat : array-like of shape = [n_samples, 4], optional (default=None) ...
387,035
def respond_from_question(self, question, user_question, importance): option_index = user_question.answer_text_to_option[ question.their_answer ].id self.respond(question.id, [option_index], [option_index], importance)
Copy the answer given in `question` to the logged in user's profile. :param question: A :class:`~.Question` instance to copy. :param user_question: An instance of :class:`~.UserQuestion` that corresponds to the same question as `question`. ...
387,036
def unpublish(namespace, name, version, registry=None): registry = registry or Registry_Base_URL url = % ( registry, namespace, name, version ) headers = _headersForRegistry(registry) response = requests.delete(url, headers=headers) response.raise_for_stat...
Try to unpublish a recently published version. Return any errors that occur.
387,037
def solarzenithangle(time: datetime, glat: float, glon: float, alt_m: float) -> tuple: time = totime(time) obs = EarthLocation(lat=glat*u.deg, lon=glon*u.deg, height=alt_m*u.m) times = Time(time, scale=) sun = get_sun(times) sunobs = sun.transform_to(AltAz(obstime=times, location=obs)) re...
Input: t: scalar or array of datetime
387,038
def is_ancestor_of_bin(self, id_, bin_id): if self._catalog_session is not None: return self._catalog_session.is_ancestor_of_catalog(id_=id_, catalog_id=bin_id) return self._hierarchy_session.is_ancestor(id_=id_, ancestor_id=bin_id)
Tests if an ``Id`` is an ancestor of a bin. arg: id (osid.id.Id): an ``Id`` arg: bin_id (osid.id.Id): the ``Id`` of a bin return: (boolean) - ``true`` if this ``id`` is an ancestor of ``bin_id,`` ``false`` otherwise raise: NotFound - ``bin_id`` is not found ...
387,039
def report_question(self, concern, pub_name, ext_name, question_id): route_values = {} if pub_name is not None: route_values[] = self._serialize.url(, pub_name, ) if ext_name is not None: route_values[] = self._serialize.url(, ext_name, ) if question_id i...
ReportQuestion. [Preview API] Flags a concern with an existing question for an extension. :param :class:`<Concern> <azure.devops.v5_1.gallery.models.Concern>` concern: User reported concern with a question for the extension. :param str pub_name: Name of the publisher who published the extension....
387,040
def spearmanr(x, y): from scipy import stats if not x or not y: return 0 corr, pvalue = stats.spearmanr(x, y) return corr
Michiel de Hoon's library (available in BioPython or standalone as PyCluster) returns Spearman rsb which does include a tie correction. >>> x = [5.05, 6.75, 3.21, 2.66] >>> y = [1.65, 26.5, -5.93, 7.96] >>> z = [1.65, 2.64, 2.64, 6.95] >>> round(spearmanr(x, y), 4) 0.4 >>> round(spearmanr(x...
387,041
def form_user_label_matrix(user_twitter_list_keywords_gen, id_to_node, max_number_of_labels): user_label_matrix, annotated_nodes, label_to_lemma, node_to_lemma_tokeywordbag = form_user_term_matrix(user_twitter_list_keywords_gen, ...
Forms the user-label matrix to be used in multi-label classification. Input: - user_twitter_list_keywords_gen: - id_to_node: A Twitter id to node map as a python dictionary. Outputs: - user_label_matrix: A user-to-label matrix in scipy sparse matrix format. - annotated_nodes: A nu...
387,042
def _mapping_to_tuple_pairs(d): t = [] ord_keys = sorted(d.keys()) for k in ord_keys: t.append(_product(k, d[k])) return tuple(product(*t))
Convert a mapping object (such as a dictionary) to tuple pairs, using its keys and values to generate the pairs and then generating all possible combinations between those e.g. {1: (1,2,3)} -> (((1, 1),), ((1, 2),), ((1, 3),))
387,043
def set_record(self, record, **kw): if isstring(record): card = FITSCard(record) self.update(card) self.verify() else: if isinstance(record, FITSRecord): self.update(record) elif isinstance(record, dict): ...
check the record is valid and set keys in the dict parameters ---------- record: string Dict representing a record or a string representing a FITS header card
387,044
def assert_strong_password(username, password, old_password=None): try: minlength = settings.MIN_PASSWORD_LENGTH except AttributeError: minlength = 12 if len(password) < minlength: raise ValueError( "Password must be at least %s characters long" % minlength) ...
Raises ValueError if the password isn't strong. Returns the password otherwise.
387,045
def libvlc_audio_set_format(mp, format, rate, channels): f = _Cfunctions.get(, None) or \ _Cfunction(, ((1,), (1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint) return f(mp, format, rate, channels)
Set decoded audio format. This only works in combination with L{libvlc_audio_set_callbacks}(), and is mutually exclusive with L{libvlc_audio_set_format_callbacks}(). @param mp: the media player. @param format: a four-characters string identifying the sample format (e.g. "S16N" or "FL32"). @param rat...
387,046
def event_update_status(self, event_id, status, scores=[], account=None, **kwargs): if not account: if "default_account" in self.config: account = self.config["default_account"] if not account: raise ValueError("You need to provide an account") ac...
Update the status of an event. This needs to be **proposed**. :param str event_id: Id of the event to update :param str status: Event status :param list scores: List of strings that represent the scores of a match (defaults to []) :param str account: (opt...
387,047
def _get_first_urn(self, urn): urn = URN(urn) subreference = None textId = urn.upTo(URN.NO_PASSAGE) if urn.reference is not None: subreference = str(urn.reference) firstId = self.resolver.getTextualNode(textId=textId, subreference=subreference).firstId ...
Provisional route for GetFirstUrn request :param urn: URN to filter the resource :param inv: Inventory Identifier :return: GetFirstUrn response
387,048
def _startMqtt(self): LOGGER.info(.format(self._server, self._port)) try: self._mqttc.connect_async(.format(self._server), int(self._port), 10) self._mqttc.loop_forever() except Exception as ex: template = "An exception of type {0} occurr...
The client start method. Starts the thread for the MQTT Client and publishes the connected message.
387,049
def get(self, request, provider=None): if USING_ALLAUTH: self.social_auths = request.user.socialaccount_set.all() else: self.social_auths = request.user.social_auth.all() self.social_friend_lists = [] if self.social_aut...
prepare the social friend model
387,050
def rates_angles(fk_candidate_observations): detections = fk_candidate_observations.get_sources() for detection in detections: measures = detection.get_readings() for measure in measures: def main(): parser = argparse.ArgumentParser() parser.add_argument(, default=Non...
:param fk_candidate_observations: name of the fk*reals.astrom file to check against Object.planted
387,051
def keep_mask(nkeep, X_train, y_train, X_test, y_test, attr_test, model_generator, metric, trained_model, random_state): X_train, X_test = to_array(X_train, X_test) assert X_train.shape[1] == X_test.shape[1] X_test_tmp = X_test.copy() yp_masked_test = np.zeros(y_test.shape) tie_bre...
The model is revaluated for each test sample with the non-important features set to their mean.
387,052
def logpdf(self, mu): if self.transform is not None: mu = self.transform(mu) return ss.t.logpdf(mu, df=self.df0, loc=self.loc0, scale=self.scale0)
Log PDF for t prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - log(p(mu))
387,053
def linear_elasticity(grid, spacing=None, E=1e5, nu=0.3, format=None): if len(grid) == 2: return q12d(grid, spacing=spacing, E=E, nu=nu, format=format) else: raise NotImplemented( % str(grid))
Linear elasticity problem discretizes with Q1 finite elements on a regular rectangular grid. Parameters ---------- grid : tuple length 2 tuple of grid sizes, e.g. (10, 10) spacing : tuple length 2 tuple of grid spacings, e.g. (1.0, 0.1) E : float Young's modulus nu : flo...
387,054
def get_meta_image_url(request, image): rendition = image.get_rendition(filter=) return request.build_absolute_uri(rendition.url)
Resize an image for metadata tags, and return an absolute URL to it.
387,055
def StartAFF4Flow(args=None, runner_args=None, parent_flow=None, sync=True, token=None, **kwargs): if runner_args is None: runner_args = rdf_flow_runner.FlowRunnerArgs() FilterArgsFromSemanticProtobuf(runner_args, k...
The main factory function for creating and executing a new flow. Args: args: An arg protocol buffer which is an instance of the required flow's args_type class attribute. runner_args: an instance of FlowRunnerArgs() protocol buffer which is used to initialize the runner for this flow. parent_...
387,056
def _handle_chat_name(self, data): self.room.user.nick = data self.conn.enqueue_data("user", self.room.user)
Handle user name changes
387,057
def get_PSD(self, NPerSegment=1000000, window="hann", timeStart=None, timeEnd=None, override=False): if timeStart == None and timeEnd == None: freqs, PSD = calc_PSD(self.voltage, self.SampleFreq, NPerSegment=NPerSegment) self.PSD = PSD self.freqs = freqs else...
Extracts the power spectral density (PSD) from the data. Parameters ---------- NPerSegment : int, optional Length of each segment used in scipy.welch default = 1000000 window : str or tuple or array_like, optional Desired window to use. See get_windo...
387,058
def action_draft(self): for rec in self: if not rec.state == : raise UserError( _()) if not (rec.am_i_owner or rec.am_i_approver): raise UserError( _( )) rec.write({: })
Set a change request as draft
387,059
def extract(data, items, out_dir=None): if vcfutils.get_paired_phenotype(data): if len(items) == 1: germline_vcf = _remove_prioritization(data["vrn_file"], data, out_dir) germline_vcf = vcfutils.bgzip_and_index(germline_vcf, data["config"]) data["vrn_file_plus"] = {"...
Extract germline calls for the given sample, if tumor only.
387,060
def on_failure(self, exc, task_id, args, kwargs, einfo): use_exc = str(exc) log.error(("{} FAIL - exc={} " "args={} kwargs={}") .format( self.log_label, use_exc, args, kwarg...
on_failure http://docs.celeryproject.org/en/latest/userguide/tasks.html#task-inheritance :param exc: exception :param task_id: task id :param args: arguments passed into task :param kwargs: keyword arguments passed into task :param einfo: exception info
387,061
def anonymous_user_required(*decorator_args, msg=None, category=None, redirect_url=None): def wrapper(fn): @wraps(fn) def decorated(*args, **kwargs): if current_user.is_authenticated: if request.is_json: abort(HTTPStatus.FORBIDDEN) ...
Decorator requiring that there is no user currently logged in. Aborts with ``HTTP 403: Forbidden`` if there is an authenticated user.
387,062
def check(self, **kwargs): errors = super().check(**kwargs) multitenant_staticfiles_dirs = settings.MULTITENANT_STATICFILES_DIRS if not isinstance(multitenant_staticfiles_dirs, (list, tuple)): errors.append( Error( "Your MULTITENANT_STATI...
In addition to parent class' checks, also ensure that MULTITENANT_STATICFILES_DIRS is a tuple or a list.
387,063
def draft_pick(self): doc = self.get_main_doc() try: p_tags = doc() draft_p_tag = next(p for p in p_tags.items() if p.text().lower().startswith()) draft_pick = int(re.search(r, draft_p_tag.text()).group(1)) return draft_pick except Excepti...
Returns when in the draft the player was picked. :returns: TODO
387,064
def log_train_metric(period, auto_reset=False): def _callback(param): if param.nbatch % period == 0 and param.eval_metric is not None: name_value = param.eval_metric.get_name_value() for name, value in name_value: logging.info(, ...
Callback to log the training evaluation result every period. Parameters ---------- period : int The number of batch to log the training evaluation metric. auto_reset : bool Reset the metric after each log. Returns ------- callback : function The callback function th...
387,065
def get_attributes(file, *, attributes=None, mime_type=None, force_document=False, voice_note=False, video_note=False, supports_streaming=False): name = file if isinstance(file, str) else getattr(file, , ) if mime_type is None: mime_type = mimetypes.guess_...
Get a list of attributes for the given file and the mime type as a tuple ([attribute], mime_type).
387,066
def delimited_file( self, hdfs_dir, schema, name=None, database=None, delimiter=, na_rep=None, escapechar=None, lineterminator=None, external=True, persist=False, ): name, database = self._get_concrete_table_pat...
Interpret delimited text files (CSV / TSV / etc.) as an Ibis table. See `parquet_file` for more exposition on what happens under the hood. Parameters ---------- hdfs_dir : string HDFS directory name containing delimited text files schema : ibis Schema name : st...
387,067
def _to_dict(self): _dict = {} if hasattr(self, ) and self.document is not None: _dict[] = self.document if hasattr(self, ) and self.targets is not None: _dict[] = self.targets return _dict
Return a json dictionary representing this model.
387,068
def ImportConfig(filename, config): sections_to_import = ["PrivateKeys"] entries_to_import = [ "Client.executable_signing_public_key", "CA.certificate", "Frontend.certificate" ] options_imported = 0 old_config = grr_config.CONFIG.MakeNewConfig() old_config.Initialize(filename) for entry in...
Reads an old config file and imports keys and user accounts.
387,069
def _create_node(self, index: int, name: str, external_id: Optional[str] = None) -> IGraphNode: return IGraphNode(graph=self._graph, index=index, name=name, external_id=external_id)
Returns a new `IGraphNode` instance with the given index and name. Arguments: index (int): The index of the node to create. name (str): The name of the node to create. external_id (Optional[str]): The external ID of the node.
387,070
async def info(self, fields: Iterable[str] = None) -> dict: s information such as resource limits. :param fields: Additional per-agent query fields to fetch. .. versionadded:: 18.12 access_keysecret_keyis_activeis_adminquery { keypair { $fields }}$fields POST/admin/graphqlquerykey...
Returns the keypair's information such as resource limits. :param fields: Additional per-agent query fields to fetch. .. versionadded:: 18.12
387,071
def from_points(cls, iterable_of_points): return MultiPoint([(p.lon, p.lat) for p in iterable_of_points])
Creates a MultiPoint from an iterable collection of `pyowm.utils.geo.Point` instances :param iterable_of_points: iterable whose items are `pyowm.utils.geo.Point` instances :type iterable_of_points: iterable :return: a *MultiPoint* instance
387,072
def es_version(self, url): try: res = self.grimoire_con.get(url) res.raise_for_status() major = res.json()[][].split(".")[0] except Exception: logger.error("Error retrieving Elasticsearch version: " + url) raise return major
Get Elasticsearch version. Get the version of Elasticsearch. This is useful because Elasticsearch and Kibiter are paired (same major version for 5, 6). :param url: Elasticseearch url hosting Kibiter indices :returns: major version, as string
387,073
def get_iam_policy(self): checker = AwsLimitChecker() policy = checker.get_required_iam_policy() return json.dumps(policy, sort_keys=True, indent=2)
Return the current IAM policy as a json-serialized string
387,074
def default_project(self, value): if value is not None: assert type(value) is unicode, \ " attribute: type is not !".format("default_project", value) self.__default_project = value
Setter for **self.__default_project** attribute. :param value: Attribute value. :type value: unicode
387,075
def ConsumeCommentOrTrailingComment(self): just_started = self._line == 0 and self._column == 0 before_parsing = self._previous_line comment = self.ConsumeComment() trailing = (self._previous_line == before_parsing and not just_started) return trailing, commen...
Consumes a comment, returns a 2-tuple (trailing bool, comment str).
387,076
def run(self): random.seed(self.seed) np.random.seed(self.np_seed) if not isinstance(self, multiprocessing.Process): mx.random.seed(self.mx_seed) try: stream_iter = iter(self.stream) self._error...
Method representing the process’s activity.
387,077
def process_frame(self, f, frame_str): frame_type = f.cmd.lower() if frame_type in []: return if frame_type == : frame_type = f.cmd = if frame_type in [, , , , ]: if frame_type == : if f.headers[] not in self.s...
:param Frame f: Frame object :param bytes frame_str: Raw frame content
387,078
def rmd_options_to_metadata(options): options = re.split(r, options, 1) if len(options) == 1: language = options[0] chunk_options = [] else: language, others = options language = language.rstrip() others = others.lstrip() chunk_options = parse_rmd_options...
Parse rmd options and return a metadata dictionary :param options: :return:
387,079
def add_file(self, name, filename, compress_hint=True): return self.add_stream(name, open(filename, ))
Saves the actual file in the store. ``compress_hint`` suggests whether the file should be compressed before transfer Works like :meth:`add_stream`, but ``filename`` is the name of an existing file in the filesystem.
387,080
def zone_absent(domain, profile): zones = __salt__[](profile) matching_zone = [z for z in zones if z[] == domain] if not matching_zone: return state_result(True, , domain) else: result = __salt__[](matching_zone[0][], profile) return state_result(result, , domain)
Ensures a record is absent. :param domain: Zone name, i.e. the domain name :type domain: ``str`` :param profile: The profile key :type profile: ``str``
387,081
def view_cancel_edit(name=None): if name is None: return redirect() else: files = glob.glob("{0}.rst".format(name)) if len(files) > 0: reset_to_last_commit() return redirect( + name) else: return abort(404)
Cancel the edition of an existing page. Then render the last modification status .. note:: this is a bottle view if no page name is given, do nothing (it may leave some .tmp. files in the directory). Keyword Arguments: :name: (str) -- name of the page (OPTIONAL) Returns: bot...
387,082
def timezone(self, value=0.0): if value is not None: try: value = float(value) except ValueError: raise ValueError( .format(value)) if value < -12.0: raise ValueError( ...
Corresponds to IDD Field `timezone` Time relative to GMT. Args: value (float): value for IDD Field `timezone` Unit: hr - not on standard units list??? Default value: 0.0 value >= -12.0 value <= 12.0 if `value` is None i...
387,083
def view_structure(self, only_chains=None, opacity=1.0, recolor=False, gui=False): if ssbio.utils.is_ipynb(): import nglview as nv else: raise EnvironmentError() if not self.structure_file: raise ValueError("Structure file not loaded") ...
Use NGLviewer to display a structure in a Jupyter notebook Args: only_chains (str, list): Chain ID or IDs to display opacity (float): Opacity of the structure recolor (bool): If structure should be cleaned and recolored to silver gui (bool): If the NGLview GUI sh...
387,084
def upload_feature_value_file(self, mapobject_type_name, plate_name, well_name, well_pos_y, well_pos_x, tpoint, filename, index_col): logger.info(, filename) if not filename.lower().endswith(): raise IOError() filename = os.path.expanduser(os.path.expandvars(file...
Uploads feature values for the given :class:`MapobjectType <tmlib.models.mapobject.MapobjectType>` at the specified :class:`Site <tmlib.models.site.Site>`. Parameters ---------- mapobject_type_name: str type of the segmented objects plate_name: str ...
387,085
def answer (self, headers, **options): self._steps.append(Answer (headers, **options).obj)
Places a call or sends an an IM, Twitter, or SMS message. To start a call, use the Session API headers tell Tropo headers launch your code. Arguments: headers is a String. Argument: **options is a set of optional keyword arguments. See https://www.tropo.com/docs/webapi/answer
387,086
def semilocal_linear_trend_transition_matrix(autoregressive_coef): fixed_entries = tf.constant( [[1., 1.], [0., 0.]], dtype=autoregressive_coef.dtype) autoregressive_coef_mask = tf.constant([[0., 0.], [0., 1.]], ...
Build the transition matrix for a semi-local linear trend model.
387,087
def __handle_changed_state(self, state): timeval = self.__get_timeval() events = self.__get_button_events(state, timeval) events.extend(self.__get_axis_events(state, timeval)) if events: self.__write_to_character_device(events, timeval)
we need to pack a struct with the following five numbers: tv_sec, tv_usec, ev_type, code, value then write it using __write_to_character_device seconds, mircroseconds, ev_type, code, value time we just use now ev_type we look up code we look up value is 0 or 1 f...
387,088
def update_title_to_proceeding(self): titles = record_get_field_instances(self.record, tag="245") for title in titles: subs = field_get_subfields(title) new_subs = [] if "a" in subs: new_subs.append(...
Move title info from 245 to 111 proceeding style.
387,089
def popup(self, title, callfn, initialdir=None): super(DirectorySelection, self).popup(title, callfn, initialdir)
Let user select a directory.
387,090
def after_request(self, f): self.record_once(lambda s: s.app.after_request_funcs .setdefault(self.name, []).append(f)) return f
Like :meth:`Flask.after_request` but for a blueprint. This function is only executed after each request that is handled by a function of that blueprint.
387,091
def load_directory(self, directory, ext=None): self._say("Loading from directory: " + directory) if ext is None: ext = [, ] elif type(ext) == str: ext = [ext] if not os.path.isdir(directory): self._warn("Error: " + ...
Load RiveScript documents from a directory. :param str directory: The directory of RiveScript documents to load replies from. :param []str ext: List of file extensions to consider as RiveScript documents. The default is ``[".rive", ".rs"]``.
387,092
def _preprocess(df): df = df.stack() df.index.rename(["id", "time"], inplace=True) df.name = "value" df = df.reset_index() return df
given a DataFrame where records are stored row-wise, rearrange it such that records are stored column-wise.
387,093
def receive_loop_with_callback(self, queue_name, callback): self.connect() channel = self.create_channel(queue_name) channel.basic_qos(prefetch_count=1) channel.basic_consume(callback, queue=queue_name) channel.start_consuming()
Process incoming messages with callback until close is called. :param queue_name: str: name of the queue to poll :param callback: func(ch, method, properties, body) called with data when data arrives :return:
387,094
def install_python_package(self, arch, name=None, env=None, is_dir=True): if env is None: env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): hostpython = sh.Command(self.ctx.hostpython) shprint(hostpython, , , , ...
Automate the installation of a Python package (or a cython package where the cython components are pre-built).
387,095
def _generate_main_scripts(self): head = self.parser.find().first_result() if head is not None: common_functions_script = self.parser.find( + AccessibleEventImplementation.ID_SCRIPT_COMMON_FUNCTIONS ).first_result() if common...
Include the scripts used by solutions.
387,096
def translate(self, dx, dy): vec = numpy.array((dx, dy)) self.polygons = [points + vec for points in self.polygons] return self
Move the polygons from one place to another Parameters ---------- dx : number distance to move in the x-direction dy : number distance to move in the y-direction Returns ------- out : ``PolygonSet`` This object.
387,097
def project(self, **kwargs: Dict[str, Any]) -> Union[Hist, Dict[str, Hist]]: if self.single_observable_projection: return self._project_single_observable(**kwargs) else: return self._project_dict(**kwargs)
Perform the requested projection(s). Note: All cuts on the original histograms will be reset when this function is completed. Args: kwargs (dict): Additional named args to be passed to projection_name(...) and output_key_name(...) Returns: The projected hist...
387,098
def pretty_exe_doc(program, parser, stack=1, under=): if os.path.basename(sys.argv[0]) == : mod = inspect.getmodule(inspect.stack()[stack][0]) _parser = parser() if in dir(parser) else parser _parser.set_usage(mod.__usage__.replace(, program)) ...
Takes the name of a script and a parser that will give the help message for it. The module that called this function will then add a header to the docstring of the script, followed immediately by the help message generated by the OptionParser :param str program: Name of the program that we want to make...
387,099
def _setup_process_environment(self, env): environ = self._process.processEnvironment() if env is None: env = {} for k, v in os.environ.items(): environ.insert(k, v) for k, v in env.items(): environ.insert(k, v) if sys.platform != : ...
Sets up the process environment.