Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
16,700
def get_tagged(self, event): self.log("Tagged objects request for", event.data, "from", event.user, lvl=debug) if event.data in self.tags: tagged = self._get_tagged(event.data) response = { : , : , : tagge...
Return a list of tagged objects for a schema
16,701
def set_isotopic_ratio(self, compound=, element=, list_ratio=[]): _stack = self.stack list_compounds = _stack.keys() if compound not in _stack.keys(): list_compounds_joined = .join(list_compounds) raise ValueError("Compound could not be find in {}".format(compo...
defines the new set of ratio of the compound/element and trigger the calculation to update the density Parameters: =========== compound: string (default is ''). Name of compound element: string (default is ''). Name of element list_ratio: list (default is []). list of new stoich...
16,702
def calc_fwhm_gaussian(self, arr1d, medv=None, gauss_fn=None): if gauss_fn is None: gauss_fn = self.gaussian N = len(arr1d) X = np.array(list(range(N))) Y = arr1d if medv is None: medv = get_median(Y) Y = Y - medv ...
FWHM calculation on a 1D array by using least square fitting of a gaussian function on the data. arr1d is a 1D array cut in either X or Y direction on the object.
16,703
def convert_data_to_ndarray(self): if self._data_structure != "DataFrame": raise Exception(f"Data is not a DataFrame but {self._data_structure}.") self._data = self._convert_to_ndarray(self._data) self._update_data_structure() return self
Converts the data from dataframe to ndarray format. Assumption: df-columns are ndarray-layers (3rd dim.)
16,704
def duplicate(self, host): duplicates = [] safe_key_value = re.sub(r + "`~!$%^&*\"|]+_$$check_commandaggregationevent_handler$$service_dependencies$$', key_value[key] ) duplicates.appen...
For a given host, look for all copy we must create for for_each property :param host: alignak host object :type host: alignak.objects.host.Host :return: list :rtype: list
16,705
def getLeader(self, vehID, dist=0.): self._connection._beginMessage( tc.CMD_GET_VEHICLE_VARIABLE, tc.VAR_LEADER, vehID, 1 + 8) self._connection._string += struct.pack("!Bd", tc.TYPE_DOUBLE, dist) return _readLeader(self._connection._checkResult(tc.CMD_GET_VEHICLE_VARIABLE, t...
getLeader(string, double) -> (string, double) Return the leading vehicle id together with the distance. The distance is measured from the front + minGap to the back of the leader, so it does not include the minGap of the vehicle. The dist parameter defines the maximum lookahead, 0 calcu...
16,706
def allow(self, ctx, acls): for acl in acls: if self._identity == acl: return True return False
Allow access to any ACL members that was equal to the user name. That is, some user u is considered a member of group u and no other.
16,707
def _check_tcpdump(): with open(os.devnull, ) as devnull: try: proc = subprocess.Popen([conf.prog.tcpdump, "--version"], stdout=devnull, stderr=subprocess.STDOUT) except OSError: return False if OPENBSD: return pr...
Return True if the tcpdump command can be started
16,708
def _do_synchronise_jobs(walltime, machines): offset = SYNCHRONISATION_OFFSET start = time.time() + offset _t = time.strptime(walltime, "%H:%M:%S") _walltime = _t.tm_hour * 3600 + _t.tm_min * 60 + _t.tm_sec demands = defaultdict(int) for machine in machines: cluster = machine[...
This returns a common reservation date for all the jobs. This reservation date is really only a hint and will be supplied to each oar server. Without this *common* reservation_date, one oar server can decide to postpone the start of the job while the other are already running. But this doens't prevent ...
16,709
def _validate_message(self, message): if message.tag != : status = -1 raise exception.IloClientInternalError(message, status) for child in message: if child.tag != : return mess...
Validate XML response from iLO. This function validates the XML response to see if the exit status is 0 or not in the response. If the status is non-zero it raises exception.
16,710
def clip_or_fit_solutions(self, pop, idx): for k in idx: self.repair_genotype(pop[k])
make sure that solutions fit to sample distribution, this interface will probably change. In particular the frequency of long vectors appearing in pop[idx] - self.mean is limited.
16,711
async def deserialize(data: dict): return await Proof._deserialize("vcx_proof_deserialize", json.dumps(data), data.get().get())
Builds a Proof object with defined attributes. Attributes are provided by a previous call to the serialize function. :param data: Example: name = "proof name" requested_attrs = [{"name": "age", "restrictions": [{"schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_...
16,712
def start_heron_tools(masters, cl_args): single_master = list(masters)[0] wait_for_master_to_start(single_master) cmd = "%s run %s >> /tmp/heron_tools_start.log 2>&1 &" \ % (get_nomad_path(cl_args), get_heron_tools_job_file(cl_args)) Log.info("Starting Heron Tools on %s" % single_master) if not i...
Start Heron tracker and UI
16,713
def _request(self, method, uri_relative, request_bytes, params, custom_headers): uri_relative_with_params = self._append_params_to_uri(uri_relative, params) if uri_relative not in self._URIS_NOT_REQUIRING_ACTIVE_SES...
:type method: str :type uri_relative: str :type request_bytes: bytes :type params: dict[str, str] :type custom_headers: dict[str, str] :return: BunqResponseRaw
16,714
def learnObject(self, objectDescription, randomLocation=False, useNoise=False, noisyTrainingTime=1): self.reset() self.column.activateRandomLocation() locationsAreUnique = True if randomLocation or useNoise: numIters = ...
Train the network to recognize the specified object. Move the sensor to one of its features and activate a random location representation in the location layer. Move the sensor over the object, updating the location representation through path integration. At each point on the object, form reciprocal co...
16,715
def get_instance(self): try: return self._instance except AttributeError: self._instance = self._decorated() return self._instance
Returns the singleton instance. Upon its first call, it creates a new instance of the decorated class and calls its `__init__` method. On all subsequent calls, the already created instance is returned.
16,716
def _dK_dR(self, R): return -self._ns * self._N / R**2 / self._sin_alpha
Return numpy array of dK/dR from K1 up to and including Kn.
16,717
def run(self, file_list): data = {: 0, : 0, : []} for filename in file_list: path, fname = os.path.split(filename) if os.path.splitext(filename)[1] != : return data
Runs pylint on the list of files and return a dictionary: {<filename>: [list of pylint errors], 'total': <int> - Total number of pylint messages, 'errors': <int> - Number of pylint errors, 'scores': (<filename>, score) - Individual score for each file.} :param file_list: ...
16,718
def _interpolationFunctionFactory(self, spline_order=None, cval=None): import scipy.ndimage if spline_order is None: spline_order = self.interpolation_spline_order if cval is None: cval = self.interpolation_cval d...
Returns a function F(x,y,z) that interpolates any values on the grid. _interpolationFunctionFactory(self,spline_order=3,cval=None) --> F *cval* is set to :meth:`Grid.grid.min`. *cval* cannot be chosen too large or too small or NaN because otherwise the spline interpolation breaks down ...
16,719
def _group_and_publish_tasks_statistics(self, result): for i in result: executor_id = i[] i[] = executor_id[:executor_id.rfind()] i[][] = 1 r = {} for i in result: executor_id = i[] r[executor_id] = r.get(executor_id, {}) ...
This function group statistics of same tasks by adding them. It also add 'instances_count' statistic to get information about how many instances is running on the server Args: result: result of mesos query. List of dictionaries with 'executor_id', 'framework_id' as a str...
16,720
def restore_geometry_on_layout_change(self, value): if value is not None: assert type(value) is bool, " attribute: type is not !".format( "restore_geometry_on_layout_change", value) self.__restore_geometry_on_layout_change = value
Setter for **self.__restore_geometry_on_layout_change** attribute. :param value: Attribute value. :type value: bool
16,721
def wet_bulb_from_db_rh(db_temp, rh, b_press=101325): es = 6.112 * math.e**((17.67 * db_temp) / (db_temp + 243.5)) e = (es * rh) / 100 t_w = 0 increse = 10.0 previoussign = 1 e_d = 1 while math.fabs(e_d) > 0.005: e_wg = 6.112 * (math.e**((17.67 * t_w) / (t_w + 243.5))) e...
Wet Bulb Temperature (C) at db_temp (C), Relative Humidity rh (%), and Pressure b_press (Pa). Note: [1] J. Sullivan and L. D. Sanders. "Method for obtaining wet-bulb temperatures by modifying the psychrometric formula." Center for Experiment Design and Data Analysis. NOAA - National Oce...
16,722
def leaf_sections(h): leaves = [] for section in h.allsec(): sref = h.SectionRef(sec=section) if sref.nchild() < 0.9: leaves.append(section) return leaves
Returns a list of all sections that have no children.
16,723
def activate_user(self, user): if not user.active: user.active = True return True return False
Activates a specified user. Returns `True` if a change was made. :param user: The user to activate
16,724
def apply_palette(img, palette, options): if not options.quiet: print() bg_color = palette[0] fg_mask = get_fg_mask(bg_color, img, options) orig_shape = img.shape pixels = img.reshape((-1, 3)) fg_mask = fg_mask.flatten() num_pixels = pixels.shape[0] labels = np.zeros...
Apply the pallete to the given image. The first step is to set all background pixels to the background color; then, nearest-neighbor matching is used to map each foreground color to the closest one in the palette.
16,725
def download_interim_for_gssha(main_directory, start_datetime, end_datetime, leftlon=-180, rightlon=180, toplat=90, bottomlat=-90, ...
Function to download ERA5 data for GSSHA .. note:: https://software.ecmwf.int/wiki/display/WEBAPI/Access+ECMWF+Public+Datasets Args: main_directory(:obj:`str`): Location of the output for the forecast data. start_datetime(:obj:`str`): Datetime for download start. end_datetime(:obj:`str...
16,726
def reporter(self): make_path(self.reportpath) logging.info(.format(self.analysistype)) header = data = with open(self.sixteens_report, ) as report: with open(os.path.join(self.reportpath, self.analysistype + ), ) as sequences: ...
Creates a report of the results
16,727
def getClassAllSubs(self, aURI): aURI = aURI try: qres = self.rdfgraph.query( % (aURI)) except: printDebug("... warning: the query failed (maybe missing SPARQL 1.1 support?)") qres = [] return list(qres)
note: requires SPARQL 1.1 2015-06-04: currenlty not used, inferred from above
16,728
async def async_input(prompt): print(prompt, end=, flush=True) return (await loop.run_in_executor(None, sys.stdin.readline)).rstrip()
Python's ``input()`` is blocking, which means the event loop we set above can't be running while we're blocking there. This method will let the loop run while we wait for input.
16,729
def loads(string): d = _loads(string) for k, v in d.items(): FILTERS[dr.get_component(k) or k] = set(v)
Loads the filters dictionary given a string.
16,730
def get_location(conn, vm_): locations = conn.list_locations() vm_location = config.get_cloud_config_value(, vm_, __opts__) if not six.PY3: vm_location = vm_location.encode( , ) for img in locations: if isinstance(img.id, six.string_types) and not six.PY3: ...
Return the location object to use
16,731
def find_one(self, id_, raw=True, recovery_name=True): url = "https://api.knackhq.com/v1/objects/%s/records/%s" % ( self.key, id_) res = self.get(url) if raw: try: res = self.get_raw_values(res, recovery_name=recovery_name) ...
Find one record. Ref: http://helpdesk.knackhq.com/support/solutions/articles/5000446111-api-reference-root-access#retrieve :param id_: record id_ :param using_name: if you are using field name in filter and sort_field, please set using_name = True (it's the default),...
16,732
def to_message(self, keywords=None, show_header=True): if keywords is None and self.layer is not None: keywords = self.read_keywords(self.layer) preferred_order = [ , , , , , , , ...
Format keywords as a message object. .. versionadded:: 3.2 .. versionchanged:: 3.3 - default keywords to None The message object can then be rendered to html, plain text etc. :param keywords: Keywords to be converted to a message. Optional. If not passed then we will atte...
16,733
def _to_dict(self): _dict = {} if hasattr(self, ) and self.classifier_id is not None: _dict[] = self.classifier_id if hasattr(self, ) and self.url is not None: _dict[] = self.url if hasattr(self, ) and self.collection is not None: _dict[] = [x...
Return a json dictionary representing this model.
16,734
def load_wmt_en_fr_dataset(path=): path = os.path.join(path, ) _WMT_ENFR_TRAIN_URL = "http://www.statmt.org/wmt10/" _WMT_ENFR_DEV_URL = "http://www.statmt.org/wmt15/" def gunzip_file(gz_path, new_path): logging.info("Unpacking %s to %s" % (gz_path, new_path)) with gzi...
Load WMT'15 English-to-French translation dataset. It will download the data from the WMT'15 Website (10^9-French-English corpus), and the 2013 news test from the same site as development set. Returns the directories of training data and test data. Parameters ---------- path : str The path...
16,735
def envelope(self, header, body): env = Element("Envelope", ns=envns) env.addPrefix(Namespace.xsins[0], Namespace.xsins[1]) env.append(header) env.append(body) return env
Build the B{<Envelope/>} for a SOAP outbound message. @param header: The SOAP message B{header}. @type header: L{Element} @param body: The SOAP message B{body}. @type body: L{Element} @return: The SOAP envelope containing the body and header. @rtype: L{Element}
16,736
def read_config(self, filename): if not os.path.exists(filename): raise Exception("Configuration file cannot be found: %s" % filename) with io.open(filename, encoding=) as stream: return yaml.safe_load(stream)
Returns data found in config file (as dict), or raises exception if file not found
16,737
def save_uca(self, rootpath, raw=False, as_int=False): self.save_array(self.uca, None, , rootpath, raw, as_int=as_int)
Saves the upstream contributing area to a file
16,738
def add(self, *args): i = 1 row = [] for button in args: row.append(button.to_dic()) if i % self.row_width == 0: self.keyboard.append(row) row = [] i += 1 if len(row) > 0: self.keyboard.append(row)
This function adds strings to the keyboard, while not exceeding row_width. E.g. ReplyKeyboardMarkup#add("A", "B", "C") yields the json result {keyboard: [["A"], ["B"], ["C"]]} when row_width is set to 1. When row_width is set to 2, the following is the result of this function: {keyboard: [["A", ...
16,739
def addfield(self, pkt, s, i): if i is None: if self.length_of is not None: fld, fval = pkt.getfield_and_val(self.length_of) tmp = pkt.tls_session.frozen pkt.tls_session.frozen = True f = fld.i2len(pkt, fval) p...
There is a hack with the _ExtensionsField.i2len. It works only because we expect _ExtensionsField.i2m to return a string of the same size (if not of the same value) upon successive calls (e.g. through i2len here, then i2m when directly building the _ExtensionsField). XXX A proper way to...
16,740
async def track_event(event, state, service_name): redis = await aioredis.create_redis( (EVENT_TRACKING_HOST, 6379), loop=loop) now = datetime.utcnow() event_id = event.event_id tracking_data = json.dumps({ "event_id": event_id, "timestamp": str(now), "state": stat...
Store state of events in memory :param event: Event object :param state: EventState object :param service_name: Name of service name
16,741
def quantile(y, k=4): w = 100. / k p = np.arange(w, 100 + w, w) if p[-1] > 100.0: p[-1] = 100.0 q = np.array([stats.scoreatpercentile(y, pct) for pct in p]) q = np.unique(q) k_q = len(q) if k_q < k: Warn(, UserWarning) Warn( % k_q, UserWarning) ...
Calculates the quantiles for an array Parameters ---------- y : array (n,1), values to classify k : int number of quantiles Returns ------- q : array (n,1), quantile values Examples -------- >>> import numpy as np >>> import mapclass...
16,742
def set_ccc(ctx, management_key, pin): controller = ctx.obj[] _ensure_authenticated(ctx, controller, pin, management_key) controller.update_ccc()
Generate and set a CCC on the YubiKey.
16,743
def working_yesterday(self, date_from=None, date_format=None): return self.delta(days=-1, date_from=date_from, date_format=date_format, days_range=[1, 2, 3, 4, 5, 6])
Retourne la date d'hier depuis maintenant ou depuis une date fournie seulement sur les jours ouvrableq. Ainsi lundi devient samedi et samedi devient vendredi :param: :date_from date de référence :return datetime
16,744
def __RetrieveContent(host, port, adapter, version, path, keyFile, certFile, thumbprint, sslContext, connectionPoolTimeout=CONNECTION_POOL_IDLE_TIMEOUT_SEC): if adapter != "SOAP": raise ValueError(adapter) stub = SoapStubAdapter(host, port, version=version, path=path, ...
Retrieve service instance for connection. @param host: Which host to connect to. @type host: string @param port: Port @type port: int @param adapter: Adapter @type adapter: string @param version: Version @type version: string @param path: Path @type path: string @param keyFile: ssl...
16,745
def run(self, root): math_tag_class = self.pelican_mathjax_extension.getConfig() for parent in root: div_math = [] children = list(parent) for div in parent.findall(): if div.get() == math_tag_class: div_math.append(chil...
Searches for <div class="math"> that are children in <p> tags and corrects the invalid HTML that results
16,746
async def invoke(self, *args, **kwargs): r try: command = args[0] except IndexError: raise TypeError() from None arguments = [] if command.cog is not None: arguments.append(command.cog) arguments.append(self) arguments.extend...
r"""|coro| Calls a command with the arguments given. This is useful if you want to just call the callback that a :class:`.Command` holds internally. Note ------ You do not pass in the context as it is done for you. Warning --------- The first p...
16,747
def show_data(self, item): child, cookie = self.mainview_tree.GetFirstChild(item) child_list = [] while child.IsOk(): child_list.append(child) child, cookie = self.mainview_tree.GetNextChild(item, cookie) lc = self.nodeview_lc lc.DeleteAllItems()...
show data key-value in ListCtrl for tree item
16,748
def fit_model(ts, sc=None): assert sc != None, "Missing SparkContext" jvm = sc._jvm jmodel = jvm.com.cloudera.sparkts.models.GARCH.fitModel(_py2java(sc, Vectors.dense(ts))) return GARCHModel(jmodel=jmodel, sc=sc)
Fits a GARCH(1, 1) model to the given time series. Parameters ---------- ts: the time series to which we want to fit a GARCH model as a Numpy array Returns a GARCH model
16,749
def update_vlan(self, name, vid, vni): cmd = % (vid, vni) return self.configure_interface(name, cmd)
Adds a new vlan to vni mapping for the interface EosVersion: 4.13.7M Args: vlan (str, int): The vlan id to map to the vni vni (str, int): The vni value to use Returns: True if the command completes successfully
16,750
def plot(cg): from androguard.core.analysis.analysis import ExternalMethod import matplotlib.pyplot as plt import networkx as nx pos = nx.spring_layout(cg) internal = [] external = [] for n in cg.node: if isinstance(n, ExternalMethod): external.append(n) el...
Plot the call graph using matplotlib For larger graphs, this should not be used, as it is very slow and probably you can not see anything on it. :param cg: A networkx call graph to plot
16,751
def _on_timeout(self, _attempts=0): if self._connection is None and _attempts < 3: self._timer = self.session.cluster.connection_class.create_timer( 0.01, partial(self._on_timeout, _attempts=_attempts + 1) ) return if...
Called when the request associated with this ResponseFuture times out. This function may reschedule itself. The ``_attempts`` parameter tracks the number of times this has happened. This parameter should only be set in those cases, where ``_on_timeout`` reschedules itself.
16,752
def _get_paths(): import os base_path = os.path.dirname(os.path.abspath(__file__)) test_data_dir = os.path.join(base_path, , , ) test_data_file = os.path.join(test_data_dir, ) return test_data_dir, test_data_file
Generate paths to test data. Done in a function to protect namespace a bit.
16,753
def disqus_sso_script(context): settings = context["settings"] public_key = getattr(settings, "COMMENTS_DISQUS_API_PUBLIC_KEY", "") secret_key = getattr(settings, "COMMENTS_DISQUS_API_SECRET_KEY", "") user = context["request"].user if public_key and secret_key and user.is_authenticated(): ...
Provides a generic context variable which adds single-sign-on support to DISQUS if ``COMMENTS_DISQUS_API_PUBLIC_KEY`` and ``COMMENTS_DISQUS_API_SECRET_KEY`` are specified.
16,754
def resetPassword(self, email=True): url = self.root + "/reset" params = { "f" : "json", "email" : email } return self._post(url=url, param_dict=params, securityHandler=self._securityHandler, ...
resets a users password for an account. The password will be randomly generated and emailed by the system. Input: email - boolean that an email password will be sent to the user's profile email address. The default is True.
16,755
def file_needs_update(target_file, source_file): if not os.path.isfile(target_file) or get_md5_file_hash(target_file) != get_md5_file_hash(source_file): return True return False
Checks if target_file is not existing or differing from source_file :param target_file: File target for a copy action :param source_file: File to be copied :return: True, if target_file not existing or differing from source_file, else False :rtype: False
16,756
def build(self, pre=None, shortest=False): global REF_LEVEL REF_LEVEL += 1 try: if pre is None: pre = [] definition = self.fuzzer.get_ref(self.cat, self.refname) res = utils.val( definition, ...
Build the ``Ref`` instance by fetching the rule from the GramFuzzer instance and building it :param list pre: The prerequisites list :param bool shortest: Whether or not the shortest reference-chain (most minimal) version of the field should be generated.
16,757
def to_dict(self, fields=_all_fields, labels=None): fields = set(fields) diff = fields.difference(_all_fields) if isinstance(labels, Sequence): labels = _map_labels(self, labels) elif labels is None: labels = {} if diff: raise ValueErr...
Encode the node as a dictionary suitable for JSON serialization. Args: fields: if given, this is a whitelist of fields to include on nodes (`daughters` and `form` are always shown) labels: optional label annotations to embed in the derivation dict; the va...
16,758
def split_unquoted_newlines(stmt): text = text_type(stmt) lines = SPLIT_REGEX.split(text) outputlines = [] for line in lines: if not line: continue elif LINE_MATCH.match(line): outputlines.append() else: outputlines[-1] += line return ...
Split a string on all unquoted newlines. Unlike str.splitlines(), this will ignore CR/LF/CR+LF if the requisite character is inside of a string.
16,759
def load_backends(self): for name, backend_settings in settings.storage.iteritems(): backend_path = backend_settings[] backend_module, backend_cls = backend_path.rsplit(, 1) backend_module = import_module(backend_module) backend_constructor = getattr(backend_module, backend_cls) ...
Loads all the backends setup in settings.py.
16,760
def pattern_to_regex(cls, pattern): if isinstance(pattern, unicode): return_type = unicode elif isinstance(pattern, bytes): return_type = bytes pattern = pattern.decode(_BYTES_ENCODING) else: raise TypeError("pattern:{!r} is not a unicode or byte string.".format(pattern)) pattern = pattern.strip...
Convert the pattern into a regular expression. *pattern* (:class:`unicode` or :class:`bytes`) is the pattern to convert into a regular expression. Returns the uncompiled regular expression (:class:`unicode`, :class:`bytes`, or :data:`None`), and whether matched files should be included (:data:`True`), exclu...
16,761
def get_list(self, id, name=None): return self.create_list(dict(id=id, name=name))
Get a list Returns: List: The list with the given `id`
16,762
def preprocessing_declaration(job, config): if config.preprocessing: job.fileStore.logToMaster( + config.uuid) disk = if config.ci_test else mem = if config.ci_test else processed_normal = job.wrapJobFn(run_gatk_preprocessing, config.normal_bam, config.normal_bai, ...
Declare jobs related to preprocessing :param JobFunctionWrappingJob job: passed automatically by Toil :param Namespace config: Argparse Namespace object containing argument inputs
16,763
def add_transformers(line): assert FROM_EXPERIMENTAL.match(line) line = FROM_EXPERIMENTAL.sub(, line) line = line.split(" for trans in line.replace(, ).split(): import_transformer(trans)
Extract the transformers names from a line of code of the form from __experimental__ import transformer1 [,...] and adds them to the globally known dict
16,764
async def send(self, message: Union[str, bytes], binary: bool=False, compress: Optional[int]=None) -> None: if isinstance(message, str): message = message.encode() if binary: await self._send_frame(message, WSMsgType.BINARY, compress...
Send a frame over the websocket with message as its payload.
16,765
def initialize(self, training_info, model, environment, device): if self.trust_region: self.average_model = self.model_factory.instantiate(action_space=environment.action_space).to(device) self.average_model.load_state_dict(model.state_dict())
Initialize policy gradient from reinforcer settings
16,766
def _prepare_sample(data, run_folder): want = set(["description", "files", "genome_build", "name", "analysis", "upload", "algorithm"]) out = {} for k, v in data.items(): if k in want: out[k] = _relative_paths(v, run_folder) if "algorithm" not in out: analysis, algorithm ...
Extract passed keywords from input LIMS information.
16,767
def check_privatenet(self): rpc_settings.setup(self.RPC_LIST) client = RPCClient() try: version = client.get_version() except NEORPCException: raise PrivnetConnectionError("Error: private network container doesn%srm -rf %s*'." % self.chain_leveldb_path ...
Check if privatenet is running, and if container is same as the current Chains/privnet database. Raises: PrivnetConnectionError: if the private net couldn't be reached or the nonce does not match
16,768
def pilot_PLL(xr,fq,fs,loop_type,Bn,zeta): T = 1/float(fs) Kv = 1.0 Norder = 5 b_lp,a_lp = signal.butter(Norder,2*(fq/2.)/float(fs)) fstate = np.zeros(Norder) Kv = 2*np.pi*Kv if loop_type == 1: fn = Bn Kt = 2*np.pi*fn elif loop_type ...
theta, phi_error = pilot_PLL(xr,fq,fs,loop_type,Bn,zeta) Mark Wickert, April 2014
16,769
def create_context_menu(self, event, shape): routes = self.df_routes.loc[self.df_routes.electrode_i == shape, ].astype(int).unique().tolist() def _connect_callback(menu_item, command_signal, group, command, data): callback_called = threading.Even...
Parameters ---------- event : gtk.gdk.Event GTK mouse click event. shape : str Electrode shape identifier (e.g., `"electrode028"`). Returns ------- gtk.Menu Context menu. .. versionchanged:: 0.13 - Deprecate hard-...
16,770
def delete_fastqs(job, patient_dict): for key in patient_dict.keys(): if not in key: continue job.fileStore.logToMaster( % (patient_dict[], key) + ) job.fileStore.deleteGlobalFile(patient_dict[key]) return None
Delete the fastqs from the job Store once their purpose has been achieved (i.e. after all mapping steps) :param dict patient_dict: Dict of list of input fastqs
16,771
async def update_template_context(self, context: dict) -> None: processors = self.template_context_processors[None] if has_request_context(): blueprint = _request_ctx_stack.top.request.blueprint if blueprint is not None and blueprint in self.template_context_processors: ...
Update the provided template context. This adds additional context from the various template context processors. Arguments: context: The context to update (mutate).
16,772
def tangent_approx(f: SYM, x: SYM, a: SYM = None, assert_linear: bool = False) -> Dict[str, SYM]: if a is None: a = ca.DM.zeros(x.numel(), 1) f_a = ca.substitute(f, x, a) J = ca.jacobian(f, x) if assert_linear and ca.depends_on(J, x): raise AssertionError() return ca...
Create a tangent approximation of a non-linear function f(x) about point a using a block lower triangular solver 0 = f(x) = f(a) + J*x # taylor series about a (if f(x) linear in x, then globally valid) J*x = -f(a) # solve for x x = -J^{-1}f(a) # but inverse is slow, so we use solv...
16,773
def parse(self): url = self.config.get() self.cnml = CNMLParser(url) self.parsed_data = self.cnml.getNodes()
parse data
16,774
def get_qtls_from_mapqtl_data(matrix, threshold, inputfile): trait_name = inputfile.split(, 1)[1].split()[0] qtls = [] qtl = None for entry in matrix[1:]: if qtl is None: qtl = entry if qtl[1] != entry[1]: if float(qtl[4]) > float(threshold): ...
Extract the QTLs found by MapQTL reading its file. This assume that there is only one QTL per linkage group. :arg matrix, the MapQTL file read in memory :arg threshold, threshold used to determine if a given LOD value is reflective the presence of a QTL. :arg inputfile, name of the inputfile in...
16,775
def get_importable_modules(folder): for fname in os.listdir(folder): if fname.endswith() and not fname.startswith(): yield fname[:-3]
Find all module files in the given folder that end with '.py' and don't start with an underscore. @return module names @rtype: iterator of string
16,776
def _cleanup_label(label): conjunctions = [, , , , , ] little_preps = [ , , , , , , , , , ] articles = [, , ] lbl = label.split(r)[0] fixedwords = [] i = 0 for wrd in lbl.split(): i += 1 ...
Reformat the ALL CAPS OMIM labels to something more pleasant to read. This will: 1. remove the abbreviation suffixes 2. convert the roman numerals to integer numbers 3. make the text title case, except for suplied conjunctions/prepositions/articles :param label: ...
16,777
def prefix_dict_keys(d: Dict[str, Any], prefix: str) -> Dict[str, Any]: result = {} for k, v in d.items(): result[prefix + k] = v return result
Returns a dictionary that's a copy of as ``d`` but with ``prefix`` prepended to its keys.
16,778
def delete(self): self.room.check_owner() self.conn.make_call("deleteFiles", [self.fid])
Remove this file
16,779
def get(self, request, *args, **kwargs): response = super(EntryProtectionMixin, self).get( request, *args, **kwargs) if self.object.login_required and not request.user.is_authenticated: return self.login() if (self.object.password and self.object.password != ...
Do the login and password protection.
16,780
def makeNetwork(self): if "weight" in self.data_friendships.keys(): self.G=G=x.DiGraph() else: self.G=G=x.Graph() F=self.data_friends for friendn in range(self.n_friends): if "posts" in F.keys(): G.add_node(F["name"][friendn], ...
Makes graph object from .gdf loaded data
16,781
def get_or_create_head(root): head = _create_cssselector("head")(root) if not head: head = etree.Element("head") body = _create_cssselector("body")(root)[0] body.getparent().insert(0, head) return head else: return head[0]
Ensures that `root` contains a <head> element and returns it.
16,782
def search(self, text, lookup=None): return self.query().search(text, lookup=lookup)
Returns a new :class:`Query` for :attr:`Manager.model` with a full text search value.
16,783
def revoke_token(self, token, headers=None, **kwargs): self._check_configuration("site", "revoke_uri") url = "%s%s" % (self.site, quote(self.revoke_url)) data = {: token} data.update(kwargs) return self._make_request(url, data=data, headers=headers)
Revoke an access token
16,784
def __call_api(self, path, params=None, api_url=FORECAST_URL): if not params: params = dict() payload = {: self.api_key} payload.update(params) url = "%s/%s" % (api_url, path) sess = se...
Call the datapoint api using the requests module
16,785
def plot_3d_dist(Z, X, Y, N=1000, AxisOffset=0, Angle=-40, LowLim=None, HighLim=None, show_fig=True): angle = Angle fig = _plt.figure(figsize=(8, 6)) ax = fig.add_subplot(111, projection=) y = Z[0:N] x = X[0:N] z = Y[0:N] ax.scatter(x, y, z, alpha=0.3) xlim = ax.get_xlim() yl...
Plots Z, X and Y as a 3d scatter plot with heatmaps of each axis pair. Parameters ---------- Z : ndarray Array of Z positions with time X : ndarray Array of X positions with time Y : ndarray Array of Y positions with time N : optional, int Number of time points t...
16,786
def trade_signals_handler(self, signals): alloc = {} if signals[] or signals[]: try: alloc, e_ret, e_risk = self.optimize( self.date, signals[], signals[], self._optimizer_parameters) exce...
Process buy and sell signals from the simulation
16,787
def _kwarg(self, kwargs, kwname, default=None): return kwargs.get(kwname) or \ self.settings.config.get(self.name, {}).get(kwname) or \ self.settings.config.get(, {}).get(kwname) or \ default
Resolves keyword arguments from constructor or :doc:`config`. .. note:: The keyword arguments take this order of precedence: 1. Arguments passed to constructor through the :func:`authomatic.login`. 2. Provider specific arguments from :doc:`config`. ...
16,788
def to_csv(weekmatrices, filename, digits=5): with open(filename, ) as f: w = csv.writer(f, lineterminator=) w.writerow([, , , , ]) def make_repr(item): if item is None: return None elif isinstance(item, float): return repr(round...
Exports a list of week-matrices to a specified filename in the CSV format. Parameters ---------- weekmatrices : list The week-matrices to export. filename : string Path for the exported CSV file.
16,789
def plot_clock_diagrams(self, colormap="summer"): cmap = plt.get_cmap(colormap) for res in self.topology_data.dict_of_plotted_res: colors = [cmap(i) for i in numpy.linspace(0, 1, len(self.topology_data.dict_of_plotted_res[res]))] traj_colors_ = {traj:colors[i] for i,traj...
Ploting clock diagrams - one or more rings around residue name and id (and chain id). The rings show the fraction of simulation time this residue has spent in the vicinity of the ligand - characterised by distance.
16,790
def get_attribute_values(self, att_name): lc = [] if not CPEComponent.is_valid_attribute(att_name): errmsg = "Invalid attribute name: {0}".format(att_name) raise ValueError(errmsg) for pk in CPE.CPE_PART_KEYS: elements = self.get(pk) fo...
Returns the values of attribute "att_name" of CPE Name. By default a only element in each part. :param string att_name: Attribute name to get :returns: List of attribute values :rtype: list :exception: ValueError - invalid attribute name
16,791
def list_vms_sub(access_token, subscription_id): endpoint = .join([get_rm_endpoint(), , subscription_id, , , COMP_API]) return do_get_next(endpoint, access_token)
List VMs in a subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of a list of VM model views.
16,792
def send_async(self, transaction, headers=None): return self.transport.forward_request( method=, path=self.path, json=transaction, params={: }, headers=headers)
Submit a transaction to the Federation with the mode `async`. Args: transaction (dict): the transaction to be sent to the Federation node(s). headers (dict): Optional headers to pass to the request. Returns: dict: The transaction sent to the Federati...
16,793
def collection_keys(coll, sep=): def _keys(x, pre=): for k in x: yield (pre + k) if isinstance(x[k], dict): for nested in _keys(x[k], pre + k + sep): yield nested return list(_keys(coll.find_one()))
Get a list of all (including nested) keys in a collection. Examines the first document in the collection. :param sep: Separator for nested keys :return: List of str
16,794
def extract(args): p = OptionParser(extract.__doc__) p.add_option("--format", default=False, action="store_true", help="enable flag to reformat header into a symbol separated list of constituent reads "+ \ "[default: %default]") p.add_option("--singlets", default=False, action="...
%prog extract [--options] ace_file Extract contigs from ace file and if necessary reformat header with a pipe(|) separated list of constituent reads.
16,795
def list_storage_accounts_rg(access_token, subscription_id, rgname): endpoint = .join([get_rm_endpoint(), , subscription_id, , rgname, , , STORAGE_API]) return do_get(endpoint, access_token)
List the storage accounts in the specified resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. Returns: HTTP response. JSON body list of storage accounts.
16,796
def display_monthly_returns(self): data = [[, , , , , , , , , , , , , ]] for k in self.return_table.index: r = self.return_table.loc[k].values data.append([k] + [fmtpn(x) for x in r]) print(tabulate(data, headers=))
Display a table containing monthly returns and ytd returns for every year in range.
16,797
def _get_rest_doc(self, request, start_response): api = request.body_json[] version = request.body_json[] generator = discovery_generator.DiscoveryGenerator(request=request) services = [s for s in self._backend.api_services if s.api_info.name == api and s.api_info.api_version == ve...
Sends back HTTP response with API directory. This calls start_response and returns the response body. It will return the discovery doc for the requested api/version. Args: request: An ApiRequest, the transformed request sent to the Discovery API. start_response: A function with semantics defi...
16,798
def _run_hooks(self, name, module): hooks = self.post_load_hooks.pop(name, []) for hook in hooks: hook(module)
Run all hooks for a module.
16,799
def RemoveObject(self, identifier): if identifier not in self._values: raise KeyError(.format( identifier)) del self._values[identifier]
Removes a cached object based on the identifier. This method ignores the cache value reference count. Args: identifier (str): VFS object identifier. Raises: KeyError: if the VFS object is not found in the cache.