Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
7,000
def tqxn(mt, x, n, t): return tpx(mt, x, t) * qx(mt, x + n)
n/qx : Probability to die in n years being alive at age x. Probability that x survives n year, and then dies in th subsequent t years
7,001
def create_routes_and_handler(transmute_func, context): @wraps(transmute_func.raw_func) def handler(): exc, result = None, None try: args, kwargs = ParamExtractorFlask().extract_params( context, transmute_func, request.content_type ) resul...
return back a handler that is the api generated from the transmute_func, and a list of routes it should be mounted to.
7,002
def geometry_checker(geometry): if geometry is None: return False, None if geometry.isGeosValid(): return True, geometry else: new_geom = geometry.makeValid() if new_geom.isGeosValid(): return False, new_geom else: r...
Perform a cleaning if the geometry is not valid. :param geometry: The geometry to check and clean. :type geometry: QgsGeometry :return: Tuple of bool and cleaned geometry. True if the geometry is already valid, False if the geometry was not valid. A cleaned geometry, or None if the geometr...
7,003
def read(self, device=None, offset=0, bs=None, count=1): volume = self.get_volume(device) block_size = bs or BLOCK_SIZE offset = int(offset) * block_size count = int(count) print("Offset: ", offset) total = 0 with directio.open(volume[], buffered=block_...
Using DIRECT_O read from the block device specified to stdout (Without any optional arguments will read the first 4k from the device)
7,004
def listen(self): _LOGGER.info() self._mcastsocket = self._create_mcast_socket() self._listening = True thread = Thread(target=self._listen_to_msg, args=()) self._threads.append(thread) thread.daemon = True thread.start()
Start listening.
7,005
def publish (self): self.lock.acquire() tw = cmdvel2Twist(self.vel) self.lock.release() if (self.jdrc.getState() == "flying"): self.pub.publish(tw)
Function to publish cmdvel.
7,006
def saveThumbnail(self,fileName,filePath): if self._thumbnail is None: self.__init() param_dict = {} if self._thumbnail is not None: imgUrl = self.root + "/info/" + self._thumbnail onlineFileName, file_ext = splitext(self._thumbnail) file...
URL to the thumbnail used for the item
7,007
def method(cache_name, key_prefix=None): def decorator(func): if (func.__name__ in [, ] and not config.CACHE_REPERTOIRES): return func @wraps(func) def wrapper(obj, *args, **kwargs): cache = getattr(obj, cache_name) key ...
Caching decorator for object-level method caches. Cache key generation is delegated to the cache. Args: cache_name (str): The name of the (already-instantiated) cache on the decorated object which should be used to store results of this method. *key_prefix: A constant t...
7,008
def read_var_str(self, max_size=sys.maxsize): length = self.read_var_int(max_size) return self.unpack(str(length) + , length)
Similar to `ReadString` but expects a variable length indicator instead of the fixed 1 byte indicator. Args: max_size (int): (Optional) maximum number of bytes to read. Returns: bytes:
7,009
def pathname(self): slug = self.name slug = unidecode.unidecode(slug) slug = slug.replace("-", "") slug = re.sub(r"[^\w\.]+", "-", slug).strip("-") return os.path.join(*slug.split("."))
Sluggified path for filenames Slugs to a filename using the follow steps * Decode unicode to approximate ascii * Remove existing hypens * Substitute hyphens for non-word characters * Break up the string as paths
7,010
def _tokenize(self, source, name, filename=None, state=None): source = self.preprocess(source, name, filename) stream = self.lexer.tokenize(source, name, filename, state) for ext in self.iter_extensions(): stream = ext.filter_stream(stream) if not isinstance(stre...
Called by the parser to do the preprocessing and filtering for all the extensions. Returns a :class:`~jinja2.lexer.TokenStream`.
7,011
def VShadowPathSpecGetStoreIndex(path_spec): store_index = getattr(path_spec, , None) if store_index is None: location = getattr(path_spec, , None) if location is None or not location.startswith(): return None store_index = None try: store_index = int(location[4:], 10) - 1 exce...
Retrieves the store index from the path specification. Args: path_spec (PathSpec): path specification. Returns: int: store index or None if not available.
7,012
def videos(self, **kwargs): path = self._get_series_id_season_number_episode_number_path() response = self._GET(path, kwargs) self._set_attrs_to_values(response) return response
Get the videos that have been added to a TV episode (teasers, clips, etc...). Args: language: (optional) ISO 639 code. Returns: A dict respresentation of the JSON returned from the API.
7,013
def make_items_for(brains_or_objects, endpoint=None, complete=False): include_children = req.get_children(False) def extract_data(brain_or_object): info = get_info(brain_or_object, endpoint=endpoint, complete=complete) if include_children and is_folderish(brain_or_object): ...
Generate API compatible data items for the given list of brains/objects :param brains_or_objects: List of objects or brains :type brains_or_objects: list/Products.ZCatalog.Lazy.LazyMap :param endpoint: The named URL endpoint for the root of the items :type endpoint: str/unicode :param complete: Fla...
7,014
def can_delete_objectives(self): url_path = construct_url(, bank_id=self._catalog_idstr) return self._get_request(url_path)[][]
Tests if this user can delete Objectives. A return of true does not guarantee successful authorization. A return of false indicates that it is known deleting an Objective will result in a PermissionDenied. This is intended as a hint to an application that may opt not to offer delete oper...
7,015
def get_portal_url_base(self): api_url = urlparse(self.url).hostname portal_url = re.sub(, , api_url) portal_url = re.sub(r, , portal_url) return portal_url
Determine root url of the data service from the url specified. :return: str root url of the data service (eg: https://dataservice.duke.edu)
7,016
def running_conversions(self, folder_id=None): params = {: folder_id} if folder_id else {} return self._get(, params=params)
Shows running file converts by folder Note: If folder_id is not provided, ``Home`` folder will be used. Args: folder_id (:obj:`str`, optional): id of the folder to list conversions of files exist in it. Returns: list: list of dictionaries, each dictionary r...
7,017
def _make_probs(self, *sequences): sequences = self._get_counters(*sequences) counts = self._sum_counters(*sequences) if self.terminator is not None: counts[self.terminator] = 1 total_letters = sum(counts.values()) prob_pairs = {} cumulative_count = ...
https://github.com/gw-c/arith/blob/master/arith.py
7,018
def correctX(args): p = OptionParser(correctX.__doc__) opts, args = p.parse_args(args) if len(args) != 2: sys.exit(not p.print_help()) folder, tag = args tag = tag.split(",") for p, pf in iter_project(folder): correct_pairs(p, pf, tag)
%prog correctX folder tag Run ALLPATHS correction on a folder of paired reads and apply tag.
7,019
def render(self, name=None, template=None, context={}): Render Template meta from jinja2 templates. ' if isinstance(template, Template): _template = template else: _template = Template.objects.get(name=name) response = self.env.from_string( ...
Render Template meta from jinja2 templates.
7,020
def tricu(P, k=0): tri = numpy.sum(numpy.mgrid[[slice(0,_,1) for _ in P.shape]], 0) tri = tri<len(tri) + k if isinstance(P, Poly): A = P.A.copy() B = {} for key in P.keys: B[key] = A[key]*tri return Poly(B, shape=P.shape, dim=P.dim, dtype=P.dtype) out =...
Cross-diagonal upper triangle.
7,021
def add_access_list(self, accesslist, rank=None): self.conditions.append( dict(access_list_ref=accesslist.href, type=, rank=rank))
Add an access list to the match condition. Valid access list types are IPAccessList (v4 and v6), IPPrefixList (v4 and v6), AS Path, CommunityAccessList, ExtendedCommunityAccessList.
7,022
def syscall(self, func): retvalueexception if getattr(self, , None) is not None: return None self.syscallfunc = func self.syscallmatcher = SyscallReturnEvent.createMatcher() return self.syscallmatcher
Call the func in core context (main loop). func should like:: def syscall_sample(scheduler, processor): something... where processor is a function which accept an event. When calling processor, scheduler directly process this event without sending i...
7,023
def is_tuple_type(tp): if NEW_TYPING: return (tp is Tuple or isinstance(tp, _GenericAlias) and tp.__origin__ is tuple or isinstance(tp, type) and issubclass(tp, Generic) and issubclass(tp, tuple)) return type(tp) is TupleMeta
Test if the type is a generic tuple type, including subclasses excluding non-generic classes. Examples:: is_tuple_type(int) == False is_tuple_type(tuple) == False is_tuple_type(Tuple) == True is_tuple_type(Tuple[str, int]) == True class MyClass(Tuple[str, int]): ...
7,024
def _get_value_from_match(self, key, match): value = match.groups(1)[0] clean_value = str(value).lstrip().rstrip() if clean_value == : self._log.info(, key) return True if clean_value == : self._log.info(, key) return False ...
Gets the value of the property in the given MatchObject. Args: key (str): Key of the property looked-up. match (MatchObject): The matched property. Return: The discovered value, as a string or boolean.
7,025
def get_checkerboard_matrix(kernel_width): return np.vstack(( np.hstack(( -1 * np.ones((kernel_width, kernel_width)), np.ones((kernel_width, kernel_width)) )), np.hstack(( np.ones((kernel_width, kernel_width)), -1 * np.ones((kernel_width, kernel_width)) ...
example matrix for width = 2 -1 -1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 -1 -1 :param kernel_width: :return:
7,026
def stripped_db_url(url): parsed = urlparse(url) if parsed.password is None: return url return parsed._replace( netloc="{}:***@{}".format(parsed.username, parsed.hostname) ).geturl()
Return a version of the DB url with the password stripped out.
7,027
def format_config(sensor_graph): cmdfile = CommandFile("Config Variables", "1.0") for slot in sorted(sensor_graph.config_database, key=lambda x: x.encode()): for conf_var, conf_def in sorted(sensor_graph.config_database[slot].items()): conf_type, conf_val = conf_def if co...
Extract the config variables from this sensor graph in ASCII format. Args: sensor_graph (SensorGraph): the sensor graph that we want to format Returns: str: The ascii output lines concatenated as a single string
7,028
def start(component, exact): from peltak.extra.gitflow import logic logic.release.start(component, exact)
Create a new release. It will bump the current version number and create a release branch called `release/<version>` with one new commit (the version bump). **Example Config**:: \b version_file: 'src/mypkg/__init__.py' **Examples**:: \b $ peltak release start patch ...
7,029
def setShadowed(self, state): self._shadowed = state if state: self._colored = False for child in self.findChildren(XToolButton): child.setShadowed(state)
Sets whether or not this toolbar is shadowed. :param state | <bool>
7,030
def subnet_get(auth=None, **kwargs): * cloud = get_operator_cloud(auth) kwargs = _clean_kwargs(**kwargs) return cloud.get_subnet(**kwargs)
Get a single subnet filters A Python dictionary of filter conditions to push down CLI Example: .. code-block:: bash salt '*' neutronng.subnet_get name=subnet1
7,031
def add_algorithm(self, parser): help = % { : ca_settings.CA_DIGEST_ALGORITHM.name, } parser.add_argument( , metavar=, default=ca_settings.CA_DIGEST_ALGORITHM, action=AlgorithmAction, help=help)
Add the --algorithm option.
7,032
def sphergal_to_rectgal(l,b,d,vr,pmll,pmbb,degree=False): XYZ= lbd_to_XYZ(l,b,d,degree=degree) vxvyvz= vrpmllpmbb_to_vxvyvz(vr,pmll,pmbb,l,b,d,XYZ=False,degree=degree) if sc.array(l).shape == (): return sc.array([XYZ[0],XYZ[1],XYZ[2],vxvyvz[0],vxvyvz[1],vxvyvz[2]]) else: out=sc.zero...
NAME: sphergal_to_rectgal PURPOSE: transform phase-space coordinates in spherical Galactic coordinates to rectangular Galactic coordinates (can take vector inputs) INPUT: l - Galactic longitude (rad) b - Galactic lattitude (rad) d - distance (kpc) vr - line-of-s...
7,033
def key(self, *args, **kwargs): if not args and not kwargs: return self.class_path try: if args and not kwargs: return "%s:%s" % (self.class_path, self.hash(args)) return "%s:%s:%s:%s" % (self.class_path,...
Return the cache key to use. If you're passing anything but primitive types to the ``get`` method, it's likely that you'll need to override this method.
7,034
def execution(): client = salt.client.get_local_client(__opts__[]) docs = {} try: for ret in client.cmd_iter(, , timeout=__opts__[]): for v in six.itervalues(ret): docs.update(v) except SaltClientError as exc: print(exc) return [] i = iterto...
Collect all the sys.doc output from each minion and return the aggregate CLI Example: .. code-block:: bash salt-run doc.execution
7,035
def flush(self): if self.redirect is not None: self.redirect.flush() super(TeeStringIO, self).flush()
Flush to this and the redirected stream
7,036
def data(self): if self._next_update and datetime.now() > self._next_update: self.update() return self._data
Get a cached post-processed result of a GitHub API call. Uses Trac cache to avoid constant querying of the remote API. If a previous API call did not succeed, automatically retries after a timeout.
7,037
def ternarize(x, thresh=0.05): shape = x.get_shape() thre_x = tf.stop_gradient(tf.reduce_max(tf.abs(x)) * thresh) w_p = tf.get_variable(, initializer=1.0, dtype=tf.float32) w_n = tf.get_variable(, initializer=1.0, dtype=tf.float32) tf.summary.scalar(w_p.op.name + , w_p) tf.summary.scalar...
Implemented Trained Ternary Quantization: https://arxiv.org/abs/1612.01064 Code modified from the authors' at: https://github.com/czhu95/ternarynet/blob/master/examples/Ternary-Net/ternary.py
7,038
def from_env(cls, prefix, kms_decrypt=False, aws_profile=None): if len(prefix) < 1: raise ValueError("prefix can_'!") if not prefix.endswith("_"): prefix = prefix + "_" data = dict( host=os.getenv(prefix + "HOST"), port=os.getenv(prefix ...
Load database credential from env variable. - host: ENV.{PREFIX}_HOST - port: ENV.{PREFIX}_PORT - database: ENV.{PREFIX}_DATABASE - username: ENV.{PREFIX}_USERNAME - password: ENV.{PREFIX}_PASSWORD :param prefix: str :param kms_decrypt: bool :param aws_p...
7,039
def red_ext(request, message=None): t have site access to the external page. Parameters: request - the request in the calling function message - a message from the caller function external'))
The external landing. Also a convenience function for redirecting users who don't have site access to the external page. Parameters: request - the request in the calling function message - a message from the caller function
7,040
def evaluate(data_source, batch_size, ctx=None): total_L = 0 hidden = cache_cell.\ begin_state(func=mx.nd.zeros, batch_size=batch_size, ctx=context[0]) next_word_history = None cache_history = None for i in range(0, len(data_source) - 1, args.bptt): if i > 0: print(%...
Evaluate the model on the dataset with cache model. Parameters ---------- data_source : NDArray The dataset is evaluated on. batch_size : int The size of the mini-batch. ctx : mx.cpu() or mx.gpu() The context of the computation. Returns ------- loss: float ...
7,041
def node_hist_fig( node_color_distribution, title="Graph Node Distribution", width=400, height=300, top=60, left=25, bottom=60, right=25, bgcolor="rgb(240,240,240)", y_gridcolor="white", ): text = [ "{perc}%".format(**locals()) for perc i...
Define the plotly plot representing the node histogram Parameters ---------- node_color_distribution: list of dicts describing the build_histogram width, height: integers - width and height of the histogram FigureWidget left, top, right, bottom: ints; number of pixels around the FigureWi...
7,042
def __set_URL(self, url): if isinstance(url, str): url.encode("ascii") self.url = url elif sys.version_info < (3, 0): self.url = url.encode("ascii") else: self.url = url.decode("ascii")
URL is stored as a str internally and must not contain ASCII chars. Raised exception in case of detected non-ASCII URL characters may be either UnicodeEncodeError or UnicodeDecodeError, depending on the used Python version's str type and the exact value passed as URL input data.
7,043
def get_events(self, **kwargs): force = kwargs.pop(, False) response = api.request_sync_events(self.blink, self.network_id, force=force) try: return response[] except (TypeError, Ke...
Retrieve events from server.
7,044
def _build_sql_query( self): self.log.info() ra1, ra2, dec1, dec2 = self.ra1, self.ra2, self.dec1, self.dec2 if self.galaxyType == "all": self.sqlQuery = u % locals() elif self.galaxyType == "specz": self.sqlQuery = u % locals() elif...
*build sql query for the sdss square search* **Key Arguments:** # - **Return:** - None .. todo::
7,045
def _update_targets(vesseldicts, environment_dict): nodelist = [] for vesseldict in vesseldicts: nodeip_port = vesseldict[]++str(vesseldict[]) if not nodeip_port in nodelist: nodelist.append(nodeip_port) seash_global_variables.targets[] = [] print nodelist retdict = seash_helper...
<Purpose> Connects to the nodes in the vesseldicts and adds them to the list of valid targets. <Arguments> vesseldicts: A list of vesseldicts obtained through SeattleClearinghouseClient calls. <Side Effects> All valid targets that the user can access on the specified nodes are ...
7,046
def list_networks(**kwargs): * conn = __get_conn(**kwargs) try: return [net.name() for net in conn.listAllNetworks()] finally: conn.close()
List all virtual networks. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults .. versionadded:: 2019.2.0 CLI Example: .. code-block:: bash salt '*...
7,047
def accept(self, origin, protocol): for factory in self.store.powerupsFor(IBoxReceiverFactory): raise ProtocolUnknown()
Create a new route attached to a L{IBoxReceiver} created by the L{IBoxReceiverFactory} with the indicated protocol. @type origin: C{unicode} @param origin: The identifier of a route on the peer which will be associated with this connection. Boxes sent back by the protocol ...
7,048
def paintEvent(self, event): pixmap = self.currentPixmap() rect = self.currentPixmapRect() with XPainter(self) as painter: painter.drawPixmap(rect.x(), rect.y(), pixmap)
Draws the pixmap for this widget. :param event | <QPaintEvent>
7,049
def cp(hdfs_src, hdfs_dst): cmd = "hadoop fs -cp %s %s" % (hdfs_src, hdfs_dst) rcode, stdout, stderr = _checked_hadoop_fs_command(cmd)
Copy a file :param hdfs_src: Source (str) :param hdfs_dst: Destination (str) :raises: IOError: If unsuccessful
7,050
def _readClusterSettings(self): mdUrl = "http://169.254.169.254/metadata/instance?api-version=2017-08-01" header = {: } request = urllib.request.Request(url=mdUrl, headers=header) response = urllib.request.urlopen(request) data = response.read() dataStr ...
Read the current instance's meta-data to get the cluster settings.
7,051
def get_top_paths(self): headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/traffic/popular/paths" ) if isinstance(data, list): return [ github.Path.Path(self._requester, headers, item, completed=True) ...
:calls: `GET /repos/:owner/:repo/traffic/popular/paths <https://developer.github.com/v3/repos/traffic/>`_ :rtype: :class:`list` of :class:`github.Path.Path`
7,052
def apply(self, s, active=None): if active is None: active = self.active return self.group.apply(s, active=active)
Apply the REPP's rewrite rules to the input string *s*. Args: s (str): the input string to process active (optional): a collection of external module names that may be applied if called Returns: a :class:`REPPResult` object containing the processed ...
7,053
def merge_dict(self, *args, **kwargs): input_dict = self._convert_input(*args, **kwargs) if input_dict: self._sift_and_init_configs(input_dict) self.token_dict.merge_serialization(input_dict)
Takes variable inputs, compiles them into a dictionary then merges it to the current nomenclate's state :param args: (dict, Nomenclate), any number of dictionary inputs or Nomenclates to be converted to dicts :param kwargs: str, any number of kwargs that represent token:value pairs
7,054
def _run_train_step(self, data, mode=): epoch_size = ((len(data) // self.batch_size) - 1) // self.num_steps costs = 0.0 iters = 0 step = 0 state = self._init_state.eval() op = self._train_op if mode == else tf.no_op() for step, (x, y) in enumerate( ...
Run a single training step. :param data: input data :param mode: 'train' or 'test'.
7,055
def partition_agent(host): network.save_iptables(host) network.flush_all_rules(host) network.allow_all_traffic(host) network.run_iptables(host, ALLOW_SSH) network.run_iptables(host, ALLOW_PING) network.run_iptables(host, DISALLOW_MESOS) network.run_iptables(host, DISALLOW_INPUT)
Partition a node from all network traffic except for SSH and loopback :param hostname: host or IP of the machine to partition from the cluster
7,056
def get_context_dict(self): context_dict = {} for s in self.sections(): for k, v in self.manifest.items(s): context_dict["%s:%s" % (s, k)] = v for k, v in self.inputs.values().items(): context_dict["config:{0}".format(k)] = v context_dict....
return a context dict of the desired state
7,057
def unset(self, host, *args): self.__check_host_args(host, args) remove_idx = [idx for idx, x in enumerate(self.lines_) if x.host == host and x.key.lower() in args] for idx in reversed(sorted(remove_idx)): del self.lines_[idx]
Removes settings for a host. Parameters ---------- host : the host to remove settings from. *args : list of settings to removes.
7,058
def search_elementnames(self, *substrings: str, name: str = ) -> : try: selection = Selection(name) for element in self.elements: for substring in substrings: if substring in element.name: se...
Return a new selection containing all elements of the current selection with a name containing at least one of the given substrings. >>> from hydpy.core.examples import prepare_full_example_2 >>> hp, pub, _ = prepare_full_example_2() Pass the (sub)strings as positional arguments and, o...
7,059
def _create_index_content(words): content = ["<h1>Index</h1>", "<ul>"] for word in words: content.append( .format(word=word) ) content.append("</ul>") if not words: content.append("<i>Nothing to see here ...yet!</i>") return "\n".join(content)
Create html string of index file. Parameters ---------- words : list of str List of cached words. Returns ------- str html string.
7,060
def setOverlayAlpha(self, ulOverlayHandle, fAlpha): fn = self.function_table.setOverlayAlpha result = fn(ulOverlayHandle, fAlpha) return result
Sets the alpha of the overlay quad. Use 1.0 for 100 percent opacity to 0.0 for 0 percent opacity.
7,061
def get_info(self, full=False): " Return printable information about current site. " if full: context = self.as_dict() return "".join("{0:<25} = {1}\n".format( key, context[key]) for key in sorted(context.iterkeys())) return "%s [%s]" % (self.g...
Return printable information about current site.
7,062
def ProcessPathSpec(self, mediator, path_spec): self.last_activity_timestamp = time.time() self.processing_status = definitions.STATUS_INDICATOR_RUNNING file_entry = path_spec_resolver.Resolver.OpenFileEntry( path_spec, resolver_context=mediator.resolver_context) if file_entry is None: ...
Processes a path specification. Args: mediator (ParserMediator): mediates the interactions between parsers and other components, such as storage and abort signals. path_spec (dfvfs.PathSpec): path specification.
7,063
def b64_decode(data: bytes) -> bytes: missing_padding = len(data) % 4 if missing_padding != 0: data += b * (4 - missing_padding) return urlsafe_b64decode(data)
:param data: Base 64 encoded data to decode. :type data: bytes :return: Base 64 decoded data. :rtype: bytes
7,064
def slicing_singlevalue(arg, length): if isinstance(arg, slice): start, stop, step = arg.indices(length) i = start if step > 0: while i < stop: yield i i += step else: while i > stop: yield i ...
Internally used.
7,065
def _check_reach_env(): path_to_reach = get_config() if path_to_reach is None: path_to_reach = environ.get(, None) if path_to_reach is None or not path.exists(path_to_reach): raise ReachError( ) ...
Check that the environment supports runnig reach.
7,066
def volumes(self, assets, dt): market_open, prev_dt, dt_value, entries = self._prelude(dt, ) volumes = [] session_label = self._trading_calendar.minute_to_session_label(dt) for asset in assets: if not asset.is_alive_for_session(session_label): volum...
The volume field's aggregation returns the sum of all volumes between the market open and the `dt` If there has been no data on or before the `dt` the volume is 0. Returns ------- np.array with dtype=int64, in order of assets parameter.
7,067
def _post_init(self): try: return self.postinit() except Exception as exc: return self._onerror(Result.from_exception(exc, uuid=self.uuid))
A post init trigger
7,068
def is_active(self): if not self.multiplexer: return False if self._is_active: return True if self._thread_for_determining_is_active: return self._is_active new_thread = threading.Thread( target=self._determine_is_active...
Determines whether this plugin is active. This plugin is only active if any run has an embedding. Returns: Whether any run has embedding data to show in the projector.
7,069
def remove_product_version(self, id, product_version_id, **kwargs): kwargs[] = True if kwargs.get(): return self.remove_product_version_with_http_info(id, product_version_id, **kwargs) else: (data) = self.remove_product_version_with_http_info(id, product_version_...
Removes a product version from the specified config set This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> ...
7,070
def add_dns(ip, interface=, index=1): * servers = get_dns_servers(interface) if servers is False: return False try: if servers[index - 1] == ip: return True except IndexError: pass if ip in servers: rm_dns(ip, interface) cmd = [,...
Add the DNS server to the network interface (index starts from 1) Note: if the interface DNS is configured by DHCP, all the DNS servers will be removed from the interface and the requested DNS will be the only one CLI Example: .. code-block:: bash salt '*' win_dns_client.add_dns <ip> <in...
7,071
async def load_credentials(self, credentials): split = credentials.split() self.identifier = split[0] self.srp.initialize(binascii.unhexlify(split[1])) _LOGGER.debug(, credentials)
Load existing credentials.
7,072
def _serialize_normalized_array(array, fmt=, quality=70): dtype = array.dtype assert np.issubdtype(dtype, np.unsignedinteger) assert np.max(array) <= np.iinfo(dtype).max assert array.shape[-1] > 1 image = PIL.Image.fromarray(array) image_bytes = BytesIO() image.save(image_bytes, fmt, quality=quality...
Given a normalized array, returns byte representation of image encoding. Args: array: NumPy array of dtype uint8 and range 0 to 255 fmt: string describing desired file format, defaults to 'png' quality: specifies compression quality from 0 to 100 for lossy formats Returns: image data as BytesIO bu...
7,073
def start(self): if self.use_user_options: user_options = self.user_options else: user_options = {} self.log.warn("user_options: {}".format(user_options)) service = yield self.get_service() if service is None: if...
Start the single-user server in a docker service. You can specify the params for the service through jupyterhub_config.py or using the user_options
7,074
def traceroute(target, dport=80, minttl=1, maxttl=30, sport=RandShort(), l4=None, filter=None, timeout=2, verbose=None, **kargs): if verbose is None: verbose = conf.verb if filter is None: filter = "(icmp and (icmp[0]=3 or icmp[0]=4 or icmp[0]=5 or icmp[0]=11 or...
Instant TCP traceroute traceroute(target, [maxttl=30,] [dport=80,] [sport=80,] [verbose=conf.verb]) -> None # noqa: E501
7,075
def get_weekly_charts(self, chart_kind, from_date=None, to_date=None): method = ".getWeekly" + chart_kind.title() + "Chart" chart_type = eval(chart_kind.title()) params = self._get_params() if from_date and to_date: params["from"] = from_date params["t...
Returns the weekly charts for the week starting from the from_date value to the to_date value. chart_kind should be one of "album", "artist" or "track"
7,076
def start_rpc_listeners(self): self._setup_rpc() if not self.endpoints: return [] self.conn = n_rpc.create_connection() self.conn.create_consumer(self.topic, self.endpoints, fanout=False) return self.conn.consume_in_threads()
Configure all listeners here
7,077
def date_of_birth(self, value): if value: self._date_of_birth = parse(value).date() if isinstance(value, type_check) else value
The date of birth of the individual. :param value: :return:
7,078
def load_config(self, path, environments, fill_with_defaults=False): yaml.add_implicit_resolver("!environ", self.__environ_pattern) yaml.add_constructor(, self.__get_from_environment) yaml.add_implicit_resolver("!vault", self.__vault_pattern) yaml.add_constructor(, self.__get_fr...
Will load default.yaml and <environment>.yaml at given path. The environment config will override the default values. :param path: directory where to find your config files. If the last character is not a slash (/) it will be appended. Example: resources/ :param environments: list of environmen...
7,079
def sufar4(ascfile, meas_output=, aniso_output=, spec_infile=None, spec_outfile=, samp_outfile=, site_outfile=, specnum=0, sample_naming_con=, user="", locname="unknown", instrument=, static_15_position_mode=False, dir_path=, input_dir_path=, data_model_num=3): cita...
Converts ascii files generated by SUFAR ver.4.0 to MagIC files Parameters ---------- ascfile : str input ASC file, required meas_output : str measurement output filename, default "measurements.txt" aniso_output : str anisotropy output filename, MagIC 2 only, "rmag_anisotropy...
7,080
def diffuse(self, *args): mode = diffusingModeEnum.unknown if (isinstance(args[0], str) and (len(args) == 3)): mode = diffusingModeEnum.element elif (hasattr(args[0], "__len__") and (len(args) == 2)): mode = diffusingModeEnum.elements ...
this is a dispatcher of diffuse implementation. Depending of the arguments used.
7,081
def post_request(profile, resource, payload): url = get_url(profile, resource) headers = get_headers(profile) response = requests.post(url, json=payload, headers=headers) return response.json()
Do a POST request to Github's API. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. resource The part of a Github A...
7,082
def QA_indicator_RSI(DataFrame, N1=12, N2=26, N3=9): CLOSE = DataFrame[] LC = REF(CLOSE, 1) RSI1 = SMA(MAX(CLOSE - LC, 0), N1) / SMA(ABS(CLOSE - LC), N1) * 100 RSI2 = SMA(MAX(CLOSE - LC, 0), N2) / SMA(ABS(CLOSE - LC), N2) * 100 RSI3 = SMA(MAX(CLOSE - LC, 0), N3) / SMA(ABS(CLOSE - LC), N3) * 100...
相对强弱指标RSI1:SMA(MAX(CLOSE-LC,0),N1,1)/SMA(ABS(CLOSE-LC),N1,1)*100;
7,083
def fdrcorrection(pvals, alpha=0.05): pvals = np.asarray(pvals) pvals_sortind = np.argsort(pvals) pvals_sorted = np.take(pvals, pvals_sortind) ecdffactor = _ecdf(pvals_sorted) reject = pvals_sorted <= ecdffactor*alpha if reject.any(): rejectmax = max(np.nonzero(reject)[0]) ...
benjamini hocheberg fdr correction. inspired by statsmodels
7,084
def save(self, *args, **kwargs): auto_update = kwargs.get(, True) if auto_update: self.updated = now() if in kwargs: kwargs.pop() super(BaseDate, self).save(*args, **kwargs)
automatically update updated date field
7,085
def sys_open(self, buf, flags, mode): filename = self.current.read_string(buf) try: f = self._sys_open_get_file(filename, flags) logger.debug(f"Opening file {filename} for real fd {f.fileno()}") except IOError as e: logger.warning(f"Could not open fil...
:param buf: address of zero-terminated pathname :param flags: file access bits :param mode: file permission mode
7,086
def prepare_mainsubstituter(): substituter = Substituter() for module in (builtins, numpy, datetime, unittest, doctest, inspect, io, os, sys, time, collections, itertools, subprocess, scipy, typing): substituter.add_module(module) for subpackage in (auxs, c...
Prepare and return a |Substituter| object for the main `__init__` file of *HydPy*.
7,087
def _make_multidim_func(one_d_func, n, *args): _args = list(args) n = np.atleast_1d(n) args = list(map(np.atleast_1d, _args)) if all([x.size == 1 for x in [n] + args]): return one_d_func(n[0], *_args) d = n.size for i in range(len(args)): if args[i].size == 1: ...
A helper function to cut down on code repetition. Almost all of the code in qnwcheb, qnwlege, qnwsimp, qnwtrap is just dealing various forms of input arguments and then shelling out to the corresponding 1d version of the function. This routine does all the argument checking and passes things throug...
7,088
def get_comments(self): return github.PaginatedList.PaginatedList( github.GistComment.GistComment, self._requester, self.url + "/comments", None )
:calls: `GET /gists/:gist_id/comments <http://developer.github.com/v3/gists/comments>`_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.GistComment.GistComment`
7,089
def java_install(self): sudo() java_home = run( ) append(bigdata_conf.global_env_home, .format( java_home ), use_sudo=True) run(.format(bigdata_conf.global_env_home))
install java :return:
7,090
def _bind_sources_to_destination(self): seen = set() for src in self._spec.sources: for src_ase in src.files( self._creds, self._spec.options, self._general_options.dry_run): ...
Bind source storage entity to destination storage entities :param SyncCopy self: this :rtype: tuple :return: (source storage entity, destination storage entity)
7,091
def _reuse_pre_installed_setuptools(env, installer): if not env.setuptools_version: return reuse_old = config.reuse_old_setuptools reuse_best = config.reuse_best_setuptools reuse_future = config.reuse_future_setuptools reuse_comment = None if reuse_old or reuse_best or reus...
Return whether a pre-installed setuptools distribution should be reused.
7,092
def on_attribute(self, name): def decorator(fn): if isinstance(name, list): for n in name: self.add_attribute_listener(n, fn) else: self.add_attribute_listener(name, fn) return decorator
Decorator for attribute listeners. The decorated function (``observer``) is invoked differently depending on the *type of attribute*. Attributes that represent sensor values or which are used to monitor connection status are updated whenever a message is received from the vehicle. Attributes wh...
7,093
def uridecode(uristring, encoding=, errors=): if not isinstance(uristring, bytes): uristring = uristring.encode(encoding or , errors) parts = uristring.split(b) result = [parts[0]] append = result.append decode = _decoded.get for s in parts[1:]: append(decode(s[:2], b + s[:2...
Decode a URI string or string component.
7,094
def to_bytes(self): out = [PNG_SIGN] other_chunks = [] seq = 0 png, control = self.frames[0] out.append(png.hdr) out.append(make_chunk("acTL", struct.pack("!II", len(self.frames), self.num_plays))) if control: out.append(make_chunk("fcTL", struct.pack("!I", seq...
Convert the entire image to bytes. :rtype: bytes
7,095
async def set_position(self, position, wait_for_completion=True): command_send = CommandSend( pyvlx=self.pyvlx, wait_for_completion=wait_for_completion, node_id=self.node_id, parameter=position) await command_send.do_api_call() if not comm...
Set window to desired position. Parameters: * position: Position object containing the target position. * wait_for_completion: If set, function will return after device has reached target position.
7,096
def generate_ill_conditioned_dot_product(n, c, dps=100): assert n >= 6 n2 = round(n / 2) x = numpy.zeros(n) y = numpy.zeros(n) b = math.log2(c) e = numpy.rint(numpy.random.rand(n2) * b / 2).astype(int) e[0] = round(b / 2) + 1 e[-1] = 0 r...
n ... length of vector c ... target condition number
7,097
def get_partition_by_name(self, db_name, tbl_name, part_name): self.send_get_partition_by_name(db_name, tbl_name, part_name) return self.recv_get_partition_by_name()
Parameters: - db_name - tbl_name - part_name
7,098
def changed(self, name): if self.first: return self.first.changed(name) else: return False
Returns true if the parameter with the specified name has its value changed by the *first* module procedure in the interface. :arg name: the name of the parameter to check changed status for.
7,099
def env(self, **kw): self._original_env = kw if self._env is None: self._env = dict(os.environ) self._env.update({k: unicode(v) for k, v in kw.iteritems()}) return self
Allows adding/overriding env vars in the execution context. :param kw: Key-value pairs :return: self