Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
19,500
def range_(range, no_border, html): from .hand import Range border = not no_border result = Range(range).to_html() if html else Range(range).to_ascii(border) click.echo(result)
Prints the given range in a formatted table either in a plain ASCII or HTML. The only required argument is the range definition, e.g. "A2s+ A5o+ 55+"
19,501
def _compute(self): self.min_ = self._min or 0 self.max_ = self._max or 0 if self.max_ - self.min_ == 0: self.min_ -= 1 self.max_ += 1 self._box.set_polar_box(0, 1, self.min_, self.max_)
Compute y min and max and y scale and set labels
19,502
def deprecated(replacement=None, message=None): def wrap(old): def wrapped(*args, **kwargs): msg = "%s is deprecated" % old.__name__ if replacement is not None: if isinstance(replacement, property): r = replacement.fget elif i...
Decorator to mark classes or functions as deprecated, with a possible replacement. Args: replacement (callable): A replacement class or method. message (str): A warning message to be displayed. Returns: Original function, but with a warning to use the updated class.
19,503
def hget(self, hashkey, attribute): redis_hash = self._get_hash(hashkey, ) return redis_hash.get(self._encode(attribute))
Emulate hget.
19,504
def get_parser(): "Specifies the arguments and defaults, and returns the parser." parser = argparse.ArgumentParser(prog="hiwenet") parser.add_argument("-f", "--in_features_path", action="store", dest="in_features_path", required=True, help="Abs. path to file...
Specifies the arguments and defaults, and returns the parser.
19,505
def enabled(name, runas=None): ret = {: name, : True, : , : {}} try: plugin_enabled = __salt__[](name, runas=runas) except CommandExecutionError as err: ret[] = False ret[] = .format(err) return ret if plugin_enabled: ret[] = {0}\.format(name) retu...
Ensure the RabbitMQ plugin is enabled. name The name of the plugin runas The user to run the rabbitmq-plugin command as
19,506
def find_from(path): realpath = os.path.realpath(path) config_path = os.path.join(realpath, ) if os.path.isfile(config_path): return config_path elif realpath == os.path.abspath(): return None else: dirname = os.path.dirname(realpath)...
Find path of an .ensime config, searching recursively upward from path. Args: path (str): Path of a file or directory from where to start searching. Returns: str: Canonical path of nearest ``.ensime``, or ``None`` if not found.
19,507
def segment_intersection1(start0, end0, start1, end1, s): if NO_IMAGES: return line0 = bezier.Curve.from_nodes(stack1d(start0, end0)) line1 = bezier.Curve.from_nodes(stack1d(start1, end1)) ax = line0.plot(2) line1.plot(256, ax=ax) (x_val,), (y_val,) = line0.evaluate(s) ax.plot(...
Image for :func:`.segment_intersection` docstring.
19,508
def make_tuple(stream, tuple_key, values, roots=None): component_name = stream.component_name stream_id = stream.id gen_task = roots[0].taskid if roots is not None and len(roots) > 0 else None return HeronTuple(id=str(tuple_key), component=component_name, stream=stream_id, tas...
Creates a HeronTuple :param stream: protobuf message ``StreamId`` :param tuple_key: tuple id :param values: a list of values :param roots: a list of protobuf message ``RootId``
19,509
def elasticsearch_matcher(text_log_error): if not settings.ELASTICSEARCH_URL: return [] failure_line = text_log_error.metadata.failure_line if failure_line.action != "test_result" or not failure_line.message: logger.debug("Skipped elasticsearch matching") return filt...
Query Elasticsearch and score the results. Uses a filtered search checking test, status, expected, and the message as a phrase query with non-alphabet tokens removed.
19,510
def _get_dataruns(self): if self._data_runs is None: raise DataStreamError("Resident datastream don't have dataruns") if not self._data_runs_sorted: self._data_runs.sort(key=_itemgetter(0)) self._data_runs_sorted = True return [data[1] for data in s...
Returns a list of dataruns, in order.
19,511
def main(argv=None): if argv is None: argv = sys.argv parser = U.OptionParser(version="%prog version: $Id$", usage=usage, description=globals()["__doc__"]) group = U.OptionGroup(parser, "count_tab-specific options") group.add_...
script main. parses command line options in sys.argv, unless *argv* is given.
19,512
def IterateAllClientSnapshots(self, min_last_ping=None, batch_size=50000): all_client_ids = self.ReadAllClientIDs(min_last_ping=min_last_ping) for batch in collection.Batch(all_client_ids, batch_size): res = self.MultiReadClientSnapshot(batch) for snapshot in itervalues(res): if snapsh...
Iterates over all available clients and yields client snapshot objects. Args: min_last_ping: If provided, only snapshots for clients with last-ping timestamps newer than (or equal to) the given value will be returned. batch_size: Always reads <batch_size> snapshots at a time. Yields: ...
19,513
def _sendline(self, line): logging.info(, self.port) self._lines = [] try: self._read() except socket.error: logging.debug(, self.port) print % line self._write(line + ) time.sleep(0.1)
Send exactly one line to the device Args: line str: data send to device
19,514
def interp_value(mass, age, feh, icol, grid, mass_col, ages, fehs, grid_Ns): Nage = len(ages) Nfeh = len(fehs) ifeh = searchsorted(fehs, Nfeh, feh) iage = searchsorted(ages, Nage, age) pts = np.zeros((8,3)) vals = np.zeros(8) i_f = ifeh - 1 ...
mass, age, feh are *single values* at which values are desired icol is the column index of desired value grid is nfeh x nage x max(nmass) x ncols array mass_col is the column index of mass ages is grid of ages fehs is grid of fehs grid_Ns keeps track of nmass in each slice (beyond this are nans...
19,515
def validate_gcs_path(path, require_object): bucket, key = datalab.storage._bucket.parse_name(path) if bucket is None: raise Exception( % path) if require_object and key is None: raise Exception( % path)
Check whether a given path is a valid GCS path. Args: path: the config to check. require_object: if True, the path has to be an object path but not bucket path. Raises: Exception if the path is invalid
19,516
def view_dupl_sources(token, dstore): fields = [, , , , ] dic = group_array(dstore[].value[fields], ) sameid = [] dupl = [] for source_id, group in dic.items(): if len(group) > 1: sources = [] for rec in group: geom = dstore[][rec[]:rec[]] ...
Show the sources with the same ID and the truly duplicated sources
19,517
def open( self, fs_url, writeable=True, create=False, cwd=".", default_protocol="osfs", ): if "://" not in fs_url: fs_url = "{}://{}".format(default_protocol, fs_url) parse_result = parse_fs_url(fs_...
Open a filesystem from a FS URL. Returns a tuple of a filesystem object and a path. If there is no path in the FS URL, the path value will be `None`. Arguments: fs_url (str): A filesystem URL. writeable (bool, optional): `True` if the filesystem must be ...
19,518
def sepBy1(p, sep): return separated(p, sep, 1, maxt=float(), end=False)
`sepBy1(p, sep)` parses one or more occurrences of `p`, separated by `sep`. Returns a list of values returned by `p`.
19,519
def _save_json_file( self, file, val, pretty=False, compact=True, sort=True, encoder=None ): try: save_json_file(file, val, pretty, compact, sort, encoder) except: self.exception("Failed to save to {}".format(file)) raise IOError("Saving f...
Save data to json file :param file: Writable file or path to file :type file: FileIO | str | unicode :param val: Value or struct to save :type val: None | int | float | str | list | dict :param pretty: Format data to be readable (default: False) :type pretty: bool ...
19,520
def _format_text(self, text): text_width = max(self.width - self.current_indent, 11) indent = " "*self.current_indent return textwrap.fill(text, text_width, initial_indent=indent, subsequent_indent=in...
Format a paragraph of free-form text for inclusion in the help output at the current indentation level.
19,521
def constant_tuples(self): return [constant_tuple for tuple_prior in self.tuple_prior_tuples for constant_tuple in tuple_prior[1].constant_tuples] + self.direct_constant_tuples
Returns ------- constants: [(String, Constant)]
19,522
def energy(self, strand, dotparens, temp=37.0, pseudo=False, material=None, dangles=, sodium=1.0, magnesium=0.0): energy\dnarnarna1999none\some\A dangle energy is incorporated for each unpaired base flanking a duplex\all material = self._set_material(stran...
Calculate the free energy of a given sequence structure. Runs the \'energy\' command. :param strand: Strand on which to run energy. Strands must be either coral.DNA or coral.RNA). :type strand: coral.DNA or coral.RNA :param dotparens: The structure in dotparens no...
19,523
def _finalize_ticks(self, axis, element, xticks, yticks, zticks): yalignments = None if xticks is not None: ticks, labels, yalignments = zip(*sorted(xticks, key=lambda x: x[0])) xticks = (list(ticks), list(labels)) super(BarPlot, self)._finalize_ticks(axis, eleme...
Apply ticks with appropriate offsets.
19,524
def check_errors(self, response): " Check some common errors." content = response.content if not in content: raise self.GeneralError() if content[] == : response._content = content return if not in content: ...
Check some common errors.
19,525
def applyMassCalMs1(msrunContainer, specfile, dataFit, **kwargs): toleranceMode = kwargs.get(, ) if toleranceMode == : for si in msrunContainer.getItems(specfile, selector=lambda si: si.msLevel==1): mzArr = msrunContainer.saic[specfile][si.id]....
Applies a correction function to the MS1 ion m/z arrays in order to correct for a m/z dependent m/z error. :param msrunContainer: intance of :class:`maspy.core.MsrunContainer`, containing the :class:`maspy.core.Sai` items of the "specfile". :param specfile: filename of an ms-run file to which the m...
19,526
def _determine_scheduled_actions(scheduled_actions, scheduled_actions_from_pillar): tmp = copy.deepcopy( __salt__[](scheduled_actions_from_pillar, {}) ) if scheduled_actions: tmp = dictupdate.update(tmp, scheduled_actions) return tmp
helper method for present, ensure scheduled actions are setup
19,527
def toggle_spot_cfg(self): if self.app.manager.current == : dummyplace = self.screendummyplace self.ids.placetab.remove_widget(dummyplace) dummyplace.clear() if self.app.spotcfg.prefix: dummyplace.prefix = self.app.spotcfg.prefix ...
Show the dialog where you select graphics and a name for a place, or hide it if already showing.
19,528
def as_xml(self): result = ElementTree.Element(self.error_qname) result.append(deepcopy(self.condition)) if self.text: text = ElementTree.SubElement(result, self.text_qname) if self.language: text.set(XML_LANG_QNAME, self.language) tex...
Return the XML error representation. :returntype: :etree:`ElementTree.Element`
19,529
def register(self, lookup: Lookup, encoder: Encoder, decoder: Decoder, label: str=None) -> None: self.register_encoder(lookup, encoder, label=label) self.register_decoder(lookup, decoder, label=label)
Registers the given ``encoder`` and ``decoder`` under the given ``lookup``. A unique string label may be optionally provided that can be used to refer to the registration by name. :param lookup: A type string or type string matcher function (predicate). When the registry is querie...
19,530
def _wait_for_exec_ready(self): while not self.response_received.wait(1) and self.query_timeout != 0: if self.query_timeout != 0 and self.query_timeout < self.get_time(): if self.prev: cmd = self.prev.cmd else: cmd = "?...
Wait for response. :return: CliResponse object coming in :raises: TestStepTimeout, TestStepError
19,531
def gen(self): data_hash = self.get_hash() return "{prefix}{hash}".format(prefix=self._prefix, hash=data_hash)
Generate stable LogicalIds based on the prefix and given data. This method ensures that the logicalId is deterministic and stable based on input prefix & data object. In other words: logicalId changes *if and only if* either the `prefix` or `data_obj` changes Internally we simply use a SHA...
19,532
def post_signup(self, user, login_user=None, send_email=None): self.signup_signal.send(self, user=user) if (login_user is None and self.options["login_user_on_signup"]) or login_user: self._login(user, user.signup_provider) to_email = getattr(user, self.options["email_colu...
Executes post signup actions: sending the signal, logging in the user and sending the welcome email
19,533
def get_objectives(self): if self.retrieved: raise errors.IllegalState() self.retrieved = True return objects.ObjectiveList(self._results, runtime=self._runtime)
Gets the objective list resulting from the search. return: (osid.learning.ObjectiveList) - the objective list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.*
19,534
def get_unix_ioctl_terminal_size(): def ioctl_gwinsz(fd): try: import fcntl import termios import struct return struct.unpack(, fcntl.ioctl(fd, termios.TIOCGWINSZ, )) except (IOError, OSError): return None cr = ioctl_gwinsz(0) or ...
Get the terminal size of a UNIX terminal using the ioctl UNIX command.
19,535
def upload(self): if self.upload_method == "setup": self.upload_by_setup() if self.upload_method == "twine": self.upload_by_twine() if self.upload_method == "gemfury": self.upload_by_gemfury()
upload via the method configured :return:
19,536
def getChangeSets(self): changeset_tag = ("rtc_cm:com.ibm.team.filesystem.workitems." "change_set.com.ibm.team.scm.ChangeSet") return (self.rtc_obj ._get_paged_resources("ChangeSet", workitem_id=self.identif...
Get all the ChangeSets of this workitem :return: a :class:`list` contains all the :class:`rtcclient.models.ChangeSet` objects :rtype: list
19,537
async def get_object(self, Bucket: str, Key: str, **kwargs) -> dict: if self._s3_client is None: await self.setup() return s3_response
S3 GetObject. Takes same args as Boto3 documentation Decrypts any CSE :param Bucket: S3 Bucket :param Key: S3 Key (filepath) :return: returns same response as a normal S3 get_object
19,538
def wrsamp(self, expanded=False, write_dir=): self.wrheader(write_dir=write_dir) if self.n_sig > 0: self.wr_dats(expanded=expanded, write_dir=write_dir)
Write a wfdb header file and any associated dat files from this object. Parameters ---------- expanded : bool, optional Whether to write the expanded signal (e_d_signal) instead of the uniform signal (d_signal). write_dir : str, optional The d...
19,539
def as_ul(self, show_leaf=True, current_linkable=False, class_current="active_link"): return self.__do_menu("as_ul", show_leaf, current_linkable, class_current)
It returns breadcrumb as ul
19,540
def _fuzzy_custom_query(issn, titles): custom_queries = journal_titles.load(issn).get(, []) titles = [{: i} for i in titles if i not in [x[] for x in custom_queries]] titles.extend(custom_queries) for item in titles: if len(item[].strip()) == 0: con...
Este metodo constroi a lista de filtros por título de periódico que será aplicada na pesquisa boleana como match por similaridade "should". A lista de filtros é coletada do template de pesquisa customizada do periódico, quanto este template existir.
19,541
def public_copy(self): d = dict(chain_code=self._chain_code, depth=self._depth, parent_fingerprint=self._parent_fingerprint, child_index=self._child_index, public_pair=self.public_pair()) return self.__class__(**d)
Yield the corresponding public node for this node.
19,542
def get(self, request, bot_id, id, format=None): return super(HookDetail, self).get(request, bot_id, id, format)
Get hook by id --- serializer: HookSerializer responseMessages: - code: 401 message: Not authenticated
19,543
def cmd_show(docid): dsearch = get_docsearch() doc = dsearch.get(docid) r = { : str(type(doc)), : doc.nb_pages, : [l.name for l in doc.labels], : _get_first_line(doc), : [] } for page in doc.pages: nb_lines = 0 nb_words = 0 for lin...
Arguments: <doc_id> Show document information (but not its content, see 'dump'). See 'search' for the document id. Possible JSON replies: -- { "status": "error", "exception": "yyy", "reason": "xxxx", "args": "(xxxx, )" } -- { "sta...
19,544
def make_witness_input_and_witness(outpoint, sequence, stack=None, **kwargs): if in riemann.get_current_network_name(): return(make_witness_input(outpoint, sequence), make_decred_witness(value=kwargs[], height=kwargs[...
Outpoint, int, list(bytearray) -> (Input, InputWitness)
19,545
def result(self): return {k: torch.stack(v) for k, v in self.accumulants.items()}
Concatenate accumulated tensors
19,546
def describe_keypairs(self, *keypair_names): keypairs = {} for index, keypair_name in enumerate(keypair_names): keypairs["KeyName.%d" % (index + 1)] = keypair_name query = self.query_factory( action="DescribeKeyPairs", creds=self.creds, endpoint=self....
Returns information about key pairs available.
19,547
def subprogram_prototype(vo): plist = .join(str(p) for p in vo.parameters) if isinstance(vo, VhdlFunction): if len(vo.parameters) > 0: proto = .format(vo.name, plist, vo.return_type) else: proto = .format(vo.name, vo.return_type) else: proto = .format(vo.name, plist) return proto
Generate a canonical prototype string Args: vo (VhdlFunction, VhdlProcedure): Subprogram object Returns: Prototype string.
19,548
def create_table(cls): schema_editor = getattr(connection, , None) if schema_editor: with schema_editor() as schema_editor: schema_editor.create_model(cls) else: raw_sql, _ = connection.creation.sql_create_model( cls, ...
create_table Manually create a temporary table for model in test data base. :return:
19,549
def find(self, title): files = backend.iterfiles(self._drive, name=title) try: return next(self[id] for id, _ in files) except StopIteration: raise KeyError(title)
Fetch and return the first spreadsheet with the given title. Args: title(str): title/name of the spreadsheet to return Returns: SpreadSheet: new SpreadSheet instance Raises: KeyError: if no spreadsheet with the given ``title`` is found
19,550
def tgread_bool(self): value = self.read_int(signed=False) if value == 0x997275b5: return True elif value == 0xbc799737: return False else: raise RuntimeError(.format(hex(value)))
Reads a Telegram boolean value.
19,551
def delete_queue(queues): current_queues.delete(queues=queues) click.secho( .format( queues or current_queues.queues.keys()), fg= )
Delete the given queues.
19,552
def random_filter(objects, reduction_factor, seed=42): assert 0 < reduction_factor <= 1, reduction_factor rnd = random.Random(seed) out = [] for obj in objects: if rnd.random() <= reduction_factor: out.append(obj) return out
Given a list of objects, returns a sublist by extracting randomly some elements. The reduction factor (< 1) tells how small is the extracted list compared to the original list.
19,553
def pos(self): if self._pos is None: tr = self.visual.get_transform(, ) self._pos = tr.map(self.mouse_event.pos) return self._pos
The position of this event in the local coordinate system of the visual.
19,554
def _get_owner_cover_photo_upload_server(session, group_id, crop_x=0, crop_y=0, crop_x2=795, crop_y2=200): group_id = abs(group_id) response = session.fetch("photos.getOwnerCoverPhotoUploadServer", group_id=group_id, crop_x=crop_x, crop_y=crop_y, crop_x2=crop_x2, crop_y2=crop_y2) return...
https://vk.com/dev/photos.getOwnerCoverPhotoUploadServer
19,555
def parse(self, rrstr): if self._initialized: raise pycdlibexception.PyCdlibInternalError() (su_len, su_entry_version_unused, check_byte1, check_byte2, self.bytes_to_skip) = struct.unpack_from(, rrstr[:7], 2) self._initialized = True
Parse a Rock Ridge Sharing Protocol record out of a string. Parameters: rrstr - The string to parse the record out of. Returns: Nothing.
19,556
def _get_aggregated_node_list(self, data): node_list = [] for node in data: local_addresses = [node[]] if in node: local_addresses += node[] node_list.append(local_addresses) return node_list
Returns list of main and secondary mac addresses.
19,557
def color_from_hls(hue, light, sat): if light > 0.95: return -1 else: hue = (-hue + 1 + 2.0/3.0) % 1 return int(floor(hue * 256))
Takes a hls color and converts to proper hue Bulbs use a BGR order instead of RGB
19,558
def delay(self, seconds=0, minutes=0): minutes += int(seconds / 60) seconds = seconds % 60 seconds += float(minutes * 60) self.robot.pause() if not self.robot.is_simulating(): _sleep(seconds) self.robot.resume() return self
Parameters ---------- seconds: float The number of seconds to freeze in place.
19,559
def __request_mark_sent(self, requestId): with self.__requests: try: req = self.__requests[requestId] except KeyError: pass else: req.exception = None req._send_time = monotonic()
Set send time & clear exception from request if set, ignoring non-existent requests
19,560
async def build_proof_req_json(self, cd_id2spec: dict, cache_only: bool = False) -> str: LOGGER.debug(, cd_id2spec, cache_only) cd_id2schema = {} now = int(time()) proof_req = { : str(int(time())), : , : , : {}, : {} ...
Build and return indy-sdk proof request for input attributes and timestamps by cred def id. Raise AbsentInterval if caller specifies cache_only and default non-revocation intervals, but revocation cache does not have delta frames for any revocation registries on a specified cred def. :param cd...
19,561
def result(self, state, action): rows = string_to_list(state) row_e, col_e = find_location(rows, ) row_n, col_n = find_location(rows, action) rows[row_e][col_e], rows[row_n][col_n] = rows[row_n][col_n], rows[row_e][col_e] return list_to_string(rows)
Return the resulting state after moving a piece to the empty space. (the "action" parameter contains the piece to move)
19,562
def _iso_handler(obj): if hasattr(obj, ): result = obj.isoformat() else: raise TypeError("Unserializable object {} of type {}".format(obj, type(obj))) return result
Transforms an object into it's ISO format, if possible. If the object can't be transformed, then an error is raised for the JSON parser. This is meant to be used on datetime instances, but will work with any object having a method called isoformat. :param obj: object to transform into it's ISO fo...
19,563
def get_advances_declines(self, as_json=False): url = self.advances_declines_url req = Request(url, None, self.headers) resp = self.opener.open(req) resp = byte_adaptor(resp) resp_dict = json.load(resp) resp_list = [self.clean_server_re...
:return: a list of dictionaries with advance decline data :raises: URLError, HTTPError
19,564
def is_avro(path_or_buffer): if is_str(path_or_buffer): fp = open(path_or_buffer, ) close = True else: fp = path_or_buffer close = False try: header = fp.read(len(MAGIC)) return header == MAGIC finally: if close: fp.close()
Return True if path (or buffer) points to an Avro file. Parameters ---------- path_or_buffer: path to file or file-like object Path to file
19,565
def sendhello(self): try: cli_hello_msg = "<hello>\n" +\ " <capabilities>\n" +\ " <capability>urn:ietf:params:netconf:base:1.0</capability>\n" +\ " </capabilities>\n" +\ ...
end of function exchgcaps
19,566
def field(self, name): if self.fields.has_key(name): return self.fields[name] elif self.extends: if not self.parent: self.parent = self.contract.struct(self.extends) return self.parent.field(name) else: return None
Returns the field on this struct with the given name. Will try to find this name on all ancestors if this struct extends another. If found, returns a dict with keys: 'name', 'comment', 'type', 'is_array' If not found, returns None :Parameters: name string name of...
19,567
def create_marking_iobject(self, uid=None, timestamp=timezone.now(), metadata_dict=None, id_namespace_uri=DINGOS_DEFAULT_ID_NAMESPACE_URI, iobject_family_name=DINGOS...
A specialized version of create_iobject with defaults set such that a default marking object is created.
19,568
def _check_samples_line(klass, arr): if len(arr) <= len(REQUIRE_NO_SAMPLE_HEADER): if tuple(arr) != REQUIRE_NO_SAMPLE_HEADER: raise exceptions.IncorrectVCFFormat( "Sample header line indicates no sample but does not " "equal required p...
Peform additional check on samples line
19,569
def user_lookup(self, ids, id_type="user_id"): if id_type not in [, ]: raise RuntimeError("id_type must be user_id or screen_name") if not isinstance(ids, types.GeneratorType): ids = iter(ids) lookup_ids = [] def do_lookup(): ids...
A generator that returns users for supplied user ids, screen_names, or an iterator of user_ids of either. Use the id_type to indicate which you are supplying (user_id or screen_name)
19,570
def _generate_type_code_query(self, value): mapping_for_value = self.TYPECODE_VALUE_TO_FIELD_AND_VALUE_PAIRS_MAPPING.get(value, None) if mapping_for_value: return generate_match_query(*mapping_for_value, with_operator_and=True) else: return { : {...
Generate type-code queries. Notes: If the value of the type-code query exists in `TYPECODE_VALUE_TO_FIELD_AND_VALUE_PAIRS_MAPPING, then we query the specified field, along with the given value according to the mapping. See: https://github.com/inspirehep/inspire-query-parser/...
19,571
def convert_rect(self, rect): return self.container.convert_rect(rect.move(self.pos))
Converts the relative position of @rect into an absolute position.To be used for event considerations, blitting is handled directly by the Container().
19,572
def inspiral_range(psd, snr=8, mass1=1.4, mass2=1.4, fmin=None, fmax=None, horizon=False): mass1 = units.Quantity(mass1, ).to() mass2 = units.Quantity(mass2, ).to() mtotal = mass1 + mass2 fisco = (constants.c ** 3 / (constants.G * 6**1.5 * pi * mtotal)).to() fmax ...
Calculate the inspiral sensitive distance from a GW strain PSD The method returns the distance (in megaparsecs) to which an compact binary inspiral with the given component masses would be detectable given the instrumental PSD. The calculation is as defined in: https://dcc.ligo.org/LIGO-T030276/public...
19,573
def do_stack(self,args): parser = CommandArgumentParser("stack") parser.add_argument(dest=,help=); args = vars(parser.parse_args(args)) print "loading stack {}".format(args[]) try: index = int(args[]) stackSummary = self.wrappedStack[...
Go to the specified stack. stack -h for detailed help.
19,574
def all_instr(self, start, end, instr, target=None, include_beyond_target=False): code = self.code assert(start >= 0 and end <= len(code)) try: None in instr except: instr = [instr] result = [] extended_arg = 0 for offset in sel...
Find all `instr` in the block from start to end. `instr` is any Python opcode or a list of opcodes If `instr` is an opcode with a target (like a jump), a target destination can be specified which must match precisely. Return a list with indexes to them or [] if none found.
19,575
def update_config(self, d): for key, value in d.items(): if hasattr(self, key): if key == "requirements": items, value = value, [] for item in items: if isinstance(item, basestring): ...
Updates the config object. :param d: dict
19,576
def list_all_zip_codes_geo_zones(cls, **kwargs): kwargs[] = True if kwargs.get(): return cls._list_all_zip_codes_geo_zones_with_http_info(**kwargs) else: (data) = cls._list_all_zip_codes_geo_zones_with_http_info(**kwargs) return data
List ZipCodesGeoZones Return a list of ZipCodesGeoZones This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.list_all_zip_codes_geo_zones(async=True) >>> result = thread.get() :param async...
19,577
def _register_elements(self, elements): self.elements = elements for key, obj in elements.items(): obj.contribute_to_class(self.metadata, key) fields = {} for key, obj in elements.items(): if obj.editable: field = obj.get_field(...
Takes elements from the metadata class and creates a base model for all backend models .
19,578
def tlog_inv(y, th=1, r=_display_max, d=_l_mmax): if th <= 0: raise ValueError( % th) x = 10 ** (y * 1. * d / r) try: x[x < th] = th except TypeError: if x < th: x = th return x
Inverse truncated log10 transform. Values Parameters ---------- y : num | num iterable values to be transformed. th : num Inverse values below th are transormed to th. Must be > positive. r : num (default = 10**4) maximal transformed value. d : num (default =...
19,579
def adjustWPPointer(self): self.headingWPText.set_size(self.fontSize) headingRotate = mpl.transforms.Affine2D().rotate_deg_around(0.0,0.0,-self.wpBearing+self.heading)+self.axes.transData self.headingWPText.set_transform(headingRotate) angle = self.wpBearing - self.heading ...
Adjust the position and orientation of the waypoint pointer.
19,580
def get_summarizer(self, name): if name in self.summarizers: pass elif name == : from . import lexrank self.summarizers[name] = lexrank.summarize elif name == : from . import mcp_summ self.summarizers[name] = mcp_summ.summarize...
import summarizers on-demand
19,581
def _get_object_from_python_path(python_path): python_path = python_path.split() module_path = python_path[:-1] object_class = python_path[-1] if isinstance(module_path, list): module_path = .join(module_path) module = import_module(module...
Method that will fetch a Marshmallow schema from a path to it. Args: python_path (str): The string path to the Marshmallow schema. Returns: marshmallow.Schema: The schema matching the provided path. Raises: TypeError: This is raised if the specified object ...
19,582
def _Reg2Py(data, size, data_type): if data_type == winreg.REG_DWORD: if size == 0: return 0 return ctypes.cast(data, ctypes.POINTER(ctypes.c_uint32)).contents.value elif data_type == winreg.REG_SZ or data_type == winreg.REG_EXPAND_SZ: return ctypes.wstring_at(data, size // 2).rstrip(...
Converts a Windows Registry value to the corresponding Python data type.
19,583
def get_instance(self, payload): return ReservationInstance( self._version, payload, workspace_sid=self._solution[], task_sid=self._solution[], )
Build an instance of ReservationInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationInstance
19,584
def fit(self, X): logger.info() if 0.0 >= self.lam: raise ValueError("Gamma parameter should be positive.") if len(X) <= 1: raise ValueError("There are not enough subjects in the input " "data to train the model.")...
Compute the Robust Shared Response Model Parameters ---------- X : list of 2D arrays, element i has shape=[voxels_i, timepoints] Each element in the list contains the fMRI data of one subject.
19,585
def read_saved_screenshot_to_array(self, screen_id, bitmap_format): if not isinstance(screen_id, baseinteger): raise TypeError("screen_id can only be an instance of type baseinteger") if not isinstance(bitmap_format, BitmapFormat): raise TypeError("bitmap_format can only...
Screenshot in requested format is retrieved to an array of bytes. in screen_id of type int Saved guest screen to read from. in bitmap_format of type :class:`BitmapFormat` The requested format. out width of type int Image width. out height of type i...
19,586
def modulate(data): seconds_per_sample = 1.0 / audiogen.sampler.FRAME_RATE phase, seconds, bits = 0, 0, 0 clock = (x / BAUD_RATE for x in itertools.count(1)) tones = (MARK_HZ if bit else SPACE_HZ for bit in data) for boundary, frequency in itertools.izip(clock, tones): phase_change_per_sample = TWO_P...
Generate Bell 202 AFSK samples for the given symbol generator Consumes raw wire symbols and produces the corresponding AFSK samples.
19,587
def assemble( iterable, patterns=None, minimum_items=2, case_sensitive=True, assume_padded_when_ambiguous=False ): collectionsremainder collection_map = defaultdict(set) collections = [] remainder = [] flags = 0 if not case_sensitive: flags |= re.IGNORECASE compiled_pa...
Assemble items in *iterable* into discreet collections. *patterns* may be specified as a list of regular expressions to limit the returned collection possibilities. Use this when interested in collections that only match specific patterns. Each pattern must contain the expression from :py:data:`DIGITS_...
19,588
def initialize_segment_register_x64(self, state, concrete_target): _l.debug("Synchronizing gs segment register") state.regs.gs = self._read_gs_register_x64(concrete_target)
Set the gs register in the angr to the value of the fs register in the concrete process :param state: state which will be modified :param concrete_target: concrete target that will be used to read the fs register :return: None
19,589
def get_rlzs_by_gsim(oqparam): cinfo = source.CompositionInfo.fake(get_gsim_lt(oqparam)) ra = cinfo.get_rlzs_assoc() dic = {} for rlzi, gsim_by_trt in enumerate(ra.gsim_by_trt): dic[gsim_by_trt[]] = [rlzi] return dic
Return an ordered dictionary gsim -> [realization index]. Work for gsim logic trees with a single tectonic region type.
19,590
def create(self, date_at=None, minutes=0, note=, user_id=None, project_id=None, service_id=None): keywords = { : date_at, : minutes, : note, : user_id, : project_id, : service_id, } foo = dict() ...
date_at - date of time entry. Format YYYY-MM-DD. default: today minutes - default: 0 note - default: '' (empty string) user_id - default: actual user id (only admin users can edit this) project_id - default: None service_id - default: None
19,591
def resource_get(self, resource_name): try: with self._resource_lock: res = self._resources[resource_name] except KeyError: return {} return res
Return resource info :param resource_name: Resource name as returned by resource_get_list() :type resource_name: str :return: Resource information (empty if not found) name: Resource name hash: Resource hash path: Path to resource checked: Last ti...
19,592
def lambda_handler(event, context): auth = check_auth(event, role=["admin"]) if not auth[]: return auth table = boto3.resource("dynamodb").Table(os.environ[]) results = table.scan() output = {: True, : list(), : 0} for item in results.get(, list()): output[].append(item) ...
Main handler.
19,593
def user_segment(self): if self.api and self.user_segment_id: return self.api._get_user_segment(self.user_segment_id)
| Comment: The id of the user segment to which this section belongs
19,594
def parse_sv_frequencies(variant): frequency_keys = [ , , , , , , , , , ] sv_frequencies = {} for key in frequency_keys: value = variant.INFO.get(key, 0) if in key: value = float(value) ...
Parsing of some custom sv frequencies These are very specific at the moment, this will hopefully get better over time when the field of structural variants is more developed. Args: variant(cyvcf2.Variant) Returns: sv_frequencies(dict)
19,595
def iter_issue_events(self, number=-1, etag=None): url = self._build_url(, , base_url=self._api) return self._iter(int(number), url, IssueEvent, etag=etag)
Iterates over issue events on this repository. :param int number: (optional), number of events to return. Default: -1 returns all available events :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Is...
19,596
def usage(ecode, msg=): print >> sys.stderr, __doc__ if msg: print >> sys.stderr, msg sys.exit(ecode)
Print usage and msg and exit with given code.
19,597
def set_coords(self, names, inplace=None): inplace = _check_inplace(inplace) if isinstance(names, str): names = [names] self._assert_all_in_dataset(names) obj = self if inplace else self.copy() obj._coord_names.update(names...
Given names of one or more variables, set them as coordinates Parameters ---------- names : str or list of str Name(s) of variables in this dataset to convert into coordinates. inplace : bool, optional If True, modify this dataset inplace. Otherwise, create a new...
19,598
def add_consumer_tag(self, tag): if not is_string(tag): raise AMQPChannelError() if tag not in self._consumer_tags: self._consumer_tags.append(tag)
Add a Consumer tag. :param str tag: Consumer tag. :return:
19,599
def file_or_filename(input): if isinstance(input, string_types): yield smart_open(input) else: input.seek(0) yield input
Return a file-like object ready to be read from the beginning. `input` is either a filename (gz/bz2 also supported) or a file-like object supporting seek.