Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
20,700
def _ParseFileEntry(self, knowledge_base, file_entry): file_object = file_entry.GetFileObject() try: self._ParseFileData(knowledge_base, file_object) finally: file_object.close()
Parses a file entry for a preprocessing attribute. Args: knowledge_base (KnowledgeBase): to fill with preprocessing information. file_entry (dfvfs.FileEntry): file entry that contains the artifact value data. Raises: PreProcessFail: if the preprocessing fails.
20,701
def isnumber(self, string, *args): try: n, u = utility.analyze_number(string) except SyntaxError: return False return True
Is number args: string (str): match returns: bool
20,702
def begin_run_group(project): from benchbuild.utils.db import create_run_group from datetime import datetime group, session = create_run_group(project) group.begin = datetime.now() group.status = session.commit() return group, session
Begin a run_group in the database. A run_group groups a set of runs for a given project. This models a series of runs that form a complete binary runtime test. Args: project: The project we begin a new run_group for. Returns: ``(group, session)`` where group is the created group in th...
20,703
def get_choices(timezones, grouped=False): TZOffset = namedtuple(, ) choices_dict = defaultdict(list) for tz in iter(timezones): now = datetime.now(pytz.timezone(tz)) offset = now.strftime("%z") timezone_offset_string = .format( ...
Retrieves timezone choices from any iterable (normally pytz).
20,704
def handle_task(self, uuid_task, worker=None): uuid, task = uuid_task if task.worker and task.worker.hostname: worker = self.handle_worker( (task.worker.hostname, task.worker), ) defaults = { : task.name, : task.args, ...
Handle snapshotted event.
20,705
def parse(self, text): if self.format == : try: import markdown except ImportError: raise RuntimeError(u"Looks like markdown is not installed") if text.startswith(u): text = text[1:] return markdown.mark...
Parses and renders a text as HTML regarding current format.
20,706
def import_rsa_key(pem_data): if not pem_data.startswith(PREFIX): pem_data = bytes(.format(PREFIX, pem_data, POSTFIX), ) else: pem_data = bytes(pem_data, ) cert = x509.load_pem_x509_certificate(pem_data, default_backend()) return cert.public_key()
Extract an RSA key from a PEM-encoded X.509 certificate :param pem_data: RSA key encoded in standard form :return: rsa.RSAPublicKey instance
20,707
def _get_base(role, **conn): base_fields = frozenset([, , , , , ]) needs_base = False for field in base_fields: if field not in role: needs_base = True break if needs_base: role_name = _get_name_from_structure(role, ) role = CloudAux.go(, RoleName=r...
Determine whether the boto get_role call needs to be made or if we already have all that data in the role object. :param role: dict containing (at the very least) role_name and/or arn. :param conn: dict containing enough information to make a connection to the desired account. :return: Camelized dict de...
20,708
def stop(self): LOGGER.debug("natsd.Driver.stop") for requester in self.requester_registry: requester.stop() self.requester_registry.clear() for service in self.services_registry: if service.is_started: service.stop() self.service...
Stop services and requestors and then connection. :return: self
20,709
def get_active_choices(self, language_code=None, site_id=None): if language_code is None: language_code = get_language() lang_dict = self.get_language(language_code, site_id=site_id) if not lang_dict[]: return [language_code] + [lang for lang in lang_dict[] if l...
Find out which translations should be visible in the site. It returns a list with either a single choice (the current language), or a list with the current language + fallback language.
20,710
def refresh_jwt_token(self, token, override_access_lifespan=None): moment = pendulum.now() with InvalidTokenHeader.handle_errors(): data = jwt.decode( token, self.encode_key, algorithms=self.allowed_algorithms, ...
Creates a new token for a user if and only if the old token's access permission is expired but its refresh permission is not yet expired. The new token's refresh expiration moment is the same as the old token's, but the new token's access expiration is refreshed :param: token: ...
20,711
def remove(self): LOGGER.debug("Endpoint.remove - " + self.id + " - " + self.url) if self.id is None: return None else: if self.id in EndpointService.local_cache_by_id: for search_params in EndpointService.local_cache_by_id[self.id]: ...
remove this endpoint from Ariane server :return:
20,712
def sub_array_2d_from_sub_array_1d(self, sub_array_1d): sub_shape = (self.mask.shape[0] * self.sub_grid_size, self.mask.shape[1] * self.sub_grid_size) sub_one_to_two = self.mask.masked_sub_grid_index_to_sub_pixel(sub_grid_size=self.sub_grid_size) return mapping_util.map_masked_1d_array_...
Map a 1D sub-array the same dimension as the sub-grid (e.g. including sub-pixels) to its original masked 2D sub array. Parameters ----------- sub_array_1d : ndarray The 1D sub_array which is mapped to its masked 2D sub-array.
20,713
def str2url(str): try: str = str.encode() except: pass mfrom = "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîï" to = "AAAAAAECEEEEIIIIDNOOOOOOUUUUYSaaaaaaaceeeeiiii" mfrom += "ñòóôõöøùúûüýÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģ" to += "noooooouuuuyyaaaaaaccccccccddddeeeeeeeeeegggggggg" mfrom += "ĤĥĦħĨĩĪīĬĭ...
Takes a UTF-8 string and replaces all characters with the equivalent in 7-bit ASCII. It returns a plain ASCII string usable in URLs.
20,714
def valuefrompostdata(self, postdata): if self.id in postdata and postdata[self.id] != : return float(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()
20,715
def _proxy(self): if self._context is None: self._context = SyncListItemContext( self._version, service_sid=self._solution[], list_sid=self._solution[], index=self._solution[], ) return self._context
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: SyncListItemContext for this SyncListItemInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemContext
20,716
def toVName(name, stripNum=0, upper=False): if upper: name = name.upper() if stripNum != 0: name = name[:-stripNum] return name.replace(, )
Turn a Python name into an iCalendar style name, optionally uppercase and with characters stripped off.
20,717
def delete(self, subnet_id): subnet = self.client.describe_subnets( SubnetIds=[subnet_id]).get()[0] vpc_id = subnet.get() self.client.delete_subnet(SubnetId=subnet_id) return self.client.delete_vpc(VpcId=vpc_id)
This is bad delete function because one vpc can have more than one subnet. It is Ok if user only use CAL for manage cloud resource We will update ASAP.
20,718
def getSkeletalSummaryData(self, action): fn = self.function_table.getSkeletalSummaryData pSkeletalSummaryData = VRSkeletalSummaryData_t() result = fn(action, byref(pSkeletalSummaryData)) return result, pSkeletalSummaryData
Reads summary information about the current pose of the skeleton associated with the given action.
20,719
def _get_namespace2go2term(go2terms): namespace2go2term = cx.defaultdict(dict) for goid, goterm in go2terms.items(): namespace2go2term[goterm.namespace][goid] = goterm return namespace2go2term
Group GO IDs by namespace.
20,720
def agreement_weighted(ci, wts): s modularity score). Such a choice would add more weight to higher modularity partitions. NOTE: Unlike AGREEMENT, this script does not have the input argument BUFFSZ. Parameters ---------- ci : MxN np.ndarray set of M (possibly degenerate) partition...
D = AGREEMENT_WEIGHTED(CI,WTS) is identical to AGREEMENT, with the exception that each partitions contribution is weighted according to the corresponding scalar value stored in the vector WTS. As an example, suppose CI contained partitions obtained using some heuristic for maximizing modularity. A possi...
20,721
def birth(self): splineReal = scipy.interpolate.splrep(self.x, self.y.real) self.y_int.real = scipy.interpolate.splev(self.x_int,splineReal) splineImag = scipy.interpolate.splrep(self.x, self.y.imag) self.y_int.imag = scipy.interpolate.splev(self.x_int,splineImag)
Create the individual (compute the spline curve)
20,722
def create(cls, interface_id, logical_interface_ref, **kw): data = {: True, : logical_interface_ref, : str(interface_id)} if in kw: data.update(reset_interface_nicid=kw.get()) return cls(data)
:param int interface_id: the interface id :param str logical_ref: logical interface reference, must be unique from inline intfs :rtype: dict
20,723
def _validate_data(dataset, target, features=None, validation_set=): _raise_error_if_not_sframe(dataset, "training dataset") if features is None: features = [feat for feat in dataset.column_names() if feat != target] if not hasattr(features, ): raise TypeError("Input must be a l...
Validate and canonicalize training and validation data. Parameters ---------- dataset : SFrame Dataset for training the model. target : string Name of the column containing the target variable. features : list[string], optional List of feature names used. validation_s...
20,724
def complete(self, text, state): if self.use_main_ns: self.namespace = __main__.__dict__ if not text.strip(): if state == 0: if _readline_available: readline.insert_text() readline.redisplay() r...
Return the next possible completion for 'text'. This is called successively with state == 0, 1, 2, ... until it returns None. The completion should begin with 'text'.
20,725
def gamma(self, gamma=1.0): if(isinstance(gamma, (list, tuple, set)) and len(gamma) != len(self.channels)): raise ValueError("Number of channels and gamma components differ.") if isinstance(gamma, (tuple, list)): gamma_list = list(gamma) else: ...
Apply gamma correction to the channels of the image. If *gamma* is a tuple, then it should have as many elements as the channels of the image, and the gamma correction is applied elementwise. If *gamma* is a number, the same gamma correction is applied on every channel, if there are seve...
20,726
def normalize_map_between(dictionary, norm_min, norm_max): if len(dictionary) < 2: return {} values = list(dictionary.values()) norm_range = norm_max - norm_min map_min = min(values) map_range = max(values) - map_min range_factor = norm_range / float(map_range) normalized_map...
Performs linear normalization of all values in Map between normMin and normMax :param: map Map to normalize values for :param: normMin Smallest normalized value :param: normMax Largest normalized value :return: A new map with double values within [normMin, normMax]
20,727
def _autobox(content, format): if format == Format.JSON: return json.loads(content) elif format == Format.XML: return etree.fromstring(content) elif format == Format.CSV: try: return csv.reader(io.BytesIO(content)) except TypeError: d...
Autobox response content. :param content: Response content :type content: str :param format: Format to return :type format: `yaxil.Format` :returns: Autoboxed content :rtype: dict|xml.etree.ElementTree.Element|csvreader
20,728
def check_error(model, path, shapes, output = , verbose = True): coreml_model = _coremltools.models.MLModel(path) input_data = {} input_data_copy = {} for ip in shapes: input_data[ip] = _np.random.rand(*shapes[ip]).astype() input_data_copy[ip] = _np.copy(input_data[ip]) dataIte...
Check the difference between predictions from MXNet and CoreML.
20,729
def _fchown(self, real, fileno, uid, gid): path = self._fake_path(self._path_from_fd(fileno)) self._chown_common(path, uid, gid)
Run fake fchown code if fileno points to a sub-path of our tree. The ownership set with this fake fchown can be inspected by looking at the self.uid/self.gid dictionaries.
20,730
def _args_from_dict(ddata: Mapping[str, Any]): d_true_keys = {} uns_is_not_key = False valid_keys = [] for keys in AnnData._H5_ALIASES.values(): valid_keys += keys valid_keys += [, , , ] for key in ddata.keys(): ...
Allows to construct an instance of AnnData from a dictionary. Acts as interface for the communication with the hdf5 file. In particular, from a dict that has been written using ``AnnData._to_dict_fixed_width_arrays``.
20,731
def copy(self, new_name=None): _tmp = copy.deepcopy(self) if not new_name: new_name = self.name + if str(type(self)) == "<class >": _tmp.meta.note(.format( new=new_name, old=self.meta.name)) _tmp.meta.change_meta(, new_name, log=False...
Returns a deep copy of the system Parameters ----------- new_name: str, optional Set a new meta name parameter. Default: <old_name>_copy
20,732
def add(self, key, value, time, compress_level=-1): return self._set_add_replace(, key, value, time, compress_level=compress_level)
Add a key/value to server ony if it does not exist. :param key: Key's name :type key: six.string_types :param value: A value to be stored on server. :type value: object :param time: Time in seconds that your key will expire. :type time: int :param compress_level:...
20,733
def convert_to_str(d): d2 = {} for k, v in d.items(): k = str(k) if type(v) in [list, tuple]: d2[k] = [str(a) for a in v] elif type(v) is dict: d2[k] = convert_to_str(v) else: d2[k] = str(v) return d2
Recursively convert all values in a dictionary to strings This is required because setup() does not like unicode in the values it is supplied.
20,734
def evaluate_binop_logical(self, operation, left, right, **kwargs): if not operation in self.binops_logical: raise ValueError("Invalid logical binary operation ".format(operation)) result = self.binops_logical[operation](left, right) return bool(result)
Evaluate given logical binary operation with given operands.
20,735
def fail_remaining(self): self._failed.update(self._graph.nodes) self._graph = Graph() self._running = set()
Mark all unfinished tasks (including currently running ones) as failed.
20,736
def boxcox_trans(p, **kwargs): if np.abs(p) < 1e-7: return log_trans() def transform(x): return (x**p - 1) / (p * np.sign(x-1)) def inverse(x): return (np.abs(x) * p + np.sign(x)) ** (1 / p) kwargs[] = p kwargs[] = kwargs.get(, .format(p)) kwargs[] = transform ...
Boxcox Transformation Parameters ---------- p : float Power parameter, commonly denoted by lower-case lambda in formulae kwargs : dict Keyword arguments passed onto :func:`trans_new`. Should not include the `transform` or `inverse`.
20,737
def process_data(key, data_list, result_info_key, identifier_keys): master_data = [] for item_data in data_list: data = item_data[key] if data is None: current_item_data = {} else: if key == : current_item_data = data[] elif key...
Given a key as the endpoint name, pulls the data for that endpoint out of the data_list for each address, processes the data into a more excel-friendly format and returns that data. Args: key: the endpoint name of the data to process data_list: the main data list to take...
20,738
async def add(self, key, value, ttl=SENTINEL, dumps_fn=None, namespace=None, _conn=None): start = time.monotonic() dumps = dumps_fn or self._serializer.dumps ns_key = self.build_key(key, namespace=namespace) await self._add(ns_key, dumps(value), ttl=self._get_ttl(ttl), _conn=_c...
Stores the value in the given key with ttl if specified. Raises an error if the key already exists. :param key: str :param value: obj :param ttl: int the expiration time in seconds. Due to memcached restrictions if you want compatibility use int. In case you need...
20,739
def describe_enum_value(enum_value): enum_value_descriptor = EnumValueDescriptor() enum_value_descriptor.name = six.text_type(enum_value.name) enum_value_descriptor.number = enum_value.number return enum_value_descriptor
Build descriptor for Enum instance. Args: enum_value: Enum value to provide descriptor for. Returns: Initialized EnumValueDescriptor instance describing the Enum instance.
20,740
def set_description(self, vrf_name, description=None, default=False, disable=False): cmds = self.command_builder(, value=description, default=default, disable=disable) return self.configure_vrf(vrf_name, cmds)
Configures the VRF description Args: vrf_name (str): The VRF name to configure description(str): The string to set the vrf description to default (bool): Configures the vrf description to its default value disable (bool): Negates the vrf description Retu...
20,741
def register_custom_adapter(cls, target_class, adapter): class_name = target_class.__name__ if adapter.can_serialize(): cls._custom_serializers[class_name] = adapter if adapter.can_deserialize(): cls._custom_deserializers[class_name] = adapter
:type target_class: type :type adapter: JsonAdapter|type :rtype: None
20,742
def sample(self, num_rows=1): self.check_fit() res = {} means = np.zeros(self.covariance.shape[0]) size = (num_rows,) clean_cov = np.nan_to_num(self.covariance) samples = np.random.multivariate_normal(means, clean_cov, size=size) for i, (label, distrib...
Creates sintentic values stadistically similar to the original dataset. Args: num_rows: `int` amount of samples to generate. Returns: np.ndarray: Sampled data.
20,743
def create_panel_of_normals(items, group_id, work_dir): out_file = os.path.join(work_dir, "%s-%s-pon.hdf5" % (dd.get_sample_name(items[0]), group_id)) if not utils.file_exists(out_file): with file_transaction(items[0], out_file) as tx_out_file: params = ["-T", "CreateReadCountPanelOfNor...
Create a panel of normals from one or more background read counts.
20,744
def restore(self): if self.proxy_object is None: if self.getter: setattr(self.getter_class, self.attr_name, self.getter) elif self.is_local: setattr(self.orig_object, self.attr_name, self.orig_value) else: ...
Restore the saved value for the attribute of the object.
20,745
def render(self, size): middle, corner, side, foreColor, backColor = self.decode(self.code) size = int(size) image = Image.new("RGB", (size * 3, size * 3)) draw = ImageDraw.Draw(image) draw.rectangle((0, 0, image.size[0], image.size[1]), fill...
render identicon to PIL.Image @param size identicon patchsize. (image size is 3 * [size]) @return PIL.Image
20,746
def average(var, key, N): global average_data if not key in average_data: average_data[key] = [var]*N return var average_data[key].pop(0) average_data[key].append(var) return sum(average_data[key])/N
average over N points
20,747
def get_comments(self, project, work_item_id, top=None, continuation_token=None, include_deleted=None, expand=None, order=None): route_values = {} if project is not None: route_values[] = self._serialize.url(, project, ) if work_item_id is not None: route_values[...
GetComments. [Preview API] Returns a list of work item comments, pageable. :param str project: Project ID or project name :param int work_item_id: Id of a work item to get comments for. :param int top: Max number of comments to return. :param str continuation_token: Used to query...
20,748
def get_small_image_url(self, page=1): template = self.resources.page.get() return template.replace( "{page}", str(page) ).replace("{size}", "small")
Returns the URL for the small sized image of a single page. The page kwarg specifies which page to return. One is the default.
20,749
def make_relationship_aggregate(self, relationship): if not self._session.IS_MANAGING_BACKREFERENCES: relationship.direction &= ~RELATIONSHIP_DIRECTIONS.REVERSE return RelationshipAggregate(self, relationship)
Returns a new relationship aggregate for the given relationship. :param relationship: Instance of :class:`everest.entities.relationship.DomainRelationship`.
20,750
def put_account(self, headers=None, query=None, cdn=False, body=None): return self.request( , , body or , headers, query=query, cdn=cdn)
PUTs the account and returns the results. This is usually done with the extract-archive bulk upload request and has no other use I know of (but the call is left open in case there ever is). :param headers: Additional headers to send with the request. :param query: Set to a dict ...
20,751
def PC_AC1_calc(P, TOP, POP): try: result = 0 classes = list(P.keys()) for i in classes: pi = ((P[i] + TOP[i]) / (2 * POP[i])) result += pi * (1 - pi) result = result / (len(classes) - 1) return result except Exception: return "None"
Calculate percent chance agreement for Gwet's AC1. :param P: condition positive :type P : dict :param TOP: test outcome positive :type TOP : dict :param POP: population :type POP:dict :return: percent chance agreement as float
20,752
def get_template(cls, message, messenger): template = message.context.get(, None) if template: return template if cls.template is None: cls.template = % ( cls.get_alias(), messenger.get_alias(), cls.template_ext ) return c...
Get a template path to compile a message. 1. `tpl` field of message context; 2. `template` field of message class; 3. deduced from message, messenger data and `template_ext` message type field (e.g. `sitemessage/messages/plain__smtp.txt` for `plain` message type). :param Mes...
20,753
def remove_temp_copy(self): if self.is_temp and self.root_dir is not None: shutil.rmtree(self.root_dir) self.root_dir = None
Removes a temporary copy of the MAGICC version shipped with Pymagicc.
20,754
def decipher(self,string): string = self.remove_punctuation(string) if len(string)%2 == 1: string = string + ret = for c in range(0,len(string.upper()),2): a,b = self.decipher_pair(string[c],string[c+1]) ret += a + b return ret
Decipher string using Foursquare cipher according to initialised key. Punctuation and whitespace are removed from the input. The ciphertext should be an even number of characters. If the input ciphertext is not an even number of characters, an 'X' will be appended. Example:: plaintext = Fo...
20,755
def linkify(self): for t_id in self.items: timeperiod = self.items[t_id] timeperiod.linkify(self)
Check exclusion for each timeperiod :return: None
20,756
def push(self, kv): if kv[0] in self: self.__delitem__(kv[0]) self.__setitem__(kv[0], kv[1])
Adds a new item from the given (key, value)-tuple. If the key exists, pushes the updated item to the head of the dict.
20,757
def run_command_on_marathon_leader( command, username=None, key_path=None, noisy=True ): return run_command(shakedown.marathon_leader_ip(), command, username, key_path, noisy)
Run a command on the Marathon leader
20,758
def ToByteArray(self): ms = StreamManager.GetStream() writer = BinaryWriter(ms) self.Serialize(writer) retval = ms.ToArray() StreamManager.ReleaseStream(ms) return retval
Serialize self and get the byte stream. Returns: bytes: serialized object.
20,759
def parse_sentence(self, string): result = [] def shift(string_): string_ = string_.strip() if not string_: return , i = string_.find() if i == -1: command_ = string_ string_ = ...
Parses the given sentence. BASIC commands must be types UPPERCASE and as SEEN in ZX BASIC. e.g. GO SUB for gosub, etc...
20,760
def enterEvent( self, event ): item = self.trackerItem() if ( item ): item.setVisible(True)
Toggles the display for the tracker item.
20,761
def _check_std(self, paths, cmd_pieces): cmd_pieces.extend(paths) process = Popen(cmd_pieces, stdout=PIPE, stderr=PIPE) out, err = process.communicate() lines = out.strip().splitlines() + err.strip().splitlines() result = [] for line in lines: match =...
Run `cmd` as a check on `paths`.
20,762
def _get_pydot(self): if self.pydot: return self.pydot self.pydot = __import__("pydot") return self.pydot
Return pydot package. Load pydot, if necessary.
20,763
def add_response_headers(h): def headers_wrapper(fun): def wrapped_function(*args, **kwargs): response = fun(*args, **kwargs) for k, v in h.iteritems(): response[k] = v return response return wrapped_function return headers_wrapper
Add HTTP-headers to response. Example: @add_response_headers({'Refresh': '10', 'X-Powered-By': 'Django'}) def view(request): ....
20,764
def clear_jobs(): if not is_authorized(): return json.dumps({: }), 403, headers days = flask.request.args.get(, None) return _clear_jobs(days)
Clear old jobs :param days: Jobs for how many days should be kept (default: 10) :type days: integer :statuscode 200: no error :statuscode 403: not authorized to delete jobs :statuscode 409: an error occurred
20,765
def bootstrap_app(): from salt.netapi.rest_cherrypy import app import salt.config __opts__ = salt.config.client_config( os.environ.get(, )) return app.get_app(__opts__)
Grab the opts dict of the master config by trying to import Salt
20,766
def show_text_glyphs(self, text, glyphs, clusters, cluster_flags=0): glyphs = ffi.new(, glyphs) clusters = ffi.new(, clusters) cairo.cairo_show_text_glyphs( self._pointer, _encode_string(text), -1, glyphs, len(glyphs), clusters, len(clusters), cluster_flags) ...
This operation has rendering effects similar to :meth:`show_glyphs` but, if the target surface supports it (see :meth:`Surface.has_show_text_glyphs`), uses the provided text and cluster mapping to embed the text for the glyphs shown in the output. If the target does not support t...
20,767
def orthogonal_basis(self): if self.dim == 3: x_arr = np.array([-self.data[1], self.data[0], 0]) if np.linalg.norm(x_arr) == 0: x_arr = np.array([self.data[2], 0, 0]) x_arr = x_arr / np.linalg.norm(x_arr) y_arr = np.cross(self.data, x_arr)...
Return an orthogonal basis to this direction. Note ---- Only implemented in 3D. Returns ------- :obj:`tuple` of :obj:`Direction` The pair of normalized Direction vectors that form a basis of this direction's orthogonal complement. Ra...
20,768
def get_name_addr(value): name_addr = NameAddr() leader = None if value[0] in CFWS_LEADER: leader, value = get_cfws(value) if not value: raise errors.HeaderParseError( "expected name-addr but found ".format(leader)) if value[0] != : if value[...
name-addr = [display-name] angle-addr
20,769
def fill_auth_list(self, auth_provider, name, groups, auth_list=None, permissive=None): if auth_list is None: auth_list = [] if permissive is None: permissive = self.opts.get() name_matched = False for match in auth_provider: if match == and ...
Returns a list of authorisation matchers that a user is eligible for. This list is a combination of the provided personal matchers plus the matchers of any group the user is in.
20,770
def conformPadding(cls, chars): pad = chars if pad and pad[0] not in PAD_MAP: pad = cls.getPaddingChars(cls.getPaddingNum(pad)) return pad
Ensure alternate input padding formats are conformed to formats defined in PAD_MAP If chars is already a format defined in PAD_MAP, then it is returned unmodified. Example:: '#' -> '#' '@@@@' -> '@@@@' '%04d' -> '#' Args: char...
20,771
def port_create(request, network_id, **kwargs): LOG.debug("port_create(): netid=%(network_id)s, kwargs=%(kwargs)s", {: network_id, : kwargs}) kwargs = unescape_port_kwargs(**kwargs) body = {: {: network_id}} if not in kwargs: kwargs[] = request.user.project_id body[].upda...
Create a port on a specified network. :param request: request context :param network_id: network id a subnet is created on :param device_id: (optional) device id attached to the port :param tenant_id: (optional) tenant id of the port created :param name: (optional) name of the port created :ret...
20,772
def snapshot(self): return dict((category, dict((name, metric.value()) for name, metric in list(metrics.items()))) for category, metrics in list(self._store.items()))
Return a nested dictionary snapshot of all metrics and their values at this time. Example: { 'category': { 'metric1_name': 42.0, 'metric2_name': 'foo' } }
20,773
def vn_info(call=None, kwargs=None): if call != : raise SaltCloudSystemExit( ) if kwargs is None: kwargs = {} name = kwargs.get(, None) vn_id = kwargs.get(, None) if vn_id: if name: log.warning( vn_id\name\ ...
Retrieves information for the virtual network. .. versionadded:: 2016.3.0 name The name of the virtual network for which to gather information. Can be used instead of ``vn_id``. vn_id The ID of the virtual network for which to gather information. Can be used instead of ``n...
20,774
def _render_headers(self): headers = getattr(self, , ()) for index, col in enumerate(headers): cell = self.worksheet.cell(row=1, column=index + 1) cell.value = col[] index += 1 extra_headers = getattr(self, , ()) for add_index, col ...
Write the headers row
20,775
async def close(self) -> None: if not self.closed: if self._connector is not None and self._connector_owner: await self._connector.close() self._connector = None
Close underlying connector. Release all acquired resources.
20,776
def write(self, obj): if self.verbose: self._warnings("cache miss for {0}", self._cache_id_desc()) if self._start_time is not None: elapsed = get_time() - self._start_time else: elapsed = None out = self._write(self._cache_id_obj, elapsed, obj...
Writes the given object to the cache file as pickle. The cache file with its path is created if needed.
20,777
def get_clan_tracking(self, *tags: crtag, **params: keys): url = self.api.CLAN + + .join(tags) + return self._get_model(url, **params)
Returns if the clan is currently being tracked by the API by having either cr-api.com or royaleapi.com in the clan description Parameters ---------- \*tags: str Valid clan tags. Minimum length: 3 Valid characters: 0289PYLQGRJCUV \*\*keys: Optional...
20,778
def timed_rotating_file_handler(name, logname, filename, when=, interval=1, backupCount=0, encoding=None, delay=False, utc=False): return wrap_log_handler(logging.handlers.TimedRotatingFileHandler( filename, when=when, interval=interval, ...
A Bark logging handler logging output to a named file. At intervals specified by the 'when', the file will be rotated, under control of 'backupCount'. Similar to logging.handlers.TimedRotatingFileHandler.
20,779
def designator(self): version = str(self.version) return .join((version, self.error) if self.error else (version,))
\ Returns the version and error correction level as string `V-E` where `V` represents the version number and `E` the error level.
20,780
def dump_yaml(data, Dumper=_Dumper, default_flow_style=False): content = yaml.dump(data, default_flow_style=default_flow_style, Dumper=Dumper) return content.strip()
Returns data as yaml-formatted string.
20,781
def delete_refresh_token(self, refresh_token): access_token = self.fetch_by_refresh_token(refresh_token) self.delete(access_token.token)
Deletes a refresh token after use :param refresh_token: The refresh token to delete.
20,782
def is_none_or(self): if self._subject is None: return NoOpInspector(subject=self._subject, error_factory=self._error_factory) else: return self
Ensures :attr:`subject` is either ``None``, or satisfies subsequent (chained) conditions:: Ensure(None).is_none_or.is_an(int)
20,783
def parse_signature(signature): if " -> " not in signature: param_types, return_type = None, signature.strip() else: lhs, return_type = [s.strip() for s in signature.split(" -> ")] csv = lhs[1:-1].strip() param_types = split_parameter_types(csv) requires = set...
Parse a signature into its input and return parameter types. This will also collect the types that are required by any of the input and return types. :sig: (str) -> Tuple[List[str], str, Set[str]] :param signature: Signature to parse. :return: Input parameter types, return type, and all required t...
20,784
def listar_por_equipamento(self, id_equipment): if not is_valid_int_param(id_equipment): raise InvalidParameterError( u) url = + str(id_equipment) + code, map = self.submit(None, , url) key = return get_list_map(self.response(code, map, ...
List all Script related Equipment. :param id_equipment: Identifier of the Equipment. Integer value and greater than zero. :return: Dictionary with the following structure: :: {script': [{‘id’: < id >, ‘nome’: < nome >, ‘descricao’: < descricao >, ...
20,785
def prev_img_ws(self, ws, loop=True): channel = self.get_active_channel_ws(ws) if channel is None: return channel.prev_image() return True
Go to the previous image in the focused channel in the workspace.
20,786
def visualize_cloud_of_words(dictionary, image_path=None): from PIL import Image if image_path is not None: mask = np.array(Image.open(image_path)) wc = WordCloud(mask=mask, background_color=, width=1600, height=1200, prefer_horizontal=0.8) wc = wc.generate_...
Renders the cloud of words representation for a given dictionary of frequencies :param dictionary: the dictionary object that contains key-frequency pairs :param image_path: the path to the image mask, None if no masking is needed
20,787
def cause_effect_info(self, mechanism, purview): return min(self.cause_info(mechanism, purview), self.effect_info(mechanism, purview))
Return the cause-effect information for a mechanism over a purview. This is the minimum of the cause and effect information.
20,788
def combs(a, r): if r == 0: return np.asarray([]) a = np.asarray(a) data_type = a.dtype if r == 0 else np.dtype([(, a.dtype)] * r) b = np.fromiter(combinations(a, r), data_type) return b.view(a.dtype).reshape(-1, r)
NumPy implementation of ``itertools.combinations``. Return successive ``r``-length combinations of elements in the array ``a``. Args: a (np.ndarray): The array from which to get combinations. r (int): The length of the combinations. Returns: np.ndarray: An array of combinations.
20,789
def fit_linear(X, y): model = linear_model.LinearRegression() model.fit(X, y) return model
Uses OLS to fit the regression.
20,790
def unpack_4to8(data): tmpdata = data.astype(np.int16) tmpdata = (tmpdata | (tmpdata << 4)) & 0x0F0F updata = tmpdata.byteswap() return updata.view(data.dtype)
Promote 2-bit unisgned data into 8-bit unsigned data. Args: data: Numpy array with dtype == uint8 Notes: # The process is this: # ABCDEFGH [Bits of one 4+4-bit value] # 00000000ABCDEFGH [astype(uint16)] # 0000ABCDEFGH0000 [<< 4] # 0000ABCDXXXXEFGH [bitwise 'or' ...
20,791
def evert(iterable: Iterable[Dict[str, Tuple]]) -> Iterable[Iterable[Dict[str, Any]]]: aaas tuple elements. Parameters ---------- :``iterable``: list of dictionaries whose values are tuples Return Value(s) --------------- All combinations of the choices in the dictionaries. ' k...
Evert dictionaries with tuples. Iterates over the list of dictionaries and everts them with their tuple values. For example: ``[ { 'a': ( 1, 2, ), }, ]`` becomes ``[ ( { 'a': 1, }, ), ( { 'a', 2, }, ) ]`` The resulting iterable contains the same number of tuples as the initial iterable...
20,792
def plot(self, entity): df = self._binary_df[[entity]] resampled = df.resample("s").ffill() resampled.columns = ["value"] fig, ax = plt.subplots(1, 1, figsize=(16, 2)) ax.fill_between(resampled.index, y1=0, y2=1, facecolor="royalblue", label="off") ax.fill_betw...
Basic plot of a single binary sensor data. Parameters ---------- entity : string The entity to plot
20,793
def execute_command(working_dir, cmd, env_dict): proc_env = os.environ.copy() proc_env["PATH"] = "{}:{}:.".format(proc_env["PATH"], working_dir) proc_env.update(env_dict) proc = subprocess.Popen( cmd, cwd=working_dir, env=proc_env, shell=True, stdout=subproce...
execute_command: run the command provided in the working dir specified adding the env_dict settings to the execution environment :param working_dir: path to directory to execute command also gets added to the PATH :param cmd: Shell command to execute :param env_dict: dictionary of additional...
20,794
def add_proxy_to(self, parent, name, multiplicity=Multiplicity.ONE_MANY, **kwargs): return self._client.create_proxy_model(self, parent, name, multiplicity, **kwargs)
Add this model as a proxy to another parent model. This will add the current model as a proxy model to another parent model. It ensure that it will copy the whole subassembly to the 'parent' model. In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` a...
20,795
def p_arglist(p): if len(p) == 2: p[0] = [p[1]] else: p[0] = p[1] p[0].append(p[3])
arglist : arg | arglist COMMA arg
20,796
def _defaultdict(dct, fallback=_illegal_character): out = defaultdict(lambda: fallback) for k, v in six.iteritems(dct): out[k] = v return out
Wraps the given dictionary such that the given fallback function will be called when a nonexistent key is accessed.
20,797
def merge(self, commit_message=, sha=None): parameters = {: commit_message} if sha: parameters[] = sha url = self._build_url(, base_url=self._api) json = self._json(self._put(url, data=dumps(parameters)), 200) self.merge_commit_sha = json[] return jso...
Merge this pull request. :param str commit_message: (optional), message to be used for the merge commit :returns: bool
20,798
def parse_type(defn, preprocess=True): if pycparser is None: raise ImportError("Please install pycparser in order to parse C definitions") defn = + defn.strip() + if preprocess: defn = do_preprocess(defn) node = pycparser.c_parser.CParser().parse(make_preamble()[0] + defn) ...
Parse a simple type expression into a SimType >>> parse_type('int *')
20,799
def classify_harmonic(self, partial_labels, use_CMN=True): labels = np.array(partial_labels, copy=True) unlabeled = labels == -1 fl, classes = _onehot(labels[~unlabeled]) L = self.laplacian(normed=False) if ss.issparse(L): L = L.tocsr()[unlabeled].toarray() else: L =...
Harmonic function method for semi-supervised classification, also known as the Gaussian Mean Fields algorithm. partial_labels: (n,) array of integer labels, -1 for unlabeled. use_CMN : when True, apply Class Mass Normalization From "Semi-Supervised Learning Using Gaussian Fields and Harmonic Functions...