Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
386,300
def get_nested_streams(dmap): return list({s for dmap in get_nested_dmaps(dmap) for s in dmap.streams})
Recurses supplied DynamicMap to find all streams Args: dmap: DynamicMap to recurse to look for streams Returns: List of streams that were found
386,301
def create_folder(query, default_name=None, default_path=None): from gi.repository import Gtk from os.path import expanduser, dirname, join, exists, isdir from rafcon.core.storage.storage import STATEMACHINE_FILE from rafcon.gui.singleton import main_window_controller from rafcon.gui.runtime_co...
Shows a user dialog for folder creation A dialog is opened with the prompt `query`. The current path is set to the last path that was opened/created. The roots of all libraries is added to the list of shortcut folders. :param str query: Prompt asking the user for a specific folder :param str ...
386,302
def get_line_flux(line_wave, wave, flux, **kwargs): return np.interp(line_wave, wave, flux, **kwargs)
Interpolated flux at a given wavelength (calls np.interp).
386,303
def get_certificate(): if os.path.exists(CERT_PATH): log(.format(CERT_PATH)) with open(CERT_PATH, ) as cert: full_cert = cert.read() begin_marker = "-----BEGIN CERTIFICATE-----" end_marker = "-----END CERTIFICATE-----" begin_index = full_cert.find...
Read openvswitch certificate from disk
386,304
def _is_empty(self): block_items = list(self.iter_block_items()) if len(block_items) > 1: return False p = block_items[0] if len(p.r_lst) == 0: return True return False
True if this cell contains only a single empty ``<w:p>`` element.
386,305
def fwdl_status_output_fwdl_state(self, **kwargs): config = ET.Element("config") fwdl_status = ET.Element("fwdl_status") config = fwdl_status output = ET.SubElement(fwdl_status, "output") fwdl_state = ET.SubElement(output, "fwdl-state") fwdl_state.text = kwargs.p...
Auto Generated Code
386,306
def dump(file_name, predictions=None, algo=None, verbose=0): dump_obj = {: predictions, : algo } pickle.dump(dump_obj, open(file_name, ), protocol=pickle.HIGHEST_PROTOCOL) if verbose: print(, file_name)
A basic wrapper around Pickle to serialize a list of prediction and/or an algorithm on drive. What is dumped is a dictionary with keys ``'predictions'`` and ``'algo'``. Args: file_name(str): The name (with full path) specifying where to dump the predictions. predictions(list of...
386,307
def _processing_controller_status(self): LOG.info() while True: LOG.info(, len(self._queue)) time.sleep(self._report_interval) if active_count() != 5: LOG.critical( , active_count(), 5)
Report on the status of the Processing Block queue(s).
386,308
def start(name, call=None): if call != : raise SaltCloudSystemExit( ) log.info(, name) instanceId = _get_node(name)[] params = {: , : instanceId} result = query(params) return result
Start a node CLI Examples: .. code-block:: bash salt-cloud -a start myinstance
386,309
def state(self): if self._proto.HasField(): return yamcsManagement_pb2.ServiceState.Name(self._proto.state) return None
State of this service.
386,310
def w(msg, *args, **kwargs): return logging.log(WARN, msg, *args, **kwargs)
log a message at warn level;
386,311
def copyfileobj(fsrc, fdst, length=16*1024): while 1: buf = fsrc.read(length) if not buf: break fdst.write(buf)
copy data from file-like object fsrc to file-like object fdst
386,312
def refresh_oauth_credential(self): if self.session.token_type == auth.SERVER_TOKEN_TYPE: return credential = self.session.oauth2credential if credential.is_stale(): refresh_session = refresh_access_token(credential) self.session = refresh_session
Refresh session's OAuth 2.0 credentials if they are stale.
386,313
def E(self,*args,**kwargs): if not in kwargs or kwargs[] is None: try: pot= self._pot except AttributeError: raise AttributeError("Integrate orbit or specify pot=") if in kwargs and kwargs[] is None: kwargs.pop() ...
NAME: E PURPOSE: calculate the energy INPUT: t - (optional) time at which to get the radius pot= potential instance or list of such instances OUTPUT: energy HISTORY: 2010-09-15 - Written - Bovy (NYU) 2011-04-18 ...
386,314
def add_callback(self, name, func): if name == : events = [] def callback(_conn_string, _conn_id, _name, event): func(self.id, event, event.get(, 60)) elif name == : events = [, ] def callback(_conn_string, conn_id, _name, event):...
Add a callback when device events happen. Args: name (str): currently support 'on_scan' and 'on_disconnect' func (callable): the function that should be called
386,315
def get_account_tokens(self, address): cur = self.db.cursor() return namedb_get_account_tokens(cur, address)
Get the list of tokens that this address owns
386,316
def push(self, undoObj): if not isinstance(undoObj, QtmacsUndoCommand): raise QtmacsArgumentError(, , inspect.stack()[0][3]) self._wasUndo = False self._push(undoObj)
Add ``undoObj`` command to stack and run its ``commit`` method. |Args| * ``undoObj`` (**QtmacsUndoCommand**): the new command object. |Returns| * **None** |Raises| * **QtmacsArgumentError** if at least one argument has an invalid type.
386,317
async def fetch_lightpad(self, lpid): url = "https://production.plum.technology/v2/getLightpad" data = {"lpid": lpid} return await self.__post(url, data)
Lookup details for a given lightpad
386,318
def Serialize(self, writer): super(Header, self).Serialize(writer) writer.WriteByte(0)
Serialize full object. Args: writer (neo.IO.BinaryWriter):
386,319
def filter_slaves(selfie, slaves): return [(s[], s[]) for s in slaves if not s[] and not s[] and s[] == ]
Remove slaves that are in an ODOWN or SDOWN state also remove slaves that do not have 'ok' master-link-status
386,320
def lookup_field_label(self, context, field, default=None): default = None for form_field in self.form: if form_field.name == field: default = form_field.label break return super(SmartFormMixin, self).lookup_field_label(context, field, defau...
Figures out what the field label should be for the passed in field name. We overload this so as to use our form to see if there is label set there. If so then we'll pass that as the default instead of having our parent derive the field from the name.
386,321
def custom_background_code(): while True: logger.info("Block %s / %s", str(Blockchain.Default().Height), str(Blockchain.Default().HeaderHeight)) sleep(15)
Custom code run in a background thread. Prints the current block height. This function is run in a daemonized thread, which means it can be instantly killed at any moment, whenever the main thread quits. If you need more safety, don't use a daemonized thread and handle exiting this thread in another way (...
386,322
def compose(f: Callable[[Any], Monad], g: Callable[[Any], Monad]) -> Callable[[Any], Monad]: r return lambda x: g(x).bind(f)
r"""Monadic compose function. Right-to-left Kleisli composition of two monadic functions. (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c f <=< g = \x -> g x >>= f
386,323
def get_critical_path_timings(self): setup_workunit = WorkUnitLabel.SETUP.lower() transitive_dependencies = dict() for goal_info in self._sorted_goal_infos: deps = transitive_dependencies.setdefault(goal_info.goal.name, set()) for dep in goal_info.goal_dependencies: deps.add(dep.nam...
Get the cumulative timings of each goal and all of the goals it (transitively) depended on.
386,324
def create_response_dic(self): dic = {} for scope in self.scopes: if scope in self._scopes_registered(): dic.update(getattr(self, + scope)()) dic = self._clean_dic(dic) return dic
Generate the dic that will be jsonify. Checking scopes given vs registered. Returns a dic.
386,325
def getTypeWidth(self, dtype: "HdlType", do_eval=False) -> Tuple[int, str, bool]: raise NotImplementedError( "Implement this method in your HdlType classes")
:return: tuple (current value of width, string of value (can be ID or int), Flag which specifies if width of signal is locked or can be changed by parameter)
386,326
def set_hostname(hostname=None, deploy=False): ** if not hostname: raise CommandExecutionError("Hostname option must not be none.") ret = {} query = {: , : , : localhost.localdomain\, : .format(hostname)} ret.update(__proxy__[](query)) if deplo...
Set the hostname of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: hostname (str): The hostname to set deploy (bool): If true then commit the full candidate configuration, if false only set pending change. .. code-block:: bash ...
386,327
def _delete(self): collection = JSONClientValidated(, collection=, runtime=self._runtime) collection.delete_one({: ObjectId(self.get_id().get_identifier())})
Deletes this AssessmentSection from database. Will be called by AssessmentTaken._delete() for clean-up purposes.
386,328
def run_license_checker(config_path): whitelist_licenses = _get_whitelist_licenses(config_path) table = PrintTable(ROW_HEADERS) warnings = [] for pkg in _get_packages(): allowed = pkg.license in whitelist_licenses table.add_row((pkg.name, pkg.version, pkg.license, str(allowed...
Generate table of installed packages and check for license warnings based off user defined restricted license values. :param config_path: str :return:
386,329
def create_unihan_table(columns, metadata): if TABLE_NAME not in metadata.tables: table = Table(TABLE_NAME, metadata) table.append_column(Column(, String(12), primary_key=True)) table.append_column(Column(, String(12), primary_key=True)) for column_name in columns: ...
Create table and return :class:`sqlalchemy.Table`. Parameters ---------- columns : list columns for table, e.g. ``['kDefinition', 'kCantonese']`` metadata : :class:`sqlalchemy.schema.MetaData` Instance of sqlalchemy metadata Returns ------- :class:`sqlalchemy.schema.Table`...
386,330
def angleOfView2(x,y, b, x0=None,y0=None): if x0 is None: x0 = x[-1,-1] if y0 is None: y0 = y[-1,-1] return np.cos( np.arctan( np.sqrt( ( (x-x0/2)**2+(y-y0/2)**2 ) ) /b ) )
Corrected AngleOfView equation by Koentges (via mail from 14/02/2017) b --> distance between the camera and the module in m x0 --> viewable with in the module plane of the camera in m y0 --> viewable height in the module plane of the camera in m x,y --> pixel position [m] from top left
386,331
def verify(info, directory_path): base_path = os.path.join(directory_path, info[]) if in info: if os.stat(base_path).st_size != info[]: return False getfile = lambda: open(base_path, ) else: assert in info, for f in info[]: p = os.path.join(bas...
Return True if the checksum values in the torrent file match the computed checksum values of downloaded file(s) in the directory and if each file has the correct length as specified in the torrent file.
386,332
def run(self, queue): time.sleep(random.random()) obj = self.get_object() obj.fullname.hset( % tuple(obj.hmget(, ))) result = % (obj.pk.get(), obj.fullname.hget()) self.result.set(result) return result
Create the fullname, and store a a message serving as result in the job
386,333
def to_dict(self, index=True, ordered=False): result = OrderedDict() if ordered else dict() if index: result.update({self._index_name: self._index}) if ordered: data_dict = [(column, self._data[i]) for i, column in enumerate(self._columns)] else: ...
Returns a dict where the keys are the column names and the values are lists of the values for that column. :param index: If True then include the index in the dict with the index_name as the key :param ordered: If True then return an OrderedDict() to preserve the order of the columns in the DataFrame ...
386,334
def expected_counts_stationary(T, n, mu=None): r if n <= 0: EC = np.zeros(T.shape) return EC else: if mu is None: mu = stationary_distribution(T) EC = n * mu[:, np.newaxis] * T return EC
r"""Expected transition counts for Markov chain in equilibrium. Since mu is stationary for T we have .. math:: E(C^{(N)})=N diag(mu)*T. Parameters ---------- T : (M, M) ndarray Transition matrix. n : int Number of steps for chain. mu : (M,) ndarray (optional) ...
386,335
def _set_preprovision(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass(v,base=preprovision.preprovision, is_container=, presence=False, yang_name="preprovision", rest_name="preprovision", parent=self, path_helper=self._path_helper, extmethods=self._extmethods...
Setter method for preprovision, mapped from YANG variable /preprovision (container) If this variable is read-only (config: false) in the source YANG file, then _set_preprovision is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_preprovisi...
386,336
def _find_single(self, match_class, **keywds): self._logger.debug() start_time = timeit.default_timer() norm_keywds = self.__normalize_args(**keywds) decl_matcher = self.__create_matcher(match_class, **norm_keywds) dtype = self.__findout_decl_type(match_class, **norm_key...
implementation details
386,337
def _group_by_batches(samples, check_fn): batch_groups = collections.defaultdict(list) extras = [] for data in [x[0] for x in samples]: if check_fn(data): batch_groups[multi.get_batch_for_key(data)].append(data) else: extras.append([data]) return batch_groups...
Group calls by batches, processing families together during ensemble calling.
386,338
def execute_task(bufs): user_ns = locals() user_ns.update({: __builtins__}) f, args, kwargs = unpack_apply_message(bufs, user_ns, copy=False) prefix = "parsl_" fname = prefix + "f" argname = prefix + "args" kwargname = prefix + "kwargs" resultname = prefix + "result" ...
Deserialize the buffer and execute the task. Returns the result or throws exception.
386,339
def backward_word_extend_selection(self, e): u self.l_buffer.backward_word_extend_selection(self.argument_reset) self.finalize()
u"""Move back to the start of the current or previous word. Words are composed of letters and digits.
386,340
def leave_room(self, sid, room, namespace=None): return self.server.leave_room(sid, room, namespace=namespace or self.namespace)
Leave a room. The only difference with the :func:`socketio.Server.leave_room` method is that when the ``namespace`` argument is not given the namespace associated with the class is used.
386,341
def calculate_mean(samples, weights): r assert len(samples) == len(weights), "The number of samples (got %i) must equal the number of weights (got %i)." % (len(samples),len(weights)) return _np.average(samples, axis=0, weights=weights)
r'''Calculate the mean of weighted samples (like the output of an importance-sampling run). :param samples: Matrix-like numpy array; the samples to be used. :param weights: Vector-like numpy array; the (unnormalized) importance weights.
386,342
def negate(arg): op = arg.op() if hasattr(op, ): result = op.negate() else: result = ops.Negate(arg) return result.to_expr()
Negate a numeric expression Parameters ---------- arg : numeric value expression Returns ------- negated : type of caller
386,343
def __process_by_ccore(self): cure_data_pointer = wrapper.cure_algorithm(self.__pointer_data, self.__number_cluster, self.__number_represent_points, self.__compression) self.__clusters = wrapper.cure_get_clusters(cure_data_pointer) ...
! @brief Performs cluster analysis using CCORE (C/C++ part of pyclustering library).
386,344
def binary_operation_math(self, rule, left, right, **kwargs): if isinstance(left, NumberRule) and isinstance(right, NumberRule): return self._calculate_operation_math(rule, left, right) return self._compile_operation_rule( rule, left, right, ...
Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.binary_operation_math` interface.
386,345
def btc_script_classify(scriptpubkey, private_key_info=None): if scriptpubkey.startswith("76a914") and scriptpubkey.endswith("88ac") and len(scriptpubkey) == 50: return elif scriptpubkey.startswith("a914") and scriptpubkey.endswith("87") and len(scriptpubkey) == 46: if private_ke...
Classify a scriptpubkey, optionally also using the private key info that will generate the corresponding scriptsig/witness Return None if not known (nonstandard)
386,346
def handle(self, t_input: inference.TranslatorInput, t_output: inference.TranslatorOutput, t_walltime: float = 0.): self.stream.write("{:.3f}\t{}\t{}\n".format(t_output.score, C.TOKEN_SEPARATOR.join(t_input...
:param t_input: Translator input. :param t_output: Translator output. :param t_walltime: Total walltime for translation.
386,347
def unapply_top_patch(self, force=False): self._check(force) patch = self.db.top_patch() self._unapply_patch(patch) self.db.save() self.unapplied(self.db.top_patch())
Unapply top patch
386,348
def wb_db020(self, value=None): if value is not None: try: value = float(value) except ValueError: raise ValueError( .format(value)) self._wb_db020 = value
Corresponds to IDD Field `wb_db020` mean coincident wet-bulb temperature to Dry-bulb temperature corresponding to 2.0% annual cumulative frequency of occurrence (warm conditions) Args: value (float): value for IDD Field `wb_db020` Unit: C if `value` i...
386,349
def remove_objects_not_in(self, objects_to_keep, verbosity): for class_ in objects_to_keep.keys(): current = class_.objects.all() current_ids = set([x.pk for x in current]) keep_ids = set([x.pk for x in objects_to_keep[class_]]) remove_these_ones = curre...
Delete all the objects in the database that are not in objects_to_keep. - objects_to_keep: A map where the keys are classes, and the values are a set of the objects of that class we should keep.
386,350
def setParameter(self, parameterName, index, parameterValue): if hasattr(self, parameterName): setattr(self, parameterName, parameterValue) else: raise Exception("Unknown parameter: " + parameterName)
Set the value of a Spec parameter. Most parameters are handled automatically by PyRegion's parameter set mechanism. The ones that need special treatment are explicitly handled here.
386,351
def list_runtime(self, scope="", skip_policy_evaluation=True, start_time=None, end_time=None): host.domain = "example.com" and container.image != "alpine:latest" containers = { : scope, : skip_policy_evaluation } if start_time or end_time: containers[]...
**Description** List runtime containers **Arguments** - scope: An AND-composed string of predicates that selects the scope in which the alert will be applied. (like: 'host.domain = "example.com" and container.image != "alpine:latest"') - skip_policy_evaluation: If true, no p...
386,352
def send_vdp_query_msg(self, mode, mgrid, typeid, typeid_ver, vsiid_frmt, vsiid, filter_frmt, gid, mac, vlan, oui_id, oui_data): if not self.is_ncb: LOG.error("EVB cannot be set on NB") return vdp_key_str = self.const...
Constructs and Sends the VDP Query Message. Please refer http://www.ieee802.org/1/pages/802.1bg.html VDP Section for more detailed information :param mode: Associate or De-associate :param mgrid: MGR ID :param typeid: Type ID :param typeid_ver: Version of the Type ID ...
386,353
def decompressBWTPoolProcess(tup): (inputDir, outputDir, startIndex, endIndex) = tup if startIndex == endIndex: return True outputBwt[startIndex:endIndex] = msbwt.getBWTRange(startIndex, endIndex) return True
Individual process for decompression
386,354
def parse_gzip(file_path): newDecoder = MMTFDecoder() newDecoder.decode_data(_unpack(gzip.open(file_path, "rb"))) return newDecoder
Return a decoded API to the data from a file path. File is gzip compressed. :param file_path: the input file path. Data is gzip compressed. :return an API to decoded data
386,355
def artist_create(self, name, other_names_comma=None, group_name=None, url_string=None, body=None): params = { : name, : other_names_comma, : group_name, : url_string, : body, } return self.get(, param...
Function to create an artist (Requires login) (UNTESTED). Parameters: name (str): other_names_comma (str): List of alternative names for this artist, comma delimited. group_name (str): The name of the group this artist belongs to. ...
386,356
def main(doc, timeout, size, debug, allow_codes, whitelist): t0 = time.time() links = [i[0] for i in LINK_RE.findall(doc.read())] request_urls = [] counts = {} for link in links: if is_static(link): STATICS.append(link) continue if lin...
Examples: simple call $ vl README.md Adding debug outputs $ vl README.md --debug Adding a custom timeout for each url. time on seconds. $ vl README.md -t 3 Adding a custom size param, to add throttle n requests per time $ vl README -s 1000 Skipping some error codes. This will ...
386,357
def at(host, command, seq, params): params_str = [] for p in params: if type(p) == int: params_str.append(.format(p)) elif type(p) == float: params_str.append(.format(f2i(p))) elif type(p) == str: params_str.append(.format(p)) msg = .format(co...
Parameters: command -- the command seq -- the sequence number params -- a list of elements which can be either int, float or string
386,358
def get_tree(self, process_name): for tree_name, tree in self.trees.items(): if process_name in tree: return tree
return tree that is managing time-periods for given process
386,359
def precheck(context): if context.noprecheck: return True func_name = "precheck_" + context.key.replace("-", "_") if func_name in globals() and isfunction(globals()[func_name]): return globals()[func_name](context) else: return True
calls a function named "precheck_<key>" where <key> is context_key with '-' changed to '_' (e.g. "precheck_ami_id") Checking function should return True if OK, or raise RuntimeError w/ message if not Args: context: a populated EFVersionContext object Returns: True if the precheck passed, or if there was...
386,360
def _runResponder(self, responder, request, command, identifier): d = defer.maybeDeferred(responder, **request) def _addIdentifier(response): response["_answer"] = identifier return response def _serializeFailure(failure): ...
Run the responser function. If it succeeds, add the _answer key. If it fails with an error known to the command, serialize the error.
386,361
def discover(service="ssdp:all", timeout=1, retries=2, ipAddress="239.255.255.250", port=1900): socket.setdefaulttimeout(timeout) messages = [] if isinstance(service, str): services = [service] elif isinstance(service, list): services = service ...
Discovers UPnP devices in the local network. Try to discover all devices in the local network which do support UPnP. The discovery process can fail for various reasons and it is recommended to do at least two discoveries, which you can specify with the ``retries`` parameter. The defaul...
386,362
def gpgga_to_dms(gpgga): deg_min, dmin = gpgga.split() degrees = int(deg_min[:-2]) minutes = float( % (deg_min[-2:], dmin)) decimal = degrees + (minutes / 60) return decimal
Convert GPS coordinate in GPGGA format to degree/minute/second Reference: http://us.cactii.net/~bb/gps.py
386,363
def geodetic_distance(lons1, lats1, lons2, lats2, diameter=2*EARTH_RADIUS): lons1, lats1, lons2, lats2 = _prepare_coords(lons1, lats1, lons2, lats2) distance = numpy.arcsin(numpy.sqrt( numpy.sin((lats1 - lats2) / 2.0) ** 2.0 + numpy.cos(lats1) * numpy.cos(lats2) * numpy.sin((lons1 -...
Calculate the geodetic distance between two points or two collections of points. Parameters are coordinates in decimal degrees. They could be scalar float numbers or numpy arrays, in which case they should "broadcast together". Implements http://williams.best.vwh.net/avform.htm#Dist :returns:...
386,364
def vlr_factory(raw_vlr): user_id = raw_vlr.header.user_id.rstrip(NULL_BYTE).decode() known_vlrs = BaseKnownVLR.__subclasses__() for known_vlr in known_vlrs: if ( known_vlr.official_user_id() == user_id and raw_vlr.header.record_id in known_vlr.official_record_ids() ...
Given a raw_vlr tries to find its corresponding KnownVLR class that can parse its data. If no KnownVLR implementation is found, returns a VLR (record_data will still be bytes)
386,365
def doExperiment(numColumns, l2Overrides, objectDescriptions, noiseMu, noiseSigma, numInitialTraversals, noiseEverywhere): layer4sdr = lambda : np.array(sorted(random.sample(xrange(L4_CELL_COUNT), 40)), dtype="uint32") featureLocationSDRs ...
Touch every point on an object 'numInitialTraversals' times, then evaluate whether it has inferred the object by touching every point once more and checking the number of correctly active and incorrectly active cells. @param numColumns (int) The number of sensors to use @param l2Overrides (dict) Parameter...
386,366
def print_tb(tb, limit=None, file=None): if file is None: file = sys.stderr if limit is None: if hasattr(sys, ): limit = sys.tracebacklimit file.write(.join(format_tb(tb, limit)) + )
Print up to 'limit' stack trace entries from the traceback 'tb'. If 'limit' is omitted or None, all entries are printed. If 'file' is omitted or None, the output goes to sys.stderr; otherwise 'file' should be an open file or file-like object with a write() method.
386,367
def on_receive_transactions(self, proto, transactions): "receives rlp.decoded serialized" log.debug() log.debug(, count=len(transactions), remote_id=proto) def _add_txs(): for tx in transactions: self.add_transaction(tx, origin=proto) gevent.spawn(_ad...
receives rlp.decoded serialized
386,368
def _with_meta_to_py_ast( ctx: GeneratorContext, node: WithMeta, **kwargs ) -> GeneratedPyAST: assert node.op == NodeOp.WITH_META handle_expr = _WITH_META_EXPR_HANDLER.get(node.expr.op) assert ( handle_expr is not None ), "No expression handler for with-meta child node type" return...
Generate a Python AST node for Python interop method calls.
386,369
def qteSplitApplet(self, applet: (QtmacsApplet, str)=None, splitHoriz: bool=True, windowObj: QtmacsWindow=None): if isinstance(applet, str): newAppObj = self.qteGetAppletHandle(applet) else: ...
Reveal ``applet`` by splitting the space occupied by the current applet. If ``applet`` is already visible then the method does nothing. Furthermore, this method does not change the focus, ie. the currently active applet will remain active. If ``applet`` is **None** then the nex...
386,370
def row_table(cls, d, order=None, labels=None): header = list(d) x = PrettyTable(labels) if order is None: order = header for key in order: value = d[key] if type(value) == list: x.add_row([key, value[0]]) ...
prints a pretty table from data in the dict. :param d: A dict to be printed :param order: The order in which the columns are printed. The order is specified by the key names of the dict. :param labels: The array of labels for the column
386,371
def security(policy, app_secret): validate(policy) policy_enc = base64.urlsafe_b64encode(json.dumps(policy).encode()) signature = hmac.new(app_secret.encode(), policy_enc, hashlib.sha256).hexdigest() return {: policy_enc, : signature}
Creates a valid signature and policy based on provided app secret and parameters ```python from filestack import Client, security # a policy requires at least an expiry policy = {'expiry': 56589012, 'call': ['read', 'store', 'pick']} sec = security(policy, 'APP_SECRET') client = Client('A...
386,372
def replace_nan( trainingset, replace_with = None ): training_data = np.array( [instance.features for instance in trainingset ] ).astype( np.float64 ) def encoder( dataset ): for instance in dataset: instance.features = instance.features.astype( np.float64 ) ...
Replace instanced of "not a number" with either the mean of the signal feature or a specific value assigned by `replace_nan_with`
386,373
def update_entity(self, table_name, entity, if_match=, timeout=None): _validate_not_none(, table_name) request = _update_entity(entity, if_match, self.require_encryption, self.key_encryption_key, self.encryption_resolver_function) request.host_locations ...
Updates an existing entity in a table. Throws if the entity does not exist. The update_entity operation replaces the entire entity and can be used to remove properties. :param str table_name: The name of the table containing the entity to update. :param entity: ...
386,374
def UpdateFlow(self, client_id, flow_id, flow_obj=db.Database.unchanged, flow_state=db.Database.unchanged, client_crash_info=db.Database.unchanged, pending_termination=db.Database.unchanged, processing...
Updates flow objects in the database.
386,375
def get_mods(self, project_path, vars): mods = [var.name for var in self.vars if vars[var.name].lower() == ] mods = set(mods) for name in self.mods_list: mods.add(name) if in mods or in mods: mods.add() m...
Build the mod list to enable
386,376
def _legacy_symbol_table(build_file_aliases): table = { alias: _make_target_adaptor(TargetAdaptor, target_type) for alias, target_type in build_file_aliases.target_types.items() } for alias, factory in build_file_aliases.target_macro_factories.items(): if len(factory....
Construct a SymbolTable for the given BuildFileAliases. :param build_file_aliases: BuildFileAliases to register. :type build_file_aliases: :class:`pants.build_graph.build_file_aliases.BuildFileAliases` :returns: A SymbolTable.
386,377
def search(self, initial_state: State, transition_function: TransitionFunction) -> Dict[int, List[State]]: finished_states: Dict[int, List[State]] = defaultdict(list) states = [initial_state] step_num = 0 while states: step_num += 1 ...
Parameters ---------- initial_state : ``State`` The starting state of our search. This is assumed to be `batched`, and our beam search is batch-aware - we'll keep ``beam_size`` states around for each instance in the batch. transition_function : ``TransitionFunction`` ...
386,378
def refresh(self, accept=MEDIA_TYPE_TAXII_V20): response = self.__raw = self._conn.get(self.url, headers={"Accept": accept}) self._populate_fields(**response)
Updates Status information
386,379
def heating_stats(self): local_5 = [] local_10 = [] for i in range(0, 10): level = self.past_heating_level(i) if level == 0: _LOGGER.debug() return if i < 5: local_5.append(level) local_10.a...
Calculate some heating data stats.
386,380
def nearest(items, pivot): return min(items, key=lambda x: abs(x - pivot))
Find nearest value in array, including datetimes Args ---- items: iterable List of values from which to find nearest value to `pivot` pivot: int or float Value to find nearest of in `items` Returns ------- nearest: int or float Value in items nearest to `pivot`
386,381
def render_response(self): name, value = self.name, self.value renderer = self.attribute_renderers.get(, None) if renderer: name = renderer(name) renderer = self.attribute_renderers.get(, None) if renderer: value = renderer(value...
Render as a string formatted for HTTP response headers (detailed 'Set-Cookie: ' style).
386,382
def get_method(self, method_name, default=None): for method in self.methods: if method.name == method_name: return method return default
Returns the contained method of the specified name, or `default` if not found.
386,383
def set_focused(self, account, is_focused): endpoint = if is_focused: classification = else: classification = data = dict(ClassifyAs=classification, SenderEmailAddress=dict(Address=self.email)) r = requests.post(endpoint, headers=ac...
Emails from this contact will either always be put in the Focused inbox, or always put in Other, based on the value of is_focused. Args: account (OutlookAccount): The :class:`OutlookAccount <pyOutlook.core.main.OutlookAccount>` the override should be set for is_f...
386,384
def _leave_event_hide(self): if (not self._hide_timer.isActive() and QtGui.qApp.topLevelAt(QtGui.QCursor.pos()) != self): self._hide_timer.start(300, self)
Hides the tooltip after some time has passed (assuming the cursor is not over the tooltip).
386,385
def p_base_type(self, p): name = p[1] if name == : name = p[0] = ast.PrimitiveType(name, p[2])
base_type : BOOL annotations | BYTE annotations | I8 annotations | I16 annotations | I32 annotations | I64 annotations | DOUBLE annotations | STRING annotations ...
386,386
def reset(self): with util.disable_constant(self): for k, p in self.params().items(): if k != : setattr(self, k, p.default)
Resets stream parameters to their defaults.
386,387
def connect(self, address=): if isinstance(address, six.string_types): addresses = parse_dbus_address(address) else: addresses = [address] for addr in addresses: try: super(DbusClient, self).connect(addr) except pyuv.error....
Connect to *address* and wait until the connection is established. The *address* argument must be a D-BUS server address, in the format described in the D-BUS specification. It may also be one of the special addresses ``'session'`` or ``'system'``, to connect to the D-BUS session and sy...
386,388
def generate(self, trilegal_filename, ra=None, dec=None, n=2e4, ichrone=, MAfn=None, mags=None, maxrad=None, f_binary=0.4, **kwargs): n = int(n) bgpop = BGStarPopulation_TRILEGAL(trilegal_filename, ra=ra, dec=de...
Generate population.
386,389
def daterange(value, details=False): if not isinstance(value, db.DateRange): raise ValueError() if details: return daterange_with_details(value) date_format = delta = value.end - value.start start, end = None, None start = format_date(value.start, date_format) if del...
Display a date range in the shorter possible maner.
386,390
def set_data(self, index, value): acces, field = self.get_item(index), self.header[index.column()] self.beginResetModel() self.set_data_hook(acces, field, value) self.endResetModel()
Uses given data setter, and emit modelReset signal
386,391
def _run_command(self, arguments: List[str], input_data: Any=None, output_encoding: str="utf-8") -> str: process = subprocess.Popen(arguments, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) if isinstance(input_data, List): for to_write in input_data: ...
Run a command as a subprocess. Ignores errors given over stderr if there is output on stdout (this is the case where baton has been run correctly and has expressed the error in it's JSON out, which can be handled more appropriately upstream to this method.) :param arguments: the argumen...
386,392
def prepare_response(self, request, cached): if "*" in cached.get("vary", {}): return for header, value in cached.get("vary", {}).items(): if request.headers.get(header, None) != value: return body_raw = cache...
Verify our vary headers match and construct a real urllib3 HTTPResponse object.
386,393
def line_cap_type(self): key = self._data.get(b).enum return self.STROKE_STYLE_LINE_CAP_TYPES.get(key, str(key))
Cap type, one of `butt`, `round`, `square`.
386,394
def nodes(self): resource = sub_collection( self.get_relation(), VSSContainerNode) resource._load_from_engine(self, ) return resource
Return the nodes for this VSS Container :rtype: SubElementCollection(VSSContainerNode)
386,395
def repl_command(fxn): @functools.wraps(fxn) def wrapper(self, arglist): args = [] kwargs = {} if arglist: for arg in shlex.split(arglist): if "=" in arg: split = arg.split("=", 1) kwargs[split[0]] = split...
Decorator for cmd methods Parses arguments from the arg string and passes them to the method as *args and **kwargs.
386,396
def verify(self, otp, for_time=None, valid_window=0): if for_time is None: for_time = datetime.datetime.now() if valid_window: for i in range(-valid_window, valid_window + 1): if utils.strings_equal(str(otp), str(self.at(for_time, i))): ...
Verifies the OTP passed in against the current time OTP @param [String/Integer] otp the OTP to check against @param [Integer] valid_window extends the validity to this many counter ticks before and after the current one
386,397
def expectation_importance_sampler_logspace( log_f, log_p, sampling_dist_q, z=None, n=None, seed=None, name=): r q = sampling_dist_q with tf.name_scope(name): z = _get_samples(q, z, n, seed) log_values = log_f(z) + log_p(z) - q.log_prob(z) return _logspace_mean(log_values)
r"""Importance sampling with a positive function, in log-space. With \\(p(z) := exp^{log_p(z)}\\), and \\(f(z) = exp{log_f(z)}\\), this `Op` returns \\(Log[ n^{-1} sum_{i=1}^n [ f(z_i) p(z_i) / q(z_i) ] ], z_i ~ q,\\) \\(\approx Log[ E_q[ f(Z) p(Z) / q(Z) ] ]\\) \\(= Log[E_p[f(Z)]]\\) This integra...
386,398
def write_elements(fd, mtp, data, is_name=False): fmt = etypes[mtp][] if isinstance(data, Sequence): if fmt == or is_name: if isinstance(data, bytes): if is_name and len(data) > 31: raise ValueError( ....
Write data element tag and data. The tag contains the array type and the number of bytes the array data will occupy when written to file. If data occupies 4 bytes or less, it is written immediately as a Small Data Element (SDE).
386,399
def graft_neuron(root_section): assert isinstance(root_section, Section) return Neuron(soma=Soma(root_section.points[:1]), neurites=[Neurite(root_section)])
Returns a neuron starting at root_section