Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
6,900 | def make_tophat_ee (lower, upper):
if not np.isfinite (lower):
raise ValueError ( % lower)
if not np.isfinite (upper):
raise ValueError ( % upper)
def range_tophat_ee (x):
x = np.asarray (x)
x1 = np.atleast_1d (x)
r = ((lower < x1) & (x1 < upper)).astype (x.dtyp... | Return a ufunc-like tophat function on the defined range, left-exclusive
and right-exclusive. Returns 1 if lower < x < upper, 0 otherwise. |
6,901 | def _get_type(self, obj):
typever = obj[]
typesplit = typever.split()
return typesplit[0] + + typesplit[1] | Return the type of an object. |
6,902 | def cov_pmrapmdec_to_pmllpmbb(cov_pmradec,ra,dec,degree=False,epoch=2000.0):
if len(cov_pmradec.shape) == 3:
out= sc.zeros(cov_pmradec.shape)
ndata= out.shape[0]
lb = radec_to_lb(ra,dec,degree=degree,epoch=epoch)
for ii in range(ndata):
out[ii,:,:]= cov_pmradec_to_pm... | NAME:
cov_pmrapmdec_to_pmllpmbb
PURPOSE:
propagate the proper motions errors through the rotation from (ra,dec) to (l,b)
INPUT:
covar_pmradec - uncertainty covariance matrix of the proper motion in ra (multplied with cos(dec)) and dec [2,2] or [:,2,2]
ra - right ascension
... |
6,903 | def getOverlayTexture(self, ulOverlayHandle, pNativeTextureRef):
fn = self.function_table.getOverlayTexture
pNativeTextureHandle = c_void_p()
pWidth = c_uint32()
pHeight = c_uint32()
pNativeFormat = c_uint32()
pAPIType = ETextureType()
pColorSpace = ECol... | Get the native texture handle/device for an overlay you have created.
On windows this handle will be a ID3D11ShaderResourceView with a ID3D11Texture2D bound.
* The texture will always be sized to match the backing texture you supplied in SetOverlayTexture above.
* You MUST call ReleaseNativeOver... |
6,904 | def set_block(arr, arr_block):
nr_col = arr.shape[1]
nr_row = arr.shape[0]
nr_col_block = arr_block.shape[1]
nr_row_block = arr_block.shape[0]
if np.mod(nr_row, nr_row_block) or np.mod(nr_col, nr_col_block):
raise ValueError(
)
if nr_row/nr_row_block != nr... | Sets the diagonal blocks of an array to an given array
Parameters
----------
arr : numpy ndarray
the original array
block_arr : numpy ndarray
the block array for the new diagonal
Returns
-------
numpy ndarray (the modified array) |
6,905 | def delete_commit_branches(self, enrich_backend):
fltr = % self.perceval_backend.origin
es_query = % fltr
index = enrich_backend.elastic.index_url
r = self.requests.post(index + "/_update_by_query?refresh", data=es_query, headers=HEADER_JSON, verify=False)
t... | Delete the information about branches from the documents representing
commits in the enriched index.
:param enrich_backend: the enrich backend |
6,906 | def sort_by_decreasing_count(self):
words = [w for w, ct in self._counts.most_common()]
v = self.subset(words)
return v | Return a **new** `Vocab` object that is ordered by decreasing count.
The word at index 1 will be most common, the word at index 2 will be
next most common, and so on.
:return: A new vocabulary sorted by decreasing count.
NOTE: UNK will remain at index 0, regardless of its frequency. |
6,907 | def image_path_from_index(self, index):
assert self.image_set_index is not None, "Dataset not initialized"
pos = self.image_set_index[index]
n_db, n_index = self._locate_index(index)
return self.imdbs[n_db].image_path_from_index(n_index) | given image index, find out full path
Parameters
----------
index: int
index of a specific image
Returns
----------
full path of this image |
6,908 | def enable_tracing(self):
if not self.connected:
raise HardwareError("Cannot enable tracing if we are not in a connected state")
if self._traces is not None:
_clear_queue(self._traces)
return self._traces
self._traces = queue.Queue()
self._... | Open the tracing interface and accumulate traces in a queue.
This method is safe to call multiple times in a single device
connection. There is no way to check if the tracing interface is
opened or to close it once it is opened (apart from disconnecting from
the device).
The fi... |
6,909 | def make_tophat_ie (lower, upper):
if not np.isfinite (lower):
raise ValueError ( % lower)
if not np.isfinite (upper):
raise ValueError ( % upper)
def range_tophat_ie (x):
x = np.asarray (x)
x1 = np.atleast_1d (x)
r = ((lower <= x1) & (x1 < upper)).astype (x.dty... | Return a ufunc-like tophat function on the defined range, left-inclusive
and right-exclusive. Returns 1 if lower <= x < upper, 0 otherwise. |
6,910 | def add(
self, job, job_add_options=None, custom_headers=None, raw=False, **operation_config):
timeout = None
if job_add_options is not None:
timeout = job_add_options.timeout
client_request_id = None
if job_add_options is not None:
client_req... | Adds a job to the specified account.
The Batch service supports two ways to control the work done as part of
a job. In the first approach, the user specifies a Job Manager task.
The Batch service launches this task when it is ready to start the job.
The Job Manager task controls all oth... |
6,911 | def get_input_list_from_task(task, placeholder_dict):
try:
if not isinstance(task, Task):
raise TypeError(expected_type=Task, actual_type=type(task))
input_data = []
if task.link_input_data:
for path in task.link_input_data:
path = resolve_p... | Purpose: Parse a Task object to extract the files to be staged as the output.
Details: The extracted data is then converted into the appropriate RP directive depending on whether the data
is to be copied/downloaded.
:arguments:
:task: EnTK Task object
:placeholder_dict: dictionary holding ... |
6,912 | def emit_data_changed(self):
item = self.get_treeitem()
m = item.get_model()
if m:
start = m.index_of_item(item)
parent = start.parent()
end = m.index(start.row(), item.column_count()-1, parent)
m.dataChanged.emit(start, end) | Emit the data changed signal on the model of the treeitem
if the treeitem has a model.
:returns: None
:rtype: None
:raises: None |
6,913 | def log_html(self, log) -> str:
if not self.omit_loglevel(log["status"]):
emoticon = EMOTICON[log["status"]]
status = log["status"]
message = html.escape(log["message"]).replace("\n", "<br/>")
return (
"<li class=>"
f"<span... | Return single check sub-result string as HTML or not if below log
level. |
6,914 | def find_dependencies(self, depslock_file_path, property_validate=True, deps_content=None):
self._raw = [x for x in
self._downloader.common_parser.iter_packages_params(depslock_file_path, deps_content=deps_content)]
self.packages = self._downloader.get_dependency_packages({... | Find all dependencies by package
:param depslock_file_path:
:param property_validate: for `root` packages we need check property, bad if we find packages from `lock` file,
:param deps_content: HACK for use --dependencies-content and existed dependencies.txt.lock file
we can skip validate... |
6,915 | def get_element_centroids(self):
centroids = np.vstack((
np.mean(self.grid[], axis=1), np.mean(self.grid[], axis=1)
)).T
return centroids | return the central points of all elements
Returns
-------
Nx2 array
x/z coordinates for all (N) elements |
6,916 | def is_functional(cls):
if not cls._tested:
cls._tested = True
np.random.seed(SEED)
test_problem_dimension = 10
mat = np.random.randn(test_problem_dimension, test_problem_dimension)
posmat = mat.dot(mat.T)
posvar = cvxpy.Variable(t... | Checks lazily whether a convex solver is installed that handles positivity constraints.
:return: True if a solver supporting positivity constraints is installed.
:rtype: bool |
6,917 | def level_matches(self, level, consumer_level):
if isinstance(level, slice):
start, stop = level.start, level.stop
if start is not None and start > consumer_level:
return False
if stop is not None and stop <= consumer_level:
return Fal... | >>> l = Logger([])
>>> l.level_matches(3, 4)
False
>>> l.level_matches(3, 2)
True
>>> l.level_matches(slice(None, 3), 3)
False
>>> l.level_matches(slice(None, 3), 2)
True
>>> l.level_matches(slice(1, 3), 1)
True
>>> l.level_matches(... |
6,918 | def timing(function):
@wraps(function)
def wrapped(*args, **kwargs):
start_time = time.time()
ret = function(*args, **salt.utils.args.clean_kwargs(**kwargs))
end_time = time.time()
if function.__module__.startswith():
mod_name = function.__module__[16:]
e... | Decorator wrapper to log execution time, for profiling purposes |
6,919 | def _get_site_type_dummy_variables(self, sites):
ssa = np.zeros(len(sites.vs30))
ssb = np.zeros(len(sites.vs30))
ssd = np.zeros(len(sites.vs30))
idx = (sites.vs30 < 180.0)
ssd[idx] = 1.0
idx = (sites.vs30 >= 360.0) & (sites.vs30 < 800.0)
... | Get site type dummy variables, which classified the sites into
different site classes based on the shear wave velocity in the
upper 30 m (Vs30) according to the EC8 (CEN 2003):
class A: Vs30 > 800 m/s
class B: Vs30 = 360 - 800 m/s
class C*: Vs30 = 180 - 360 m/s
class D: V... |
6,920 | def get_proteins_for_db(fastafn):
objects = {}
for record in parse_fasta(fastafn):
objects[parse_protein_identifier(record)] = record
return (((acc,) for acc in list(objects)),
((acc, str(record.seq)) for acc, record in objects.items()),
((acc, get_uniprot_evidence_level... | Runs through fasta file and returns proteins accession nrs, sequences
and evidence levels for storage in lookup DB. Duplicate accessions in
fasta are accepted and removed by keeping only the last one. |
6,921 | def closest(self):
current = self.tag
closest = None
while closest is None and current is not None:
if self.match(current):
closest = current
else:
current = self.get_parent(current)
return closest | Match closest ancestor. |
6,922 | def add_command_formatting(self, command):
if command.description:
self.paginator.add_line(command.description, empty=True)
signature = self.get_command_signature(command)
if command.aliases:
self.paginator.add_line(signature)
self.add_aliases_forma... | A utility function to format commands and groups.
Parameters
------------
command: :class:`Command`
The command to format. |
6,923 | def get_urn(self):
urn = self.ecrm_P1_is_identified_by.one
try:
return CTS_URN(urn)
except Exception, e:
raise e | TODO |
6,924 | def search_dashboard_for_facet(self, facet, **kwargs):
kwargs[] = True
if kwargs.get():
return self.search_dashboard_for_facet_with_http_info(facet, **kwargs)
else:
(data) = self.search_dashboard_for_facet_with_http_info(facet, **kwargs)
return ... | Lists the values of a specific facet over the customer's non-deleted dashboards # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.search_dashboard_for_facet(facet, async... |
6,925 | def chat(self, id):
json = self.skype.conn("GET", "{0}/users/ME/conversations/{1}".format(self.skype.conn.msgsHost, id),
auth=SkypeConnection.Auth.RegToken, params={"view": "msnp24Equivalent"}).json()
cls = SkypeSingleChat
if "threadProperties" in json:
... | Get a single conversation by identifier.
Args:
id (str): single or group chat identifier |
6,926 | def write_pdf_files(args, infilenames, outfilename):
if not outfilename.endswith():
outfilename = outfilename +
outfilename = overwrite_file_check(args, outfilename)
options = {}
try:
if args[]:
infilename = infilenames[0]
if not a... | Write pdf file(s) to disk using pdfkit.
Keyword arguments:
args -- program arguments (dict)
infilenames -- names of user-inputted and/or downloaded files (list)
outfilename -- name of output pdf file (str) |
6,927 | def _parse_ISBN_EAN(details):
isbn_ean = _get_td_or_none(
details,
"ctl00_ContentPlaceHolder1_tblRowIsbnEan"
)
if not isbn_ean:
return None, None
ean = None
isbn = None
if "/" in isbn_ean:
isbn, ean = isbn_ean.split("/")
isbn = isbn.strip()
... | Parse ISBN and EAN.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(ISBN, EAN): Tuple with two string or two None. |
6,928 | def _netstat_sunos():
log.warning()
ret = []
for addr_family in (, ):
cmd = .format(addr_family)
out = __salt__[](cmd, python_shell=True)
for line in out.splitlines():
comps = line.split()
ret.append({
: if addr_family == else ... | Return netstat information for SunOS flavors |
6,929 | def get_value(self, **kwargs):
key = tuple(kwargs[group] for group in self.groups)
if key not in self.data:
self.data[key] = 0
return self.data[key] | Return the value for a specific key. |
6,930 | def reread(user=None, conf_file=None, bin_env=None):
s configuration files
user
user to run supervisorctl as
conf_file
path to supervisord config file
bin_env
path to supervisorctl bin or path to virtualenv with supervisor
installed
CLI Example:
.. code-block::... | Reload the daemon's configuration files
user
user to run supervisorctl as
conf_file
path to supervisord config file
bin_env
path to supervisorctl bin or path to virtualenv with supervisor
installed
CLI Example:
.. code-block:: bash
salt '*' supervisord.rer... |
6,931 | def compute_venn2_colors(set_colors):
rg
ccv = ColorConverter()
base_colors = [np.array(ccv.to_rgb(c)) for c in set_colors]
return (base_colors[0], base_colors[1], mix_colors(base_colors[0], base_colors[1])) | Given two base colors, computes combinations of colors corresponding to all regions of the venn diagram.
returns a list of 3 elements, providing colors for regions (10, 01, 11).
>>> compute_venn2_colors(('r', 'g'))
(array([ 1., 0., 0.]), array([ 0. , 0.5, 0. ]), array([ 0.7 , 0.35, 0. ])) |
6,932 | def send_message(self, chat_id, text, **options):
return self.api_call("sendMessage", chat_id=chat_id, text=text, **options) | Send a text message to chat
:param int chat_id: ID of the chat to send the message to
:param str text: Text to send
:param options: Additional sendMessage options
(see https://core.telegram.org/bots/api#sendmessage) |
6,933 | def _read_certificates(self):
stack_pointer = libssl.SSL_get_peer_cert_chain(self._ssl)
if is_null(stack_pointer):
handle_openssl_error(0, TLSError)
if libcrypto_version_info < (1, 1):
number_certs = libssl.sk_num(stack_pointer)
else:
number... | Reads end-entity and intermediate certificate information from the
TLS session |
6,934 | def hardware_info():
try:
if sys.platform == :
out = _mac_hardware_info()
elif sys.platform == :
out = _win_hardware_info()
elif sys.platform in [, ]:
out = _linux_hardware_info()
else:
out = {}
except:
return {}
el... | Returns basic hardware information about the computer.
Gives actual number of CPU's in the machine, even when hyperthreading is
turned on.
Returns
-------
info : dict
Dictionary containing cpu and memory information. |
6,935 | def addDataModels(self, mods):
nameclass.path.ctordocThe foo thing.namebasetype
for modlname, mdef in mods:
for name, ctor, opts, info in mdef.get(, ()):
item = s_dyndeps.tryDynFunc(ctor, self, name, info, opts)
self.types[name] = item
... | Add a list of (name, mdef) tuples.
A model definition (mdef) is structured as follows::
{
"ctors":(
('name', 'class.path.ctor', {}, {'doc': 'The foo thing.'}),
),
"types":(
('name', ('basetype', {typeopts}), {... |
6,936 | def result(self):
self._event.wait()
if self._final_result is not _NOT_SET:
return ResultSet(self, self._final_result)
else:
raise self._final_exception | Return the final result or raise an Exception if errors were
encountered. If the final result or error has not been set
yet, this method will block until it is set, or the timeout
set for the request expires.
Timeout is specified in the Session request execution functions.
If t... |
6,937 | def default_cy(self):
px_height = self.image.px_height
horz_dpi = self.image.horz_dpi
height_in_emu = 914400 * px_height / horz_dpi
return Emu(height_in_emu) | Native height of this image, calculated from its height in pixels and
vertical dots per inch (dpi). |
6,938 | def _list_resource_descriptors(args, _):
project_id = args[]
pattern = args[] or
descriptors = gcm.ResourceDescriptors(project_id=project_id)
dataframe = descriptors.as_dataframe(pattern=pattern)
return _render_dataframe(dataframe) | Lists the resource descriptors in the project. |
6,939 | def _make_repr(attrs, ns):
attr_names = tuple(a.name for a in attrs if a.repr)
def __repr__(self):
try:
working_set = _already_repring.working_set
except AttributeError:
working_set = set()
_already_repring.working_set = working_set
if ... | Make a repr method for *attr_names* adding *ns* to the full name. |
6,940 | def get_machines(self, origin, hostnames):
hostnames = {
hostname: True
for hostname in hostnames
}
machines = origin.Machines.read(hostnames=hostnames)
machines = [
machine
for machine in machines
if hostnames.pop(mach... | Return a set of machines based on `hostnames`.
Any hostname that is not found will result in an error. |
6,941 | def console_to_str(data):
encoding = locale.getpreferredencoding()
if (not encoding) or codecs.lookup(encoding).name == "ascii":
encoding = "utf-8"
try:
decoded_data = data.decode(encoding)
except UnicodeDecodeError:
logger.warning(
... | Return a string, safe for output, of subprocess output.
We assume the data is in the locale preferred encoding.
If it won't decode properly, we warn the user but decode as
best we can.
We also ensure that the output can be safely written to
standard output without encoding errors. |
6,942 | def to_json(self):
commands = ",".join(map(lambda x: x.to_json(), self._commands))
return "{\"commands\": [" + commands + "]}" | Returns:
str: Json for commands array object and all of the commands inside the array. |
6,943 | def parse(self, data):
self.validate_packet(data)
id_ = self.dump_hex(data[4:6])
humidity = data[6]
humidity_status = self._extract_humidity_status(data[7])
sensor_specific = {
: id_,
: humidity,
: humidity_st... | Parse a 9 bytes packet in the Humidity format and return a
dictionary containing the data extracted. An example of a return value
would be:
.. code-block:: python
{
'id': "0x2EB2",
'packet_length': 8,
'packet_type': 81,
... |
6,944 | def parse_usearch61_failures(seq_path,
failures,
output_fasta_fp):
parsed_out = open(output_fasta_fp, "w")
for label, seq in parse_fasta(open(seq_path), "U"):
curr_label = label.split()[0]
if curr_label in failures:
par... | Parses seq IDs from failures list, writes to output_fasta_fp
seq_path: filepath of original input fasta file.
failures: list/set of failure seq IDs
output_fasta_fp: path to write parsed sequences |
6,945 | def stop(self, reason=None):
self.logger.info()
self.loop.stop(pyev.EVBREAK_ALL) | Shutdown the service with a reason. |
6,946 | def parse_links(self, markup):
links = []
m = re.findall(self.re["link"], markup)
for link in m:
if link.find("{") >= 0:
link = re.sub("\{{1,3}[0-9]{0,2}\|", "", link)
link = link.replace("{", "")
... | Returns a list of internal Wikipedia links in the markup.
# A Wikipedia link looks like:
# [[List of operating systems#Embedded | List of embedded operating systems]]
# It does not contain a colon, this indicates images, users, languages, etc.
The return value is a list contain... |
6,947 | def DateTimeField(formatter=types.DEFAULT_DATETIME_FORMAT, default=NOTHING,
required=True, repr=True, cmp=True, key=None):
default = _init_fields.init_default(required, default, None)
validator = _init_fields.init_validator(required, datetime)
converter = converters.to_datetime_field(... | Create new datetime field on a model.
:param formatter: datetime formatter string (default: "ISO_FORMAT")
:param default: any datetime or string that can be converted to a datetime
:param bool required: whether or not the object is invalid if not provided.
:param bool repr: include this field should ap... |
6,948 | def sendMessage(self,chat_id,text,parse_mode=None,disable_web=None,reply_msg_id=None,markup=None):
payload={ : chat_id, : text, : parse_mode , : disable_web , : reply_msg_id}
if(markup):
payload[]=json.dumps(markup)
response_str = self._command(,payload,method=)
return _validate_response_msg(... | On failure returns False
On success returns Message Object |
6,949 | def _fill_disk_filename(vm_name, disk, hypervisor, **kwargs):
base_dir = disk.get(, None)
if hypervisor in [, , ]:
if not base_dir:
base_dir = _get_images_dir()
else:
if not base_dir.startswith():
infos = po... | Compute the disk file name and update it in the disk value. |
6,950 | def is_on(self):
return self.status not in (CONST.STATUS_OFF, CONST.STATUS_OFFLINE,
CONST.STATUS_CLOSED, CONST.STATUS_OPEN) | Get sensor state.
Assume offline or open (worst case). |
6,951 | def evaluate(self, x, y, flux, x_0, y_0, sigma):
return (flux / 4 *
((self._erf((x - x_0 + 0.5) / (np.sqrt(2) * sigma)) -
self._erf((x - x_0 - 0.5) / (np.sqrt(2) * sigma))) *
(self._erf((y - y_0 + 0.5) / (np.sqrt(2) * sigma)) -
self.... | Model function Gaussian PSF model. |
6,952 | def remove_highdepth_regions(in_file, items):
encode_bed = tz.get_in(["genome_resources", "variation", "encode_blacklist"], items[0])
if encode_bed and os.path.exists(encode_bed):
return _remove_regions(in_file, [encode_bed], "glimit", items[0])
else:
return in_file | Remove high depth regions from a BED file for analyzing a set of calls.
Tries to avoid spurious errors and slow run times in collapsed repeat regions.
Also adds ENCODE blacklist regions which capture additional collapsed repeats
around centromeres. |
6,953 | def hold(self, policy="combine"):
combinecollectcombinecollectcombinecombine
if self._hold is not None and self._hold != policy:
log.warning("hold already active with , ignoring " % (self._hold, policy))
return
if policy not in HoldPolicy:
raise ValueError("Un... | Activate a document hold.
While a hold is active, no model changes will be applied, or trigger
callbacks. Once ``unhold`` is called, the events collected during the
hold will be applied according to the hold policy.
Args:
hold ('combine' or 'collect', optional)
... |
6,954 | def Parse(self, how):
if type(how) == types.ClassType: how = how.typecode
return how.parse(self.body_root, self) | Parse the message. |
6,955 | def position(self):
dLbl = self._dLbl
if dLbl is None:
return None
dLblPos = dLbl.dLblPos
if dLblPos is None:
return None
return dLblPos.val | Read/write :ref:`XlDataLabelPosition` member specifying the position
of this data label with respect to its data point, or |None| if no
position is specified. Assigning |None| causes PowerPoint to choose
the default position, which varies by chart type. |
6,956 | def list_nodes(conn=None, call=None):
if call == :
raise SaltCloudSystemExit(
)
if not conn:
conn = get_conn()
ret = {}
datacenter_id = get_datacenter_id()
try:
nodes = conn.list_servers(datacenter_id=datacenter_id)
except PBNotFoundError:
... | Return a list of VMs that are on the provider |
6,957 | def retrieve_all(self, sids, default_none=False):
failures = set()
hits = {}
for sid in sids:
try:
hits[sid] = self._asset_cache[sid]
except KeyError:
if not default_none:
failures.add(sid)
else... | Retrieve all assets in `sids`.
Parameters
----------
sids : iterable of string
Assets to retrieve.
default_none : bool
If True, return None for failed lookups.
If False, raise `SidsNotFound`.
Returns
-------
assets : list[Asse... |
6,958 | def stretch(self, factor, window=20):
if not is_number(factor) or factor <= 0:
raise ValueError("factor must be a positive number")
if factor < 0.5 or factor > 2:
logger.warning(
"Using an extreme time stretching factor. "
"Quality of res... | Change the audio duration (but not its pitch).
**Unless factor is close to 1, use the tempo effect instead.**
This effect is broadly equivalent to the tempo effect with search set
to zero, so in general, its results are comparatively poor; it is
retained as it can sometimes out-perform ... |
6,959 | def _set_redistribute_bgp(self, v, load=False):
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=redistribute_bgp.redistribute_bgp, is_container=, presence=True, yang_name="redistribute-bgp", rest_name="bgp", parent=self, path_helper=self._path_helper, extmethods=self._extm... | Setter method for redistribute_bgp, mapped from YANG variable /rbridge_id/ipv6/router/ospf/redistribute/redistribute_bgp (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_redistribute_bgp is considered as a private
method. Backends looking to populate this variable... |
6,960 | def _obj_getattr(obj, fqdn, start=1):
node = obj
for chain in fqdn.split()[start:]:
if hasattr(node, chain):
node = getattr(node, chain)
else:
node = None
break
return node | Returns the attribute specified by the fqdn list from obj. |
6,961 | def findSnpWithMaf0(freqFileName, prefix):
maf_0_set = set()
na_set = set()
try:
with open(freqFileName, "r") as inputFile:
headerIndex = None
for i, line in enumerate(inputFile):
row = createRowFromPlinkSpacedOutput(line)
if i == 0:
... | Finds SNPs with MAF of 0 and put them in a file.
:param freqFileName: the name of the frequency file.
:param prefix: the prefix of all the files.
:type freqFileName: str
:type prefix: str
Reads a frequency file from Plink, and find markers with a minor allele
frequency of zero. |
6,962 | def tolist(val):
if val is None:
return None
try:
val.extend([])
return val
except AttributeError:
pass
try:
return re.split(r, val)
except TypeError:
return list(val) | Convert a value that may be a list or a (possibly comma-separated)
string into a list. The exception: None is returned as None, not [None].
>>> tolist(["one", "two"])
['one', 'two']
>>> tolist("hello")
['hello']
>>> tolist("separate,values, with, commas, spaces , are ,ok")
['separate', ... |
6,963 | def seal_aes_ctr_legacy(key_service, secret, digest_method=DEFAULT_DIGEST):
key, encoded_key = key_service.generate_key_data(64)
ciphertext, hmac = _seal_aes_ctr(
secret, key, LEGACY_NONCE, digest_method,
)
return {
: b64encode(encoded_key).decode(),
: b64encode(ci... | Encrypts `secret` using the key service.
You can decrypt with the companion method `open_aes_ctr_legacy`. |
6,964 | def compute_extra_rows(self,
all_dates,
start_date,
end_date,
min_extra_rows):
try:
current_start_pos = all_dates.get_loc(start_date) - min_extra_rows
if current_start_pos... | Ensure that min_extra_rows pushes us back to a computation date.
Parameters
----------
all_dates : pd.DatetimeIndex
The trading sessions against which ``self`` will be computed.
start_date : pd.Timestamp
The first date for which final output is requested.
... |
6,965 | def user_organization_membership_show(self, user_id, id, **kwargs):
"https://developer.zendesk.com/rest_api/docs/core/organization_memberships
api_path = "/api/v2/users/{user_id}/organization_memberships/{id}.json"
api_path = api_path.format(user_id=user_id, id=id)
return self.call(api_p... | https://developer.zendesk.com/rest_api/docs/core/organization_memberships#show-membership |
6,966 | def median_depth_img(self, num_img=1, fill_depth=0.0):
depths = []
for _ in range(num_img):
_, depth, _ = self.frames()
depths.append(depth)
median_depth = Image.median_images(depths)
median_depth.data[median_depth.data == 0.0] = fill_depth
retu... | Collect a series of depth images and return the median of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
DepthImage
The median DepthImage collected from the frames. |
6,967 | def iterShapes(self):
shp = self.__getFileObj(self.shp)
shp.seek(0,2)
self.shpLength = shp.tell()
shp.seek(100)
while shp.tell() < self.shpLength:
yield self.__shape() | Serves up shapes in a shapefile as an iterator. Useful
for handling large shapefiles. |
6,968 | def action_size(self) -> Sequence[Sequence[int]]:
fluents = self.domain.action_fluents
ordering = self.domain.action_fluent_ordering
return self._fluent_size(fluents, ordering) | The size of each action fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent. |
6,969 | def download_data(identifier, outdir):
if use_local_data_repository is not None:
url_base = + request.pathname2url(
use_local_data_repository + os.sep)
else:
url_base = repository_url
print(.format(url_base))
url = url_base + inventory_filename
filename, ... | Download data from a separate data repository for testing.
Parameters
----------
identifier: string
The identifier used to find the data set
outdir: string
unzip the data in this directory |
6,970 | def get_el_from_z(z):
if(type(z)==float):
z=int(z)
if(type(z)==int):
z=str(z)
dict_z={: , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , : , :... | Very simple Vfunction that gives the atomic number AS A STRING when given the element symbol.
Uses predefined a dictionnary.
Parameter :
z : string or number
For the other way, see get_z_from_el |
6,971 | def mkproject_cmd(argv):
if in argv or in argv:
templates = [t.name[9:] for t in workon_home.glob("template_*")]
print("Available project templates:", *templates, sep=)
return
parser = mkvirtualenv_argparser()
parser.add_argument()
parser.add_argument(
, action=, ... | Create a new project directory and its associated virtualenv. |
6,972 | def _keplerian_circular_to_keplerian(cls, coord, center):
a, ex, ey, i, Ω, u = coord
e = sqrt(ex ** 2 + ey ** 2)
ω = arctan2(ey / e, ex / e)
ν = u - ω
return np.array([a, e, i, Ω, ω, ν], dtype=float) | Conversion from Keplerian near-circular elements to Mean Keplerian |
6,973 | def copy(self):
a, b = it.tee(self._data)
self._data = a
return Stream(b) | Returns a "T" (tee) copy of the given stream, allowing the calling
stream to continue being used. |
6,974 | def build_machine(network=None,
machine_type=None,
preemptible=None,
service_account=None,
boot_disk_size_gb=None,
disks=None,
accelerators=None,
labels=None,
cpu_platform=None... | Build a VirtualMachine object for a Pipeline request.
Args:
network (dict): Network details for the pipeline to run in.
machine_type (str): GCE Machine Type string for the pipeline.
preemptible (bool): Use a preemptible VM for the job.
service_account (dict): Service account configuration for the VM.... |
6,975 | def list_to_file(orig_list, file_name, file_location):
file = __os.path.join(file_location, file_name)
def add_line_break(list_line):
list_line = ( % (list_line,))
return list_line
write_file = open(file, "a")
for orig_list_line in orig_list:
write_file.write(add_l... | Function to export a list to a text file
Args:
orig_list: The list you want exported
file_name: The name of the exported file
file_location: The location of the file, derive from the os module
Returns: returns the filename info |
6,976 | def unselect(self, value=None, field=None, **kwargs):
if field:
self.find("select", field, **kwargs).find("option", value, **kwargs).unselect_option()
else:
self.find("option", value, **kwargs).unselect_option() | Find a select box on the page and unselect a particular option from it. If the select box is
a multiple select, ``unselect`` can be called multiple times to unselect more than one
option. The select box can be found via its name, id, or label text. ::
page.unselect("March", field="Month")
... |
6,977 | def sort_by_distance(cls, consumer_offsets_metadata):
sorted_offsets = sorted(
list(consumer_offsets_metadata.items()),
key=lambda topic_offsets: sum([o.highmark - o.current for o in topic_offsets[1]])
)
return OrderedDict(sorted_offsets) | Receives a dict of (topic_name: ConsumerPartitionOffset) and returns a
similar dict where the topics are sorted by total offset distance. |
6,978 | def _set_show_ntp(self, v, load=False):
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=show_ntp.show_ntp, is_leaf=True, yang_name="show-ntp", rest_name="show-ntp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=False, extensions={u... | Setter method for show_ntp, mapped from YANG variable /brocade_ntp_rpc/show_ntp (rpc)
If this variable is read-only (config: false) in the
source YANG file, then _set_show_ntp is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_show_ntp() d... |
6,979 | def savemap(self, filename, filetype=, papertype="a4"):
self.fig.savefig(filename,
dpi=self.dpi,
format=filetype,
papertype=papertype) | Save the figure |
6,980 | def relative_resources(pathstring, failover=):
if working_dir is None:
return Path(failover, pathstring).resolve()
else:
return Path(devconfig.resources, pathstring).resolve().relative_to(working_dir.resolve()) | relative paths to resources in this repository
`failover` matches the location relative to the
github location (usually for prov purposes) |
6,981 | def get_properties(cls):
property_names = [p for p in dir(cls)
if isinstance(getattr(cls, p), property)]
return property_names | Get all properties of the MessageFlags class. |
6,982 | def when(self, key):
ctx = Context(key, self)
self.context.append(ctx)
return ctx | Specify context, i.e. condition that must be met.
Arguments:
key (str): Name of the context whose value you want to query.
Returns:
Context: |
6,983 | def heartbeat(self):
super(SchedulerMetricsJob, self).heartbeat()
session = settings.Session()
TI = TaskInstance
successful_tis = (
session
.query(TI)
.filter(TI.dag_id.in_(DAG_IDS))
.filter(TI.state.in_([State.SUCCESS]))
... | Override the scheduler heartbeat to determine when the test is complete |
6,984 | def _ul_per_mm(self, ul: float, func: str) -> float:
sequence = self.ul_per_mm[func]
return pipette_config.piecewise_volume_conversion(ul, sequence) | :param ul: microliters as a float
:param func: must be one of 'aspirate' or 'dispense'
:return: microliters/mm as a float |
6,985 | def type(self, variant_probe_coverages, variant=None):
if not isinstance(variant_probe_coverages, list):
variant_probe_coverages = [variant_probe_coverages]
calls = []
for variant_probe_coverage in variant_probe_coverages:
calls.append(
self._type... | Takes a list of VariantProbeCoverages and returns a Call for the Variant.
Note, in the simplest case the list will be of length one. However, we may be typing the
Variant on multiple backgrouds leading to multiple VariantProbes for a single Variant. |
6,986 | def getSingleVisualPropertyValue(self, networkId, viewId, objectType, objectId, visualProperty, verbose=None):
response=api(url=self.___url++str(networkId)++str(viewId)++str(objectType)++str(objectId)++str(visualProperty)+, method="H", verbose=verbose, parse_params=False)
return response | Gets the Visual Property specificed by the `visualProperty` parameter for the node or edge specified by the `objectId` parameter in the Network View specified by the `viewId` and `networkId` parameters.
Additional details on common Visual Properties can be found in the [Basic Visual Lexicon JavaDoc API... |
6,987 | def _match_exec(self, i):
self.col_match = self.RE_EXEC.match(self._source[i])
if self.col_match is not None:
if self.col_match.group("codetype") == "function":
self.el_type = Function
else:
self.el_type = Subroutine
self.el_na... | Looks at line 'i' for a subroutine or function definition. |
6,988 | def DocbookSlidesHtml(env, target, source=None, *args, **kw):
if not SCons.Util.is_List(target):
target = [target]
if not source:
source = target
target = []
elif not SCons.Util.is_List(source):
source = [source]
__init_xsl_stylesheet(kw, env, , [,,])
... | A pseudo-Builder, providing a Docbook toolchain for HTML slides output. |
6,989 | def lev_bounds(self):
try:
for domname, dom in self.domains.items():
try:
thislev = dom.axes[].bounds
except:
pass
return thislev
except:
raise ValueError(t resolve a lev axis.') | Pressure levels at grid interfaces (hPa or mb)
:getter: Returns the bounds of axis ``'lev'`` if availible in the
process's domains.
:type: array
:raises: :exc:`ValueError`
if no ``'lev'`` axis can be found. |
6,990 | def get_dataset(self, key, info):
res = super(HRITJMAFileHandler, self).get_dataset(key, info)
self._check_sensor_platform_consistency(info[])
res = self._mask_space(self.calibrate(res, key.calibration))
res.attrs.update(info)
... | Get the dataset designated by *key*. |
6,991 | def play_env_problem_randomly(env_problem,
num_steps):
env_problem.reset()
for _ in range(num_steps):
actions = np.stack([env_problem.action_space.sample() for _ in range(
env_problem.batch_size)])
_, _, dones, _ = env_problem.step(actions)
... | Plays the env problem by randomly sampling actions for `num_steps`. |
6,992 | def update_key(
self, vault_base_url, key_name, key_version, key_ops=None, key_attributes=None, tags=None, custom_headers=None, raw=False, **operation_config):
parameters = models.KeyUpdateParameters(key_ops=key_ops, key_attributes=key_attributes, tags=tags)
url = self.upd... | The update key operation changes specified attributes of a stored key
and can be applied to any key type and key version stored in Azure Key
Vault.
In order to perform this operation, the key must already exist in the
Key Vault. Note: The cryptographic material of a key itself cannot be... |
6,993 | def tracking_save(sender, instance, raw, using, update_fields, **kwargs):
if _has_changed(instance):
if instance._original_fields[] is None:
_create_create_tracking_event(instance)
else:
_create_update_tracking_event(instance)
if _has_change... | Post save, detect creation or changes and log them.
We need post_save to have the object for a create. |
6,994 | def QA_util_future_to_tradedatetime(real_datetime):
if len(str(real_datetime)) >= 19:
dt = datetime.datetime.strptime(
str(real_datetime)[0:19],
)
return dt if dt.time(
) < datetime.time(21,
0) else QA_util_get_next_datetime(dt,... | 输入是真实交易时间,返回按期货交易所规定的时间* 适用于tb/文华/博弈的转换
Arguments:
real_datetime {[type]} -- [description]
Returns:
[type] -- [description] |
6,995 | def xstatus(self):
return max(node.xstatus for node in self.nodes) if len(self.nodes) else 0 | UNIX-like exit status, only coherent if the context has stopped. |
6,996 | def SetStatus(self, status, message="", backtrace=None):
self.status.status = status
self.status.error_message = utils.SmartUnicode(message)
if backtrace:
self.status.backtrace = utils.SmartUnicode(backtrace) | Set a status to report back to the server. |
6,997 | def add_platform(name, platform_set, server_url):
config = _get_asam_configuration(server_url)
if not config:
return False
platforms = list_platforms(server_url)
if name in platforms[server_url]:
return {name: "Specified platform already exists on {0}".format(server_url)}
plat... | To add an ASAM platform using the specified ASAM platform set on the Novell
Fan-Out Driver
CLI Example:
.. code-block:: bash
salt-run asam.add_platform my-test-vm test-platform-set prov1.domain.com |
6,998 | def team_names_to_ids(self):
d = self.team_ids_to_names()
return {v: k for k, v in d.items()} | Mapping from full team names to 3-letter team IDs.
:returns: Dictionary with tean names as keys and team IDs as values. |
6,999 | def UNIFAC_groups(self):
rs online service <http://www.ddbst.com/unifacga.html>`_.
Examples
--------
>>> pprint(Chemical().UNIFAC_groups)
{1: 2, 9: 5, 13: 1}
'
if self.__UNIFAC_groups:
return self.__UNIFAC_groups
else:
load_group_a... | r'''Dictionary of UNIFAC subgroup: count groups for the original
UNIFAC subgroups, as determined by `DDBST's online service <http://www.ddbst.com/unifacga.html>`_.
Examples
--------
>>> pprint(Chemical('Cumene').UNIFAC_groups)
{1: 2, 9: 5, 13: 1} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.