Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
14,600
def get(self, request, enterprise_uuid, course_id): enrollment_course_mode = request.GET.get() enterprise_catalog_uuid = request.GET.get() if not enrollment_course_mode: return redirect(LMS_DASHBOARD_URL) enrollment_api_client = EnrollmentApiClien...
Handle the enrollment of enterprise learner in the provided course. Based on `enterprise_uuid` in URL, the view will decide which enterprise customer's course enrollment record should be created. Depending on the value of query parameter `course_mode` then learner will be either redire...
14,601
def get_file_sha1(filename_or_io): file_data = get_file_io(filename_or_io) cache_key = file_data.cache_key if cache_key and cache_key in FILE_SHAS: return FILE_SHAS[cache_key] with file_data as file_io: hasher = sha1() buff = file_io.read(BLOCKSIZE) while len(buf...
Calculates the SHA1 of a file or file object using a buffer to handle larger files.
14,602
def author(self, value): if value is not None: assert type(value) is unicode, " attribute: type is not !".format( "author", value) self.__author = value
Setter for **self.__author** attribute. :param value: Attribute value. :type value: unicode
14,603
def get_as_nullable_integer(self, key): value = self.get(key) return IntegerConverter.to_nullable_integer(value)
Converts map element into an integer or returns None if conversion is not possible. :param key: an index of element to get. :return: integer value of the element or None if conversion is not supported.
14,604
def from_hoy(cls, hoy, leap_year=False): return cls.from_moy(round(hoy * 60), leap_year)
Create Ladybug Datetime from an hour of the year. Args: hoy: A float value 0 <= and < 8760
14,605
async def kick_chat_member(self, chat_id: typing.Union[base.Integer, base.String], user_id: base.Integer, until_date: typing.Union[base.Integer, None] = None) -> base.Boolean: until_date = prepare_arg(until_date) payload = generate_payload(**locals()) res...
Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must ...
14,606
def requirements(work_dir, hive_root, with_requirements, with_dockerfile, active_module, active_module_file): import sys sys.path.insert(0, hive_root) hive_root = os.path.abspath(os.path.expanduser(hive_root)) work_dir = work_dir or os.path.join( os.environ.get(, ...
编译全新依赖文件
14,607
def delete_edges(self, edges: Iterable[Tuple[str, str]]): for edge in edges: if self.has_edge(*edge): self.remove_edge(*edge)
Iterate over a set of edges and remove the ones that are present in the graph.
14,608
def lock(self, key, lease_time=-1): check_not_none(key, "key can't be None") key_data = self._to_data(key) return self._encode_invoke_on_key(multi_map_lock_codec, key_data, key=key_data, thread_id=thread_id(), ttl=to_millis(lease_time), ...
Acquires the lock for the specified key infinitely or for the specified lease time if provided. If the lock is not available, the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired. Scope of the lock is this map only. Acquired lock ...
14,609
async def _send_to_messenger_profile(self, page, content): log_name = .join(repr(x) for x in content.keys()) page_id = page[] current = await self._get_messenger_profile(page, content.keys()) if dict_is_subset(content, current): logger.info(, page_id, log_name) ...
The messenger profile API handles all meta-information about the bot, like the menu. This allows to submit data to this API endpoint. :param page: page dict from the configuration :param content: content to be sent to Facebook (as dict)
14,610
def send_trending_data(events): bodies = {} top_hits = sorted( [(key, count) for key, count in events.items()], key=lambda x: x[1], reverse=True )[:100] for (site, content_id), count in top_hits: if not len(site) or not re.match(CONTENT_ID_REGEX, content_...
creates data point payloads for trending data to influxdb
14,611
def lcp(s1, s2): abcdxabcdyaxyz i = 0 for i, (c1, c2) in enumerate(zip(s1, s2)): if c1 != c2: return i return min(len(s1), len(s2))
longest common prefix >>> lcp('abcdx', 'abcdy'), lcp('', 'a'), lcp('x', 'yz') (4, 0, 0)
14,612
def log(msg, delay=0.5, chevrons=True, verbose=True): if verbose: if chevrons: click.echo("\n❯❯ " + msg) else: click.echo(msg) time.sleep(delay)
Log a message to stdout.
14,613
def channels_remove_moderator(self, room_id, user_id, **kwargs): return self.__call_api_post(, roomId=room_id, userId=user_id, kwargs=kwargs)
Removes the role of moderator from a user in the current channel.
14,614
def get_queue_bindings(self, vhost, qname): vhost = quote(vhost, ) qname = quote(qname, ) path = Client.urls[] % (vhost, qname) bindings = self._call(path, ) return bindings
Return a list of dicts, one dict per binding. The dict format coming from RabbitMQ for queue named 'testq' is: {"source":"sourceExch","vhost":"/","destination":"testq", "destination_type":"queue","routing_key":"*.*","arguments":{}, "properties_key":"%2A.%2A"}
14,615
def get(self, sid): return MemberContext( self._version, service_sid=self._solution[], channel_sid=self._solution[], sid=sid, )
Constructs a MemberContext :param sid: The unique string that identifies the resource :returns: twilio.rest.chat.v2.service.channel.member.MemberContext :rtype: twilio.rest.chat.v2.service.channel.member.MemberContext
14,616
def bear_push(title, content, send_key=None): if not send_key: raise ValueError("请配置通道send_key,如果还没有," "可以到这里创建通道获取:https://pushbear.ftqq.com/admin/ api = "https://pushbear.ftqq.com/sub" requests.post(api, data={: title, : content, "sendkey": send_key})
使用PushBear推送消息给所有订阅者微信,关于PushBear, 请参考:https://pushbear.ftqq.com/admin/#/ :param title: str 消息标题 :param content: str 消息内容,最长64Kb,可空,支持MarkDown :param send_key: str 从[PushBear](https://pushbear.ftqq.com/admin/#/)获取的通道send_key :return: None
14,617
async def await_event(self, event=None, timeout=30): return await self._protocol.await_event(event, timeout=timeout)
Wait for an event from QTM. :param event: A :class:`qtm.QRTEvent` to wait for a specific event. Otherwise wait for any event. :param timeout: Max time to wait for event. :rtype: A :class:`qtm.QRTEvent`
14,618
def generate_moffat_profile(seeing_fwhm, alpha): scale = 2 * math.sqrt(2**(1.0 / alpha) - 1) gamma = seeing_fwhm / scale amplitude = 1.0 / math.pi * (alpha - 1) / gamma**2 seeing_model = Moffat2D(amplitude=amplitude, x_mean=0.0, y_mean=0.0, ...
Generate a normalized Moffat profile from its FWHM and alpha
14,619
def add(self, origin, rel, target, attrs=None): if not origin: raise ValueError() if not rel: raise ValueError() attrs = attrs or {} origin_item = self._db_coll.find_one({: origin}) rel = self._abbreviate(rel) target = self._abbreviate...
Add one relationship to the model origin - origin of the relationship (similar to an RDF subject) rel - type IRI of the relationship (similar to an RDF predicate) target - target of the relationship (similar to an RDF object), a boolean, floating point or unicode object attrs - optional...
14,620
def _minimally_quoted_parameter_value(value): if re.match("^[{charset}]*$".format(charset=MediaType.RFC7320_TOKEN_CHARSET), value): return value else: return MediaType._quote(value)
Per RFC 7321 (https://tools.ietf.org/html/rfc7231#section-3.1.1.1): Parameters values don't need to be quoted if they are a "token". Token characters are defined by RFC 7320 (https://tools.ietf.org/html/rfc7230#section-3.2.6). Otherwise, parameters values can be a "quoted-string". So we ...
14,621
def get_welcome_response(): session_attributes = {} card_title = "Welcome" speech_output = "Welcome to the Alexa Skills Kit sample. " \ "Please tell me your favorite color by saying, " \ "my favorite color is red" reprompt_text = "Please tell me yo...
If we wanted to initialize the session to have some attributes we could add those here
14,622
def get_resource_subscription(self, device_id, resource_path, fix_path=True): fixed_path = resource_path if fix_path and resource_path.startswith("/"): fixed_path = resource_path[1:] api = self._get_api(mds.SubscriptionsApi) try: api.ch...
Read subscription status. :param device_id: Name of device to set the subscription on (Required) :param resource_path: The resource path on device to observe (Required) :param fix_path: Removes leading / on resource_path if found :returns: status of subscription
14,623
def get_update_service(self): update_service_url = utils.get_subresource_path_by(self, ) return (update_service. HPEUpdateService(self._conn, update_service_url, redfish_version=self.redf...
Return a HPEUpdateService object :returns: The UpdateService object
14,624
def title(self, value=None): if not (value is None): if (self.metadatatype == "native"): self.metadata[] = value else: self._title = value if (self.metadatatype == "native"): if in self.metadata: return self.me...
Get or set the document's title from/in the metadata No arguments: Get the document's title from metadata Argument: Set the document's title in metadata
14,625
def set(self, section, option, value=None): if isinstance(section, bytes): section = section.decode() if isinstance(option, bytes): option = option.decode() if isinstance(value, bytes): value = value.decode() return super(VSGConfigParser, s...
Extends :meth:`~configparser.ConfigParser.set` by auto formatting byte strings into unicode strings.
14,626
def down_by_name(*filters, remote_dir=DEFAULT_REMOTE_DIR, local_dir=".", count=1): files = command.list_files(*filters, remote_dir=remote_dir) greatest = sorted(files, key=lambda f: f.filename) to_sync = greatest[-count:] _notify_sync(Direction.down, to_sync) down_by_files(to_sync[::-1], local_...
Sync files whose filename attribute is highest in alphanumeric order
14,627
def iplot(self, places=-1, c_poly=, c_holes=, c_sop=, s_sop=25, extra_height=0, ret=False, ax=None): if places == -1: places = range(len(self.places)) elif type(places) == int: places = [places] places = np.array(places) ...
Improved plot that allows to visualize the Places in the Space selectively. It also allows to plot polygons and holes in different colors and to change the size and the color of the set of points. The points can be plotted accordingly to a ndarray colormap. ...
14,628
def binomial(n): if n == 1: return [1, 1] elif n == 2: return [1, 2, 1] elif n == 3: return [1, 3, 3, 1] elif n == 4: return [1, 4, 6, 4, 1] elif n == 5: return [1, 5, 10, 10, 5, 1] else: from scipy.special import binom return binom(n,...
Return all binomial coefficients for a given order. For n > 5, scipy.special.binom is used, below we hardcode to avoid the scipy.special dependency. Parameters -------------- n : int Order Returns --------------- binom : (n + 1,) int Binomial coefficients of a given order
14,629
def ascii(graph): from .._ascii import DAG from .._echo import echo_via_pager echo_via_pager(str(DAG(graph)))
Format graph as an ASCII art.
14,630
def _replication_request(command, host=None, core_name=None, params=None): hostname=valuesuccessdataerrorswarnings params = [] if params is None else params extra = ["command={0}".format(command)] + params url = _format_url(, host=host, core_name=core_name, extra=extra) return ...
PRIVATE METHOD Performs the requested replication command and returns a dictionary with success, errors and data as keys. The data object will contain the JSON response. command : str The replication command to execute. host : str (None) The solr host to query. __opts__['host'] is d...
14,631
def get_issuer_keys(self, issuer): res = [] for kbl in self.issuer_keys[issuer]: res.extend(kbl.keys()) return res
Get all the keys that belong to an entity. :param issuer: The entity ID :return: A possibly empty list of keys
14,632
def sum_tbl(tbl, kfield, vfields): pairs = [(n, tbl.dtype[n]) for n in [kfield] + vfields] dt = numpy.dtype(pairs + [(, int)]) def sum_all(group): vals = numpy.zeros(1, dt)[0] for rec in group: for vfield in vfields: vals[vfield] += rec[vfield] v...
Aggregate a composite array and compute the totals on a given key. >>> dt = numpy.dtype([('name', (bytes, 10)), ('value', int)]) >>> tbl = numpy.array([('a', 1), ('a', 2), ('b', 3)], dt) >>> sum_tbl(tbl, 'name', ['value'])['value'] array([3, 3])
14,633
def cohort_queryplan(plan): cohort = plan[] action = plan[] source = plan[] cohort_start = datetime_to_kronos_time(_date_to_datetime(cohort[])) cohort_span = timedelta(**{cohort[]: cohort[]}) cohort_end = cohort[] + cohort_span action_span = timedelta(**{action[]: action[]}) action_end = co...
Input: { 'source': 'kronos', # Name of data source from settings 'cohort': {'stream': CohortTest.EMAIL_STREAM, # Kronos stream to define cohort from. 'transform': lambda x: x, # Transformations on the kstream. 'start': date.now(), # The day of the first cohort. 'unit': ...
14,634
def from_string(cls, s): for num, text in cls._STATUS_TABLE.items(): if text == s: return cls(num) else: logger.warning("Got unknown status: %s" % s) return cls.from_string("UNKNOWN")
Return a :class:`JobStatus` instance from its string representation.
14,635
def choose_key(gpg_private_keys): uid_strings_fp = [] uid_string_fp2key = {} current_key_index = None for i, key in enumerate(gpg_private_keys): fingerprint = key[] if fingerprint == config["gpg_key_fingerprint"]: current_key_index = i for uid_string in key[...
Displays gpg key choice and returns key
14,636
def hidden_item_tags(self): hidden_item_tags = self.cp.get(, ) return [] if hidden_item_tags == else [tag.strip() for tag in hidden_item_tags.split()]
Returns a list of tags which hide an item from the 'ls' output.
14,637
def numpyStr(array, format=, includeIndices=False, includeZeros=True): shape = array.shape assert (len(shape) <= 2) items = [] if len(shape) == 1: if includeIndices: format = + format if includeZeros: rowItems = [format % (c,x) for (c,x) in enumerate(array)] else: rowI...
Pretty print a numpy matrix using the given format string for each value. Return the string representation Parameters: ------------------------------------------------------------ array: The numpy array to print. This can be either a 1D vector or 2D matrix format: The format string to use for each value...
14,638
def download_align(from_idx, to_idx, _params): succ = set() fail = set() for idx in range(from_idx, to_idx): name = + str(idx) if idx == 0: continue script = "http://spandh.dcs.shef.ac.uk/gridcorpus/{nm}/align/{nm}.tar".format(nm=name) down_sc = .format(scri...
download aligns
14,639
def predict(self, X): check_is_fitted(self, []) X = check_array(X) return self.__find_leverages(X, self.inverse_influence_matrix) <= self.threshold_value
Predict inside or outside AD for X. Parameters ---------- X : array-like or sparse matrix, shape (n_samples, n_features) The input samples. Internally, it will be converted to ``dtype=np.float32`` and if a sparse matrix is provided to a sparse ``csr_matrix``....
14,640
def geopotential_to_height(geopot): r height = (((1 / mpconsts.Re) - (geopot / (mpconsts.G * mpconsts.me))) ** -1) - mpconsts.Re return height
r"""Compute height from a given geopotential. Parameters ---------- geopotential : `pint.Quantity` Geopotential (array_like) Returns ------- `pint.Quantity` The corresponding height value(s) Examples -------- >>> from metpy.constants import g, G, me, Re >>> imp...
14,641
def get_focus(self, filt=False, samples=None, subset=None, nominal=False): if samples is not None: subset = self.make_subset(samples) samples = self._get_samples(subset) focus = {: []} focus.update({a: [] for a in self.analytes}) for sa i...
Collect all data from all samples into a single array. Data from standards is not collected. Parameters ---------- filt : str, dict or bool Either logical filter expression contained in a str, a dict of expressions specifying the filter string to use ...
14,642
def reboot(self, target_mode=None, timeout_ms=None): return self._simple_command(, arg=target_mode, timeout_ms=timeout_ms)
Reboots the device. Args: target_mode: Normal reboot when unspecified (or None). Can specify other target modes, such as 'recovery' or 'bootloader'. timeout_ms: Optional timeout in milliseconds to wait for a response. Returns: Usually the empty string. Depends on the bootloa...
14,643
def make_argument_subquery(arg): return Subquery.create(arg) if isinstance(arg, (GroupBy, Projection)) or arg.restriction else arg
Decide when a Join argument needs to be wrapped in a subquery
14,644
def setAccessRules(self, pid, public=False): url = "{url_base}/resource/accessRules/{pid}/".format(url_base=self.url_base, pid=pid) params = {: public} r = self._request(, url, data=params) if r.status_code != 200: ...
Set access rules for a resource. Current only allows for setting the public or private setting. :param pid: The HydroShare ID of the resource :param public: True if the resource should be made public.
14,645
def img_search_bing(album): setup() album = album + " Album Art" api_key = "Key" endpoint = "https://api.cognitive.microsoft.com/bing/v5.0/images/search" links_dict = {} headers = {: str(BING_KEY)} param = {: album, : } response = requests.get(endpoint, headers=headers, params=...
Bing image search
14,646
def current_values(self): current_dict = { : self.current_session_date, : self.current_sleep_score, : self.current_sleep_stage, : self.current_sleep_breakdown, : self.current_tnt, : self.current_bed_temp, : self.current...
Return a dict of all the 'current' parameters.
14,647
def _move_cursor_to_column(self, column): last_col = len(self._cursor.block().text()) self._cursor.movePosition(self._cursor.EndOfBlock) to_insert = for i in range(column - last_col): to_insert += if to_insert: self._cursor.insertText(to_insert)...
Moves the cursor to the specified column, if possible.
14,648
def _discover_mac(self): mac = None mac_reversed = None cmd = MAGIC + DISCOVERY resp = self._udp_transact(cmd, self._discovery_resp, broadcast=True, timeout=DISCOVERY_TIMEOUT) if resp: (mac, ...
Discovers MAC address of device. Discovery is done by sending a UDP broadcast. All configured devices reply. The response contains the MAC address in both needed formats. Discovery of multiple switches must be done synchronously. :returns: Tuple of MAC address and reversed MAC...
14,649
def keep_impute(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] C = np.cov(X_train.T) C += np.eye(C.shape[0]) * 1e-6 X_test_tmp = X_test...
The model is revaluated for each test sample with the non-important features set to an imputed value. Note that the imputation is done using a multivariate normality assumption on the dataset. This depends on being able to estimate the full data covariance matrix (and inverse) accuractly. So X_train.shape[0] s...
14,650
def _get_ignore_from_manifest(filename): class MyTextFile(TextFile): def error(self, msg, line=None): raise Failure(self.gen_error(msg, line)) def warn(self, msg, line=None): warning(self.gen_error(msg, line)) template = MyTextFile(filename, ...
Gather the various ignore patterns from a MANIFEST.in. Returns a list of standard ignore patterns and a list of regular expressions to ignore.
14,651
def get_public_rooms(self, **kwargs): return GetPublicRooms(settings=self.settings, **kwargs).call(**kwargs)
Get a listing of all public rooms with their names and IDs
14,652
def selected(script, face=True, vert=True): if face and vert: filter_xml = elif face and not vert: filter_xml = elif not face and vert: filter_xml = util.write_filter(script, filter_xml) return None
Delete selected vertices and/or faces Note: if the mesh has no faces (e.g. a point cloud) you must set face=False, or the vertices will not be deleted Args: script: the FilterScript object or script filename to write the filter to. face (bool): if True the selected faces will b...
14,653
async def on_reaction_add(reaction, user): server = reaction.message.server emoji = reaction.emoji data = datatools.get_data() if not data["discord"]["servers"][server.id][_data.modulename]["activated"]: return if user != reaction.message.channel.server.me: if serv...
The on_message event handler for this module Args: reaction (discord.Reaction): Input reaction user (discord.User): The user that added the reaction
14,654
def require(self, fieldname, allow_blank=False): if self.request.form and fieldname not in self.request.form.keys(): raise Exception("Required field not found in request: %s" % fieldname) if self.request.form and (not self.request.form[fieldname] or allow_blank): raise E...
fieldname is required
14,655
def by_date(self, chamber, date): "Return votes cast in a chamber on a single day" date = parse_date(date) return self.by_range(chamber, date, date)
Return votes cast in a chamber on a single day
14,656
def plugins(self): from fluent_contents import extensions if self._plugins is None: return extensions.plugin_pool.get_plugins() else: try: return extensions.plugin_pool.get_plugins_by_name(*self._plugins) except extensions.PluginNotFou...
Get the set of plugins that this field may display.
14,657
def uniform(self, a: float, b: float, precision: int = 15) -> float: return round(a + (b - a) * self.random(), precision)
Get a random number in the range [a, b) or [a, b] depending on rounding. :param a: Minimum value. :param b: Maximum value. :param precision: Round a number to a given precision in decimal digits, default is 15.
14,658
def refresh(self) -> None: if not self: self.values[:] = 0. elif len(self) == 1: values = list(self._toy2values.values())[0] self.values[:] = self.apply_timefactor(values) else: for idx, date in enumerate( timetools.TOY...
Update the actual simulation values based on the toy-value pairs. Usually, one does not need to call refresh explicitly. The "magic" methods __call__, __setattr__, and __delattr__ invoke it automatically, when required. Instantiate a 1-dimensional |SeasonalParameter| object: ...
14,659
def _extract_dot15d4address(pkt, source=True): underlayer = pkt.underlayer while underlayer is not None and not isinstance(underlayer, Dot15d4Data): underlayer = underlayer.underlayer if type(underlayer) == Dot15d4Data: addr = underlayer.src_addr if source else underlayer.dest_addr ...
This function extracts the source/destination address of a 6LoWPAN from its upper Dot15d4Data (802.15.4 data) layer. params: - source: if True, the address is the source one. Otherwise, it is the destination. returns: the packed & processed address
14,660
def to_statement(self, parameter_values): missing = self.missing_parameter_values(parameter_values) if len(missing) > 0: raise InsufficientParameterValues("Following required parameters of template don't have values: {}" ....
With the given values for each parameter, this method will return a policy statement that can be used directly with IAM. :param dict parameter_values: Dict containing values for each parameter defined in the template :return dict: Dictionary containing policy statement :raises InvalidPa...
14,661
def kde(data, grid, package, **kwargs): if package == : package = func = KDE_FUNCS[package] return func(data, grid, **kwargs)
Kernel Density Estimation Parameters ---------- package : str Package whose kernel density estimation to use. Should be one of `['statsmodels-u', 'statsmodels-m', 'scipy', 'sklearn']`. data : numpy.array Data points used to compute a density estimator. It has `n ...
14,662
def check_for_cores(self): if not len(self.cores): if self.session.options.get(, False): logging.error("No cores were discovered!") else: raise exceptions.DebugError("No cores were discovered!")
! @brief Init task: verify that at least one core was discovered.
14,663
def _indent(text, prefix, predicate=None): if predicate is None: predicate = lambda line: line.strip() def prefixed_lines(): for line in text.splitlines(True): yield prefix + line if predicate(line) else line return "".join(prefixed_lines())
Adds 'prefix' to the beginning of selected lines in 'text'. If 'predicate' is provided, 'prefix' will only be added to the lines where 'predicate(line)' is True. If 'predicate' is not provided, it will default to adding 'prefix' to all non-empty lines that do not consist solely of whitespace characters...
14,664
def get_sites_in_sphere(self, pt, r, include_index=False, include_image=False): site_fcoords = np.mod(self.frac_coords, 1) neighbors = [] for fcoord, dist, i, img in self._lattice.get_points_in_sphere( site_fcoords, pt, r): nnsite = PeriodicSite(self[i].speci...
Find all sites within a sphere from the point. This includes sites in other periodic images. Algorithm: 1. place sphere of radius r in crystal and determine minimum supercell (parallelpiped) which would contain a sphere of radius r. for this we need the projection of a_1 ...
14,665
def get_board_mapping_parent_items(self, team_context, child_backlog_context_category_ref_name, workitem_ids): project = None team = None if team_context is not None: if team_context.project_id: project = team_context.project_id else: ...
GetBoardMappingParentItems. [Preview API] Returns the list of parent field filter model for the given list of workitem ids :param :class:`<TeamContext> <azure.devops.v5_0.work.models.TeamContext>` team_context: The team context for the operation :param str child_backlog_context_category_ref_name...
14,666
def from_labels_and_predictions(labels, predictions, num_classes): assert len(labels) == len(predictions) cm = np.zeros((num_classes, num_classes), dtype=np.int32) for i in range(len(labels)): cm[labels[i], predictions[i]] += 1 return cm
Compute a confusion matrix from labels and predictions. A drop-in replacement for tf.confusion_matrix that works on CPU data and not tensors. Params ------ labels : array-like 1-D array of real labels for classification predicitions: array-like 1-D array of predicted label...
14,667
def create_with( cls, event: str = None, observable: T.Union[str, Observable] = None ) -> T.Callable[..., "ObservableProperty"]: return functools.partial(cls, event=event, observable=observable)
Creates a partial application of ObservableProperty with event and observable preset.
14,668
def iter_relation(self): for point in iter_points(self.inputs): yield (point, self.restrict(point))
Iterate through all (point, element) pairs in the relation.
14,669
def hash_args(*args, **kwargs): arg_string = .join([str(arg) for arg in args]) kwarg_string = .join([str(key) + + str(value) for key, value in iteritems(kwargs)]) combined = .join([arg_string, kwarg_string]) hasher = md5() hasher.update(b(combined)) return has...
Define a unique string for any set of representable args.
14,670
def alphafilter(request, queryset, template): qs_filter = {} for key in list(request.GET.keys()): if in key: qs_filter[str(key)] = request.GET[key] break return render_to_response( template, {: queryset.filter(**qs_filter), : queryset}, ...
Render the template with the filtered queryset
14,671
def update_domain_base_path_mapping(self, domain_name, lambda_name, stage, base_path): api_id = self.get_api_id(lambda_name) if not api_id: print("Warning! CanitemsrestApiIdstagebasePathbasePath' if base_path is None else base_path, restApiId=api_id, ...
Update domain base path mapping on API Gateway if it was changed
14,672
def get_metric(run_id, metric_id): data = current_app.config["data"] dao = data.get_metrics_dao() metric = dao.get(run_id, metric_id) return Response(render_template( "api/metric.js", run_id=metric["run_id"], metric_id=metric["metric_id"], name=metric["name"], ...
Get a specific Sacred metric from the database. Returns a JSON response or HTTP 404 if not found. Issue: https://github.com/chovanecm/sacredboard/issues/58
14,673
def tradingStatusSSE(symbols=None, on_data=None, token=, version=): return _runSSE(, symbols, on_data, token, version)
The Trading status message is used to indicate the current trading status of a security. For IEX-listed securities, IEX acts as the primary market and has the authority to institute a trading halt or trading pause in a security due to news dissemination or regulatory reasons. For non-IEX-listed securities, IEX abides...
14,674
def binary_operator(op): commuted_method_getter = attrgetter(method_name_for_op(op, commute=True)) @with_doc("Binary Operator: " % op) @with_name(method_name_for_op(op)) @coerce_numbers_to_my_dtype def binary_operator(self, other): return_type = binop_r...
Factory function for making binary operator methods on a Factor subclass. Returns a function, "binary_operator" suitable for implementing functions like __add__.
14,675
def parse_simpleexprsp(self, tup_tree): raise CIMXMLParseError( _format("Internal Error: Parsing support for element {0!A} is not " "implemented", name(tup_tree)), conn_id=self.conn_id)
This Function not implemented. This response is for export senders (indication senders) so it is not implemented in the pywbem client.
14,676
def env(key, default=None, required=False): try: value = os.environ[key] return ast.literal_eval(value) except (SyntaxError, ValueError): return value except KeyError: if default or not required: return default raise ImproperlyConfigured( ...
Retrieves environment variables and returns Python natives. The (optional) default will be returned if the environment variable does not exist.
14,677
def cmd_long(self, args): if len(args) < 1: print("Usage: long <command> [arg1] [arg2]...") return command = None if args[0].isdigit(): command = int(args[0]) else: try: command = eval("mavutil.mavlink." + args[0]) ...
execute supplied command long
14,678
def set_unavailable(self): show = PresenceShow.NONE self.set_presence(PresenceState(available=False, show=show))
Sets the agent availability to False.
14,679
def get_group_value(self, token, match): try: value = match.group(.format(token.name, self.group)) except IndexError: value = return self.func(value) if callable(self.func) else value
Return value of regex match for the specified group
14,680
def send_rsp_recv_cmd(self, target, data, timeout): return super(Device, self).send_rsp_recv_cmd(target, data, timeout)
While operating as *target* send response *data* to the remote device and return new command data if received within *timeout* seconds.
14,681
def get_thumbprint(self): extensions = self.extensions.split() name_str = .join( % ext for ext in extensions) cmd = + self.base_dir + r + name_str + r return getoutput(cmd)
Calculates the current thumbprint of the item being tracked.
14,682
def apply_lens(df, lens=, dist=, n_dim=2, **kwargs): if n_dim != 2: raise if dist not in [, ]: raise if lens == and dist != : raise if lens == : df_lens = pd.DataFrame(decomposition.PCA(n_components=n_dim, **kwargs).fit_transform(df), df.index) elif lens == ...
input: N x F dataframe of observations output: N x n_dim image of input data under lens function
14,683
def p_route_version(self, p): if len(p) > 2: if p[2] <= 0: msg = "Version number should be a positive integer." self.errors.append((msg, p.lineno(2), self.path)) p[0] = p[2] else: p[0] = 1
route_version : COLON INTEGER | empty
14,684
def energy(self, spins, break_aux_symmetry=True): subtheta = self.theta.copy() subtheta.fix_variables(spins) av = next(self._auxvar_counter) auxvars = {v: Symbol(.format(av, v), BOOL) for v in subtheta.linear} if break_aux_symmetry and av == 0: ...
A formula for the exact energy of Theta with spins fixed. Args: spins (dict): Spin values for a subset of the variables in Theta. break_aux_symmetry (bool, optional): Default True. If True, break the aux variable symmetry by setting all aux variable to 1 ...
14,685
def density(pressure, temperature, mixing, molecular_weight_ratio=mpconsts.epsilon): r virttemp = virtual_temperature(temperature, mixing, molecular_weight_ratio) return (pressure / (mpconsts.Rd * virttemp)).to(units.kilogram / units.meter ** 3)
r"""Calculate density. This calculation must be given an air parcel's pressure, temperature, and mixing ratio. The implementation uses the formula outlined in [Hobbs2006]_ pg.67. Parameters ---------- temperature: `pint.Quantity` The temperature pressure: `pint.Quantity` Total ...
14,686
def file_to_str(fname): data = None with open(fname, ) as fd: data = fd.read() return data
Read a file into a string PRE: fname is a small file (to avoid hogging memory and its discontents)
14,687
def prioritize(): while True: hp_qs = Message.objects.high_priority().using() mp_qs = Message.objects.medium_priority().using() lp_qs = Message.objects.low_priority().using() while hp_qs.count() or mp_qs.count(): while hp_qs.count(): for message in h...
Yield the messages in the queue in the order they should be sent.
14,688
def get(self, timeout=None): valid = False result = None for tube in self._output_tubes: if timeout: valid, result = tube.get(timeout) if valid: result = result[0] else: result = tube.get()[0] ...
Retrieve results from all the output tubes.
14,689
def get(method, hmc, uri, uri_parms, logon_required): cpc_oid = uri_parms[0] query_str = uri_parms[1] try: cpc = hmc.cpcs.lookup_by_oid(cpc_oid) except KeyError: raise InvalidResourceError(method, uri) assert not cpc.dpm_enabled result_p...
Operation: List Load Activation Profiles (requires classic mode).
14,690
def is_lop(ch,block_op_pairs_dict=get_block_op_pairs()): {[}]a for i in range(1,block_op_pairs_dict.__len__()+1): if(ch == block_op_pairs_dict[i][0]): return(True) else: pass return(False)
# is_lop('{',block_op_pairs_dict) # is_lop('[',block_op_pairs_dict) # is_lop('}',block_op_pairs_dict) # is_lop(']',block_op_pairs_dict) # is_lop('a',block_op_pairs_dict)
14,691
def query(*args, **kwargs): localremoteallpasswd -S -a** query = _("query") try: return query.Query(kwargs.get(), cachedir=__opts__[])(*args, **kwargs) except InspectorQueryException as ex: raise CommandExecutionError(ex) except Exception as ex: log.error(_get_error_message(e...
Query the node for specific information. Parameters: * **scope**: Specify scope of the query. * **System**: Return system data. * **Software**: Return software information. * **Services**: Return known services. * **Identity**: Return user accounts information for this system. ...
14,692
def get_lecture_filename(combined_section_lectures_nums, section_dir, secnum, lecnum, lecname, title, fmt): fmt = fmt[:FORMAT_MAX_LENGTH] titl...
Prepare a destination lecture filename. @param combined_section_lectures_nums: Flag that indicates whether section lectures should have combined numbering. @type combined_section_lectures_nums: bool @param section_dir: Path to current section directory. @type section_dir: str @param secnu...
14,693
def _get_block_publisher(self, state_hash): state_view = self._state_view_factory.create_view(state_hash) try: class BatchPublisher: def send(self, transactions): ...
Returns the block publisher based on the consensus module set by the "sawtooth_settings" transaction family. Args: state_hash (str): The current state root hash for reading settings. Raises: InvalidGenesisStateError: if any errors occur getting the Block...
14,694
def output_args(f): args = [ magic_arguments.argument(, action="store_const", dest=, const=, help="collate outputs in order (same as group-outputs=order)" ), magic_arguments.argument(, action="store_const", dest=, const=, help="group outpu...
decorator for output-formatting args applied to %pxresult and %%px
14,695
def _Connect(self): elastic_host = {: self._host, : self._port} if self._url_prefix: elastic_host[] = self._url_prefix elastic_http_auth = None if self._username is not None: elastic_http_auth = (self._username, self._password) self._client = elasticsearch.Elasticsearch( ...
Connects to an Elasticsearch server.
14,696
def draw_special_char_key(self, surface, key): key.value = u if key.is_activated(): key.value = u self.draw_character_key(surface, key, True)
Default drawing method for special char key. Drawn as character key. :param surface: Surface background should be drawn in. :param key: Target key to be drawn.
14,697
def rows(self): for s_name, s in self.sections.items(): if s.name != : yield [] yield [, s.value] + s.property_names for row in s.rows: term, value = row term = term.replace(, ).titl...
Iterate over all of the rows
14,698
def results(self, Pc): r Psatn = self[] <= Pc Tsatn = self[] <= Pc inv_phase = {} inv_phase[] = sp.array(Psatn, dtype=float) inv_phase[] = sp.array(Tsatn, dtype=float) return inv_phase
r""" This method determines which pores and throats are filled with invading phase at the specified capillary pressure, and creates several arrays indicating the occupancy status of each pore and throat for the given pressure. Parameters ---------- Pc : scalar ...
14,699
def convert_directory_2_to_3(meas_fname="magic_measurements.txt", input_dir=".", output_dir=".", meas_only=False, data_model=None): convert = {: map_magic.spec_magic2_2_magic3_map, : map_magic.samp_magic2_2_magic3_map, : map_magic.site_magic2_2_magic3_...
Convert 2.0 measurements file into 3.0 measurements file. Merge and convert specimen, sample, site, and location data. Also translates criteria data. Parameters ---------- meas_name : name of measurement file (do not include full path, default is "magic_measurements.txt") input_dir : na...