Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
376,300 | def cancel(self):
if self.OBSERVE_UPDATES:
self.detach()
self.ioloop.add_callback(self.cancel_timeouts) | Detach strategy from its sensor and cancel ioloop callbacks. |
376,301 | def pdna_network_from_bbox(
lat_min=None, lng_min=None, lat_max=None, lng_max=None, bbox=None,
network_type=, two_way=True,
timeout=180, memory=None, max_query_area_size=50 * 1000 * 50 * 1000):
nodes, edges = network_from_bbox(lat_min=lat_min, lng_min=lng_min,
... | Make a Pandana network from a bounding lat/lon box
request to the Overpass API. Distance will be in the default units meters.
Parameters
----------
lat_min, lng_min, lat_max, lng_max : float
bbox : tuple
Bounding box formatted as a 4 element tuple:
(lng_max, lat_min, lng_min, lat_ma... |
376,302 | def validate_format(self, obj, pointer=None):
if in self.attrs:
substituted = {
: ,
: ,
: ,
: ,
: ,
: ,
}.get(self.attrs[], self.attrs[])
logger.debug(, substituted)
... | ================= ============
Expected draft04 Alias of
----------------- ------------
date-time rfc3339.datetime
email email
hostname hostname
ipv4 ipv4
ipv6 ipv6
uri uri
=====... |
376,303 | def set_chat_description(
self,
chat_id: Union[int, str],
description: str
) -> bool:
peer = self.resolve_peer(chat_id)
if isinstance(peer, (types.InputPeerChannel, types.InputPeerChat)):
self.send(
functions.messages.EditChatAbout(
... | Use this method to change the description of a supergroup or a channel.
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
... |
376,304 | def from_str(text):
segment_list = chat_message_parser.parse(text)
return [ChatMessageSegment(segment.text, **segment.params)
for segment in segment_list] | Construct :class:`ChatMessageSegment` list parsed from a string.
Args:
text (str): Text to parse. May contain line breaks, URLs and
formatting markup (simplified Markdown and HTML) to be
converted into equivalent segments.
Returns:
List of :class... |
376,305 | def readTempC(self):
v = self._read32()
if v & 0x7:
return float()
if v & 0x80000000:
v >>= 18
v -= 16384
else:
v >>= 18
return v * 0.25 | Return the thermocouple temperature value in degrees celsius. |
376,306 | def get_none_policy_text(none_policy,
verbose=False
):
if none_policy is NonePolicy.SKIP:
return "accept None without performing validation" if verbose else
elif none_policy is NonePolicy.FAIL:
return "fail on None without performing v... | Returns a user-friendly description of a NonePolicy taking into account NoneArgPolicy
:param none_policy:
:param verbose:
:return: |
376,307 | def _make_2d_array(self, data):
if data.shape != self.mesh_idx.shape:
raise ValueError()
if np.ma.is_masked(data):
raise ValueError()
data2d = np.zeros(self._mesh_shape).astype(data.dtype)
data2d[self.mesh_yidx, self.mesh_xidx] = data
if len(s... | Convert a 1D array of mesh values to a masked 2D mesh array
given the 1D mesh indices ``mesh_idx``.
Parameters
----------
data : 1D `~numpy.ndarray`
A 1D array of mesh values.
Returns
-------
result : 2D `~numpy.ma.MaskedArray`
A 2D maske... |
376,308 | def _bitResponseToValue(bytestring):
_checkString(bytestring, description=, minlength=1, maxlength=1)
RESPONSE_ON =
RESPONSE_OFF =
if bytestring == RESPONSE_ON:
return 1
elif bytestring == RESPONSE_OFF:
return 0
else:
raise ValueError(.format(bytestring)) | Convert a response string to a numerical value.
Args:
bytestring (str): A string of length 1. Can be for example ``\\x01``.
Returns:
The converted value (int).
Raises:
TypeError, ValueError |
376,309 | def get_results(self, *, block=False, timeout=None):
deadline = None
if timeout:
deadline = time.monotonic() + timeout / 1000
for message in self.messages:
if deadline:
timeout = max(0, int((deadline - time.monotonic()) * 1000))
yiel... | Get the results of each job in the pipeline.
Parameters:
block(bool): Whether or not to block until a result is set.
timeout(int): The maximum amount of time, in ms, to wait for
a result when block is True. Defaults to 10 seconds.
Raises:
ResultMissing: When ... |
376,310 | def generate_map_from_dataset(self, l_dataset):
l_map = []
headers = l_dataset.get_header()
print(headers)
for row_num, col in enumerate(headers):
if col != :
l_map.append( + str(row_num) + + l_dataset.force_to_string(col))
for row_n... | creates a map file (in the standard CSV format) based on
columns of a dataset.
1. read column names, lookup names in list
2. read column content, get highest match of distinct values
from ontology lists (eg, Years, countries, cities, ages) |
376,311 | def asset_save_callback(self, *args, **kwargs):
tasksel = self.browser.assetbrws.selected_indexes(2)
if not tasksel or not tasksel[0].isValid():
self.statusbar.showMessage()
return
taskitem = tasksel[0].internalPointer()
task = taskitem.internal_data()
... | Callback for the shot open button
:returns: None
:rtype: None
:raises: None |
376,312 | def get_auth_settings():
from yacms.conf import settings
try:
auth_settings = (settings.TWITTER_CONSUMER_KEY,
settings.TWITTER_CONSUMER_SECRET,
settings.TWITTER_ACCESS_TOKEN_KEY,
settings.TWITTER_ACCESS_TOKEN_SECRET)
exc... | Returns all the key/secret settings for Twitter access,
only if they're all defined. |
376,313 | def fetch(self, category=CATEGORY_ENTRY):
kwargs = {}
items = super().fetch(category, **kwargs)
return items | Fetch the entries from the url.
The method retrieves all entries from a RSS url
:param category: the category of items to fetch
:returns: a generator of entries |
376,314 | def register_views(app_name, view_filename, urlpatterns=None):
app_module = __import__(app_name)
view_module = getattr(app_module, view_filename)
views = dir(view_module)
for view_name in views:
if view_name.endswith():
view = getattr(view_module, view_name)
if isins... | app_name APP名
view_filename views 所在的文件
urlpatterns url中已经存在的urlpatterns
return urlpatterns
只导入View结尾的,是类的视图 |
376,315 | def chunk(sentence, format=None):
sentence = pos_tag(sentence)
crf_model = CRFChunkingPredictor.Instance()
result = crf_model.predict(sentence, format)
return result | Vietnamese chunking
Parameters
==========
sentence: {unicode, str}
raw sentence
Returns
=======
tokens: list of tuple with word, pos tag, chunking tag
tagged sentence
Examples
--------
>>> # -*- coding: utf-8 -*-
>>> from underthesea import chunk
>>> sen... |
376,316 | def disembowel(rest):
"Disembowel some(one|thing)!"
if rest:
stabee = rest
karma.Karma.store.change(stabee, -1)
else:
stabee = "someone nearby"
return (
"/me takes %s, brings them down to the basement, ties them to a "
"leaky pipe, and once bored of playing with them mercifully "
"ritually disembowels t... | Disembowel some(one|thing)! |
376,317 | def set_resource(self, service_name, resource_name, to_cache):
self.services.setdefault(service_name, {})
self.services[service_name].setdefault(, {})
self.services[service_name][].setdefault(resource_name, {})
options = self.services[service_name][][resource_name]
class... | Sets the resource class within the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param resource_name: The name of the ``Resource``. Ex.
``Queue``, ``Notification``, ``Table``, ... |
376,318 | def plot_kde(data, ax, title=None, color=, fill_bt=True):
if isinstance(data, list):
data = np.asarray(data)
e = kde.KDEUnivariate(data.astype(np.float))
e.fit()
ax.plot(e.support, e.density, color=color, alpha=0.9, linewidth=2.25)
if fill_bt:
ax.fill_between(e.support, e.densit... | Plot a smoothed (by kernel density estimate) histogram.
:type data: numpy array
:param data: An array containing the data to be plotted
:type ax: matplotlib.Axes
:param ax: The Axes object to draw to
:type title: str
:param title: The plot title
:type color: str
:param color: The colo... |
376,319 | def global_instance(cls):
try:
return GLOBAL_BATCHER.instance
except AttributeError:
instance = PrioritizedBatcher(
**getattr(settings, , {})
)
GLOBAL_BATCHER.instance = instance
return instance | Return a per-thread global batcher instance. |
376,320 | def get_modules(self):
if not self.project_abspath:
raise TypeError("project_abspath can not be empty.")
packages_abspath = self.get_package_abspath()
for package_abspath in packages_abspath:
self.get_module_name(package_abspath)
return self._modules | Get modules by project_abspath and packages_scan.
Traverse all files under folder packages_scan which set by customer.
And get all modules name. |
376,321 | def config_hook(self, func):
argspec = inspect.getargspec(func)
args = [, , ]
if not (argspec.args == args and argspec.varargs is None and
argspec.keywords is None and argspec.defaults is None):
raise ValueError(
)
self.co... | Decorator to add a config hook to this ingredient.
Config hooks need to be a function that takes 3 parameters and returns
a dictionary:
(config, command_name, logger) --> dict
Config hooks are run after the configuration of this Ingredient, but
before any further ingredient-con... |
376,322 | def _get_band(self, high_res, low_res, color, ratio):
if self.high_resolution_band == color:
ret = high_res
else:
ret = low_res * ratio
ret.attrs = low_res.attrs.copy()
return ret | Figure out what data should represent this color. |
376,323 | def bare_except(logical_line, noqa):
r
if noqa:
return
regex = re.compile(r"except\s*:")
match = regex.match(logical_line)
if match:
yield match.start(), "E722 do not use bare except'" | r"""When catching exceptions, mention specific exceptions whenever possible.
Okay: except Exception:
Okay: except BaseException:
E722: except: |
376,324 | def hrule(width=None, char=None):
width = width or HRWIDTH
char = char or HRCHAR
return echo(getline(char, width)) | Outputs or returns a horizontal line of the given character and width.
Returns printed string. |
376,325 | def _color_level(str_, level):
fore_color, back_color, styles = _get_style_from_config(level)
return _color(str_, fore_color, back_color, styles) | Return the string wrapped with the appropriate styling for the message
level. The styling will be determined based on the rez configuration.
Args:
str_ (str): The string to be wrapped.
level (str): The message level. Should be one of 'critical', 'error',
'warning', 'info' or 'debug'.
... |
376,326 | def clear(self):
if len(self.list):
self._LOG.debug("List cleared.")
self.list.clear() | Clears the server list |
376,327 | def get_validators_description(view):
action = getattr(view, , None)
if action is None:
return
description =
validators = getattr(view, action + , [])
for validator in validators:
validator_description = get_entity_description(validator)
description += + validator_de... | Returns validators description in format:
### Validators:
* validator1 name
* validator1 docstring
* validator2 name
* validator2 docstring |
376,328 | def run_task(message):
task = Task.objects.get(pk=message[])
if task.allow_overlap:
task.run(message)
else:
if not task.running:
task.running = True
task.save()
try:
task.run(message)
finally:
task.running =... | Internal ``RUN_TASK`` consumer to run the task's callable |
376,329 | def nacm_rule_list_rule_comment(self, **kwargs):
config = ET.Element("config")
nacm = ET.SubElement(config, "nacm", xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm")
rule_list = ET.SubElement(nacm, "rule-list")
name_key = ET.SubElement(rule_list, "name")
name_key.tex... | Auto Generated Code |
376,330 | def expand(doc, doc_url="param://", params=None):
if doc_url.find("://") == -1:
Log.error("{{url}} must have a prototcol (eg http://) declared", url=doc_url)
url = URL(doc_url)
url.query = set_default(url.query, params)
phase1 = _replace_ref(doc, url)
phase2 = _replace_locals(phase1,... | ASSUMING YOU ALREADY PULED THE doc FROM doc_url, YOU CAN STILL USE THE
EXPANDING FEATURE
USE mo_json_config.expand({}) TO ASSUME CURRENT WORKING DIRECTORY
:param doc: THE DATA STRUCTURE FROM JSON SOURCE
:param doc_url: THE URL THIS doc CAME FROM (DEFAULT USES params AS A DOCUMENT SOURCE)
:param pa... |
376,331 | def run_mash(self):
self.pipeline = True
mash.Mash(inputobject=self,
analysistype=) | Run MASH to determine the closest refseq genomes |
376,332 | def has_comic(name):
names = [
("Creators/%s" % name).lower(),
("DrunkDuck/%s" % name).lower(),
("GoComics/%s" % name).lower(),
("KeenSpot/%s" % name).lower(),
("ComicGenesis/%s" % name).lower(),
("SmackJeeves/%s" % name).lower(),
]
for scraperclass in ge... | Check if comic name already exists. |
376,333 | def _finish(self):
self.finished = True
if self._callback:
self._callback(self)
self._finish_event.set() | Mark transition as finished and execute callback. |
376,334 | def __ordinal(self, num):
if 10 <= num % 100 < 20:
return str(num) +
else:
ord_info = {1: , 2: , 3: }.get(num % 10, )
return .format(num, ord_info) | Returns the ordinal number of a given integer, as a string.
eg. 1 -> 1st, 2 -> 2nd, 3 -> 3rd, etc. |
376,335 | def profile_device_delete(name, device_name, remote_addr=None,
cert=None, key=None, verify_cert=True):
*
profile = profile_get(
name,
remote_addr,
cert,
key,
verify_cert,
_raw=True
)
return _delete_property_dict_item(
pro... | Delete a profile device.
name :
The name of the profile to delete the device.
device_name :
The name of the device to delete.
remote_addr :
An URL to a remote Server, you also have to give cert and key if
you provide remote_addr and its a TCP Ad... |
376,336 | def set(self, instance, value, **kw):
return self._set(instance, value, **kw) | Set the value of the field |
376,337 | def key_to_dimension(self, fact_key, fact_join_col, dimension_name, dimension_join_col, dimension_key):
self.sql_text += "UPDATE " + self.fact_table + " op SET op." + fact_key + " = NVL(\n"
self.sql_text += " (SELECT MAX (ip." + dimension_key + ")\n"
self.sql_text += " FROM... | create SQL to join a fact table key based on "join_col" to a dimension
The fact table is aliased as "op" and the join dimension is aliased as "ip"
meaning you can pass substrings or SQL to match values.
e.g. the command:
aup.key_to_dimension('GENDER_KEY', 'substr(op.GENDER, 1,1)', 'tbl_... |
376,338 | def ReverseComplementMembership(x, y, **kwargs):
return ast.Complement(
ast.Membership(y, x, **kwargs), **kwargs) | Change (x doesn't contain y) to not(y in x). |
376,339 | def _options():
opts = sys.argv[1:]
return [click.Option((v.split()[0],)) for v in opts
if v[0] == and v != ] | Collect all command line options |
376,340 | def is_valid_pep484_type_hint(typ_hint, allow_forward_refs: bool = False):
try:
if isinstance(typ_hint, type):
return True
except:
pass
try:
if allow_forward_refs and is_forward_ref(typ_hint):
return True
except:
pass
try:... | Returns True if the provided type is a valid PEP484 type hint, False otherwise.
Note: string type hints (forward references) are not supported by default, since callers of this function in
parsyfiles lib actually require them to be resolved already.
:param typ_hint:
:param allow_forward_refs:
:ret... |
376,341 | def _endpoint_from_socksport_line(reactor, socks_config):
if socks_config.startswith():
return UNIXClientEndpoint(reactor, socks_config[5:])
if in socks_config:
socks_config = socks_config.split()[0]
if in socks_config:
host, port = socks_... | Internal helper.
Returns an IStreamClientEndpoint for the given config, which is of
the same format expected by the SOCKSPort option in Tor. |
376,342 | def build_row(self, line):
items = []
row = dict(items=items)
fields = line.split()
image_exts = [, ]
if not fields: return row
for field in fields:
ext = os.path.splitext(field)[-1]
if ext.lower() in image_exts:
... | Line describes an image or images to show
Returns a dict with a list of dicts of image names or text items
Examples:
# A single image to display
>>> x.build_row('foo.png')
[{'image': 'foo.png'}]
# Two images with text in between:
>>> x.build_row('foo.png or ba... |
376,343 | def filter_queryset(self, attrs, queryset):
if self.instance is not None:
for field_name in self.fields:
if field_name not in attrs:
attrs[field_name] = getattr(self.instance, field_name)
filter_kwargs = {
f... | Filter the queryset to all instances matching the given attributes. |
376,344 | def writeFromDict(dataDict, headers, csvFile):
with open(csvFile, "wb") as f:
writer = csv.writer(f, delimiter=",")
writer.writerow(headers)
for row in sorted(dataDict.keys()):
writer.writerow(dataDict[row]) | Write dictionary to a CSV, where keys are row numbers and values are a list. |
376,345 | def get_game_for_worker(map_name, directory_id):
if map_name == "v100unfriendly":
games = ["chopper_command", "boxing", "asterix", "seaquest"]
worker_per_game = 5
elif map_name == "human_nice":
games = gym_env.ATARI_GAMES_WITH_HUMAN_SCORE_NICE
worker_per_game = 5
else:
raise ValueError("Unk... | Get game for the given worker (directory) id. |
376,346 | def provision_system_user(items, database_name, overwrite=False, clear=False, skip_user_check=False):
from hfos.provisions.base import provisionList
from hfos.database import objectmodels
if overwrite is True:
hfoslog(, lvl=warn,
emitter=)
overwrite = F... | Provision a system user |
376,347 | def main_update(self):
try:
os.nice(1)
except AttributeError as er:
pass
time.sleep(self.refresh)
try:
while True:
timestamp=time.time()
self.commit()
except Exception as e:
self.error=e
raise | Main function called by the updater thread.
Direct call is unnecessary. |
376,348 | def clean_year_month(year, month, month_orig):
error = False
error_msg = "The date given was invalid."
if month_orig not in xrange(1, 13) and month_orig is not None:
month = now.month
error = error_msg
while month > 12:
month -= 12
year += 1
while month... | If 'month_orig', which is the month given in the url BEFORE any next/prev
query strings have been applied, is out of range, sets month to the
current month and returns an error message. Also Returns an error
message if the year given is +/- 50 years from now.
If 'month', which is the month given in the ... |
376,349 | def playlist_create(
self,
name,
description=,
*,
make_public=False,
songs=None
):
share_state = if make_public else
playlist = self._call(
mc_calls.PlaylistsCreate,
name,
description,
share_state
).body
if songs:
playlist = self.playlist_songs_add(songs, playlist)
return ... | Create a playlist.
Parameters:
name (str): Name to give the playlist.
description (str): Description to give the playlist.
make_public (bool, Optional): If ``True`` and account has a subscription,
make playlist public.
Default: ``False``
songs (list, Optional): A list of song dicts to add to the ... |
376,350 | def getAssemblies(pth):
if not os.path.isfile(pth):
pth = check_extract_from_egg(pth)[0][0]
if pth.lower().endswith(".manifest"):
return []
manifestnm = pth + ".manifest"
if os.path.isfile(manifestnm):
fd = open(manifestnm, "rb")
res = {RT_MANIFEST: {1: {0: fd.r... | Return the dependent assemblies of a binary. |
376,351 | def __geometryToGeomTemplate(self, geometry):
template = {"geometryType": None,
"geometry" : None}
if isinstance(geometry, Polyline):
template[] = "esriGeometryPolyline"
elif isinstance(geometry, Polygon):
template[] = "esriGeometryPolygon"
... | Converts a single geometry object to a geometry service geometry
template value.
Input:
geometry - ArcREST geometry object
Output:
python dictionary of geometry template |
376,352 | def bios_settings(self):
return bios.BIOSSettings(
self._conn, utils.get_subresource_path_by(self, ),
redfish_version=self.redfish_version) | Property to provide reference to `BIOSSettings` instance
It is calculated once when the first time it is queried. On refresh,
this property gets reset. |
376,353 | def enforce_periodic_boundary_conditions( self ):
for s in self.sites:
for i in range(3):
if s.r[i] < 0.0:
s.r[i] += self.cell_lengths[i]
if s.r[i] > self.cell_lengths[i]:
s.r[i] -= self.cell_lengths[i] | Ensure that all lattice sites are within the central periodic image of the simulation cell.
Sites that are outside the central simulation cell are mapped back into this cell.
Args:
None
Returns:
None |
376,354 | def xception_entry(inputs, hidden_dim):
with tf.variable_scope("xception_entry"):
def xnet_resblock(x, filters, res_relu, name):
with tf.variable_scope(name):
y = common_layers.separable_conv_block(
x,
filters, [((1, 1), (3, 3)), ((1, 1), (3, 3))],
firs... | Xception entry flow. |
376,355 | def get_deposit(self, deposit_id, **params):
return self.api_client.get_deposit(self.id, deposit_id, **params) | https://developers.coinbase.com/api/v2#show-a-deposit |
376,356 | def nintegral(wave, indep_min=None, indep_max=None):
r
ret = copy.copy(wave)
_bound_waveform(ret, indep_min, indep_max)
return np.trapz(ret._dep_vector, ret._indep_vector) | r"""
Return the numerical integral of a waveform's dependent variable vector.
The method used is the `trapezoidal
<https://en.wikipedia.org/wiki/Trapezoidal_rule>`_ method
:param wave: Waveform
:type wave: :py:class:`peng.eng.Waveform`
:param indep_min: Independent vector start point of comp... |
376,357 | def envCheckFilter(self, name, attr):
flt = self._filters.get(name)
if flt:
return flt.check(attr)
else:
raise AttributeError("Undefined filter: %s" % name) | Check if a specific graph attribute is enabled or disabled through
the use of a filter based on include_<name> and exclude_<name>
environment variables.
@param name: Name of the Filter.
@param attr: Name of the Attribute.
@return: Return True if the attribute is en... |
376,358 | def highres_imu_send(self, time_usec, xacc, yacc, zacc, xgyro, ygyro, zgyro, xmag, ymag, zmag, abs_pressure, diff_pressure, pressure_alt, temperature, fields_updated, force_mavlink1=False):
return self.send(self.highres_imu_encode(time_usec, xacc, yacc, zacc, xgyro, ygyro, zgyro, xmag, ... | The IMU readings in SI units in NED body frame
time_usec : Timestamp (microseconds, synced to UNIX time or since system boot) (uint64_t)
xacc : X acceleration (m/s^2) (float)
yacc : Y acceleration (m/s^2) (float)
... |
376,359 | def convert_html_to_text(value, preserve_urls=False):
r
s = MLStripper(preserve_urls=preserve_urls)
s.feed(value)
s.close()
return s.get_data() | r"""
>>> convert_html_to_text(
... '''
... <html><body>
... Look & click
... <a href="https://example.com">here</a>
... </body></html>''', preserve_urls=True)
'Look & click here (https://example.com)'
>>> convert_html_to_text(
... '''
... <... |
376,360 | def rename_in_module(occurrences_finder, new_name, resource=None,
pymodule=None, replace_primary=False, region=None,
reads=True, writes=True):
if resource is not None:
source_code = resource.read()
else:
source_code = pymodule.source_code
change... | Returns the changed source or `None` if there is no changes |
376,361 | def change_parameters(self,params):
no_of_params = 0
for core_param in range(len(self.q)):
for approx_param in range(self.q[core_param].param_no):
self.q[core_param].vi_change_param(approx_param, params[no_of_params])
no_of_params += 1 | Utility function for changing the approximate distribution parameters |
376,362 | def wrapComponent(comp):
if hasattr(comp, ):
return comp
current_module = sys.modules[__name__]
module_classes = {name[1:]: obj for name, obj in inspect.getmembers(sys.modules[__name__], inspect.isclass) if
obj.__module__ == __name__}
stimclass = co... | Wraps a StimulusComponent with a class containing methods
for painting and editing. Class will in fact, be the same as
the component provided, but will also be a subclass of
QStimulusComponent
:param comp: Component to wrap
:type comp: subclass of AbstractStimulusComponent
:returns: sublass o... |
376,363 | def read(self, limit=-1):
remaining = self.len - self.parent_fd.tell() + self.offset
if limit > remaining or limit == -1:
limit = remaining
return self.parent_fd.read(limit) | Read content. See file.read |
376,364 | def rows_to_columns(data, schema=None):
if not schema:
schema = SchemaTree()
all_schema = schema
all_leaves = schema.leaves
values = {full_name: [] for full_name in all_leaves}
reps = {full_name: [] for full_name in all_leaves}
defs = {full_name: [] for full_name in all_leaves}
... | :param data: array of objects
:param schema: Known schema, will be extended to include all properties found in data
:return: Table |
376,365 | def run(self, command, application):
if len(command) == 1:
profile = application.profile
if profile is None:
self._output.write(
"Current shell profile: no profile configured\n"
"You can change profiles using: .profile prof... | Get or set the profile.
If .profile is called with no args, the current profile
is displayed. If the .profile command is called with a
single arg, then the current profile for the application
will be set to the new value. |
376,366 | def _wrap_value_with_context(self, tokens: List[Token], start: int, end: int) -> Extraction:
return Extraction(.join([x.orth_ if isinstance(x, Token) else x for x in tokens[start:end]]),
self.name,
start_token=start,
end_toke... | Wraps the final result |
376,367 | def pbis(a):
return(math.cos(3*a - math.pi), (math.sin(3*a - math.pi))) | End point of a reflected sun ray, given an angle a. |
376,368 | def main(argv=None):
parser = create_parser(, description=__doc__)
parser.add_argument(, default=,
help="hostname of the site (default: cnx.org)")
parser.add_argument(,
default=LOG_FORMAT_GZ, choices=LOG_FORMATS,
help="(default: {}... | Count the hits from logfile. |
376,369 | def parse_rawprofile_blocks(text):
delim =
delim2 =
profile_block_list = ut.regex_split( + delim, text)
for ix in range(1, len(profile_block_list)):
profile_block_list[ix] = delim2 + profile_block_list[ix]
return profile_block_list | Split the file into blocks along delimters and and put delimeters back in
the list |
376,370 | def get_lyrics_genius(song_title):
base_url = "http://api.genius.com"
headers = {: %(GENIUS_KEY)}
search_url = base_url + "/search"
data = {: song_title}
response = requests.get(search_url, data=data, headers=headers)
json = response.json()
song_api_path = json["response"]["hits"][0][... | Scrapes the lyrics from Genius.com |
376,371 | def _viewbox_set(self, viewbox):
self._viewbox = viewbox
viewbox.events.mouse_press.connect(self.viewbox_mouse_event)
viewbox.events.mouse_release.connect(self.viewbox_mouse_event)
viewbox.events.mouse_move.connect(self.viewbox_mouse_event)
viewbox.events.mouse_... | Friend method of viewbox to register itself. |
376,372 | def partialReleaseComplete():
a = TpPd(pd=0x6)
b = MessageType(mesType=0xf)
packet = a / b
return packet | PARTIAL RELEASE COMPLETE Section 9.1.27 |
376,373 | def _init_append(self):
self._write_buffer[:] = self._readall()
self._seek = self._size | Initializes file on 'a' mode. |
376,374 | def connect(filename: str, mode: str = , *, validate: bool = True, spec_version: str = "2.0.1") -> LoomConnection:
return LoomConnection(filename, mode, validate=validate, spec_version=spec_version) | Establish a connection to a .loom file.
Args:
filename: Path to the Loom file to open
mode: Read/write mode, 'r+' (read/write) or 'r' (read-only), defaults to 'r+'
validate: Validate the file structure against the Loom file format specification
spec_version: The loom file spec version to validate against ... |
376,375 | def MobileDeviceConfigurationProfile(self, data=None, subset=None):
return self.factory.get_object(
jssobjects.MobileDeviceConfigurationProfile, data, subset) | {dynamic_docstring} |
376,376 | def from_s3_json(cls, bucket_name, key,
json_path=None, key_mapping=None,
aws_profile=None,
aws_access_key_id=None,
aws_secret_access_key=None,
region_name=None):
import boto3
ses = boto3... | Load database credential from json on s3.
:param bucket_name: str
:param key: str
:param aws_profile: if None, assume that you are using this from
AWS cloud. (service on the same cloud doesn't need profile name)
:param aws_access_key_id: str, not recommend to use
:pa... |
376,377 | def __modify(self, checkout_id, **kwargs):
params = {
: checkout_id
}
return self.make_call(self.__modify, params, kwargs) | Call documentation: `/checkout/modify
<https://www.wepay.com/developer/reference/checkout#modify>`_, plus
extra keyword parameters:
:keyword str access_token: will be used instead of instance's
``access_token``, with ``batch_mode=True`` will set `authorization`
par... |
376,378 | def _map_from_binaries(self, eopatch, dst_shape, request_data):
if self.feature_name in eopatch[self.feature_type]:
raster = eopatch[self.feature_type][self.feature_name].squeeze()
else:
raster = np.ones(dst_shape, dtype=self.raster_dtype) * self.no_data_val
new... | Each request represents a binary class which will be mapped to the scalar `raster_value` |
376,379 | def synchronizeResponse(self, pid, vendorSpecific=None):
mmp_dict = {: pid}
return self.POST([], fields=mmp_dict, headers=vendorSpecific) | CNRead.synchronize(session, pid) → boolean POST /synchronize.
Args: pid: vendorSpecific: |
376,380 | def userInformation(MoreData_presence=0):
a = TpPd(pd=0x3)
b = MessageType(mesType=0x20)
c = UserUser()
packet = a / b / c
if MoreData_presence is 1:
d = MoreDataHdr(ieiMD=0xA0, eightBitMD=0x0)
packet = packet / d
return packet | USER INFORMATION Section 9.3.31 |
376,381 | def register_dataframe_method(method):
def inner(*args, **kwargs):
class AccessorMethod(object):
def __init__(self, pandas_obj):
self._obj = pandas_obj
@wraps(method)
def __call__(self, *args, **kwargs):
return method(self._obj, *a... | Register a function as a method attached to the Pandas DataFrame.
Example
-------
.. code-block:: python
@register_dataframe_method
def print_column(df, col):
'''Print the dataframe column given'''
print(df[col]) |
376,382 | def points_are_in_a_straight_line( points, tolerance=1e-7 ):
a = points[0]
b = points[1]
for c in points[2:]:
if area_of_a_triangle_in_cartesian_space( a, b, c ) > tolerance:
return False
return True | Check whether a set of points fall on a straight line.
Calculates the areas of triangles formed by triplets of the points.
Returns False is any of these areas are larger than the tolerance.
Args:
points (list(np.array)): list of Cartesian coordinates for each point.
tolerance (optional:floa... |
376,383 | def serviceViewChangerOutBox(self, limit: int = None) -> int:
msgCount = 0
while self.view_changer.outBox and (not limit or msgCount < limit):
msgCount += 1
msg = self.view_changer.outBox.popleft()
if isinstance(msg, (InstanceChange, ViewChangeDone)):
... | Service at most `limit` number of messages from the view_changer's outBox.
:return: the number of messages successfully serviced. |
376,384 | def z(self, position=None):
p = self.GetPosition()
if position is None:
return p[2]
self.SetPosition(p[0], p[1], position)
if self.trail:
self.updateTrail()
return self | Set/Get actor position along z axis. |
376,385 | def pop_parameter(key):
names = key.split()
if len(names) > 1:
with parameter_scope(names[0]):
return pop_parameter(.join(names[1:]))
global current_scope
param = current_scope.get(key, None)
if param is not None:
del current_scope[key]
return param | Remove and get parameter by key.
Args:
key(str): Key of parameter.
Returns: ~nnabla.Variable
Parameter if key found, otherwise None. |
376,386 | def _coligative(self, rho, A, fav):
prop = {}
prop["mu"] = fav["fira"]
prop["muw"] = fav["fir"]+rho*fav["fird"]-A*fav["fira"]
prop["M"] = 1/((1-A)/Mw+A/Ma)
prop["HR"] = 1/A-1
prop["xa"] = A*Mw/Ma/(1-A*(1-Mw/Ma))
prop["xw"] = 1-prop["xa"]
return pr... | Miscelaneous properties of humid air
Parameters
----------
rho : float
Density, [kg/m³]
A : float
Mass fraction of dry air in humid air, [kg/kg]
fav : dict
dictionary with helmholtz energy and derivatives
Returns
-------
... |
376,387 | def to_csv(self, file):
file.write("description,time,value\n")
for traj in self:
for t,v in traj:
file.write("%s,%f,%f\n"% (traj.description.symbol, t, v)) | Write all the trajectories of a collection to a csv file with the headers 'description', 'time' and 'value'.
:param file: a file object to write to
:type file: :class:`file`
:return: |
376,388 | def start(self):
self.log.info("Starting SSL Session for Monitor %s."
% self.monitor_id)
if self.socket is not None:
raise Exception("Socket already established for %s." % self)
try:
self.socket = socket.socket(socket.AF_INET, ... | Creates a SSL connection to the iDigi Server and sends a
ConnectionRequest message. |
376,389 | def center_text_cursor(object):
@functools.wraps(object)
def center_text_cursor_wrapper(*args, **kwargs):
if args:
if hasattr(foundations.common.get_first_item(args), "setCenterOnScroll"):
foundations.common.get_first_item(args).setCenterOnScroll(True)
... | Centers the text cursor position.
:param object: Object to decorate.
:type object: object
:return: Object.
:rtype: object |
376,390 | def copy_vpcs_configs(source, target):
vpcs_files = glob.glob(os.path.join(source, , ))
vpcs_hist = os.path.join(source, , )
vpcs_config_path = os.path.join(target, , )
if os.path.isfile(vpcs_hist):
vpcs_files.append(vpcs_hist)
if len(vpcs_files) > 0:
os.makedirs(vpcs_... | Copy any VPCS configs to the converted topology
:param str source: Source topology directory
:param str target: Target topology files directory |
376,391 | def read_string(self, content):
header_file = utils.create_temp_file_name(suffix=)
with open(header_file, "w+") as f:
f.write(content)
try:
decls = self.read_file(header_file)
except Exception:
utils.remove_file_no_raise(header_file, self.__... | Reads a Python string that contains C++ code, and return
the declarations tree. |
376,392 | def log_images(self, name, images, step=None):
if isinstance(images, six.string_types):
raise TypeError(
.format(type(images)))
self._check_step(step)
tf_name = self._ensure_tf_name(name)
summary = self._image_summary(tf_name, images, st... | Log new images for given name on given step.
Args:
name (str): name of the variable (it will be converted to a valid
tensorflow summary name).
images (list): list of images to visualize
step (int): non-negative integer used for visualization |
376,393 | def remotes_get(self):
remotes = {}
cmd = self.run([])
ret = filter(None, cmd.split())
for remote_name in ret:
remotes[remote_name] = self.remote_get(remote_name)
return remotes | Return remotes like git remote -v.
:rtype: dict of tuples |
376,394 | def get_uids(self, filename=None):
self._update()
if filename:
if filename not in self._reminders:
return []
return self._reminders[filename].keys()
return [uid for uids in self._reminders.values() for uid in uids] | UIDs of all reminders in the file excluding included files
If a filename is specified, only it's UIDs are return, otherwise all.
filename -- the remind file |
376,395 | def check_backslashes(self, definition, docstring):
r
if docstring and in docstring and not docstring.startswith(
(, )):
return violations.D301() | r'''D301: Use r""" if any backslashes in a docstring.
Use r"""raw triple double quotes""" if you use any backslashes
(\) in your docstrings. |
376,396 | def all_dims(self):
return [
_get_dims(arr) if not isinstance(arr, ArrayList) else
arr.all_dims
for arr in self] | The dimensions for each of the arrays in this list |
376,397 | def run_with_tornado(self):
from zengine.tornado_server.server import runserver
runserver(self.manager.args.addr, int(self.manager.args.port)) | runs the tornado/websockets based test server |
376,398 | def _collapse_edge_passing_predicates(graph: BELGraph, edge_predicates: EdgePredicates = None) -> None:
for u, v, _ in filter_edges(graph, edge_predicates=edge_predicates):
collapse_pair(graph, survivor=u, victim=v) | Collapse all edges passing the given edge predicates. |
376,399 | def read_csv(csv_name, usecols=None):
csv_path = os.path.join(DATA_FOLDER, csv_name)
csv = pd.read_csv(csv_path, low_memory=False,
usecols=usecols, encoding="utf-8")
return csv | Returns a DataFrame from a .csv file stored in /data/raw/ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.