Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
9,600 | def polygonize(layer):
output_layer_name = polygonize_steps[]
output_layer_name = output_layer_name % layer.keywords[]
gdal_layer_name = polygonize_steps[]
if layer.keywords.get() == :
output_field = exposure_type_field
else:
output_field = hazard_value_field
input_raster ... | Polygonize a raster layer into a vector layer using GDAL.
Issue https://github.com/inasafe/inasafe/issues/3183
:param layer: The layer to reproject.
:type layer: QgsRasterLayer
:return: Reprojected memory layer.
:rtype: QgsRasterLayer
.. versionadded:: 4.0 |
9,601 | def _clamp_value(value, minimum, maximum):
if maximum < minimum:
raise ValueError
if value < minimum:
return minimum
elif value > maximum:
return maximum
else:
return value | Clamp a value to fit between a minimum and a maximum.
* If ``value`` is between ``minimum`` and ``maximum``, return ``value``
* If ``value`` is below ``minimum``, return ``minimum``
* If ``value is above ``maximum``, return ``maximum``
Args:
value (float or int): The number to clamp
mi... |
9,602 | def task_collection_thread_handler(self, results_queue):
while self.tasks_to_add and not self.errors:
max_tasks = self._max_tasks_per_request
chunk_tasks_to_add = []
with self._pending_queue_lock:
while len(chunk_tasks_to_add) < max_tasks a... | Main method for worker to run
Pops a chunk of tasks off the collection of pending tasks to be added and submits them to be added.
:param collections.deque results_queue: Queue for worker to output results to |
9,603 | def read_shakemap(self, haz_sitecol, assetcol):
oq = self.oqparam
E = oq.number_of_ground_motion_fields
oq.risk_imtls = oq.imtls or self.datastore.parent[].imtls
extra = self.riskmodel.get_extra_imts(oq.risk_imtls)
if extra:
logging.warning(
... | Enabled only if there is a shakemap_id parameter in the job.ini.
Download, unzip, parse USGS shakemap files and build a corresponding
set of GMFs which are then filtered with the hazard site collection
and stored in the datastore. |
9,604 | def convert_out(self, obj):
newobj = super(ProcessedImageProduct, self).convert_out(obj)
if newobj:
hdulist = newobj.open()
hdr = hdulist[0].header
if not in hdr:
hdr[] = str(uuid.uuid1())
return newobj | Write EMIRUUID header on reduction |
9,605 | def delete(self):
if not self._created:
return
try:
node1 = self._nodes[0]["node"]
adapter_number1 = self._nodes[0]["adapter_number"]
port_number1 = self._nodes[0]["port_number"]
except IndexError:
return
try:
... | Delete the link and free the resources |
9,606 | def _action_allowed(self, action):
if getattr(self.layer.participation_settings, .format(action)) is False:
return False
else:
return getattr(self.participation_settings, .format(action)) | participation actions can be disabled on layer level, or disabled on a per node basis |
9,607 | def _expr2bddnode(expr):
if expr.is_zero():
return BDDNODEZERO
elif expr.is_one():
return BDDNODEONE
else:
top = expr.top
_ = bddvar(top.names, top.indices)
root = top.uniqid
lo = _expr2bddnode(expr.restrict({top: 0}))
hi = _expr2bddnod... | Convert an expression into a BDD node. |
9,608 | def get_select_sql(self):
return .format(
self.field.get_select_sql(),
self.name.upper(),
self.get_field_identifier(),
self.get_over(),
) | Calculate the difference between this record's value and the lag/lead record's value |
9,609 | def tiered_alignment(in_bam, tier_num, multi_mappers, extra_args,
genome_build, pair_stats,
work_dir, dirs, config):
nomap_fq1, nomap_fq2 = select_unaligned_read_pairs(in_bam, "tier{}".format(tier_num),
work_dir, c... | Perform the alignment of non-mapped reads from previous tier. |
9,610 | def put(self, storagemodel:object, modeldefinition = None) -> StorageQueueModel:
try:
message = modeldefinition[].put_message(storagemodel._queuename, storagemodel.getmessage())
storagemodel.mergemessage(message)
except Exception as e:
storagemodel = None
... | insert queue message into storage |
9,611 | def filter_accept_reftrack(self, reftrack):
if reftrack.status() in self._forbidden_status:
return False
if reftrack.get_typ() in self._forbidden_types:
return False
if reftrack.uptodate() in self._forbidden_uptodate:
return False
if reftrack.... | Return True, if the filter accepts the given reftrack
:param reftrack: the reftrack to filter
:type reftrack: :class:`jukeboxcore.reftrack.Reftrack`
:returns: True, if the filter accepts the reftrack
:rtype: :class:`bool`
:raises: None |
9,612 | def p_for_sentence_start(p):
gl.LOOPS.append((, p[2]))
p[0] = None
if p[4] is None or p[6] is None or p[7] is None:
return
if is_number(p[4], p[6], p[7]):
if p[4].value != p[6].value and p[7].value == 0:
warning(p.lineno(5), )
if p[4].value > p[6].value and p[... | for_start : FOR ID EQ expr TO expr step |
9,613 | def get_name_type_dict(self):
attrs = self.get_attributes()
types = self.get_types()
d = dict()
for i,a in enumerate(attrs):
d[a] = types[i]
return d | Returns a dictionary of the type
{'column_name': data_type, ...}
:return: dict |
9,614 | def _make_txn_selector(self):
if self._transaction_id is not None:
return TransactionSelector(id=self._transaction_id)
if self._read_timestamp:
key = "read_timestamp"
value = _datetime_to_pb_timestamp(self._read_timestamp)
elif self._min_read_timesta... | Helper for :meth:`read`. |
9,615 | async def remove(self, *instances, using_db=None) -> None:
db = using_db if using_db else self.model._meta.db
if not instances:
raise OperationalError("remove() called on no instances")
through_table = Table(self.field.through)
if len(instances) == 1:
co... | Removes one or more of ``instances`` from the relation. |
9,616 | def list_engines_by_priority(engines=None):
if engines is None:
engines = ENGINES
return sorted(engines, key=operator.methodcaller("priority")) | Return a list of engines supported sorted by each priority. |
9,617 | def platform_cache_dir():
if WIN32:
dpath_ =
elif LINUX:
dpath_ =
elif DARWIN:
dpath_ =
else:
raise NotImplementedError( % (sys.platform,))
dpath = normpath(expanduser(dpath_))
return dpath | Returns a directory which should be writable for any application
This should be used for temporary deletable data. |
9,618 | def _spinboxValueChanged(self, index, spinBox=None):
if spinBox is None:
spinBox = self.sender()
assert spinBox, "spinBox not defined and not the sender"
logger.debug("{} sigContentsChanged signal (spinBox)"
.format("Blocked" if self.signalsBlocked() e... | Is called when a spin box value was changed.
Updates the spin boxes and sets other combo boxes having the same index to
the fake dimension of length 1. |
9,619 | def creep_data(data_set=):
if not data_available(data_set):
download_data(data_set)
path = os.path.join(data_path, data_set)
tar_file = os.path.join(path, )
tar = tarfile.open(tar_file)
print()
tar.extractall(path=path)
tar.close()
all_data = np.loadt... | Brun and Yoshida's metal creep rupture data. |
9,620 | def consume_token(self, tokens, index, tokens_len):
del tokens_len
consumption_ended = False
q_type = self.quote_type
begin_literal_type = getattr(TokenType,
"Begin{0}QuotedLiteral".format(q_type))
end_literal_type = getattr(TokenT... | Consume a token.
Returns tuple of (tokens, tokens_len, index) when consumption is
completed and tokens have been merged together. |
9,621 | def train(self):
self.stamp_start = time.time()
for iteration, batch in tqdm.tqdm(enumerate(self.iter_train),
desc=, total=self.max_iter,
ncols=80):
self.epoch = self.iter_train.epoch
sel... | Train the network using the training dataset.
Parameters
----------
None
Returns
-------
None |
9,622 | def evalrepr(self):
if self.is_model():
return self.get_fullname()
else:
return self.parent.evalrepr + "." + self.name | Evaluable repr |
9,623 | def _put_key(file_path, dest_key=None, overwrite=True):
ret = api("POST /3/PutKey?destination_key={}&overwrite={}".format(dest_key if dest_key else , overwrite),
filename=file_path)
return ret["destination_key"] | Upload given file into DKV and save it under give key as raw object.
:param dest_key: name of destination key in DKV
:param file_path: path to file to upload
:return: key name if object was uploaded successfully |
9,624 | def copy(self):
copied = Trimesh()
copied._data.data = copy.deepcopy(self._data.data)
copied.visual = self.visual.copy()
copied.metadata = copy.deepcopy(self.metadata)
if self._center_mass is not None:
copied.center_mass =... | Safely get a copy of the current mesh.
Copied objects will have emptied caches to avoid memory
issues and so may be slow on initial operations until
caches are regenerated.
Current object will *not* have its cache cleared.
Returns
---------
copied : trimesh.Tri... |
9,625 | def update(self):
der = self.subpars
self(numpy.clip(1. - der.c1 - der.c3, 0., 1.)) | Update |C2| based on :math:`c_2 = 1.-c_1-c_3`.
Examples:
The following examples show the calculated value of |C2| are
clipped when to low or to high:
>>> from hydpy.models.hstream import *
>>> parameterstep('1d')
>>> derived.c1 = 0.6
>>>... |
9,626 | def info():
try:
platform_info = {
: platform.system(),
: platform.release(),
}
except IOError:
platform_info = {
: ,
: ,
}
implementation_info = _implementation()
urllib3_info = {: urllib3.__version__}
chardet_inf... | Generate information for a bug report. |
9,627 | def alias_composition(self, composition_id, alias_id):
self._alias_id(primary_id=composition_id, equivalent_id=alias_id) | Adds an ``Id`` to a ``Composition`` for the purpose of creating compatibility.
The primary ``Id`` of the ``Composition`` is determined by the
provider. The new ``Id`` is an alias to the primary ``Id``. If
the alias is a pointer to another composition, it is reassigned
to the given compo... |
9,628 | def parse_xml_node(self, node):
self.sequence = int(node.getAttributeNS(RTS_NS, ))
c = node.getElementsByTagNameNS(RTS_NS, )
if c.length != 1:
raise InvalidParticipantNodeError
self.target_component = TargetExecutionContext().parse_xml_node(c[0])
for c in get... | Parse an xml.dom Node object representing a condition into this
object. |
9,629 | def average(numbers, numtype=):
if type == :
return Decimal(sum(numbers)) / len(numbers)
else:
return float(sum(numbers)) / len(numbers) | Calculates the average or mean of a list of numbers
Args:
numbers: a list of integers or floating point numbers.
numtype: string, 'decimal' or 'float'; the type of number to return.
Returns:
The average (mean) of the numbers as a floating point number
or a Decimal object.
... |
9,630 | def find(self, name):
collectors = self.get_collectors()
for collector in collectors:
if name.lower() == collector[].lower():
self.collector_id = collector[]
return collector
return {: } | Returns a dict of collector's details if found.
Args:
name (str): name of collector searching for |
9,631 | def run_command(self, codeobj):
try:
value, stdout = yield from self.attempt_exec(codeobj, self.namespace)
except Exception:
yield from self.send_exception()
return
else:
yield from self.send_output(value, stdout) | Execute a compiled code object, and write the output back to the client. |
9,632 | def clients(self, protocol=None, groups=None):
groups = self.__group_replace_eval_by_genuine__(groups)
groups = self.check_parameters_for_validity(groups, "group", self.client_types())
q = self.query(Client)
if groups:
q = q.filter(Client.stype.in_(groups))
q = q.order_by(Client.id)... | Returns a list of :py:class:`.Client` for the specific query by the user.
Keyword Parameters:
protocol
Ignored.
groups
The groups (types) to which the clients belong either from ('Genuine', 'Impostor')
Note that 'eval' is an alias for 'Genuine'.
If no groups are specified, then bo... |
9,633 | def play_sync(self):
self.play()
logger.info("Playing synchronously")
try:
time.sleep(0.05)
logger.debug("Wait for playing to start")
while self.is_playing():
time.sleep(0.05)
except DBusException:
logger.error(
... | Play the video and block whilst the video is playing |
9,634 | def err_exit(msg, rc=1):
print(msg, file=sys.stderr)
sys.exit(rc) | Print msg to stderr and exit with rc. |
9,635 | def picknthweekday(year, month, dayofweek, hour, minute, whichweek):
first = datetime.datetime(year, month, 1, hour, minute)
weekdayone = first.replace(day=((dayofweek - first.isoweekday()) % 7) + 1)
wd = weekdayone + ((whichweek - 1) * ONEWEEK)
if (wd.month != month):
wd -= ONEW... | dayofweek == 0 means Sunday, whichweek 5 means last instance |
9,636 | def most_visited_venues_card(num=10):
if spectator_apps.is_enabled():
object_list = most_visited_venues(num=num)
object_list = chartify(object_list, , cutoff=1)
return {
: ,
: ,
: object_list,
} | Displays a card showing the Venues that have the most Events.
In spectator_core tags, rather than spectator_events so it can still be
used on core pages, even if spectator_events isn't installed. |
9,637 | def items(self) -> Iterable[Tuple[str, Any]]:
return [(opt.name, opt.value()) for name, opt in self._options.items()] | An iterable of (name, value) pairs.
.. versionadded:: 3.1 |
9,638 | def restore(self, state):
selector = DataStreamSelector.FromString(state.get(u))
if selector != self.selector:
raise ArgumentError("Attempted to restore a BufferedStreamWalker with a different selector",
selector=self.selector, serialized_data=state)... | Restore a previous state of this stream walker.
Raises:
ArgumentError: If the state refers to a different selector or the
offset is invalid. |
9,639 | def get_default_config(self):
config = super(NumaCollector, self).get_default_config()
config.update({
: ,
: self.find_binary(),
})
return config | Returns the default collector settings |
9,640 | def _set_mode(self, discover_mode, connect_mode):
payload = struct.pack("<BB", discover_mode, connect_mode)
response = self._send_command(6, 1, payload)
result, = unpack("<H", response.payload)
if result != 0:
return False, {: , : result}
return True, None | Set the mode of the BLED112, used to enable and disable advertising
To enable advertising, use 4, 2.
To disable advertising use 0, 0.
Args:
discover_mode (int): The discoverability mode, 0 for off, 4 for on (user data)
connect_mode (int): The connectability mode, 0 for ... |
9,641 | def iter_package_families(paths=None):
for path in (paths or config.packages_path):
repo = package_repository_manager.get_repository(path)
for resource in repo.iter_package_families():
yield PackageFamily(resource) | Iterate over package families, in no particular order.
Note that multiple package families with the same name can be returned.
Unlike packages, families later in the searchpath are not hidden by earlier
families.
Args:
paths (list of str, optional): paths to search for package families,
... |
9,642 | def close(self):
self.time_to_quit = True
self.close_window.release()
if self.child.is_alive():
self.child.join(1)
self.child.terminate()
self.mavlink_message_queue_handler.join()
self.event_queue_lock.acquire()
self.event_queue.put(Mission... | close the Mission Editor window |
9,643 | def send_command(self, *args, **kwargs):
if len(args) >= 2:
expect_string = args[1]
else:
expect_string = kwargs.get("expect_string")
if expect_string is None:
expect_string = r"(OK|ERROR|Command not recognized\.)"
expect_strin... | Send command to network device retrieve output until router_prompt or expect_string
By default this method will keep waiting to receive data until the network device prompt is
detected. The current network device prompt will be determined automatically.
command_string = command to execute
... |
9,644 | def build_listen(self, listen_node):
proxy_name = listen_node.listen_header.proxy_name.text
service_address_node = listen_node.listen_header.service_address
config_block_lines = self.__build_config_block(
listen_node.config_block)
host, port = ,
... | parse `listen` sections, and return a config.Listen
Args:
listen_node (TreeNode): Description
Returns:
config.Listen: an object |
9,645 | def _get_bgp_route_attr(self, destination, vrf, next_hop, ip_version=4):
CMD_SHIBNV =
search_re_dict = {
"aspath": {
"re": r"AS-Path: ([\d\(\)]([\d\(\) ])*)",
"group": 1,
"default": "",
},
"bgpnh": {
... | BGP protocol attributes for get_route_tp
Only IPv4 supported |
9,646 | def register(linter):
linter.register_checker(TypeChecker(linter))
linter.register_checker(IterableChecker(linter)) | required method to auto register this checker |
9,647 | def modify(
login, password=None, password_hashed=False,
domain=None, profile=None, script=None,
drive=None, homedir=None, fullname=None,
account_desc=None, account_control=None,
machine_sid=None, user_sid=None,
reset_login_hours=False, reset_bad_password_count=False,
):
*Inara Serra**V:\\\\... | Modify user account
login : string
login name
password : string
password
password_hashed : boolean
set if password is a nt hash instead of plain text
domain : string
users domain
profile : string
profile path
script : string
logon script
drive... |
9,648 | def advance_for_next_slice(self, recovery_slice=False):
self.slice_start_time = None
self.slice_request_id = None
self.slice_retries = 0
self.acquired_once = False
if recovery_slice:
self.slice_id += 2
else:
self.slice_id += 1 | Advance self for next slice.
Args:
recovery_slice: True if this slice is running recovery logic.
See handlers.MapperWorkerCallbackHandler._attempt_slice_recovery
for more info. |
9,649 | def Hide(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
return self.ShowWindow(SW.Hide, waitTime) | Call native `ShowWindow(SW.Hide)`.
waitTime: float
Return bool, True if succeed otherwise False. |
9,650 | def delete_datapoints_in_time_range(self, start_dt=None, end_dt=None):
start_dt = to_none_or_dt(validate_type(start_dt, datetime.datetime, type(None)))
end_dt = to_none_or_dt(validate_type(end_dt, datetime.datetime, type(None)))
params = {}
if start_dt is not None:
... | Delete datapoints from this stream between the provided start and end times
If neither a start or end time is specified, all data points in the stream
will be deleted.
:param start_dt: The datetime after which data points should be deleted or None
if all data points from the beginn... |
9,651 | def _update_doc(self, func_doc):
deprecated_doc = "Deprecated"
if self.tip_info:
deprecated_doc = "{}: {}".format(deprecated_doc, self.tip_info)
if func_doc:
func_doc = "{}\n{}".format(deprecated_doc, func_doc)
return func_doc | 更新文档信息,把原来的文档信息进行合并格式化,
即第一行为deprecated_doc(Deprecated: tip_info),下一行为原始func_doc |
9,652 | def push(cpu, value, size):
assert size in (8, 16, cpu.address_bit_size)
cpu.STACK = cpu.STACK - size // 8
base, _, _ = cpu.get_descriptor(cpu.read_register())
address = cpu.STACK + base
cpu.write_int(address, value, size) | Writes a value in the stack.
:param value: the value to put in the stack.
:param size: the size of the value. |
9,653 | def savvyize(self, input_string, recursive=False, stemma=False):
input_string = os.path.abspath(input_string)
tasks = []
restricted = [ symbol for symbol in self.settings[] ] if self.settings[] else []
if os.path.isdir(input_string):
if recursive:
... | Determines which files should be processed
NB: this is the PUBLIC method
@returns filenames_list |
9,654 | def _get_connection(self):
try:
if self._ncc_connection and self._ncc_connection.connected:
return self._ncc_connection
else:
self._ncc_connection = manager.connect(
host=self._host_ip, port=se... | Make SSH connection to the IOS XE device.
The external ncclient library is used for creating this connection.
This method keeps state of any existing connections and reuses them if
already connected. Also interfaces (except management) are typically
disabled by default when it is booted... |
9,655 | def _wrap(value):
if is_primitive(value):
return value
if isinstance(value, (dict, set)) or is_namedtuple(value):
return value
elif isinstance(value, collections.Iterable):
try:
if type(value).__name__ == :
import pandas
if isinstance(... | Wraps the passed value in a Sequence if it is not a primitive. If it is a string
argument it is expanded to a list of characters.
>>> _wrap(1)
1
>>> _wrap("abc")
['a', 'b', 'c']
>>> type(_wrap([1, 2]))
functional.pipeline.Sequence
:param value: value to wrap
:return: wrapped or n... |
9,656 | def requeue(self, message_id, timeout=0, backoff=True):
self.send(nsq.requeue(message_id, timeout))
self.finish_inflight()
self.on_requeue.send(
self,
message_id=message_id,
timeout=timeout,
backoff=backoff
) | Re-queue a message (indicate failure to process). |
9,657 | def start_greedy_ensemble_search(automated_run, session, path):
module = functions.import_string_code_as_module(automated_run.source)
assert module.metric_to_optimize in automated_run.base_learner_origin.metric_generators
best_ensemble = []
secondary_learner = automated_run.base_learner_origin.... | Starts an automated ensemble search using greedy forward model selection.
The steps for this search are adapted from "Ensemble Selection from Libraries of Models" by
Caruana.
1. Start with the empty ensemble
2. Add to the ensemble the model in the library that maximizes the ensemmble's
performanc... |
9,658 | def stopMessage(self, apiMsgId):
content = self.parseRest(self.request( + apiMsgId, {}, {}, ))
return {
: content[].encode(),
: content[].encode(),
: self.getStatus(content[])
} | See parent method for documentation |
9,659 | def _delete_resource(name, name_param, desc, res_type, wait=0, status_param=None,
status_gone=, region=None, key=None, keyid=None, profile=None,
**args):
try:
wait = int(wait)
except Exception:
raise SaltInvocationError("Bad value () passed for par... | Delete a generic Elasticache resource. |
9,660 | def asset_create_task(self, *args, **kwargs):
if not self.cur_asset:
return
task = self.create_task(element=self.cur_asset)
if task:
taskdata = djitemdata.TaskItemData(task)
treemodel.TreeItem(taskdata, self.asset_task_model.root) | Create a new task
:returns: None
:rtype: None
:raises: None |
9,661 | def _refresh_outlineexplorer(self, index=None, update=True, clear=False):
oe = self.outlineexplorer
if oe is None:
return
if index is None:
index = self.get_stack_index()
if self.data:
finfo = self.data[index]
oe.setEnable... | Refresh outline explorer panel |
9,662 | def map_port(protocol, public_port, private_port, lifetime=3600,
gateway_ip=None, retry=9, use_exception=True):
if protocol not in [NATPMP_PROTOCOL_UDP, NATPMP_PROTOCOL_TCP]:
raise ValueError("Must be either NATPMP_PROTOCOL_UDP or "
"NATPMP_PROTOCOL_TCP")
... | A function to map public_port to private_port of protocol.
Returns the complete response on success.
protocol - NATPMP_PROTOCOL_UDP or NATPMP_PROTOCOL_TCP
public_port - the public port of the mapping requested
private_port - the private port of the mapping request... |
9,663 | def customize_compiler_for_nvcc(compiler, nvcc_settings):
compiler.src_extensions.append()
default_compiler_so = compiler.compiler_so
default_compile = compiler._compile
default_compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
compiler.compiler_s... | inject deep into distutils to customize gcc/nvcc dispatch |
9,664 | def jinja_loader(self):
loaders = self._jinja_loaders
del self._jinja_loaders
loaders.append(Flask.jinja_loader.func(self))
loaders.reverse()
return jinja2.ChoiceLoader(loaders) | Search templates in custom app templates dir (default Flask
behaviour), fallback on abilian templates. |
9,665 | def get_ppis(self, ppi_df):
logger.info()
for ix, row in ppi_df.iterrows():
agA = self._make_agent(row[])
agB = self._make_agent(row[])
stmt = Complex([agA, agB], evidence=ev_list)
self.statements.append(stmt) | Generate Complex Statements from the HPRD PPI data.
Parameters
----------
ppi_df : pandas.DataFrame
DataFrame loaded from the BINARY_PROTEIN_PROTEIN_INTERACTIONS.txt
file. |
9,666 | def document_frequencies(self, hashes):
result = {}
for (k, v) in self.client.get(HASH_FREQUENCY_TABLE,
*[(h,) for h in hashes]):
if v is None:
v = 0
result[k[0]] = v
return result | Get document frequencies for a list of hashes.
This will return all zeros unless the index was written with
`hash_frequencies` set. If :data:`DOCUMENT_HASH_KEY` is
included in `hashes`, that value will be returned with the
total number of documents indexed. If you are looking for
... |
9,667 | def create_account(self, body, **kwargs):
kwargs[] = True
if kwargs.get():
return self.create_account_with_http_info(body, **kwargs)
else:
(data) = self.create_account_with_http_info(body, **kwargs)
return data | Create a new account. # noqa: E501
An endpoint for creating a new account. **Example usage:** `curl -X POST https://api.us-east-1.mbedcloud.com/v3/accounts -d '{\"display_name\": \"MyAccount1\", \"admin_name\": \"accountAdmin1\", \"email\": \"example_admin@myaccount.info\"}' -H 'content-type: application/js... |
9,668 | def TargetDirectory(ID, season, relative=False, **kwargs):
if season is None:
return None
if relative:
path =
else:
path = EVEREST_DAT
return os.path.join(path, , % season,
( % ID)[:4] + ,
( % ID)[4:]) | Returns the location of the :py:mod:`everest` data on disk
for a given target.
:param ID: The target ID
:param int season: The target season number
:param bool relative: Relative path? Default :py:obj:`False` |
9,669 | def section_tortuosity(section):
pts = section.points
return 1 if len(pts) < 2 else mm.section_length(pts) / mm.point_dist(pts[-1], pts[0]) | Tortuosity of a section
The tortuosity is defined as the ratio of the path length of a section
and the euclidian distnce between its end points.
The path length is the sum of distances between consecutive points.
If the section contains less than 2 points, the value 1 is returned. |
9,670 | def prepare_url(hostname, path, params=None):
url = hostname + path
if params:
url = url + + urlencode(params)
if not url.startswith((, )):
url = "http://" + url
return url.encode() | Prepare Elasticsearch request url.
:param hostname: host name
:param path: request path
:param params: optional url params
:return: |
9,671 | def _parse_date_rfc822(dateString):
data = dateString.split()
if data[0][-1] in (, ) or data[0].lower() in _daynames:
del data[0]
if len(data) == 4:
s = data[3]
s = s.split(, 1)
if len(s) == 2:
data[3:] = s
else:
data.append()
date... | Parse an RFC822, RFC1123, RFC2822, or asctime-style date |
9,672 | def ack(self, device_uuid, ack_keys):
attributes = {: ack_keys}
status_code, _, _ = self.http_client.post(,
body=attributes,
headers=self.build_headers(device_uuid))
return status_code ... | Acknowledge received data
Send acknowledgement keys to let know the Sync service which data you have.
As you fetch new data, you need to send acknowledgement keys.
:calls: ``post /sync/ack``
:param string device_uuid: Device's UUID for which to perform synchronization.
:param l... |
9,673 | def do_symbols_matching(self):
self._clear_decorations()
current_block = self.editor.textCursor().block()
data = get_block_symbol_data(self.editor, current_block)
pos = self.editor.textCursor().block().position()
for symbol in [PAREN, SQUARE, BRACE]:
self._ma... | Performs symbols matching. |
9,674 | def add_contacts(
self,
contacts: List["pyrogram.InputPhoneContact"]
):
imported_contacts = self.send(
functions.contacts.ImportContacts(
contacts=contacts
)
)
return imported_contacts | Use this method to add contacts to your Telegram address book.
Args:
contacts (List of :obj:`InputPhoneContact <pyrogram.InputPhoneContact>`):
The contact list to be added
Returns:
On success, the added contacts are returned.
Raises:
:class:... |
9,675 | def make_signature(name, params, common_params, common_param_values):
tokens = []
seen = set()
def tokens_append(key, value):
if isinstance(value, str):
value = "".format(value)
tokens.append(.format(key, value))
for key in common_params:
seen.add(key)
... | Create a signature for a geom or stat
Gets the DEFAULT_PARAMS (params) and creates are comma
separated list of the `name=value` pairs. The common_params
come first in the list, and they get take their values from
either the params-dict or the common_geom_param_values-dict. |
9,676 | def copy_files(filelist, destdir):
for filename in filelist:
destfile = os.path.join(destdir, filename)
assert destfile.startswith(destdir + os.path.sep)
destfiledir = os.path.dirname(destfile)
if not os.path.isdir(destfiledir):
os.makedirs(destfiledir)
... | Copy a list of files to destdir, preserving directory structure.
File names should be relative to the current working directory. |
9,677 | def ts_func(f):
def wrap_func(df, *args):
return Chromatogram(f(df.values, *args), df.index, df.columns)
return wrap_func | This wraps a function that would normally only accept an array
and allows it to operate on a DataFrame. Useful for applying
numpy functions to DataFrames. |
9,678 | def __voronoi_finite_polygons_2d(vor, radius=None):
if vor.points.shape[1] != 2:
raise ValueError("Requires 2D input")
new_regions = []
new_vertices = vor.vertices.tolist()
center = vor.points.mean(axis=0)
if radius is None:
radius = vor.points... | Reconstruct infinite voronoi regions in a 2D diagram to finite
regions.
Parameters
----------
vor : Voronoi
Input diagram
radius : float, optional
Distance to 'points at infinity'.
Returns
-------
regions : list of tuples
... |
9,679 | def create_shield_layer(shield, hashcode):
return pgnreader.parse_pagan_file(( % (PACKAGE_DIR, os.sep, os.sep)) + shield + , hashcode, sym=False, invert=False) | Creates the layer for shields. |
9,680 | def push_dcp(event, callback, position=):
ctx = stack.top
ctx.app.extensions.get().push_dcp(event, callback, position) | Push a callable for :class:`~flask_pluginkit.PluginManager`, :func:`push_dcp`.
Example usage::
push_dcp('demo', lambda:'Hello dcp')
.. versionadded:: 2.1.0 |
9,681 | def make_index(gff_file):
import gffutils
db_file = gff_file + ".db"
if need_update(gff_file, db_file):
if op.exists(db_file):
os.remove(db_file)
logging.debug("Indexing `{0}`".format(gff_file))
gffutils.create_db(gff_file, db_file, merge_strategy="create_unique")
... | Make a sqlite database for fast retrieval of features. |
9,682 | def add_section(self, name=None, anchor=None, description=, comment=, helptext=, plot=, content=, autoformat=True, autoformat_type=):
if anchor is None:
if name is not None:
nid = name.lower().strip().replace(,)
anchor = .format(self.anchor, nid)
... | Add a section to the module report output |
9,683 | def monthly(usaf, year, field=):
m = []
lastm = 1
usafdata = Data(usaf, year)
t = 0
for r in usafdata:
r[] = r[]
r[] = r[]
r[] = r[]
if r[].month != lastm:
m.append(t/1000.)
t = 0
lastm = r[].month
t += float(r[field])
... | monthly insolation |
9,684 | def parse_napp(napp_id):
regex = r
compiled_regex = re.compile(regex)
matched = compiled_regex.fullmatch(napp_id)
if not matched:
msg =
raise KytosException(msg.format(napp_id))
return matched.groups() | Convert a napp_id in tuple with username, napp name and version.
Args:
napp_id: String with the form 'username/napp[:version]' (version is
optional). If no version is found, it will be None.
Returns:
tuple: A tuple with (username, napp, version)
Raises:
KytosExce... |
9,685 | def constraints(self):
if self._parent is not None:
return tuple(self._constraints) + self._parent.constraints
return tuple(self._constraints) | :rtype tuple
:return: All constraints represented by this and parent sets. |
9,686 | def intersect_arc(self, arc):
intersections = self.intersect_circle(arc.center, arc.radius)
isections = [pt for pt in intersections if arc.contains_angle_degrees(arc.point_as_angle(pt))]
return isections | Given an arc, finds the intersection point(s) of this arc with that.
Returns a list of 2x1 numpy arrays. The list has length 0, 1 or 2, depending on how many intesection points there are.
Points are ordered along the arc.
Intersection with the arc along the same circle (which means infinitely ma... |
9,687 | def convert_multiPointSource(self, node):
geom = node.multiPointGeometry
lons, lats = zip(*split_coords_2d(~geom.posList))
msr = valid.SCALEREL[~node.magScaleRel]()
return source.MultiPointSource(
source_id=node[],
name=node[],
tectonic_region... | Convert the given node into a MultiPointSource object.
:param node: a node with tag multiPointGeometry
:returns: a :class:`openquake.hazardlib.source.MultiPointSource` |
9,688 | def git_log_iterator(path):
N = 10
count = 0
while True:
lines = _run_git_command_lines([, ,
, str(N),
, str(count),
, ], cwd=path)
for line in lines:
sha ... | yield commits using git log -- <dir> |
9,689 | def clear_lock(self, key):
lock_path = self._get_lock_path(key)
os.remove(lock_path) | Remove the lock file. |
9,690 | def is_all_field_none(self):
if self._share_detail is not None:
return False
if self._start_date is not None:
return False
if self._end_date is not None:
return False
return True | :rtype: bool |
9,691 | def _temporary_keychain():
random_bytes = os.urandom(40)
filename = base64.b16encode(random_bytes[:8]).decode()
password = base64.b16encode(random_bytes[8:])
tempdirectory = tempfile.mkdtemp()
keychain_path = os.path.join(tempdirectory, filename).encode()
keycha... | This function creates a temporary Mac keychain that we can use to work with
credentials. This keychain uses a one-time password and a temporary file to
store the data. We expect to have one keychain per socket. The returned
SecKeychainRef must be freed by the caller, including calling
SecKeychainDelete.... |
9,692 | def setdefault (self, key, *args):
assert isinstance(key, basestring)
return dict.setdefault(self, key.lower(), *args) | Set lowercase key value and return. |
9,693 | def get_step_f(step_f, lR2, lS2):
mu, tau = 10, 2
if lR2 > mu*lS2:
return step_f * tau
elif lS2 > mu*lR2:
return step_f / tau
return step_f | Update the stepsize of given the primal and dual errors.
See Boyd (2011), section 3.4.1 |
9,694 | def wgan(cls, data:DataBunch, generator:nn.Module, critic:nn.Module, switcher:Callback=None, clip:float=0.01, **learn_kwargs):
"Create a WGAN from `data`, `generator` and `critic`."
return cls(data, generator, critic, NoopLoss(), WassersteinLoss(), switcher=switcher, clip=clip, **learn_kwargs) | Create a WGAN from `data`, `generator` and `critic`. |
9,695 | def from_coords(cls, coords, sort=True):
coords = list(coords)
if sort:
coords.sort()
if len(coords[0]) == 2:
lons, lats = zip(*coords)
depths = None
else:
lons, lats, depths = zip(*coords)
depths = numpy.array(dept... | Create a mesh object from a list of 3D coordinates (by sorting them)
:params coords: list of coordinates
:param sort: flag (default True)
:returns: a :class:`Mesh` instance |
9,696 | def change(self, inpt, hashfun=DEFAULT_HASHFUN):
self.img = self.__create_image(inpt, hashfun) | Change the avatar by providing a new input.
Uses the standard hash function if no one is given. |
9,697 | def join_path(a, *p):
path = a
for b in p:
if len(b) == 0:
continue
if b.startswith():
path += b[1:]
elif path == or path.endswith():
path += b
else:
path += + b
return path | Join path tokens together similar to osp.join, but always use
'/' instead of possibly '\' on windows. |
9,698 | def sudo_yield_file_lines(file_path=):
r
sudo_cat_cmd = .format(file_path)
process = subprocess.Popen(sudo_cat_cmd, stdout=subprocess.PIPE, shell=True)
for line in iter(process.stdout.readline, ):
yield line | r"""Cat a file iterating/yielding one line at a time,
shell will execute: `sudo cat $file_path` so if your shell doesn't have sudo or cat, no joy
Input:
file_path(str): glob stars are fine
>> for line in sudo_yield_file_lines('/etc/NetworkManager/system-connections/*') |
9,699 | def get_symbols_list(self):
slist = []
rc, nSymb, nElem = gdxcc.gdxSystemInfo(self.gdx_handle)
assert rc, % self.filename
self.number_symbols = nSymb
self.number_elements = nElem
slist = [None]*(nSymb+1)
for j in range(0,nSymb+1):
sinfo = sel... | Return a list of GdxSymb found in the GdxFile. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.