Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
6,000 | def logs(self, follow=False):
follow = ["--follow"] if follow else []
cmdline = ["podman", "logs"] + follow + [self._id or self.get_id()]
output = run_cmd(cmdline, return_output=True)
return output | Get logs from this container. Iterator has one log line followed by a newline in next item.
The logs are NOT encoded (they are str, not bytes).
Let's look at an example::
image = conu.PodmanImage("fedora", tag="27")
command = ["bash", "-c", "for x in `seq 1 5`; do echo $x; slee... |
6,001 | def get_genericpage(cls, kb_app):
q = dectate.Query()
klasses = sorted(q(kb_app), key=lambda args: args[0].order)
if not klasses:
return Genericpage
else:
return klasses[0][1] | Return the one class if configured, otherwise default |
6,002 | def _check_dtype(self, dtype):
try:
return _ffi_types[dtype]
except KeyError:
raise ValueError("dtype must be one of {0!r} and not {1!r}".format(
sorted(_ffi_types.keys()), dtype)) | Check if dtype string is valid and return ctype string. |
6,003 | def saveData(self, dataOutputFile, categoriesOutputFile):
if self.records is None:
return False
if not dataOutputFile.endswith("csv"):
raise TypeError("data output file must be csv.")
if not categoriesOutputFile.endswith("json"):
raise TypeError("category output file must be json")
... | Save the processed data and the associated category mapping.
@param dataOutputFile (str) Location to save data
@param categoriesOutputFile (str) Location to save category map
@return (str) Path to the saved data file iff
saveData() is s... |
6,004 | def cli(env, sortby, columns, datacenter, username, storage_type):
block_manager = SoftLayer.BlockStorageManager(env.client)
block_volumes = block_manager.list_block_volumes(datacenter=datacenter,
username=username,
... | List block storage. |
6,005 | def processing_blocks(self):
pb_list = ProcessingBlockList()
return json.dumps(dict(active=pb_list.active,
completed=pb_list.completed,
aborted=pb_list.aborted)) | Return the a JSON dict encoding the PBs known to SDP. |
6,006 | def to_pandas_df(self, column_names=None, selection=None, strings=True, virtual=False, index_name=None):
import pandas as pd
data = self.to_dict(column_names=column_names, selection=selection, strings=strings, virtual=virtual)
if index_name is not None:
if index_name in data... | Return a pandas DataFrame containing the ndarray corresponding to the evaluated data
If index is given, that column is used for the index of the dataframe.
Example
>>> df_pandas = df.to_pandas_df(["x", "y", "z"])
>>> df_copy = vaex.from_pandas(df_pandas)
:param column_nam... |
6,007 | def get_fc2(supercell,
symmetry,
dataset,
atom_list=None,
decimals=None):
if atom_list is None:
fc_dim0 = supercell.get_number_of_atoms()
else:
fc_dim0 = len(atom_list)
force_constants = np.zeros((fc_dim0,
... | Force constants are computed.
Force constants, Phi, are calculated from sets for forces, F, and
atomic displacement, d:
Phi = -F / d
This is solved by matrix pseudo-inversion.
Crystal symmetry is included when creating F and d matrices.
Returns
-------
ndarray
Force constants... |
6,008 | def down_by_time(*filters, remote_dir=DEFAULT_REMOTE_DIR, local_dir=".", count=1):
files = command.list_files(*filters, remote_dir=remote_dir)
most_recent = sorted(files, key=lambda f: f.datetime)
to_sync = most_recent[-count:]
_notify_sync(Direction.down, to_sync)
down_by_files(to_sync[::-1], ... | Sync most recent file by date, time attribues |
6,009 | def merge(cls, *args, **kwargs):
newkeys = bool(kwargs.get(, False))
ignore = kwargs.get(, list())
if len(args) < 1:
raise ValueError()
elif not all(isinstance(s, Ent) for s in args):
raise ValueError(
)
ent = args[0... | Create a new Ent from one or more existing Ents. Keys in the
later Ent objects will overwrite the keys of the previous Ents.
Later keys of different type than in earlier Ents will be bravely
ignored.
The following keyword arguments are recognized:
newkeys: boolean value to det... |
6,010 | def apply_policy(self, policy):
tenant_name = policy[]
fw_id = policy[]
fw_name = policy[]
LOG.info("asa_apply_policy: tenant=%(tenant)s fw_id=%(fw_id)s "
"fw_name=%(fw_name)s",
{: tenant_name, : fw_id, : fw_name})
cmds = ["conf t", "cha... | Apply a firewall policy. |
6,011 | def run(file, access_key, secret_key, **kwargs):
if file:
import sys
file_path, file_name = os.path.split(file)
sys.path.append(file_path)
strategy_module = importlib.import_module(os.path.splitext(file_name)[0])
init = getattr(strategy_module, , None)
handle_fun... | 命令行运行huobitrade |
6,012 | def set_owner(obj_name, principal, obj_type=):
C:\\MyDirectoryjsnuffyfile
sid = get_sid(principal)
obj_flags = flags()
if obj_type.lower() not in obj_flags.obj_type:
raise SaltInvocationError(
.format(obj_type))
if in obj_type.lower():
obj_name = dacl().get_reg_n... | Set the owner of an object. This can be a file, folder, registry key,
printer, service, etc...
Args:
obj_name (str):
The object for which to set owner. This can be the path to a file or
folder, a registry key, printer, etc. For more information about how
to format t... |
6,013 | def _update_service_profile(self, handle, service_profile,
vlan_id, ucsm_ip):
virtio_port_list = (
CONF.ml2_cisco_ucsm.ucsms[ucsm_ip].ucsm_virtio_eth_ports)
eth_port_paths = ["%s%s" % (service_profile, ep)
for ep in virtio_port_list]
... | Updates Service Profile on the UCS Manager.
Each of the ethernet ports on the Service Profile representing
the UCS Server, is updated with the VLAN profile corresponding
to the vlan_id passed in. |
6,014 | def get_max_value(self):
value = self.get_default_value()
if self.attribute_type is str:
max_value = value.ljust(self.max_length + 1, )
elif self.attribute_type is int:
max_value = self.max_length + 1
else:
raise TypeError( % self.local_na... | Get the maximum value |
6,015 | def readLocationElement(self, locationElement):
if self._strictAxisNames and not self.documentObject.axes:
raise DesignSpaceDocumentError("No axes defined")
loc = {}
for dimensionElement in locationElement.findall(".dimension"):
dimName = dimensionElement.attrib.... | Format 0 location reader |
6,016 | def get_security_attributes_for_user(user=None):
if user is None:
user = get_current_user()
assert isinstance(user, security.TOKEN_USER), (
"user must be TOKEN_USER instance")
SD = security.SECURITY_DESCRIPTOR()
SA = security.SECURITY_ATTRIBUTES()
SA.descriptor = SD
SA.bInheritHandle = 1
ctypes.wind... | Return a SECURITY_ATTRIBUTES structure with the SID set to the
specified user (uses current user if none is specified). |
6,017 | def recorddiff(a, b, buffersize=None, tempdir=None, cache=True, strict=False):
added = recordcomplement(b, a, buffersize=buffersize, tempdir=tempdir,
cache=cache, strict=strict)
subtracted = recordcomplement(a, b, buffersize=buffersize, tempdir=tempdir,
... | Find the difference between records in two tables. E.g.::
>>> import petl as etl
>>> a = [['foo', 'bar', 'baz'],
... ['A', 1, True],
... ['C', 7, False],
... ['B', 2, False],
... ['C', 9, True]]
>>> b = [['bar', 'foo', 'baz'],
... ... |
6,018 | def run_interrupted(self):
start = datetime.datetime.now()
try:
cwd = os.getcwd()
v = sys.version.replace("\n", " ")
logger.info("Custodian started in singleshot mode at {} in {}."
.format(start, cwd))
logger.info("Custodia... | Runs custodian in a interuppted mode, which sets up and
validates jobs but doesn't run the executable
Returns:
number of remaining jobs
Raises:
ValidationError: if a job fails validation
ReturnCodeError: if the process has a return code different from 0
... |
6,019 | def get_date_822():
cmd =
if not os.path.exists(cmd):
raise ValueError(%cmd)
args = [cmd,]
result = get_cmd_stdout(args).strip()
result = normstr(result)
return result | return output of 822-date command |
6,020 | def qn_to_qubo(expr):
try:
import sympy
except ImportError:
raise ImportError("This function requires sympy. Please install it.")
assert type(expr) == sympy.Add
to_i = lambda s: int(str(s)[1:])
max_i = max(map(to_i, expr.free_symbols)) + 1
qubo = [[0.] * max_i for _ in range... | Convert Sympy's expr to QUBO.
Args:
expr: Sympy's quadratic expression with variable `q0`, `q1`, ...
Returns:
[[float]]: Returns QUBO matrix. |
6,021 | def parse_env(self, env=None, namespace=None):
env = env or os.environ
results = {}
if not namespace:
namespace = self.prog
namespace = namespace.upper()
for option in self._options:
env_var = option.kwargs.get()
default_env = "%s_%s... | Parse environment variables. |
6,022 | def _get_fields(self):
if self.data is not None:
return self.begin, self.end, self.data
else:
return self.begin, self.end | Used by str, unicode, repr and __reduce__.
Returns only the fields necessary to reconstruct the Interval.
:return: reconstruction info
:rtype: tuple |
6,023 | def reorient(self, up, look):
from blmath.geometry.transform import rotation_from_up_and_look
from blmath.numerics import as_numeric_array
up = as_numeric_array(up, (3,))
look = as_numeric_array(look, (3,))
if self.v is not None:
self.v = np.dot(rotation_fr... | Reorient the mesh by specifying two vectors.
up: The foot-to-head direction.
look: The direction the body is facing.
In the result, the up will end up along +y, and look along +z
(i.e. facing towards a default OpenGL camera). |
6,024 | def _process_callbacks(self):
os.read(self._schedule_pipe[0], 1024)
calls_from_executor, self._calls_from_executor = self._calls_from_executor, []
for c in calls_from_executor:
c() | Process callbacks from `call_from_executor` in eventloop. |
6,025 | def get_line_value(self, context_type):
if context_type.upper() == "ENV":
return self.line_envs
elif context_type.upper() == "LABEL":
return self.line_labels | Get the values defined on this line.
:param context_type: "ENV" or "LABEL"
:return: values of given type defined on this line |
6,026 | def peek_assoc(store, container, _stack=None):
assoc = []
try:
if store.getRecordAttr(, container) == :
for i in container:
assoc.append(store.peek(i, container, _stack=_stack))
else:
for i in container:
assoc.append((store.strRecord(i... | Deserialize association lists. |
6,027 | async def _post(self, zone_id: int = None, json: dict = None) -> dict:
return await self._request(
, .format(zone_id), json=json) | Post data to a (non)existing zone. |
6,028 | def thumbUrl(self):
thumb = self.firstAttr(, , )
return self._server.url(thumb, includeToken=True) if thumb else None | Return the first first thumbnail url starting on
the most specific thumbnail for that item. |
6,029 | def retry(ex=RETRIABLE, tries=4, delay=5, backoff=2, logger=None):
def deco_retry(func):
@wraps(func)
def f_retry(*args, **kwargs):
mtries, mdelay = tries, delay
while mtries > 1:
try:
return func(*args, **kwargs... | Retry calling the decorated function using an exponential backoff.
http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/
original from: http://wiki.python.org/moin/PythonDecoratorLibrary#Retry
:param ex: the exception to check. may be a tuple of exceptions to check
:param tries: nu... |
6,030 | def set_job(self, key, func, args):
res, pk = key
jobs, lock = self._jobs
task = _tasks.UpdateTask(func(*args), key)
with lock:
job = jobs[res].get(pk)
had = bool(job)
if not job:
job = task
jobs[res][pk] = job
... | Get a scheduled task or set if none exists.
Returns:
- task coroutine/continuation |
6,031 | def generate_strip_subparser(subparsers):
parser = subparsers.add_parser(
, description=constants.STRIP_DESCRIPTION,
epilog=constants.STRIP_EPILOG, formatter_class=ParagraphFormatter,
help=constants.STRIP_HELP)
parser.set_defaults(func=strip_files)
utils.add_common_arguments(par... | Adds a sub-command parser to `subparsers` to process prepared files
for use with the tacl ngrams command. |
6,032 | def get_attached_pipettes(self):
api = object.__getattribute__(self, )
instrs = {}
for mount, data in api.attached_instruments.items():
instrs[mount.name.lower()] = {
: data.get(, None),
: data.get(, None),
: Axis.by_mount(moun... | Mimic the behavior of robot.get_attached_pipettes |
6,033 | def run(self,evloop=None):
self.sendEvent("peng3d:peng.run",{"peng":self,"window":self.window,"evloop":evloop})
self.window.run(evloop)
self.sendEvent("peng3d:peng.exit",{"peng":self}) | Runs the application main loop.
This method is blocking and needs to be called from the main thread to avoid OpenGL bugs that can occur.
``evloop`` may optionally be a subclass of :py:class:`pyglet.app.base.EventLoop` to replace the default event loop. |
6,034 | def _read_opt_pad(self, code, *, desc):
_type = self._read_opt_type(code)
if code == 0:
opt = dict(
desc=desc,
type=_type,
length=1,
)
elif code == 1:
_size = self._read_unpack(1)
_padn = se... | Read HOPOPT padding options.
Structure of HOPOPT padding options [RFC 8200]:
* Pad1 Option:
+-+-+-+-+-+-+-+-+
| 0 |
+-+-+-+-+-+-+-+-+
Octets Bits Name Description
0 ... |
6,035 | def store(self, store_item):
required_keys = {"type": str, "timestamp": float}
if not isinstance(store_item, dict):
raise TypeError("The stored item should be a dict")
for k, v in required_keys.items():
if k not in store_item:
... | Store for tweets and user information. Must have all required information and types |
6,036 | def lock(self, key, client):
self.key = key
self.client = client | Set the key that will be used to ensure messages come from one party
Args:
key (string): The key used to validate future messages
client (string): A string that will be returned to indicate who
locked this device. |
6,037 | def PSLLDQ(cpu, dest, src):
count = Operators.ZEXTEND(src.read(), dest.size * 2)
byte_count = Operators.ITEBV(src.size * 2, count > 15, 16, count)
bit_count = byte_count * 8
val = Operators.ZEXTEND(dest.read(), dest.size * 2)
val = val << (Operators.ZEXTEND(bit_count, de... | Packed Shift Left Logical Double Quadword
Shifts the destination operand (first operand) to the left by the number
of bytes specified in the count operand (second operand). The empty low-order
bytes are cleared (set to all 0s). If the value specified by the count
operand is greater th... |
6,038 | def calculate_overlap(self):
overs = []
if not self.tx_obj1.range.overlaps(self.tx_obj2.range): return []
for i in range(0,len(self.j1)):
for j in range(0,len(self.j2)):
if self.j1[i].overlaps(self.j2[j],tolerance=self.tolerance):
overs.append([i,j])
return ... | Create the array that describes how junctions overlap |
6,039 | def compute(self, bottomUpInput, enableLearn, enableInference=None):
assert (bottomUpInput.dtype == numpy.dtype()) or \
(bottomUpInput.dtype == numpy.dtype()) or \
(bottomUpInput.dtype == numpy.dtype())
self.iterationIdx = self.iterationIdx + 1
if enableInfer... | Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.compute`. |
6,040 | def authenticate(self, provider=None, identifier=None):
"Fetch user for a given provider by id."
provider_q = Q(provider__name=provider)
if isinstance(provider, Provider):
provider_q = Q(provider=provider)
try:
access = AccountAccess.objects.filter(
... | Fetch user for a given provider by id. |
6,041 | def _generate_throw_error(self, name, reason):
throw_exc =
self.emit(throw_exc.format(name, reason)) | Emits a generic error throwing line. |
6,042 | def FinalizeTaskStorage(self, task):
if task.identifier not in self._task_storage_writers:
raise IOError(.format(
task.identifier)) | Finalizes a processed task storage.
Args:
task (Task): task.
Raises:
IOError: if the task storage does not exist.
OSError: if the task storage does not exist. |
6,043 | def aggregation_not_used_text_element(feature, parent):
_ = feature, parent
header = aggregation_not_used_text[]
return header.capitalize() | Retrieve reference title header string from definitions. |
6,044 | def safe_cast(invar, totype):
outvar = totype(invar)
if not isinstance(outvar, totype):
raise TypeError("Result of cast to is "
.format(totype, type(outvar)))
return outvar | Performs a "safe" typecast.
Ensures that `invar` properly casts to `totype`. Checks after
casting that the result is actually of type `totype`. Any exceptions raised
by the typecast itself are unhandled.
Parameters
----------
invar
(arbitrary) -- Value to be typecast.
totype
... |
6,045 | def interpret_element(element_type: str, text: str, span: str) -> Element:
return Element(element_type,
interpret_span(span),
text) | Construct an Element instance from regexp
groups. |
6,046 | def clause_indices(self):
if not self.is_tagged(CLAUSE_ANNOTATION):
self.tag_clause_annotations()
return [word.get(CLAUSE_IDX, None) for word in self[WORDS]] | The list of clause indices in ``words`` layer.
The indices are unique only in the boundary of a single sentence. |
6,047 | def scrape_links(self, text, context=False):
return self.iter_processed_links(io.StringIO(text), context=context) | Convenience function for scraping from a text string. |
6,048 | def mpim_open(self, *, users: List[str], **kwargs) -> SlackResponse:
kwargs.update({"users": users})
return self.api_call("mpim.open", json=kwargs) | This method opens a multiparty direct message.
Args:
users (list): A lists of user ids. The ordering of the users
is preserved whenever a MPIM group is returned.
e.g. ['W1234567890', 'U2345678901', 'U3456789012'] |
6,049 | def intervals(graph):
interval_graph = Graph()
heads = [graph.entry]
interv_heads = {}
processed = {i: False for i in graph}
edges = defaultdict(list)
while heads:
head = heads.pop(0)
if not processed[head]:
processed[head] = True
interv_heads... | Compute the intervals of the graph
Returns
interval_graph: a graph of the intervals of G
interv_heads: a dict of (header node, interval) |
6,050 | def _indexed_ifilter(self, recursive=True, matches=None, flags=FLAGS,
forcetype=None):
match = self._build_matcher(matches, flags)
if recursive:
restrict = forcetype if recursive == self.RECURSE_OTHERS else None
def getter(i, node):
... | Iterate over nodes and their corresponding indices in the node list.
The arguments are interpreted as for :meth:`ifilter`. For each tuple
``(i, node)`` yielded by this method, ``self.index(node) == i``. Note
that if *recursive* is ``True``, ``self.nodes[i]`` might not be the
node itself... |
6,051 | def p_continue_statement_2(self, p):
p[0] = self.asttypes.Continue(p[2])
p[0].setpos(p) | continue_statement : CONTINUE identifier SEMI
| CONTINUE identifier AUTOSEMI |
6,052 | def print_number_str(self, value, justify_right=True):
length = len(value.translate(None, ))
if length > 4:
self.print_str()
return
pos = (4-length) if justify_right else 0
for i, ch in enumerate(value):
if ... | Print a 4 character long string of numeric values to the display. This
function is similar to print_str but will interpret periods not as
characters but as decimal points associated with the previous character. |
6,053 | def _set_mct_l2ys_state(self, v, load=False):
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=mct_l2ys_state.mct_l2ys_state, is_container=, presence=False, yang_name="mct-l2ys-state", rest_name="mct-l2ys-state", parent=self, path_helper=self._path_helper, extmethods=self._... | Setter method for mct_l2ys_state, mapped from YANG variable /mct_l2ys_state (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_mct_l2ys_state is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_mct_... |
6,054 | def parse_fields_http(self, response, extra_org_map=None):
org_map = self.org_map.copy()
try:
org_map.update(extra_org_map)
except (TypeError, ValueError, IndexError, KeyError):
pass
try:
asn_data = {
: None,
... | The function for parsing ASN fields from a http response.
Args:
response (:obj:`str`): The response from the ASN http server.
extra_org_map (:obj:`dict`): Dictionary mapping org handles to
RIRs. This is for limited cases where ARIN REST (ASN fallback
HTTP... |
6,055 | def setup_client(self, client_id=None, user_data=None, scan=True, broadcast=False):
if client_id is None:
client_id = str(uuid.uuid4())
if client_id in self._clients:
raise ArgumentError("Duplicate client_id: {}".format(client_id))
async def _client_callback(... | Setup a newly connected client.
``client_id`` must be unique among all connected clients. If it is
passed as None, a random client_id will be generated as a string and
returned.
This method reserves internal resources for tracking what devices this
client has connected to and ... |
6,056 | def _compare_rows(from_recs, to_recs, keys):
"Return the set of keys which have changed."
return set(
k for k in keys
if sorted(from_recs[k].items()) != sorted(to_recs[k].items())
) | Return the set of keys which have changed. |
6,057 | def build_url_request(self):
params = {}
headers = {}
self._authenticator(params, headers)
self._grant(params)
return Request(self._endpoint, urlencode(params), headers) | Consults the authenticator and grant for HTTP request parameters and
headers to send with the access token request, builds the request using
the stored endpoint and returns it. |
6,058 | def from_iterable(cls, frames, sort=False):
return FrameSet(sorted(frames) if sort else frames) | Build a :class:`FrameSet` from an iterable of frames.
Args:
frames (collections.Iterable): an iterable object containing frames as integers
sort (bool): True to sort frames before creation, default is False
Returns:
:class:`FrameSet`: |
6,059 | def trace_dispatch(self, frame, event, arg):
if hasattr(self, ):
return self.pdb.trace_dispatch(frame, event, arg)
else:
return Pdb.trace_dispatch(self, frame, event, arg) | allow to switch to Pdb instance |
6,060 | def add(self, f_ipaddr, f_macaddr, f_hostname, f_netbios_name, f_engineer, f_asset_group, f_confirmed):
return self.send.host_add(f_ipaddr, f_macaddr, f_hostname, f_netbios_name, f_engineer,
f_asset_group, f_confirmed) | Add a t_hosts record
:param f_ipaddr: IP address
:param f_macaddr: MAC Address
:param f_hostname: Hostname
:param f_netbios_name: NetBIOS Name
:param f_engineer: Engineer username
:param f_asset_group: Asset group
:param f_confirmed: Confirmed boolean
:re... |
6,061 | def save(self, filename, ftype=):
from ..param import Param
def gather_params(self, plist):
if isinstance(self,Param):
plist.append(self)
plist = []
self.traverse(gather_params, plist)
names = self.parameter_names(adjust_for_printing=True)
... | Save all the model parameters into a file (HDF5 by default).
This is not supported yet. We are working on having a consistent,
human readable way of saving and loading GPy models. This only
saves the parameter array to a hdf5 file. In order
to load the model again, use the same script f... |
6,062 | def create_mbed_detector(**kwargs):
host_os = platform.system()
if host_os == "Windows":
from .windows import StlinkDetectWindows
return StlinkDetectWindows(**kwargs)
elif host_os == "Linux":
from .linux import StlinkDetectLinuxGeneric
return StlinkDetectLinuxGeneric(*... | ! Factory used to create host OS specific mbed-lstools object
:param kwargs: keyword arguments to pass along to the constructors
@return Returns MbedLsTools object or None if host OS is not supported |
6,063 | def get_sorted_source_files(
self,
source_filenames_or_globs: Union[str, List[str]],
recursive: bool = True) -> List[str]:
if isinstance(source_filenames_or_globs, str):
source_filenames_or_globs = [source_filenames_or_globs]
final_filenames = [] ... | Returns a sorted list of filenames to process, from a filename,
a glob string, or a list of filenames/globs.
Args:
source_filenames_or_globs: filename/glob, or list of them
recursive: use :func:`glob.glob` in recursive mode?
Returns:
sorted list of files to ... |
6,064 | def create_host(self, host_id, name, ipaddr, rack_id = None):
return hosts.create_host(self, host_id, name, ipaddr, rack_id) | Create a host.
@param host_id: The host id.
@param name: Host name
@param ipaddr: IP address
@param rack_id: Rack id. Default None.
@return: An ApiHost object |
6,065 | def _encode_dict_as_string(value):
if value.startswith("{\n"):
value = "{" + value[2:]
if value.endswith("\n}"):
value = value[:-2] + "}"
return value.replace(, ).replace("\\n", "\\\\n").replace("\n", "\\n") | Takes the PLIST string of a dict, and returns the same string
encoded such that it can be included in the string representation
of a GSNode. |
6,066 | def get_extended_summaryf(self, *args, **kwargs):
def func(f):
doc = f.__doc__
self.get_extended_summary(doc or , *args, **kwargs)
return f
return func | Extract the extended summary from a function docstring
This function can be used as a decorator to extract the extended
summary of a function docstring (similar to :meth:`get_sectionsf`).
Parameters
----------
``*args`` and ``**kwargs``
See the :meth:`get_extended_s... |
6,067 | def _get_pieces(tiles, ports, players_opts, pieces_opts):
if pieces_opts == Opt.empty:
return dict()
elif pieces_opts == Opt.debug:
players = catan.game.Game.get_debug_players()
return {
(hexgrid.NODE, 0x23): catan.pieces.Piece(catan.pieces.PieceType.settlement, players[... | Generate a dictionary of pieces using the given options.
pieces options supported:
- Opt.empty -> no locations have pieces
- Opt.random ->
- Opt.preset -> robber is placed on the first desert found
- Opt.debug -> a variety of pieces are placed around the board
:param tiles: list of tiles from ... |
6,068 | def pull_alignments_from(self, reads_to_use, shallow=False):
new_alnmat = self.copy(shallow=shallow)
for hid in xrange(self.num_haplotypes):
hdata = new_alnmat.data[hid]
hdata.data *= reads_to_use[hdata.indices]
hdata.eliminate_zeros()
if new_a... | Pull out alignments of certain reads
:param reads_to_use: numpy array of dtype=bool specifying which reads to use
:param shallow: whether to copy sparse 3D matrix only or not
:return: a new AlignmentPropertyMatrix object that particular reads are |
6,069 | def crop_to_seg_extents(img, seg, padding):
beg_coords, end_coords = crop_coords(seg, padding)
img = crop_3dimage(img, beg_coords, end_coords)
seg = crop_3dimage(seg, beg_coords, end_coords)
return img, seg | Crop the image (usually MRI) to fit within the bounding box of a segmentation (or set of seg) |
6,070 | def update_item(self, item, expected_value=None, return_values=None):
expected_value = self.dynamize_expected_value(expected_value)
key = self.build_key_from_values(item.table.schema,
item.hash_key, item.range_key)
attr_updates = self.dynamize_at... | Commit pending item updates to Amazon DynamoDB.
:type item: :class:`boto.dynamodb.item.Item`
:param item: The Item to update in Amazon DynamoDB. It is expected
that you would have called the add_attribute, put_attribute
and/or delete_attribute methods on this Item prior to call... |
6,071 | def cmp(self,range2,overlap_size=0):
if self.overlaps(range2,padding=overlap_size): return 0
if self.chr < range2.chr: return -1
elif self.chr > range2.chr: return 1
elif self.end < range2.start: return -1
elif self.start > range2.end: return 1
sys.stderr.write("ERROR: cmp function unexpcte... | the comparitor for ranges
* return 1 if greater than range2
* return -1 if less than range2
* return 0 if overlapped
:param range2:
:param overlap_size: allow some padding for an 'equal' comparison (default 0)
:type range2: GenomicRange
:type overlap_size: int |
6,072 | def version(self):
try:
_version = (curl[Gentoo._LATEST_TXT] | \
awk[] | \
cut["-f2", "-d="])().strip()
_version = datetime.utcfromtimestamp(int(_version))\
.strftime("%Y-%m-%d")
except ProcessExecutionError as proc... | Return the build date of the gentoo container. |
6,073 | def create(self):
if not self._sync and not hasattr(self, ):
self._buffer = {}
if not os.path.exists(self.cache_dir):
os.makedirs(self.cache_dir) | Create the write buffer and cache directory. |
6,074 | def add(self, interval, offset):
start, stop = self.get_start_stop(interval)
if len(self.starts) > 0:
if start < self.starts[-1] or offset <= self.offsets[-1][1]:
raise ValueError()
self.offsets[-1][1] = offset
self.offsets[-1][2] += 1
... | The added interval must be overlapping or beyond the last stored interval ie. added in sorted order.
:param interval: interval to add
:param offset: full virtual offset to add
:return: |
6,075 | def make_request(self, method, path, params={}, body="", username=None,
password=None, base_uri=None, content_type=None):
headers = {
: CreateSend.user_agent,
: ,
: }
if content_type:
headers[] = content_type
parsed_base_uri = ... | username and password should only be set when it is intended that
the default basic authentication mechanism using the API key be
overridden (e.g. when using the apikey route with username and password). |
6,076 | def derivative(self, point=None):
if self.pad_mode == and self.pad_const != 0:
return PartialDerivative(self.domain, self.axis, self.range,
self.method, self.pad_mode, 0)
else:
return self | Return the derivative operator.
The partial derivative is usually linear, but in case the 'constant'
``pad_mode`` is used with nonzero ``pad_const``, the
derivative is given by the derivative with 0 ``pad_const``.
Parameters
----------
point : `domain` `element-like`, o... |
6,077 | def cache(opts, serial):
return LazyLoader(
_module_dirs(opts, , ),
opts,
tag=,
pack={: opts, : {: serial}},
) | Returns the returner modules |
6,078 | def generate(self, api):
for namespace in api.namespaces.values():
with self.output_to_relative_path(.format(fmt_namespace(namespace.name))):
self._generate_base_namespace_module(namespace) | Generates a module for each namespace.
Each namespace will have Python classes to represent data types and
routes in the Stone spec. |
6,079 | def clr(args):
p = OptionParser(clr.__doc__)
p.set_bedpe()
opts, args = p.parse_args(args)
if len(args) != 2:
sys.exit(not p.print_help())
bedpe, ref = args
if bedpe.endswith(".bam"):
bedpefile = bedpe.replace(".bam", ".bedpe")
if need_update(bedpe, bedpefile):
... | %prog clr [bamfile|bedpefile] ref.fasta
Use mates from BEDPE to extract ranges where the ref is covered by mates.
This is useful in detection of chimeric contigs. |
6,080 | def get_all_resources(datasets):
resources = []
for dataset in datasets:
for resource in dataset.get_resources():
resources.append(resource)
return resources | Get all resources from a list of datasets (such as returned by search)
Args:
datasets (List[Dataset]): list of datasets
Returns:
List[hdx.data.resource.Resource]: list of resources within those datasets |
6,081 | def DeleteResource(self, path, type, id, initial_headers, options=None):
if options is None:
options = {}
initial_headers = initial_headers or self.default_headers
headers = base.GetHeaders(self,
initial_headers,
... | Deletes a Azure Cosmos resource and returns it.
:param str path:
:param str type:
:param str id:
:param dict initial_headers:
:param dict options:
The request options for the request.
:return:
The deleted Azure Cosmos resource.
:rtype:
... |
6,082 | def update_existing_peers( self, num_to_remove, peer_table=None, con=None, path=None ):
if path is None:
path = self.atlasdb_path
if self.last_clean_time + atlas_peer_clean_interval() < time_now():
log.debug("%s: revalidate old peers" % se... | Update the set of existing peers:
* revalidate the existing but old peers
* remove at most $num_to_remove unhealthy peers
Return the number of peers removed |
6,083 | def _does_not_contain_replica_sections(sysmeta_pyxb):
if len(getattr(sysmeta_pyxb, , [])):
raise d1_common.types.exceptions.InvalidSystemMetadata(
0,
.format(
d1_common.xml.get_req_val(sysmeta_pyxb.identifier)
),
identifier=d1... | Assert that ``sysmeta_pyxb`` does not contain any replica information. |
6,084 | def generate_key(filepath):
fs = path.abspath(path.expanduser(filepath))
with open(fs, ) as outfile:
outfile.write(Fernet.generate_key())
chmod(fs, 0o400)
return fs | generates a new, random secret key at the given location on the
filesystem and returns its path |
6,085 | def build_absolute_uri(request, url):
if app_settings.get():
return urljoin(app_settings.get(), url)
return request.build_absolute_uri(url) | Allow to override printing url, not necessarily on the same
server instance. |
6,086 | def valid_address(address):
if not address:
return False
components = str(address).split()
if len(components) > 2 or not valid_hostname(components[0]):
return False
if len(components) == 2 and not valid_port(components[1]):
return False
return True | Determines whether the specified address string is valid. |
6,087 | def _plot_ts_cols(ts):
logger_dataframes.info("enter get_ts_cols()")
d = {}
try:
units = " (" + ts["paleoData_units"] + ")"
except KeyError as e:
units = ""
logger_dataframes.warn("get_ts_cols: KeyError: paleoData_units not found, {}".format(e))
try:
d... | Get variable + values vs year, age, depth (whichever are available)
:param dict ts: TimeSeries dictionary
:return dict: Key: variableName, Value: Panda Series object |
6,088 | def video_loss(top_out, targets, model_hparams, vocab_size, weights_fn):
del vocab_size
logits = top_out
logits = tf.reshape(logits, [-1] + common_layers.shape_list(logits)[2:])
targets = tf.reshape(targets, [-1] + common_layers.shape_list(targets)[2:])
cutoff = getattr(model_hparams, "video_modality_los... | Compute loss numerator and denominator for one shard of output. |
6,089 | def _collect_args(args) -> ISeq:
if isinstance(args, tuple):
return llist.list(args)
raise TypeError("Python variadic arguments should always be a tuple") | Collect Python starred arguments into a Basilisp list. |
6,090 | def diff_medians(array_one, array_two):
array_one = check_array(array_one)
array_two = check_array(array_two)
diff_medians = np.ma.median(array_one) - np.ma.median(array_two)
return diff_medians | Computes the difference in medians between two arrays of values.
Given arrays will be flattened (to 1D array) regardless of dimension,
and any non-finite/NaN values will be ignored.
Parameters
----------
array_one, array_two : iterable
Two arrays of values, possibly of different length... |
6,091 | def get_equalisers(self):
if not self.__equalisers:
self.__equalisers = yield from self.handle_list(
self.API.get())
return self.__equalisers | Get the equaliser modes supported by this device. |
6,092 | def getDataFromFIFO(self, bytesToRead):
return self.i2c_io.readBlock(self.MPU6050_ADDRESS, self.MPU6050_RA_FIFO_R_W, bytesToRead) | reads the specified number of bytes from the FIFO, should be called after a call to getFifoCount to ensure there
is new data available (to avoid reading duplicate data).
:param bytesToRead: the number of bytes to read.
:return: the bytes read. |
6,093 | def delete(self):
removed = False
try:
with db.session.begin_nested():
if self.is_new():
db.session.delete(self)
removed = True
else:
self.status = P... | Delete the persistent identifier.
If the persistent identifier haven't been registered yet, it is
removed from the database. Otherwise, it's marked as
:attr:`invenio_pidstore.models.PIDStatus.DELETED`.
:returns: `True` if the PID is successfully removed. |
6,094 | def dim(self):
if len(self._orb.vxvv) == 2:
return 1
elif len(self._orb.vxvv) == 3 or len(self._orb.vxvv) == 4:
return 2
elif len(self._orb.vxvv) == 5 or len(self._orb.vxvv) == 6:
return 3 | NAME:
dim
PURPOSE:
return the dimension of the Orbit
INPUT:
(none)
OUTPUT:
dimension
HISTORY:
2011-02-03 - Written - Bovy (NYU) |
6,095 | def QA_SU_save_stock_terminated(client=DATABASE):
print("!!! tushare 这个函数已经失效!!!")
df = QATs.get_terminated()
print(
" Get stock terminated from tushare,stock count is %d (终止上市股票列表)" %
len(df)
)
coll = client.stock_terminated
client.drop_collection(coll)
... | 获取已经被终止上市的股票列表,数据从上交所获取,目前只有在上海证券交易所交易被终止的股票。
collection:
code:股票代码 name:股票名称 oDate:上市日期 tDate:终止上市日期
:param client:
:return: None |
6,096 | def analyses(self):
response = self._request("tasks/list")
return json.loads(response.content.decode())[] | Retrieve a list of analyzed samples.
:rtype: list
:return: List of objects referencing each analyzed file. |
6,097 | def set_level(self, position, channel=None):
try:
position = float(position)
except Exception as err:
LOG.debug("HelperLevel.set_level: Exception %s" % (err,))
return False
self.writeNodeData("LEVEL", position, channel) | Seek a specific value by specifying a float() from 0.0 to 1.0. |
6,098 | def set_breaks_and_labels(self, ranges, layout_info, pidx):
ax = self.axs[pidx]
facet.set_breaks_and_labels(self, ranges, layout_info, pidx)
ax.xaxis.set_ticks_position()
ax.yaxis.set_ticks_position() | Add breaks and labels to the axes
Parameters
----------
ranges : dict-like
range information for the axes
layout_info : dict-like
facet layout information
pidx : int
Panel index |
6,099 | def read_input_registers(slave_id, starting_address, quantity):
function = ReadInputRegisters()
function.starting_address = starting_address
function.quantity = quantity
return _create_request_adu(slave_id, function.request_pdu) | Return ADU for Modbus function code 04: Read Input Registers.
:param slave_id: Number of slave.
:return: Byte array with ADU. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.