repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
lsbardel/python-stdnet | stdnet/backends/redisb/client/extensions.py | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/extensions.py#L156-L165 | def zdiffstore(self, dest, keys, withscores=False):
'''Compute the difference of multiple sorted.
The difference of sets specified by ``keys`` into a new sorted set
in ``dest``.
'''
keys = (dest,) + tuple(keys)
wscores = 'withscores' if withscores else ''
... | [
"def",
"zdiffstore",
"(",
"self",
",",
"dest",
",",
"keys",
",",
"withscores",
"=",
"False",
")",
":",
"keys",
"=",
"(",
"dest",
",",
")",
"+",
"tuple",
"(",
"keys",
")",
"wscores",
"=",
"'withscores'",
"if",
"withscores",
"else",
"''",
"return",
"se... | Compute the difference of multiple sorted.
The difference of sets specified by ``keys`` into a new sorted set
in ``dest``. | [
"Compute",
"the",
"difference",
"of",
"multiple",
"sorted",
".",
"The",
"difference",
"of",
"sets",
"specified",
"by",
"keys",
"into",
"a",
"new",
"sorted",
"set",
"in",
"dest",
"."
] | python | train |
jimzhan/pyx | rex/debug/function.py | https://github.com/jimzhan/pyx/blob/819e8251323a7923e196c0c438aa8524f5aaee6e/rex/debug/function.py#L36-L47 | def timeit(func):
"""
Decorator that logs the cost time of a function.
"""
@wraps(func)
def wrapped_func(*args, **kwargs):
start = timer()
result = func(*args, **kwargs)
cost = timer() - start
logger.debug('<method: %s> finished in %2.2f sec' % (func.__name__, cost... | [
"def",
"timeit",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"start",
"=",
"timer",
"(",
")",
"result",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs... | Decorator that logs the cost time of a function. | [
"Decorator",
"that",
"logs",
"the",
"cost",
"time",
"of",
"a",
"function",
"."
] | python | train |
arve0/leicascanningtemplate | leicascanningtemplate/template.py | https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L170-L185 | def update_well_positions(self):
"""Set ``well_attrib['FieldXStartCoordinate']`` and
``well_attrib['FieldYStartCoordinate']`` to FieldXCoordinate and
FieldYCoordinate of first field in well.
"""
for well in self.wells:
well_x = well.attrib['WellX']
well_y ... | [
"def",
"update_well_positions",
"(",
"self",
")",
":",
"for",
"well",
"in",
"self",
".",
"wells",
":",
"well_x",
"=",
"well",
".",
"attrib",
"[",
"'WellX'",
"]",
"well_y",
"=",
"well",
".",
"attrib",
"[",
"'WellY'",
"]",
"first_field",
"=",
"self",
"."... | Set ``well_attrib['FieldXStartCoordinate']`` and
``well_attrib['FieldYStartCoordinate']`` to FieldXCoordinate and
FieldYCoordinate of first field in well. | [
"Set",
"well_attrib",
"[",
"FieldXStartCoordinate",
"]",
"and",
"well_attrib",
"[",
"FieldYStartCoordinate",
"]",
"to",
"FieldXCoordinate",
"and",
"FieldYCoordinate",
"of",
"first",
"field",
"in",
"well",
"."
] | python | train |
yyuu/botornado | boto/dynamodb/layer2.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/dynamodb/layer2.py#L184-L208 | def dynamize_request_items(self, batch_list):
"""
Convert a request_items parameter into the data structure
required for Layer1.
"""
d = None
if batch_list:
d = {}
for batch in batch_list:
batch_dict = {}
key_list = ... | [
"def",
"dynamize_request_items",
"(",
"self",
",",
"batch_list",
")",
":",
"d",
"=",
"None",
"if",
"batch_list",
":",
"d",
"=",
"{",
"}",
"for",
"batch",
"in",
"batch_list",
":",
"batch_dict",
"=",
"{",
"}",
"key_list",
"=",
"[",
"]",
"for",
"key",
"... | Convert a request_items parameter into the data structure
required for Layer1. | [
"Convert",
"a",
"request_items",
"parameter",
"into",
"the",
"data",
"structure",
"required",
"for",
"Layer1",
"."
] | python | train |
xflr6/graphviz | graphviz/files.py | https://github.com/xflr6/graphviz/blob/7376095ef1e47abad7e0b0361b6c9720b706e7a0/graphviz/files.py#L136-L160 | def save(self, filename=None, directory=None):
"""Save the DOT source to file. Ensure the file ends with a newline.
Args:
filename: Filename for saving the source (defaults to ``name`` + ``'.gv'``)
directory: (Sub)directory for source saving and rendering.
Returns:
... | [
"def",
"save",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"directory",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"not",
"None",
":",
"self",
".",
"filename",
"=",
"filename",
"if",
"directory",
"is",
"not",
"None",
":",
"self",
".",
"direct... | Save the DOT source to file. Ensure the file ends with a newline.
Args:
filename: Filename for saving the source (defaults to ``name`` + ``'.gv'``)
directory: (Sub)directory for source saving and rendering.
Returns:
The (possibly relative) path of the saved source fi... | [
"Save",
"the",
"DOT",
"source",
"to",
"file",
".",
"Ensure",
"the",
"file",
"ends",
"with",
"a",
"newline",
"."
] | python | train |
user-cont/colin | colin/core/target.py | https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L184-L191 | def get_file(self, file_path, mode="r"):
"""
provide File object specified via 'file_path'
:param file_path: str, path to the file
:param mode: str, mode used when opening the file
:return: File instance
"""
return open(self.cont_path(file_path), mode=mode) | [
"def",
"get_file",
"(",
"self",
",",
"file_path",
",",
"mode",
"=",
"\"r\"",
")",
":",
"return",
"open",
"(",
"self",
".",
"cont_path",
"(",
"file_path",
")",
",",
"mode",
"=",
"mode",
")"
] | provide File object specified via 'file_path'
:param file_path: str, path to the file
:param mode: str, mode used when opening the file
:return: File instance | [
"provide",
"File",
"object",
"specified",
"via",
"file_path",
":",
"param",
"file_path",
":",
"str",
"path",
"to",
"the",
"file",
":",
"param",
"mode",
":",
"str",
"mode",
"used",
"when",
"opening",
"the",
"file",
":",
"return",
":",
"File",
"instance"
] | python | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/worker_engine.py | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/worker_engine.py#L187-L210 | def create_data_object_from_data(data_object, engine, data_type):
"""Create a new WorkflowObject from given data and return it.
Returns a data object wrapped around data_object given.
:param data_object: object containing the data
:type data_object: object
:param engine: Instance of Workflow that... | [
"def",
"create_data_object_from_data",
"(",
"data_object",
",",
"engine",
",",
"data_type",
")",
":",
"# Data is not already a WorkflowObject, we first",
"# create an initial object for each data object.",
"return",
"workflow_object_class",
".",
"create",
"(",
"data",
"=",
"dat... | Create a new WorkflowObject from given data and return it.
Returns a data object wrapped around data_object given.
:param data_object: object containing the data
:type data_object: object
:param engine: Instance of Workflow that is currently running.
:type engine: py:class:`.engine.WorkflowEngine... | [
"Create",
"a",
"new",
"WorkflowObject",
"from",
"given",
"data",
"and",
"return",
"it",
"."
] | python | train |
05bit/peewee-async | peewee_async.py | https://github.com/05bit/peewee-async/blob/d15f4629da1d9975da4ec37306188e68d288c862/peewee_async.py#L382-L385 | def _subclassed(base, *classes):
"""Check if all classes are subclassed from base.
"""
return all(map(lambda obj: isinstance(obj, base), classes)) | [
"def",
"_subclassed",
"(",
"base",
",",
"*",
"classes",
")",
":",
"return",
"all",
"(",
"map",
"(",
"lambda",
"obj",
":",
"isinstance",
"(",
"obj",
",",
"base",
")",
",",
"classes",
")",
")"
] | Check if all classes are subclassed from base. | [
"Check",
"if",
"all",
"classes",
"are",
"subclassed",
"from",
"base",
"."
] | python | train |
wmayner/pyphi | pyphi/models/mechanism.py | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/models/mechanism.py#L431-L441 | def eq_repertoires(self, other):
"""Return whether this concept has the same repertoires as another.
.. warning::
This only checks if the cause and effect repertoires are equal as
arrays; mechanisms, purviews, or even the nodes that the mechanism
and purview indices ... | [
"def",
"eq_repertoires",
"(",
"self",
",",
"other",
")",
":",
"return",
"(",
"np",
".",
"array_equal",
"(",
"self",
".",
"cause_repertoire",
",",
"other",
".",
"cause_repertoire",
")",
"and",
"np",
".",
"array_equal",
"(",
"self",
".",
"effect_repertoire",
... | Return whether this concept has the same repertoires as another.
.. warning::
This only checks if the cause and effect repertoires are equal as
arrays; mechanisms, purviews, or even the nodes that the mechanism
and purview indices refer to, might be different. | [
"Return",
"whether",
"this",
"concept",
"has",
"the",
"same",
"repertoires",
"as",
"another",
"."
] | python | train |
balloob/aiohue | aiohue/sensors.py | https://github.com/balloob/aiohue/blob/c0270637a8a6ce3f5684c8559decac79fb0f0192/aiohue/sensors.py#L322-L333 | async def set_config(self, on=None, tholddark=None, tholdoffset=None):
"""Change config of a CLIP LightLevel sensor."""
data = {
key: value for key, value in {
'on': on,
'tholddark': tholddark,
'tholdoffset': tholdoffset,
}.items() ... | [
"async",
"def",
"set_config",
"(",
"self",
",",
"on",
"=",
"None",
",",
"tholddark",
"=",
"None",
",",
"tholdoffset",
"=",
"None",
")",
":",
"data",
"=",
"{",
"key",
":",
"value",
"for",
"key",
",",
"value",
"in",
"{",
"'on'",
":",
"on",
",",
"'t... | Change config of a CLIP LightLevel sensor. | [
"Change",
"config",
"of",
"a",
"CLIP",
"LightLevel",
"sensor",
"."
] | python | train |
OTL/jps | jps/security.py | https://github.com/OTL/jps/blob/2c5a438d59611fffca6853072c822ef22665ed87/jps/security.py#L32-L35 | def set_server_key(self, zmq_socket, server_secret_key_path):
'''must call before bind'''
load_and_set_key(zmq_socket, server_secret_key_path)
zmq_socket.curve_server = True | [
"def",
"set_server_key",
"(",
"self",
",",
"zmq_socket",
",",
"server_secret_key_path",
")",
":",
"load_and_set_key",
"(",
"zmq_socket",
",",
"server_secret_key_path",
")",
"zmq_socket",
".",
"curve_server",
"=",
"True"
] | must call before bind | [
"must",
"call",
"before",
"bind"
] | python | train |
wbond/oscrypto | oscrypto/_openssl/asymmetric.py | https://github.com/wbond/oscrypto/blob/af778bf1c88bf6c4a7342f5353b130686a5bbe1c/oscrypto/_openssl/asymmetric.py#L1168-L1436 | def _verify(certificate_or_public_key, signature, data, hash_algorithm, rsa_pss_padding=False):
"""
Verifies an RSA, DSA or ECDSA signature
:param certificate_or_public_key:
A Certificate or PublicKey instance to verify the signature with
:param signature:
A byte string of the signatur... | [
"def",
"_verify",
"(",
"certificate_or_public_key",
",",
"signature",
",",
"data",
",",
"hash_algorithm",
",",
"rsa_pss_padding",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"certificate_or_public_key",
",",
"(",
"Certificate",
",",
"PublicKey",
")",
... | Verifies an RSA, DSA or ECDSA signature
:param certificate_or_public_key:
A Certificate or PublicKey instance to verify the signature with
:param signature:
A byte string of the signature to verify
:param data:
A byte string of the data the signature is for
:param hash_algori... | [
"Verifies",
"an",
"RSA",
"DSA",
"or",
"ECDSA",
"signature"
] | python | valid |
lmjohns3/downhill | downhill/base.py | https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L153-L167 | def _compile(self, **kwargs):
'''Compile the Theano functions for evaluating and updating our model.
'''
util.log('compiling evaluation function')
self.f_eval = theano.function(self._inputs,
self._monitor_exprs,
... | [
"def",
"_compile",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"util",
".",
"log",
"(",
"'compiling evaluation function'",
")",
"self",
".",
"f_eval",
"=",
"theano",
".",
"function",
"(",
"self",
".",
"_inputs",
",",
"self",
".",
"_monitor_exprs",
",... | Compile the Theano functions for evaluating and updating our model. | [
"Compile",
"the",
"Theano",
"functions",
"for",
"evaluating",
"and",
"updating",
"our",
"model",
"."
] | python | train |
polyaxon/polyaxon | polyaxon/hpsearch/iteration_managers/hyperband.py | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/hpsearch/iteration_managers/hyperband.py#L50-L77 | def get_reduced_configs(self):
"""Reduce the experiments to restart."""
iteration_config = self.experiment_group.iteration_config
if iteration_config is None:
logger.error(
'Experiment group `%s` attempt to update iteration, but has no iteration',
self... | [
"def",
"get_reduced_configs",
"(",
"self",
")",
":",
"iteration_config",
"=",
"self",
".",
"experiment_group",
".",
"iteration_config",
"if",
"iteration_config",
"is",
"None",
":",
"logger",
".",
"error",
"(",
"'Experiment group `%s` attempt to update iteration, but has n... | Reduce the experiments to restart. | [
"Reduce",
"the",
"experiments",
"to",
"restart",
"."
] | python | train |
zeth/inputs | inputs.py | https://github.com/zeth/inputs/blob/a46681dbf77d6ab07834f550e5855c1f50701f99/inputs.py#L3243-L3258 | def _find_xinput(self):
"""Find most recent xinput library."""
for dll in XINPUT_DLL_NAMES:
try:
self.xinput = getattr(ctypes.windll, dll)
except OSError:
pass
else:
# We found an xinput driver
self.xinpu... | [
"def",
"_find_xinput",
"(",
"self",
")",
":",
"for",
"dll",
"in",
"XINPUT_DLL_NAMES",
":",
"try",
":",
"self",
".",
"xinput",
"=",
"getattr",
"(",
"ctypes",
".",
"windll",
",",
"dll",
")",
"except",
"OSError",
":",
"pass",
"else",
":",
"# We found an xin... | Find most recent xinput library. | [
"Find",
"most",
"recent",
"xinput",
"library",
"."
] | python | train |
IRC-SPHERE/HyperStream | hyperstream/session.py | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/session.py#L120-L146 | def clear_sessions(hyperstream, inactive_only=True, clear_history=False):
"""
Clear all (inactive) sessions and (optionally) their history
:param hyperstream: The hyperstream object
:param inactive_only: Whether to only clear inactive sessions (active sessions may be owned by an... | [
"def",
"clear_sessions",
"(",
"hyperstream",
",",
"inactive_only",
"=",
"True",
",",
"clear_history",
"=",
"False",
")",
":",
"query",
"=",
"dict",
"(",
")",
"if",
"inactive_only",
":",
"query",
"[",
"'active'",
"]",
"=",
"False",
"if",
"hyperstream",
".",... | Clear all (inactive) sessions and (optionally) their history
:param hyperstream: The hyperstream object
:param inactive_only: Whether to only clear inactive sessions (active sessions may be owned by another process)
:param clear_history: Whether to clear the history of the session. Note... | [
"Clear",
"all",
"(",
"inactive",
")",
"sessions",
"and",
"(",
"optionally",
")",
"their",
"history",
":",
"param",
"hyperstream",
":",
"The",
"hyperstream",
"object",
":",
"param",
"inactive_only",
":",
"Whether",
"to",
"only",
"clear",
"inactive",
"sessions",... | python | train |
belbio/bel | bel/terms/terms.py | https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/terms/terms.py#L49-L98 | def get_equivalents(term_id: str) -> List[Mapping[str, Union[str, bool]]]:
"""Get equivalents given ns:id
Args:
term_id (str): term id
Returns:
List[Mapping[str, Union[str, bool]]]: e.g. [{'term_id': 'HGNC:5', 'namespace': 'HGNC'}, 'primary': False]
"""
try:
errors = []
... | [
"def",
"get_equivalents",
"(",
"term_id",
":",
"str",
")",
"->",
"List",
"[",
"Mapping",
"[",
"str",
",",
"Union",
"[",
"str",
",",
"bool",
"]",
"]",
"]",
":",
"try",
":",
"errors",
"=",
"[",
"]",
"terms",
"=",
"get_terms",
"(",
"term_id",
")",
"... | Get equivalents given ns:id
Args:
term_id (str): term id
Returns:
List[Mapping[str, Union[str, bool]]]: e.g. [{'term_id': 'HGNC:5', 'namespace': 'HGNC'}, 'primary': False] | [
"Get",
"equivalents",
"given",
"ns",
":",
"id"
] | python | train |
tapilab/brandelion | brandelion/cli/analyze.py | https://github.com/tapilab/brandelion/blob/40a5a5333cf704182c8666d1fbbbdadc7ff88546/brandelion/cli/analyze.py#L99-L109 | def vectorize(json_file, vec, dofit=True):
""" Return a matrix where each row corresponds to a Twitter account, and
each column corresponds to the number of times a term is used by that
account. """
## CountVectorizer, efficiently.
screen_names = [x[0] for x in extract_tweets(json_file)]
if dofi... | [
"def",
"vectorize",
"(",
"json_file",
",",
"vec",
",",
"dofit",
"=",
"True",
")",
":",
"## CountVectorizer, efficiently.",
"screen_names",
"=",
"[",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"extract_tweets",
"(",
"json_file",
")",
"]",
"if",
"dofit",
":",
"... | Return a matrix where each row corresponds to a Twitter account, and
each column corresponds to the number of times a term is used by that
account. | [
"Return",
"a",
"matrix",
"where",
"each",
"row",
"corresponds",
"to",
"a",
"Twitter",
"account",
"and",
"each",
"column",
"corresponds",
"to",
"the",
"number",
"of",
"times",
"a",
"term",
"is",
"used",
"by",
"that",
"account",
"."
] | python | train |
rkhleics/wagtailmodeladmin | wagtailmodeladmin/views.py | https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L809-L821 | def get_dict_for_field(self, field_name):
"""
Return a dictionary containing `label` and `value` values to display
for a field.
"""
try:
field = self.model._meta.get_field(field_name)
except FieldDoesNotExist:
field = None
return {
... | [
"def",
"get_dict_for_field",
"(",
"self",
",",
"field_name",
")",
":",
"try",
":",
"field",
"=",
"self",
".",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"except",
"FieldDoesNotExist",
":",
"field",
"=",
"None",
"return",
"{",
"'label'... | Return a dictionary containing `label` and `value` values to display
for a field. | [
"Return",
"a",
"dictionary",
"containing",
"label",
"and",
"value",
"values",
"to",
"display",
"for",
"a",
"field",
"."
] | python | train |
pantsbuild/pants | src/python/pants/build_graph/build_file_aliases.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/build_graph/build_file_aliases.py#L247-L275 | def merge(self, other):
"""Merges a set of build file aliases and returns a new set of aliases containing both.
Any duplicate aliases from `other` will trump.
:API: public
:param other: The BuildFileAliases to merge in.
:type other: :class:`BuildFileAliases`
:returns: A new BuildFileAliases c... | [
"def",
"merge",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"BuildFileAliases",
")",
":",
"raise",
"TypeError",
"(",
"'Can only merge other BuildFileAliases, given {0}'",
".",
"format",
"(",
"other",
")",
")",
"def",
"mer... | Merges a set of build file aliases and returns a new set of aliases containing both.
Any duplicate aliases from `other` will trump.
:API: public
:param other: The BuildFileAliases to merge in.
:type other: :class:`BuildFileAliases`
:returns: A new BuildFileAliases containing `other`'s aliases mer... | [
"Merges",
"a",
"set",
"of",
"build",
"file",
"aliases",
"and",
"returns",
"a",
"new",
"set",
"of",
"aliases",
"containing",
"both",
"."
] | python | train |
shotastage/mirage-django-lts | mirage/proj/environ.py | https://github.com/shotastage/mirage-django-lts/blob/4e32dd48fff4b191abb90813ce3cc5ef0654a2ab/mirage/proj/environ.py#L81-L97 | def search_app_root():
"""
Search your Django application root
returns:
- (String) Django application root path
"""
while True:
current = os.getcwd()
if pathlib.Path("apps.py").is_file():
return current
elif pathl... | [
"def",
"search_app_root",
"(",
")",
":",
"while",
"True",
":",
"current",
"=",
"os",
".",
"getcwd",
"(",
")",
"if",
"pathlib",
".",
"Path",
"(",
"\"apps.py\"",
")",
".",
"is_file",
"(",
")",
":",
"return",
"current",
"elif",
"pathlib",
".",
"Path",
"... | Search your Django application root
returns:
- (String) Django application root path | [
"Search",
"your",
"Django",
"application",
"root"
] | python | train |
Keda87/python-quran-odoa | odoa.py | https://github.com/Keda87/python-quran-odoa/blob/1bf58feeef0355f5ca6c9ad678e54a8195f33eb8/odoa.py#L120-L137 | def __get_sound(self, surah, ayah):
"""
Perform http request to get sound from given surah and ayah.
Parameter:
:surah -- Surah index from API pages.
:ayat -- Ayat key.
Return:
:string -- URL for mp3 sound.
"""
# For... | [
"def",
"__get_sound",
"(",
"self",
",",
"surah",
",",
"ayah",
")",
":",
"# Formatting ayah with 0 leading.",
"# http://stackoverflow.com/questions/17118071/python-add-leading-zeroes-using-str-format",
"format_ayah",
"=",
"'{0:0>3}'",
".",
"format",
"(",
"ayah",
")",
"sound_ur... | Perform http request to get sound from given surah and ayah.
Parameter:
:surah -- Surah index from API pages.
:ayat -- Ayat key.
Return:
:string -- URL for mp3 sound. | [
"Perform",
"http",
"request",
"to",
"get",
"sound",
"from",
"given",
"surah",
"and",
"ayah",
"."
] | python | train |
numenta/htmresearch | projects/high_order_cell_assembly/sparsity_over_trial.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/projects/high_order_cell_assembly/sparsity_over_trial.py#L35-L61 | def loadExperimentData(folder, area):
"""
Loads the experiment's data from a MATLAB file into a python friendly structure.
:param folder: Experiment data folder
:param area: Experiament area to load. It should be 'V1' or 'AL'
:return: The data as scipy matlab structure with the following fields:
:Spik... | [
"def",
"loadExperimentData",
"(",
"folder",
",",
"area",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"folder",
",",
"\"Combo3_{}.mat\"",
".",
"format",
"(",
"area",
")",
")",
"contents",
"=",
"sio",
".",
"loadmat",
"(",
"filename",
... | Loads the experiment's data from a MATLAB file into a python friendly structure.
:param folder: Experiment data folder
:param area: Experiament area to load. It should be 'V1' or 'AL'
:return: The data as scipy matlab structure with the following fields:
:Spiketrain.st: spike timing during stimulus (grati... | [
"Loads",
"the",
"experiment",
"s",
"data",
"from",
"a",
"MATLAB",
"file",
"into",
"a",
"python",
"friendly",
"structure",
"."
] | python | train |
cs50/check50 | check50/runner.py | https://github.com/cs50/check50/blob/42c1f0c36baa6a24f69742d74551a9ea7a5ceb33/check50/runner.py#L214-L225 | def _skip_children(self, check_name, results):
"""
Recursively skip the children of check_name (presumably because check_name
did not pass).
"""
for name, description in self.child_map[check_name]:
if results[name] is None:
results[name] = CheckResult(... | [
"def",
"_skip_children",
"(",
"self",
",",
"check_name",
",",
"results",
")",
":",
"for",
"name",
",",
"description",
"in",
"self",
".",
"child_map",
"[",
"check_name",
"]",
":",
"if",
"results",
"[",
"name",
"]",
"is",
"None",
":",
"results",
"[",
"na... | Recursively skip the children of check_name (presumably because check_name
did not pass). | [
"Recursively",
"skip",
"the",
"children",
"of",
"check_name",
"(",
"presumably",
"because",
"check_name",
"did",
"not",
"pass",
")",
"."
] | python | train |
yjzhang/uncurl_python | uncurl/pois_ll.py | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/pois_ll.py#L53-L62 | def poisson_dist(p1, p2):
"""
Calculates the Poisson distance between two vectors.
p1 can be a sparse matrix, while p2 has to be a dense matrix.
"""
# ugh...
p1_ = p1 + eps
p2_ = p2 + eps
return np.dot(p1_-p2_, np.log(p1_/p2_)) | [
"def",
"poisson_dist",
"(",
"p1",
",",
"p2",
")",
":",
"# ugh...",
"p1_",
"=",
"p1",
"+",
"eps",
"p2_",
"=",
"p2",
"+",
"eps",
"return",
"np",
".",
"dot",
"(",
"p1_",
"-",
"p2_",
",",
"np",
".",
"log",
"(",
"p1_",
"/",
"p2_",
")",
")"
] | Calculates the Poisson distance between two vectors.
p1 can be a sparse matrix, while p2 has to be a dense matrix. | [
"Calculates",
"the",
"Poisson",
"distance",
"between",
"two",
"vectors",
"."
] | python | train |
Kozea/pygal | pygal/graph/public.py | https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/graph/public.py#L67-L74 | def render_table(self, **kwargs):
"""Render the data as a html table"""
# Import here to avoid lxml import
try:
from pygal.table import Table
except ImportError:
raise ImportError('You must install lxml to use render table')
return Table(self).render(**kwa... | [
"def",
"render_table",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Import here to avoid lxml import",
"try",
":",
"from",
"pygal",
".",
"table",
"import",
"Table",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"'You must install lxml to use rende... | Render the data as a html table | [
"Render",
"the",
"data",
"as",
"a",
"html",
"table"
] | python | train |
nicferrier/md | src/mdlib/cli.py | https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/cli.py#L62-L77 | def get_optparser(self):
"""Override to allow specification of the maildir"""
p = Cmdln.get_optparser(self)
p.add_option(
"-M",
"--maildir",
action="store",
dest="maildir"
)
p.add_option(
"-V",
"--verbose... | [
"def",
"get_optparser",
"(",
"self",
")",
":",
"p",
"=",
"Cmdln",
".",
"get_optparser",
"(",
"self",
")",
"p",
".",
"add_option",
"(",
"\"-M\"",
",",
"\"--maildir\"",
",",
"action",
"=",
"\"store\"",
",",
"dest",
"=",
"\"maildir\"",
")",
"p",
".",
"add... | Override to allow specification of the maildir | [
"Override",
"to",
"allow",
"specification",
"of",
"the",
"maildir"
] | python | train |
jbloomlab/phydms | phydmslib/treelikelihood.py | https://github.com/jbloomlab/phydms/blob/9cdebc10bafbe543c552d79486c7f950780ed3c0/phydmslib/treelikelihood.py#L641-L651 | def dloglikarray(self):
"""Derivative of `loglik` with respect to `paramsarray`."""
assert self.dparamscurrent, "dloglikarray requires paramscurrent == True"
nparams = len(self._index_to_param)
dloglikarray = scipy.ndarray(shape=(nparams,), dtype='float')
for (i, param) in self._... | [
"def",
"dloglikarray",
"(",
"self",
")",
":",
"assert",
"self",
".",
"dparamscurrent",
",",
"\"dloglikarray requires paramscurrent == True\"",
"nparams",
"=",
"len",
"(",
"self",
".",
"_index_to_param",
")",
"dloglikarray",
"=",
"scipy",
".",
"ndarray",
"(",
"shap... | Derivative of `loglik` with respect to `paramsarray`. | [
"Derivative",
"of",
"loglik",
"with",
"respect",
"to",
"paramsarray",
"."
] | python | train |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L2762-L2784 | def getDeviceToAbsoluteTrackingPose(self, eOrigin, fPredictedSecondsToPhotonsFromNow, unTrackedDevicePoseArrayCount, pTrackedDevicePoseArray=None):
"""
The pose that the tracker thinks that the HMD will be in at the specified number of seconds into the
future. Pass 0 to get the state at the ins... | [
"def",
"getDeviceToAbsoluteTrackingPose",
"(",
"self",
",",
"eOrigin",
",",
"fPredictedSecondsToPhotonsFromNow",
",",
"unTrackedDevicePoseArrayCount",
",",
"pTrackedDevicePoseArray",
"=",
"None",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getDeviceToAbsolut... | The pose that the tracker thinks that the HMD will be in at the specified number of seconds into the
future. Pass 0 to get the state at the instant the method is called. Most of the time the application should
calculate the time until the photons will be emitted from the display and pass that time into... | [
"The",
"pose",
"that",
"the",
"tracker",
"thinks",
"that",
"the",
"HMD",
"will",
"be",
"in",
"at",
"the",
"specified",
"number",
"of",
"seconds",
"into",
"the",
"future",
".",
"Pass",
"0",
"to",
"get",
"the",
"state",
"at",
"the",
"instant",
"the",
"me... | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/gurumate-2.8.6-py2.7.egg/gurumate/linux2/files.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/gurumate-2.8.6-py2.7.egg/gurumate/linux2/files.py#L147-L152 | def check_filemode(filepath, mode):
"""Return True if 'file' matches ('permission') which should be entered in octal.
"""
filemode = stat.S_IMODE(os.stat(filepath).st_mode)
return (oct(filemode) == mode) | [
"def",
"check_filemode",
"(",
"filepath",
",",
"mode",
")",
":",
"filemode",
"=",
"stat",
".",
"S_IMODE",
"(",
"os",
".",
"stat",
"(",
"filepath",
")",
".",
"st_mode",
")",
"return",
"(",
"oct",
"(",
"filemode",
")",
"==",
"mode",
")"
] | Return True if 'file' matches ('permission') which should be entered in octal. | [
"Return",
"True",
"if",
"file",
"matches",
"(",
"permission",
")",
"which",
"should",
"be",
"entered",
"in",
"octal",
"."
] | python | test |
zhanglab/psamm | psamm/datasource/native.py | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L322-L349 | def parse_exchange(self):
"""Yield tuples of exchange compounds.
Each exchange compound is a tuple of compound, reaction ID, lower and
upper flux limits.
"""
if 'media' in self._model:
if 'exchange' in self._model:
raise ParseError('Both "media" and ... | [
"def",
"parse_exchange",
"(",
"self",
")",
":",
"if",
"'media'",
"in",
"self",
".",
"_model",
":",
"if",
"'exchange'",
"in",
"self",
".",
"_model",
":",
"raise",
"ParseError",
"(",
"'Both \"media\" and \"exchange\" are specified'",
")",
"logger",
".",
"warning",... | Yield tuples of exchange compounds.
Each exchange compound is a tuple of compound, reaction ID, lower and
upper flux limits. | [
"Yield",
"tuples",
"of",
"exchange",
"compounds",
"."
] | python | train |
futapi/fut | fut/core.py | https://github.com/futapi/fut/blob/3792c9eee8f5884f38a02210e649c46c6c7a756d/fut/core.py#L77-L176 | def itemParse(item_data, full=True):
"""Parser for item data. Returns nice dictionary.
:params item_data: Item data received from ea servers.
:params full: (optional) False if you're sniping and don't need extended info. Anyone really use this?
"""
# TODO: object
# TODO: dynamically parse all d... | [
"def",
"itemParse",
"(",
"item_data",
",",
"full",
"=",
"True",
")",
":",
"# TODO: object",
"# TODO: dynamically parse all data",
"# TODO: make it less ugly",
"# ItemRareType={NONE:0,RARE:1,LOCK:2,TOTW:3,PURPLE:4,TOTY:5,RB:6,GREEN:7,ORANGE:8,PINK:9,TEAL:10,TOTS:11,LEGEND:12,WC:13,UNICEF:14... | Parser for item data. Returns nice dictionary.
:params item_data: Item data received from ea servers.
:params full: (optional) False if you're sniping and don't need extended info. Anyone really use this? | [
"Parser",
"for",
"item",
"data",
".",
"Returns",
"nice",
"dictionary",
"."
] | python | valid |
Clinical-Genomics/scout | scout/utils/requests.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/utils/requests.py#L15-L43 | def get_request(url):
"""Return a requests response from url
Args:
url(str)
Returns:
decoded_data(str): Decoded response
"""
try:
LOG.info("Requesting %s", url)
response = urllib.request.urlopen(url)
if url.endswith('.gz'):
LOG.info("Deco... | [
"def",
"get_request",
"(",
"url",
")",
":",
"try",
":",
"LOG",
".",
"info",
"(",
"\"Requesting %s\"",
",",
"url",
")",
"response",
"=",
"urllib",
".",
"request",
".",
"urlopen",
"(",
"url",
")",
"if",
"url",
".",
"endswith",
"(",
"'.gz'",
")",
":",
... | Return a requests response from url
Args:
url(str)
Returns:
decoded_data(str): Decoded response | [
"Return",
"a",
"requests",
"response",
"from",
"url",
"Args",
":",
"url",
"(",
"str",
")",
"Returns",
":",
"decoded_data",
"(",
"str",
")",
":",
"Decoded",
"response"
] | python | test |
miquelo/resort | packages/resort/component/glassfish.py | https://github.com/miquelo/resort/blob/097a25d3257c91a75c194fd44c2797ab356f85dd/packages/resort/component/glassfish.py#L406-L418 | def delete(self, context):
"""
Undeploy application.
:param resort.engine.execution.Context context:
Current execution context.
"""
status_code, msg = self.__endpoint.delete(
"/applications/application/{}".format(self.__name)
)
self.__available = False | [
"def",
"delete",
"(",
"self",
",",
"context",
")",
":",
"status_code",
",",
"msg",
"=",
"self",
".",
"__endpoint",
".",
"delete",
"(",
"\"/applications/application/{}\"",
".",
"format",
"(",
"self",
".",
"__name",
")",
")",
"self",
".",
"__available",
"=",... | Undeploy application.
:param resort.engine.execution.Context context:
Current execution context. | [
"Undeploy",
"application",
".",
":",
"param",
"resort",
".",
"engine",
".",
"execution",
".",
"Context",
"context",
":",
"Current",
"execution",
"context",
"."
] | python | train |
glomex/gcdt | gcdt/ramuda_wire.py | https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_wire.py#L238-L313 | def unwire_deprecated(awsclient, function_name, s3_event_sources=None,
time_event_sources=None, alias_name=ALIAS_NAME):
"""Deprecated! Please use unwire!
:param awsclient:
:param function_name:
:param s3_event_sources: dictionary
:param time_event_sources:
:param alias_nam... | [
"def",
"unwire_deprecated",
"(",
"awsclient",
",",
"function_name",
",",
"s3_event_sources",
"=",
"None",
",",
"time_event_sources",
"=",
"None",
",",
"alias_name",
"=",
"ALIAS_NAME",
")",
":",
"if",
"not",
"lambda_exists",
"(",
"awsclient",
",",
"function_name",
... | Deprecated! Please use unwire!
:param awsclient:
:param function_name:
:param s3_event_sources: dictionary
:param time_event_sources:
:param alias_name:
:return: exit_code | [
"Deprecated!",
"Please",
"use",
"unwire!"
] | python | train |
mbakker7/timml | timml/besselaesnumba/besselaesnumba.py | https://github.com/mbakker7/timml/blob/91e99ad573cb8a9ad8ac1fa041c3ca44520c2390/timml/besselaesnumba/besselaesnumba.py#L101-L158 | def potbeslsho(x, y, z1, z2, labda, order, ilap, naq):
"""
Parameters
----------
x,y: Point where potential is computed
z1: Complex begin point of line-sink
z2: Complex end point of line-sink
labda(naq): labda's (zero for first labda if Laplace)
order: Order of the line-s... | [
"def",
"potbeslsho",
"(",
"x",
",",
"y",
",",
"z1",
",",
"z2",
",",
"labda",
",",
"order",
",",
"ilap",
",",
"naq",
")",
":",
"rv",
"=",
"np",
".",
"zeros",
"(",
"naq",
")",
"# lstype = 1 means line-sink",
"lstype",
"=",
"1",
"# Radius of convergence",... | Parameters
----------
x,y: Point where potential is computed
z1: Complex begin point of line-sink
z2: Complex end point of line-sink
labda(naq): labda's (zero for first labda if Laplace)
order: Order of the line-sink
ilap: equals 1 when first value is Laplace line-sink and... | [
"Parameters",
"----------",
"x",
"y",
":",
"Point",
"where",
"potential",
"is",
"computed",
"z1",
":",
"Complex",
"begin",
"point",
"of",
"line",
"-",
"sink",
"z2",
":",
"Complex",
"end",
"point",
"of",
"line",
"-",
"sink",
"labda",
"(",
"naq",
")",
":... | python | train |
RedFantom/ttkwidgets | ttkwidgets/checkboxtreeview.py | https://github.com/RedFantom/ttkwidgets/blob/02150322060f867b6e59a175522ef84b09168019/ttkwidgets/checkboxtreeview.py#L84-L102 | def state(self, statespec=None):
"""
Modify or inquire widget state.
:param statespec: Widget state is returned if `statespec` is None,
otherwise it is set according to the statespec
flags and then a new state spec is returned
... | [
"def",
"state",
"(",
"self",
",",
"statespec",
"=",
"None",
")",
":",
"if",
"statespec",
":",
"if",
"\"disabled\"",
"in",
"statespec",
":",
"self",
".",
"bind",
"(",
"'<Button-1>'",
",",
"lambda",
"e",
":",
"'break'",
")",
"elif",
"\"!disabled\"",
"in",
... | Modify or inquire widget state.
:param statespec: Widget state is returned if `statespec` is None,
otherwise it is set according to the statespec
flags and then a new state spec is returned
indicating which flags were chan... | [
"Modify",
"or",
"inquire",
"widget",
"state",
".",
":",
"param",
"statespec",
":",
"Widget",
"state",
"is",
"returned",
"if",
"statespec",
"is",
"None",
"otherwise",
"it",
"is",
"set",
"according",
"to",
"the",
"statespec",
"flags",
"and",
"then",
"a",
"ne... | python | train |
brechtm/rinohtype | src/rinoh/backend/pdf/xobject/purepng.py | https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L387-L415 | def check_color(c, greyscale, which):
"""
Checks that a colour argument is the right form.
Returns the colour
(which, if it's a bar integer, is "corrected" to a 1-tuple).
For transparent or background options.
"""
if c is None:
return c
if greyscale:
try:
len... | [
"def",
"check_color",
"(",
"c",
",",
"greyscale",
",",
"which",
")",
":",
"if",
"c",
"is",
"None",
":",
"return",
"c",
"if",
"greyscale",
":",
"try",
":",
"len",
"(",
"c",
")",
"except",
"TypeError",
":",
"c",
"=",
"(",
"c",
",",
")",
"if",
"le... | Checks that a colour argument is the right form.
Returns the colour
(which, if it's a bar integer, is "corrected" to a 1-tuple).
For transparent or background options. | [
"Checks",
"that",
"a",
"colour",
"argument",
"is",
"the",
"right",
"form",
"."
] | python | train |
senaite/senaite.core | bika/lims/browser/dashboard/dashboard.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/dashboard/dashboard.py#L129-L157 | def get_dashboard_panels_visibility_by_section(section_name):
"""
Return a list of pairs as values that represents the role-permission
view relation for the panel section passed in.
:param section_name: the panels section id.
:return: a list of tuples.
"""
registry_info = get_dashboard_regis... | [
"def",
"get_dashboard_panels_visibility_by_section",
"(",
"section_name",
")",
":",
"registry_info",
"=",
"get_dashboard_registry_record",
"(",
")",
"if",
"section_name",
"not",
"in",
"registry_info",
":",
"# Registry hasn't been set, do it at least for this section",
"registry_i... | Return a list of pairs as values that represents the role-permission
view relation for the panel section passed in.
:param section_name: the panels section id.
:return: a list of tuples. | [
"Return",
"a",
"list",
"of",
"pairs",
"as",
"values",
"that",
"represents",
"the",
"role",
"-",
"permission",
"view",
"relation",
"for",
"the",
"panel",
"section",
"passed",
"in",
".",
":",
"param",
"section_name",
":",
"the",
"panels",
"section",
"id",
".... | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L1551-L1573 | def cpos(string, chars, start):
"""
Find the first occurrence in a string of a character belonging
to a collection of characters, starting at a specified location,
searching forward.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cpos_c.html
:param string: Any character string.
:t... | [
"def",
"cpos",
"(",
"string",
",",
"chars",
",",
"start",
")",
":",
"string",
"=",
"stypes",
".",
"stringToCharP",
"(",
"string",
")",
"chars",
"=",
"stypes",
".",
"stringToCharP",
"(",
"chars",
")",
"start",
"=",
"ctypes",
".",
"c_int",
"(",
"start",
... | Find the first occurrence in a string of a character belonging
to a collection of characters, starting at a specified location,
searching forward.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cpos_c.html
:param string: Any character string.
:type string: str
:param chars: A collecti... | [
"Find",
"the",
"first",
"occurrence",
"in",
"a",
"string",
"of",
"a",
"character",
"belonging",
"to",
"a",
"collection",
"of",
"characters",
"starting",
"at",
"a",
"specified",
"location",
"searching",
"forward",
"."
] | python | train |
ga4gh/ga4gh-server | ga4gh/server/backend.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/backend.py#L937-L944 | def runSearchVariantSets(self, request):
"""
Runs the specified SearchVariantSetsRequest.
"""
return self.runSearchRequest(
request, protocol.SearchVariantSetsRequest,
protocol.SearchVariantSetsResponse,
self.variantSetsGenerator) | [
"def",
"runSearchVariantSets",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"runSearchRequest",
"(",
"request",
",",
"protocol",
".",
"SearchVariantSetsRequest",
",",
"protocol",
".",
"SearchVariantSetsResponse",
",",
"self",
".",
"variantSetsGenera... | Runs the specified SearchVariantSetsRequest. | [
"Runs",
"the",
"specified",
"SearchVariantSetsRequest",
"."
] | python | train |
yohell/python-tui | tui/formats.py | https://github.com/yohell/python-tui/blob/de2e678e2f00e5940de52c000214dbcb8812a222/tui/formats.py#L623-L631 | def present(self, value):
"""Return a user-friendly representation of a value.
Lookup value in self.specials, or call .to_literal() if absent.
"""
for k, v in self.special.items():
if v == value:
return k
return ''.join(self.get_separator(i) +... | [
"def",
"present",
"(",
"self",
",",
"value",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"special",
".",
"items",
"(",
")",
":",
"if",
"v",
"==",
"value",
":",
"return",
"k",
"return",
"''",
".",
"join",
"(",
"self",
".",
"get_separator",
... | Return a user-friendly representation of a value.
Lookup value in self.specials, or call .to_literal() if absent. | [
"Return",
"a",
"user",
"-",
"friendly",
"representation",
"of",
"a",
"value",
".",
"Lookup",
"value",
"in",
"self",
".",
"specials",
"or",
"call",
".",
"to_literal",
"()",
"if",
"absent",
"."
] | python | valid |
log2timeline/dfvfs | dfvfs/vfs/cpio_file_entry.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/cpio_file_entry.py#L108-L116 | def _GetDirectory(self):
"""Retrieves a directory.
Returns:
CPIODirectory: a directory or None if not available.
"""
if self.entry_type != definitions.FILE_ENTRY_TYPE_DIRECTORY:
return None
return CPIODirectory(self._file_system, self.path_spec) | [
"def",
"_GetDirectory",
"(",
"self",
")",
":",
"if",
"self",
".",
"entry_type",
"!=",
"definitions",
".",
"FILE_ENTRY_TYPE_DIRECTORY",
":",
"return",
"None",
"return",
"CPIODirectory",
"(",
"self",
".",
"_file_system",
",",
"self",
".",
"path_spec",
")"
] | Retrieves a directory.
Returns:
CPIODirectory: a directory or None if not available. | [
"Retrieves",
"a",
"directory",
"."
] | python | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/archive.py | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/archive.py#L142-L160 | def extract(self, name):
"""
Get the object corresponding to name, or None.
For use with imputil ArchiveImporter, object is a python code object.
'name' is the name as specified in an 'import name'.
'import a.b' will become:
extract('a') (return None because 'a' is not a ... | [
"def",
"extract",
"(",
"self",
",",
"name",
")",
":",
"ispkg",
",",
"pos",
"=",
"self",
".",
"toc",
".",
"get",
"(",
"name",
",",
"(",
"0",
",",
"None",
")",
")",
"if",
"pos",
"is",
"None",
":",
"return",
"None",
"self",
".",
"lib",
".",
"see... | Get the object corresponding to name, or None.
For use with imputil ArchiveImporter, object is a python code object.
'name' is the name as specified in an 'import name'.
'import a.b' will become:
extract('a') (return None because 'a' is not a code object)
extract('a.__init__') (r... | [
"Get",
"the",
"object",
"corresponding",
"to",
"name",
"or",
"None",
".",
"For",
"use",
"with",
"imputil",
"ArchiveImporter",
"object",
"is",
"a",
"python",
"code",
"object",
".",
"name",
"is",
"the",
"name",
"as",
"specified",
"in",
"an",
"import",
"name"... | python | train |
jf-parent/brome | brome/core/proxy_driver.py | https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/core/proxy_driver.py#L1280-L1340 | def assert_text_equal(self, selector, value, testid=None, **kwargs):
"""Assert that the element's text is equal to the provided value
Args:
selector (str): the selector used to find the element
value (str): the value that will be compare
with the element.text val... | [
"def",
"assert_text_equal",
"(",
"self",
",",
"selector",
",",
"value",
",",
"testid",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"info_log",
"(",
"\"Assert text equal selector(%s) testid(%s)\"",
"%",
"(",
"selector",
",",
"testid",
")",
")... | Assert that the element's text is equal to the provided value
Args:
selector (str): the selector used to find the element
value (str): the value that will be compare
with the element.text value
test_id (str): the test_id or a str
Kwargs:
... | [
"Assert",
"that",
"the",
"element",
"s",
"text",
"is",
"equal",
"to",
"the",
"provided",
"value"
] | python | train |
zetaops/zengine | zengine/lib/utils.py | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/utils.py#L46-L63 | def merge_truthy(*dicts):
"""Merge multiple dictionaries, keeping the truthy values in case of key collisions.
Accepts any number of dictionaries, or any other object that returns a 2-tuple of
key and value pairs when its `.items()` method is called.
If a key exists in multiple dictionaries passed to ... | [
"def",
"merge_truthy",
"(",
"*",
"dicts",
")",
":",
"merged",
"=",
"{",
"}",
"for",
"d",
"in",
"dicts",
":",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"merged",
"[",
"k",
"]",
"=",
"v",
"or",
"merged",
".",
"get",
"(",
"... | Merge multiple dictionaries, keeping the truthy values in case of key collisions.
Accepts any number of dictionaries, or any other object that returns a 2-tuple of
key and value pairs when its `.items()` method is called.
If a key exists in multiple dictionaries passed to this function, the values from th... | [
"Merge",
"multiple",
"dictionaries",
"keeping",
"the",
"truthy",
"values",
"in",
"case",
"of",
"key",
"collisions",
"."
] | python | train |
facelessuser/soupsieve | soupsieve/css_match.py | https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L1294-L1306 | def select(self, limit=0):
"""Match all tags under the targeted tag."""
if limit < 1:
limit = None
for child in self.get_descendants(self.tag):
if self.match(child):
yield child
if limit is not None:
limit -= 1
... | [
"def",
"select",
"(",
"self",
",",
"limit",
"=",
"0",
")",
":",
"if",
"limit",
"<",
"1",
":",
"limit",
"=",
"None",
"for",
"child",
"in",
"self",
".",
"get_descendants",
"(",
"self",
".",
"tag",
")",
":",
"if",
"self",
".",
"match",
"(",
"child",... | Match all tags under the targeted tag. | [
"Match",
"all",
"tags",
"under",
"the",
"targeted",
"tag",
"."
] | python | train |
ianclegg/ntlmlib | ntlmlib/authentication.py | https://github.com/ianclegg/ntlmlib/blob/49eadfe4701bcce84a4ca9cbab5b6d5d72eaad05/ntlmlib/authentication.py#L147-L191 | def get_ntlm_response(self, flags, challenge, target_info=None, channel_binding=None):
"""
Computes the 24 byte NTLM challenge response given the 8 byte server challenge, along with the session key.
If NTLMv2 is used, the TargetInfo structure must be supplied, the updated TargetInfo structure wi... | [
"def",
"get_ntlm_response",
"(",
"self",
",",
"flags",
",",
"challenge",
",",
"target_info",
"=",
"None",
",",
"channel_binding",
"=",
"None",
")",
":",
"# TODO: IMPLEMENT THE FOLLOWING FEATURES",
"# If NTLM v2 authentication is used and the CHALLENGE_MESSAGE does not contain b... | Computes the 24 byte NTLM challenge response given the 8 byte server challenge, along with the session key.
If NTLMv2 is used, the TargetInfo structure must be supplied, the updated TargetInfo structure will be returned
:param challenge: The 8-byte challenge message generated by the server
:retu... | [
"Computes",
"the",
"24",
"byte",
"NTLM",
"challenge",
"response",
"given",
"the",
"8",
"byte",
"server",
"challenge",
"along",
"with",
"the",
"session",
"key",
".",
"If",
"NTLMv2",
"is",
"used",
"the",
"TargetInfo",
"structure",
"must",
"be",
"supplied",
"th... | python | train |
echinopsii/net.echinopsii.ariane.community.cli.python3 | ariane_clip3/directory.py | https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/directory.py#L1486-L1520 | def save(self):
"""
:return: save this IP Address on Ariane server (create or update)
"""
LOGGER.debug("IPAddress.save")
post_payload = {}
if self.id is not None:
post_payload['ipAddressID'] = self.id
if self.ip_address is not None:
post_... | [
"def",
"save",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"IPAddress.save\"",
")",
"post_payload",
"=",
"{",
"}",
"if",
"self",
".",
"id",
"is",
"not",
"None",
":",
"post_payload",
"[",
"'ipAddressID'",
"]",
"=",
"self",
".",
"id",
"if",
"... | :return: save this IP Address on Ariane server (create or update) | [
":",
"return",
":",
"save",
"this",
"IP",
"Address",
"on",
"Ariane",
"server",
"(",
"create",
"or",
"update",
")"
] | python | train |
mozilla/FoxPuppet | foxpuppet/windows/browser/notifications/addons.py | https://github.com/mozilla/FoxPuppet/blob/6575eb4c72fd024c986b254e198c8b4e6f68cddd/foxpuppet/windows/browser/notifications/addons.py#L24-L33 | def addon_name(self):
"""Provide access to the add-on name.
Returns:
str: Add-on name.
"""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
el = self.find_description()
return el.find_element(By.CSS_SELECTOR, "b").text | [
"def",
"addon_name",
"(",
"self",
")",
":",
"with",
"self",
".",
"selenium",
".",
"context",
"(",
"self",
".",
"selenium",
".",
"CONTEXT_CHROME",
")",
":",
"el",
"=",
"self",
".",
"find_description",
"(",
")",
"return",
"el",
".",
"find_element",
"(",
... | Provide access to the add-on name.
Returns:
str: Add-on name. | [
"Provide",
"access",
"to",
"the",
"add",
"-",
"on",
"name",
"."
] | python | train |
CityOfZion/neo-python | neo/Core/AssetType.py | https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/AssetType.py#L22-L31 | def AllTypes():
"""
Get a list of all available asset types.
Returns:
list: of AssetType items.
"""
return [AssetType.CreditFlag, AssetType.DutyFlag, AssetType.GoverningToken,
AssetType.UtilityToken, AssetType.Currency, AssetType.Share,
... | [
"def",
"AllTypes",
"(",
")",
":",
"return",
"[",
"AssetType",
".",
"CreditFlag",
",",
"AssetType",
".",
"DutyFlag",
",",
"AssetType",
".",
"GoverningToken",
",",
"AssetType",
".",
"UtilityToken",
",",
"AssetType",
".",
"Currency",
",",
"AssetType",
".",
"Sha... | Get a list of all available asset types.
Returns:
list: of AssetType items. | [
"Get",
"a",
"list",
"of",
"all",
"available",
"asset",
"types",
"."
] | python | train |
daler/metaseq | metaseq/helpers.py | https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/helpers.py#L93-L113 | def tointerval(s):
"""
If string, then convert to an interval; otherwise just return the input
"""
if isinstance(s, basestring):
m = coord_re.search(s)
if m.group('strand'):
return pybedtools.create_interval_from_list([
m.group('chrom'),
m.grou... | [
"def",
"tointerval",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"basestring",
")",
":",
"m",
"=",
"coord_re",
".",
"search",
"(",
"s",
")",
"if",
"m",
".",
"group",
"(",
"'strand'",
")",
":",
"return",
"pybedtools",
".",
"create_interval_... | If string, then convert to an interval; otherwise just return the input | [
"If",
"string",
"then",
"convert",
"to",
"an",
"interval",
";",
"otherwise",
"just",
"return",
"the",
"input"
] | python | train |
genialis/resolwe | resolwe/flow/views/entity.py | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/entity.py#L81-L104 | def destroy(self, request, *args, **kwargs):
"""Destroy a model instance.
If ``delete_content`` flag is set in query parameters, also all
Data objects contained in entity will be deleted.
"""
obj = self.get_object()
user = request.user
if strtobool(request.query... | [
"def",
"destroy",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"self",
".",
"get_object",
"(",
")",
"user",
"=",
"request",
".",
"user",
"if",
"strtobool",
"(",
"request",
".",
"query_params",
".",
"... | Destroy a model instance.
If ``delete_content`` flag is set in query parameters, also all
Data objects contained in entity will be deleted. | [
"Destroy",
"a",
"model",
"instance",
"."
] | python | train |
cltl/KafNafParserPy | KafNafParserPy/KafNafParserMod.py | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/KafNafParserMod.py#L230-L305 | def to_kaf(self):
"""
Converts a NAF object to KAF (in memory). You will have to use the method dump later to save it as a new KAF file
"""
if self.type == 'NAF':
self.root.tag = 'KAF'
self.type = 'KAF'
## Convert the header
if self.header is not... | [
"def",
"to_kaf",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"==",
"'NAF'",
":",
"self",
".",
"root",
".",
"tag",
"=",
"'KAF'",
"self",
".",
"type",
"=",
"'KAF'",
"## Convert the header",
"if",
"self",
".",
"header",
"is",
"not",
"None",
":",
... | Converts a NAF object to KAF (in memory). You will have to use the method dump later to save it as a new KAF file | [
"Converts",
"a",
"NAF",
"object",
"to",
"KAF",
"(",
"in",
"memory",
")",
".",
"You",
"will",
"have",
"to",
"use",
"the",
"method",
"dump",
"later",
"to",
"save",
"it",
"as",
"a",
"new",
"KAF",
"file"
] | python | train |
zalando/patroni | patroni/dcs/etcd.py | https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/dcs/etcd.py#L288-L310 | def _load_machines_cache(self):
"""This method should fill up `_machines_cache` from scratch.
It could happen only in two cases:
1. During class initialization
2. When all etcd members failed"""
self._update_machines_cache = True
if 'srv' not in self._config and 'host' ... | [
"def",
"_load_machines_cache",
"(",
"self",
")",
":",
"self",
".",
"_update_machines_cache",
"=",
"True",
"if",
"'srv'",
"not",
"in",
"self",
".",
"_config",
"and",
"'host'",
"not",
"in",
"self",
".",
"_config",
"and",
"'hosts'",
"not",
"in",
"self",
".",
... | This method should fill up `_machines_cache` from scratch.
It could happen only in two cases:
1. During class initialization
2. When all etcd members failed | [
"This",
"method",
"should",
"fill",
"up",
"_machines_cache",
"from",
"scratch",
".",
"It",
"could",
"happen",
"only",
"in",
"two",
"cases",
":",
"1",
".",
"During",
"class",
"initialization",
"2",
".",
"When",
"all",
"etcd",
"members",
"failed"
] | python | train |
dereneaton/ipyrad | ipyrad/assemble/util.py | https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/assemble/util.py#L192-L205 | def ambigcutters(seq):
"""
Returns both resolutions of a cut site that has an ambiguous base in
it, else the single cut site
"""
resos = []
if any([i in list("RKSYWM") for i in seq]):
for base in list("RKSYWM"):
if base in seq:
resos.append(seq.replace(base, A... | [
"def",
"ambigcutters",
"(",
"seq",
")",
":",
"resos",
"=",
"[",
"]",
"if",
"any",
"(",
"[",
"i",
"in",
"list",
"(",
"\"RKSYWM\"",
")",
"for",
"i",
"in",
"seq",
"]",
")",
":",
"for",
"base",
"in",
"list",
"(",
"\"RKSYWM\"",
")",
":",
"if",
"base... | Returns both resolutions of a cut site that has an ambiguous base in
it, else the single cut site | [
"Returns",
"both",
"resolutions",
"of",
"a",
"cut",
"site",
"that",
"has",
"an",
"ambiguous",
"base",
"in",
"it",
"else",
"the",
"single",
"cut",
"site"
] | python | valid |
aleju/imgaug | imgaug/augmentables/lines.py | https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/lines.py#L377-L488 | def clip_out_of_image(self, image):
"""
Clip off all parts of the line_string that are outside of the image.
Parameters
----------
image : ndarray or tuple of int
Either an image with shape ``(H,W,[C])`` or a tuple denoting
such an image shape.
R... | [
"def",
"clip_out_of_image",
"(",
"self",
",",
"image",
")",
":",
"if",
"len",
"(",
"self",
".",
"coords",
")",
"==",
"0",
":",
"return",
"[",
"]",
"inside_image_mask",
"=",
"self",
".",
"get_pointwise_inside_image_mask",
"(",
"image",
")",
"ooi_mask",
"=",... | Clip off all parts of the line_string that are outside of the image.
Parameters
----------
image : ndarray or tuple of int
Either an image with shape ``(H,W,[C])`` or a tuple denoting
such an image shape.
Returns
-------
list of imgaug.augmentabl... | [
"Clip",
"off",
"all",
"parts",
"of",
"the",
"line_string",
"that",
"are",
"outside",
"of",
"the",
"image",
"."
] | python | valid |
bioasp/caspo | caspo/predict.py | https://github.com/bioasp/caspo/blob/a68d1eace75b9b08f23633d1fb5ce6134403959e/caspo/predict.py#L52-L79 | def predict(self):
"""
Computes all possible weighted average predictions and their variances
Example::
>>> from caspo import core, predict
>>> networks = core.LogicalNetworkList.from_csv('behaviors.csv')
>>> setup = core.Setup.from_json('setup.json')
... | [
"def",
"predict",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Computing all predictions and their variance for %s logical networks...\"",
",",
"len",
"(",
"self",
".",
"networks",
")",
")",
"return",
"self",
".",
"networks",
".",
"predictio... | Computes all possible weighted average predictions and their variances
Example::
>>> from caspo import core, predict
>>> networks = core.LogicalNetworkList.from_csv('behaviors.csv')
>>> setup = core.Setup.from_json('setup.json')
>>> predictor = predict.Predict... | [
"Computes",
"all",
"possible",
"weighted",
"average",
"predictions",
"and",
"their",
"variances"
] | python | train |
Nekmo/amazon-dash | amazon_dash/execute.py | https://github.com/Nekmo/amazon-dash/blob/0e2bdc24ff8ea32cecb2f5f54f5cc1c0f99c197b/amazon_dash/execute.py#L336-L346 | def get_url(self):
"""Home assistant url
:return: url
:rtype: str
"""
url = super(ExecuteHomeAssistant, self).get_url()
if not self.data.get('event'):
raise InvalidConfig(extra_body='Event option is required for HomeAsistant on {} device.'.format(self.name))
... | [
"def",
"get_url",
"(",
"self",
")",
":",
"url",
"=",
"super",
"(",
"ExecuteHomeAssistant",
",",
"self",
")",
".",
"get_url",
"(",
")",
"if",
"not",
"self",
".",
"data",
".",
"get",
"(",
"'event'",
")",
":",
"raise",
"InvalidConfig",
"(",
"extra_body",
... | Home assistant url
:return: url
:rtype: str | [
"Home",
"assistant",
"url"
] | python | test |
tanghaibao/jcvi | jcvi/projects/pistachio.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/projects/pistachio.py#L24-L71 | def agp(args):
"""
%prog agp Siirt_Female_pistachio_23May2017_table.txt
The table file, as prepared by Dovetail Genomics, is not immediately useful
to convert gene model coordinates, as assumed by formats.chain.fromagp().
This is a quick script to do such conversion. The file structure of this
... | [
"def",
"agp",
"(",
"args",
")",
":",
"p",
"=",
"OptionParser",
"(",
"agp",
".",
"__doc__",
")",
"opts",
",",
"args",
"=",
"p",
".",
"parse_args",
"(",
"args",
")",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
":",
"sys",
".",
"exit",
"(",
"not",
... | %prog agp Siirt_Female_pistachio_23May2017_table.txt
The table file, as prepared by Dovetail Genomics, is not immediately useful
to convert gene model coordinates, as assumed by formats.chain.fromagp().
This is a quick script to do such conversion. The file structure of this
table file is described in ... | [
"%prog",
"agp",
"Siirt_Female_pistachio_23May2017_table",
".",
"txt"
] | python | train |
ioos/compliance-checker | compliance_checker/cf/cf.py | https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cf/cf.py#L1908-L1967 | def check_time_coordinate(self, ds):
'''
Check variables defining time are valid under CF
CF §4.4 Variables representing time must always explicitly include the
units attribute; there is no default value.
The units attribute takes a string value formatted as per the
rec... | [
"def",
"check_time_coordinate",
"(",
"self",
",",
"ds",
")",
":",
"ret_val",
"=",
"[",
"]",
"for",
"name",
"in",
"cfutil",
".",
"get_time_variables",
"(",
"ds",
")",
":",
"variable",
"=",
"ds",
".",
"variables",
"[",
"name",
"]",
"# Has units",
"has_unit... | Check variables defining time are valid under CF
CF §4.4 Variables representing time must always explicitly include the
units attribute; there is no default value.
The units attribute takes a string value formatted as per the
recommendations in the Udunits package.
The accepta... | [
"Check",
"variables",
"defining",
"time",
"are",
"valid",
"under",
"CF"
] | python | train |
horazont/aioxmpp | aioxmpp/errors.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/errors.py#L575-L586 | def localize(self, formatter, translator):
"""
Return a localized version of the `localizable_string` passed to the
consturctor. It is formatted using the `formatter` with the `args` and
`kwargs` passed to the constructor of :class:`UserError`.
"""
return self.localizable... | [
"def",
"localize",
"(",
"self",
",",
"formatter",
",",
"translator",
")",
":",
"return",
"self",
".",
"localizable_string",
".",
"localize",
"(",
"formatter",
",",
"translator",
",",
"*",
"self",
".",
"args",
",",
"*",
"*",
"self",
".",
"kwargs",
")"
] | Return a localized version of the `localizable_string` passed to the
consturctor. It is formatted using the `formatter` with the `args` and
`kwargs` passed to the constructor of :class:`UserError`. | [
"Return",
"a",
"localized",
"version",
"of",
"the",
"localizable_string",
"passed",
"to",
"the",
"consturctor",
".",
"It",
"is",
"formatted",
"using",
"the",
"formatter",
"with",
"the",
"args",
"and",
"kwargs",
"passed",
"to",
"the",
"constructor",
"of",
":",
... | python | train |
gem/oq-engine | openquake/server/db/upgrade_manager.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/upgrade_manager.py#L219-L229 | def check_versions(self, conn):
"""
:param conn: a DB API 2 connection
:returns: a message with the versions that will be applied or None
"""
scripts = self.read_scripts(skip_versions=self.get_db_versions(conn))
versions = [s['version'] for s in scripts]
if versio... | [
"def",
"check_versions",
"(",
"self",
",",
"conn",
")",
":",
"scripts",
"=",
"self",
".",
"read_scripts",
"(",
"skip_versions",
"=",
"self",
".",
"get_db_versions",
"(",
"conn",
")",
")",
"versions",
"=",
"[",
"s",
"[",
"'version'",
"]",
"for",
"s",
"i... | :param conn: a DB API 2 connection
:returns: a message with the versions that will be applied or None | [
":",
"param",
"conn",
":",
"a",
"DB",
"API",
"2",
"connection",
":",
"returns",
":",
"a",
"message",
"with",
"the",
"versions",
"that",
"will",
"be",
"applied",
"or",
"None"
] | python | train |
chemlab/chemlab | chemlab/libs/periodic_kdtree.py | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/libs/periodic_kdtree.py#L340-L382 | def query_ball_point(self, x, r, p=2., eps=0):
"""
Find all points within distance r of point(s) x.
Parameters
----------
x : array_like, shape tuple + (self.m,)
The point or points to search for neighbors of.
r : positive float
The radius of poin... | [
"def",
"query_ball_point",
"(",
"self",
",",
"x",
",",
"r",
",",
"p",
"=",
"2.",
",",
"eps",
"=",
"0",
")",
":",
"x",
"=",
"np",
".",
"asarray",
"(",
"x",
")",
".",
"astype",
"(",
"np",
".",
"float",
")",
"if",
"x",
".",
"shape",
"[",
"-",
... | Find all points within distance r of point(s) x.
Parameters
----------
x : array_like, shape tuple + (self.m,)
The point or points to search for neighbors of.
r : positive float
The radius of points to return.
p : float, optional
Which Minkows... | [
"Find",
"all",
"points",
"within",
"distance",
"r",
"of",
"point",
"(",
"s",
")",
"x",
"."
] | python | train |
dhermes/bezier | src/bezier/_curve_helpers.py | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L458-L490 | def _evaluate_hodograph(s, nodes):
r"""Evaluate the Hodograph curve at a point :math:`s`.
The Hodograph (first derivative) of a B |eacute| zier curve
degree :math:`d = n - 1` and is given by
.. math::
B'(s) = n \sum_{j = 0}^{d} \binom{d}{j} s^j
(1 - s)^{d - j} \cdot \Delta v_j
wher... | [
"def",
"_evaluate_hodograph",
"(",
"s",
",",
"nodes",
")",
":",
"_",
",",
"num_nodes",
"=",
"np",
".",
"shape",
"(",
"nodes",
")",
"first_deriv",
"=",
"nodes",
"[",
":",
",",
"1",
":",
"]",
"-",
"nodes",
"[",
":",
",",
":",
"-",
"1",
"]",
"retu... | r"""Evaluate the Hodograph curve at a point :math:`s`.
The Hodograph (first derivative) of a B |eacute| zier curve
degree :math:`d = n - 1` and is given by
.. math::
B'(s) = n \sum_{j = 0}^{d} \binom{d}{j} s^j
(1 - s)^{d - j} \cdot \Delta v_j
where each forward difference is given by
... | [
"r",
"Evaluate",
"the",
"Hodograph",
"curve",
"at",
"a",
"point",
":",
"math",
":",
"s",
"."
] | python | train |
mitsei/dlkit | dlkit/handcar/learning/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/learning/sessions.py#L1337-L1367 | def get_objective_nodes(self,
objective_id=None,
ancestor_levels=None,
descendant_levels=None,
include_siblings=None):
"""Gets a portion of the hierarchy for the given objective.
arg: obje... | [
"def",
"get_objective_nodes",
"(",
"self",
",",
"objective_id",
"=",
"None",
",",
"ancestor_levels",
"=",
"None",
",",
"descendant_levels",
"=",
"None",
",",
"include_siblings",
"=",
"None",
")",
":",
"if",
"objective_id",
"is",
"None",
":",
"url_path",
"=",
... | Gets a portion of the hierarchy for the given objective.
arg: objective_id (osid.id.Id): the Id to query
arg: ancestor_levels (cardinal): the maximum number of
ancestor levels to include. A value of 0 returns no
parents in the node.
arg: descendant_level... | [
"Gets",
"a",
"portion",
"of",
"the",
"hierarchy",
"for",
"the",
"given",
"objective",
"."
] | python | train |
fprimex/zdesk | zdesk/zdesk_api.py | https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L3067-L3071 | def shortcut_update(self, shortcut_id, data, **kwargs):
"https://developer.zendesk.com/rest_api/docs/chat/shortcuts#update-shortcut"
api_path = "/api/v2/shortcuts/{shortcut_id}"
api_path = api_path.format(shortcut_id=shortcut_id)
return self.call(api_path, method="PUT", data=data, **kwar... | [
"def",
"shortcut_update",
"(",
"self",
",",
"shortcut_id",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"api_path",
"=",
"\"/api/v2/shortcuts/{shortcut_id}\"",
"api_path",
"=",
"api_path",
".",
"format",
"(",
"shortcut_id",
"=",
"shortcut_id",
")",
"return",
... | https://developer.zendesk.com/rest_api/docs/chat/shortcuts#update-shortcut | [
"https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"chat",
"/",
"shortcuts#update",
"-",
"shortcut"
] | python | train |
chemlab/chemlab | chemlab/libs/cirpy.py | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/libs/cirpy.py#L42-L64 | def query(input, representation, resolvers=None, **kwargs):
""" Get all results for resolving input to the specified output representation """
apiurl = API_BASE+'/%s/%s/xml' % (urlquote(input), representation)
if resolvers:
kwargs['resolver'] = ",".join(resolvers)
if kwargs:
apiurl+= '?%... | [
"def",
"query",
"(",
"input",
",",
"representation",
",",
"resolvers",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"apiurl",
"=",
"API_BASE",
"+",
"'/%s/%s/xml'",
"%",
"(",
"urlquote",
"(",
"input",
")",
",",
"representation",
")",
"if",
"resolvers",... | Get all results for resolving input to the specified output representation | [
"Get",
"all",
"results",
"for",
"resolving",
"input",
"to",
"the",
"specified",
"output",
"representation"
] | python | train |
spry-group/python-vultr | vultr/v1_server.py | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/v1_server.py#L53-L61 | def get_user_data(self, subid, params=None):
''' /v1/server/get_user_data
GET - account
Retrieves the (base64 encoded) user-data for this subscription.
Link: https://www.vultr.com/api/#server_get_user_data
'''
params = update_params(params, {'SUBID': subid})
retu... | [
"def",
"get_user_data",
"(",
"self",
",",
"subid",
",",
"params",
"=",
"None",
")",
":",
"params",
"=",
"update_params",
"(",
"params",
",",
"{",
"'SUBID'",
":",
"subid",
"}",
")",
"return",
"self",
".",
"request",
"(",
"'/v1/server/get_user_data'",
",",
... | /v1/server/get_user_data
GET - account
Retrieves the (base64 encoded) user-data for this subscription.
Link: https://www.vultr.com/api/#server_get_user_data | [
"/",
"v1",
"/",
"server",
"/",
"get_user_data",
"GET",
"-",
"account",
"Retrieves",
"the",
"(",
"base64",
"encoded",
")",
"user",
"-",
"data",
"for",
"this",
"subscription",
"."
] | python | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L620-L623 | def reduce_mean(attrs, inputs, proto_obj):
"""Reduce the array along a given axis by mean value"""
new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'})
return 'mean', new_attrs, inputs | [
"def",
"reduce_mean",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'axes'",
":",
"'axis'",
"}",
")",
"return",
"'mean'",
",",
"new_attrs",
",",
"inputs"
... | Reduce the array along a given axis by mean value | [
"Reduce",
"the",
"array",
"along",
"a",
"given",
"axis",
"by",
"mean",
"value"
] | python | train |
cozy/python_cozy_management | cozy_management/ssl.py | https://github.com/cozy/python_cozy_management/blob/820cea58458ae3e067fa8cc2da38edbda4681dac/cozy_management/ssl.py#L259-L294 | def normalize_cert_dir():
'''
Put old cerfificate form to new one
'''
current_cn = get_crt_common_name()
if not os.path.isdir(COZY_CONFIG_PATH):
print 'Need to create {}'.format(COZY_CONFIG_PATH)
os.mkdir(COZY_CONFIG_PATH, 0755)
if not os.path.isdir(CERTIFICATES_PATH):
... | [
"def",
"normalize_cert_dir",
"(",
")",
":",
"current_cn",
"=",
"get_crt_common_name",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"COZY_CONFIG_PATH",
")",
":",
"print",
"'Need to create {}'",
".",
"format",
"(",
"COZY_CONFIG_PATH",
")",
"os",
... | Put old cerfificate form to new one | [
"Put",
"old",
"cerfificate",
"form",
"to",
"new",
"one"
] | python | train |
markovmodel/PyEMMA | pyemma/util/types.py | https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/util/types.py#L268-L287 | def ensure_float_vector_or_None(F, require_order = False):
"""Ensures that F is either None, or a numpy array of floats
If F is already either None or a numpy array of floats, F is returned (no copied!)
Otherwise, checks if the argument can be converted to an array of floats and does that.
Parameters
... | [
"def",
"ensure_float_vector_or_None",
"(",
"F",
",",
"require_order",
"=",
"False",
")",
":",
"if",
"F",
"is",
"None",
":",
"return",
"F",
"else",
":",
"return",
"ensure_float_vector",
"(",
"F",
",",
"require_order",
"=",
"require_order",
")"
] | Ensures that F is either None, or a numpy array of floats
If F is already either None or a numpy array of floats, F is returned (no copied!)
Otherwise, checks if the argument can be converted to an array of floats and does that.
Parameters
----------
F: float, list of float or 1D-ndarray of float
... | [
"Ensures",
"that",
"F",
"is",
"either",
"None",
"or",
"a",
"numpy",
"array",
"of",
"floats"
] | python | train |
moonlitesolutions/SolrClient | SolrClient/solrclient.py | https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L131-L144 | def index(self, collection, docs, params=None, min_rf=None, **kwargs):
"""
:param str collection: The name of the collection for the request.
:param docs list docs: List of dicts. ex: [{"title": "testing solr indexing", "id": "test1"}]
:param min_rf int min_rf: Required number of replica... | [
"def",
"index",
"(",
"self",
",",
"collection",
",",
"docs",
",",
"params",
"=",
"None",
",",
"min_rf",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"json",
".",
"dumps",
"(",
"docs",
")",
"return",
"self",
".",
"index_json",
"(",
... | :param str collection: The name of the collection for the request.
:param docs list docs: List of dicts. ex: [{"title": "testing solr indexing", "id": "test1"}]
:param min_rf int min_rf: Required number of replicas to write to'
Sends supplied list of dicts to solr for indexing. ::
... | [
":",
"param",
"str",
"collection",
":",
"The",
"name",
"of",
"the",
"collection",
"for",
"the",
"request",
".",
":",
"param",
"docs",
"list",
"docs",
":",
"List",
"of",
"dicts",
".",
"ex",
":",
"[",
"{",
"title",
":",
"testing",
"solr",
"indexing",
"... | python | train |
foliant-docs/foliantcontrib.flags | foliant/preprocessors/flags.py | https://github.com/foliant-docs/foliantcontrib.flags/blob/467b46eb77b341ba989c6165f8d3bcae9532df6d/foliant/preprocessors/flags.py#L16-L64 | def process_flagged_blocks(self, content: str) -> str:
'''Replace flagged blocks either with their contents or nothing, depending on the value
of ``FOLIANT_FLAGS`` environment variable and ``flags`` config value.
:param content: Markdown content
:returns: Markdown content without flagg... | [
"def",
"process_flagged_blocks",
"(",
"self",
",",
"content",
":",
"str",
")",
"->",
"str",
":",
"def",
"_sub",
"(",
"flagged_block",
")",
":",
"options",
"=",
"self",
".",
"get_options",
"(",
"flagged_block",
".",
"group",
"(",
"'options'",
")",
")",
"r... | Replace flagged blocks either with their contents or nothing, depending on the value
of ``FOLIANT_FLAGS`` environment variable and ``flags`` config value.
:param content: Markdown content
:returns: Markdown content without flagged blocks | [
"Replace",
"flagged",
"blocks",
"either",
"with",
"their",
"contents",
"or",
"nothing",
"depending",
"on",
"the",
"value",
"of",
"FOLIANT_FLAGS",
"environment",
"variable",
"and",
"flags",
"config",
"value",
"."
] | python | train |
chemlab/chemlab | chemlab/mviewer/api/appeareance.py | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/appeareance.py#L166-L181 | def screenshot(filename, width=None, height=None):
'''Make a screenshot of the current view. You can tweak the
resolution up to what your GPU memory supports.
By defaults it uses the current window resolution.
Example::
screenshot('screen.png', 1200, 1200)
'''
width = width... | [
"def",
"screenshot",
"(",
"filename",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
")",
":",
"width",
"=",
"width",
"or",
"viewer",
".",
"widget",
".",
"width",
"(",
")",
"height",
"=",
"height",
"or",
"viewer",
".",
"widget",
".",
"height"... | Make a screenshot of the current view. You can tweak the
resolution up to what your GPU memory supports.
By defaults it uses the current window resolution.
Example::
screenshot('screen.png', 1200, 1200) | [
"Make",
"a",
"screenshot",
"of",
"the",
"current",
"view",
".",
"You",
"can",
"tweak",
"the",
"resolution",
"up",
"to",
"what",
"your",
"GPU",
"memory",
"supports",
".",
"By",
"defaults",
"it",
"uses",
"the",
"current",
"window",
"resolution",
".",
"Exampl... | python | train |
Robpol86/colorclass | colorclass/core.py | https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/core.py#L234-L239 | def join(self, iterable):
"""Return a string which is the concatenation of the strings in the iterable.
:param iterable: Join items in this iterable.
"""
return self.__class__(super(ColorStr, self).join(iterable), keep_tags=True) | [
"def",
"join",
"(",
"self",
",",
"iterable",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"super",
"(",
"ColorStr",
",",
"self",
")",
".",
"join",
"(",
"iterable",
")",
",",
"keep_tags",
"=",
"True",
")"
] | Return a string which is the concatenation of the strings in the iterable.
:param iterable: Join items in this iterable. | [
"Return",
"a",
"string",
"which",
"is",
"the",
"concatenation",
"of",
"the",
"strings",
"in",
"the",
"iterable",
"."
] | python | train |
CSchoel/nolds | nolds/measures.py | https://github.com/CSchoel/nolds/blob/8a5ecc472d67ac08b571bd68967287668ca9058e/nolds/measures.py#L109-L343 | def lyap_r(data, emb_dim=10, lag=None, min_tsep=None, tau=1, min_neighbors=20,
trajectory_len=20, fit="RANSAC", debug_plot=False, debug_data=False,
plot_file=None, fit_offset=0):
"""
Estimates the largest Lyapunov exponent using the algorithm of Rosenstein
et al. [lr_1]_.
Explanation of L... | [
"def",
"lyap_r",
"(",
"data",
",",
"emb_dim",
"=",
"10",
",",
"lag",
"=",
"None",
",",
"min_tsep",
"=",
"None",
",",
"tau",
"=",
"1",
",",
"min_neighbors",
"=",
"20",
",",
"trajectory_len",
"=",
"20",
",",
"fit",
"=",
"\"RANSAC\"",
",",
"debug_plot",... | Estimates the largest Lyapunov exponent using the algorithm of Rosenstein
et al. [lr_1]_.
Explanation of Lyapunov exponents:
See lyap_e.
Explanation of the algorithm:
The algorithm of Rosenstein et al. is only able to recover the largest
Lyapunov exponent, but behaves rather robust to parameter choi... | [
"Estimates",
"the",
"largest",
"Lyapunov",
"exponent",
"using",
"the",
"algorithm",
"of",
"Rosenstein",
"et",
"al",
".",
"[",
"lr_1",
"]",
"_",
"."
] | python | train |
keans/lmnotify | lmnotify/lmnotify.py | https://github.com/keans/lmnotify/blob/b0a5282a582e5090852dc20fea8a135ca258d0d3/lmnotify/lmnotify.py#L537-L569 | def _app_exec(self, package, action, params=None):
"""
meta method for all interactions with apps
:param package: name of package/app
:type package: str
:param action: the action to be executed
:type action: str
:param params: optional parameters for this action
... | [
"def",
"_app_exec",
"(",
"self",
",",
"package",
",",
"action",
",",
"params",
"=",
"None",
")",
":",
"# get list of possible commands from app.actions",
"allowed_commands",
"=",
"[",
"]",
"for",
"app",
"in",
"self",
".",
"get_apps_list",
"(",
")",
":",
"if",
... | meta method for all interactions with apps
:param package: name of package/app
:type package: str
:param action: the action to be executed
:type action: str
:param params: optional parameters for this action
:type params: dict
:return: None
:rtype: None | [
"meta",
"method",
"for",
"all",
"interactions",
"with",
"apps"
] | python | train |
senaite/senaite.core | bika/lims/exportimport/instruments/genexpert/genexpert.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/exportimport/instruments/genexpert/genexpert.py#L224-L241 | def _submit_result(self):
"""
Adding current values as a Raw Result and Resetting everything.
Notice that we are not calculating final result of assay. We just set
NP and GP values and in Bika, AS will have a Calculation to generate
final result based on NP and GP values.
... | [
"def",
"_submit_result",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cur_res_id",
"and",
"self",
".",
"_cur_values",
":",
"# Setting DefaultResult just because it is obligatory. However,",
"# it won't be used because AS must have a Calculation based on",
"# GP and NP results.",
"... | Adding current values as a Raw Result and Resetting everything.
Notice that we are not calculating final result of assay. We just set
NP and GP values and in Bika, AS will have a Calculation to generate
final result based on NP and GP values. | [
"Adding",
"current",
"values",
"as",
"a",
"Raw",
"Result",
"and",
"Resetting",
"everything",
".",
"Notice",
"that",
"we",
"are",
"not",
"calculating",
"final",
"result",
"of",
"assay",
".",
"We",
"just",
"set",
"NP",
"and",
"GP",
"values",
"and",
"in",
"... | python | train |
singularityhub/sregistry-cli | sregistry/logger/message.py | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/logger/message.py#L149-L155 | def write(self, stream, message):
'''write will write a message to a stream,
first checking the encoding
'''
if isinstance(message, bytes):
message = message.decode('utf-8')
stream.write(message) | [
"def",
"write",
"(",
"self",
",",
"stream",
",",
"message",
")",
":",
"if",
"isinstance",
"(",
"message",
",",
"bytes",
")",
":",
"message",
"=",
"message",
".",
"decode",
"(",
"'utf-8'",
")",
"stream",
".",
"write",
"(",
"message",
")"
] | write will write a message to a stream,
first checking the encoding | [
"write",
"will",
"write",
"a",
"message",
"to",
"a",
"stream",
"first",
"checking",
"the",
"encoding"
] | python | test |
JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/treemodel.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/treemodel.py#L256-L271 | def add_child(self, child):
"""Add child to children of this TreeItem
:param child: the child TreeItem
:type child: :class:`TreeItem`
:returns: None
:rtype: None
:raises: None
"""
child.set_model(self._model)
if self._model:
row = len(... | [
"def",
"add_child",
"(",
"self",
",",
"child",
")",
":",
"child",
".",
"set_model",
"(",
"self",
".",
"_model",
")",
"if",
"self",
".",
"_model",
":",
"row",
"=",
"len",
"(",
"self",
".",
"childItems",
")",
"parentindex",
"=",
"self",
".",
"_model",
... | Add child to children of this TreeItem
:param child: the child TreeItem
:type child: :class:`TreeItem`
:returns: None
:rtype: None
:raises: None | [
"Add",
"child",
"to",
"children",
"of",
"this",
"TreeItem"
] | python | train |
mpapi/lazylights | lazylights.py | https://github.com/mpapi/lazylights/blob/536dbd3ce75c28b3545cf66f25fc72589488063f/lazylights.py#L118-L126 | def _unbytes(bytestr):
"""
Returns a bytestring from the human-friendly string returned by `_bytes`.
>>> _unbytes('123456')
'\x12\x34\x56'
"""
return ''.join(chr(int(bytestr[k:k + 2], 16))
for k in range(0, len(bytestr), 2)) | [
"def",
"_unbytes",
"(",
"bytestr",
")",
":",
"return",
"''",
".",
"join",
"(",
"chr",
"(",
"int",
"(",
"bytestr",
"[",
"k",
":",
"k",
"+",
"2",
"]",
",",
"16",
")",
")",
"for",
"k",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"bytestr",
")",
... | Returns a bytestring from the human-friendly string returned by `_bytes`.
>>> _unbytes('123456')
'\x12\x34\x56' | [
"Returns",
"a",
"bytestring",
"from",
"the",
"human",
"-",
"friendly",
"string",
"returned",
"by",
"_bytes",
"."
] | python | train |
yandex/yandex-tank | yandextank/plugins/Telegraf/config.py | https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Telegraf/config.py#L185-L225 | def create_startup_config(self):
""" Startup and shutdown commands config
Used by agent.py on the target
"""
cfg_path = "agent_startup_{}.cfg".format(self.host)
if os.path.isfile(cfg_path):
logger.info(
'Found agent startup config file in working dire... | [
"def",
"create_startup_config",
"(",
"self",
")",
":",
"cfg_path",
"=",
"\"agent_startup_{}.cfg\"",
".",
"format",
"(",
"self",
".",
"host",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"cfg_path",
")",
":",
"logger",
".",
"info",
"(",
"'Found agent s... | Startup and shutdown commands config
Used by agent.py on the target | [
"Startup",
"and",
"shutdown",
"commands",
"config",
"Used",
"by",
"agent",
".",
"py",
"on",
"the",
"target"
] | python | test |
openstack/proliantutils | proliantutils/ilo/ribcl.py | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/ilo/ribcl.py#L188-L211 | def _serialize_xml(self, root):
"""Serialize XML data into string
It serializes the dynamic xml created and converts
it to a string. This is done before sending the
xml to the ILO.
:param root: root of the dynamic xml.
"""
if hasattr(etree, 'tostringlist'):
... | [
"def",
"_serialize_xml",
"(",
"self",
",",
"root",
")",
":",
"if",
"hasattr",
"(",
"etree",
",",
"'tostringlist'",
")",
":",
"if",
"six",
".",
"PY3",
":",
"xml_content_list",
"=",
"[",
"x",
".",
"decode",
"(",
"\"utf-8\"",
")",
"for",
"x",
"in",
"etr... | Serialize XML data into string
It serializes the dynamic xml created and converts
it to a string. This is done before sending the
xml to the ILO.
:param root: root of the dynamic xml. | [
"Serialize",
"XML",
"data",
"into",
"string"
] | python | train |
pandas-dev/pandas | pandas/core/groupby/generic.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/generic.py#L1183-L1196 | def count(self):
""" Compute count of group, excluding missing values """
ids, _, ngroups = self.grouper.group_info
val = self.obj.get_values()
mask = (ids != -1) & ~isna(val)
ids = ensure_platform_int(ids)
minlength = ngroups or 0
out = np.bincount(ids[mask], mi... | [
"def",
"count",
"(",
"self",
")",
":",
"ids",
",",
"_",
",",
"ngroups",
"=",
"self",
".",
"grouper",
".",
"group_info",
"val",
"=",
"self",
".",
"obj",
".",
"get_values",
"(",
")",
"mask",
"=",
"(",
"ids",
"!=",
"-",
"1",
")",
"&",
"~",
"isna",... | Compute count of group, excluding missing values | [
"Compute",
"count",
"of",
"group",
"excluding",
"missing",
"values"
] | python | train |
PmagPy/PmagPy | programs/demag_gui.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/demag_gui.py#L7763-L7800 | def on_equalarea_specimen_select(self, event):
"""
Get mouse position on double click find the nearest interpretation
to the mouse
position then select that interpretation
Parameters
----------
event : the wx Mouseevent for that click
Alters
----... | [
"def",
"on_equalarea_specimen_select",
"(",
"self",
",",
"event",
")",
":",
"if",
"not",
"self",
".",
"specimen_EA_xdata",
"or",
"not",
"self",
".",
"specimen_EA_ydata",
":",
"return",
"pos",
"=",
"event",
".",
"GetPosition",
"(",
")",
"width",
",",
"height"... | Get mouse position on double click find the nearest interpretation
to the mouse
position then select that interpretation
Parameters
----------
event : the wx Mouseevent for that click
Alters
------
current_fit | [
"Get",
"mouse",
"position",
"on",
"double",
"click",
"find",
"the",
"nearest",
"interpretation",
"to",
"the",
"mouse",
"position",
"then",
"select",
"that",
"interpretation"
] | python | train |
Clinical-Genomics/scout | scout/adapter/mongo/hgnc.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/adapter/mongo/hgnc.py#L455-L475 | def ensembl_genes(self, build='37'):
"""Return a dictionary with ensembl ids as keys and gene objects as value.
Args:
build(str)
Returns:
genes(dict): {<ensg_id>: gene_obj, ...}
"""
genes = {}
LOG.info("Fetching all genes")
... | [
"def",
"ensembl_genes",
"(",
"self",
",",
"build",
"=",
"'37'",
")",
":",
"genes",
"=",
"{",
"}",
"LOG",
".",
"info",
"(",
"\"Fetching all genes\"",
")",
"for",
"gene_obj",
"in",
"self",
".",
"hgnc_collection",
".",
"find",
"(",
"{",
"'build'",
":",
"b... | Return a dictionary with ensembl ids as keys and gene objects as value.
Args:
build(str)
Returns:
genes(dict): {<ensg_id>: gene_obj, ...} | [
"Return",
"a",
"dictionary",
"with",
"ensembl",
"ids",
"as",
"keys",
"and",
"gene",
"objects",
"as",
"value",
"."
] | python | test |
pyamg/pyamg | pyamg/gallery/example.py | https://github.com/pyamg/pyamg/blob/89dc54aa27e278f65d2f54bdaf16ab97d7768fa6/pyamg/gallery/example.py#L17-L45 | def load_example(name):
"""Load an example problem by name.
Parameters
----------
name : string (e.g. 'airfoil')
Name of the example to load
Notes
-----
Each example is stored in a dictionary with the following keys:
- 'A' : sparse matrix
- 'B' : near-... | [
"def",
"load_example",
"(",
"name",
")",
":",
"if",
"name",
"not",
"in",
"example_names",
":",
"raise",
"ValueError",
"(",
"'no example with name (%s)'",
"%",
"name",
")",
"else",
":",
"return",
"loadmat",
"(",
"os",
".",
"path",
".",
"join",
"(",
"example... | Load an example problem by name.
Parameters
----------
name : string (e.g. 'airfoil')
Name of the example to load
Notes
-----
Each example is stored in a dictionary with the following keys:
- 'A' : sparse matrix
- 'B' : near-nullspace candidates
- ... | [
"Load",
"an",
"example",
"problem",
"by",
"name",
"."
] | python | train |
gbowerman/azurerm | azurerm/networkrp.py | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L518-L532 | def list_load_balancers(access_token, subscription_id):
'''List the load balancers in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON body of load balancer list with properties.... | [
"def",
"list_load_balancers",
"(",
"access_token",
",",
"subscription_id",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/providers/Microsoft.Network/'",
",",
"'/loadBala... | List the load balancers in a subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON body of load balancer list with properties. | [
"List",
"the",
"load",
"balancers",
"in",
"a",
"subscription",
"."
] | python | train |
kstaniek/condoor | condoor/drivers/generic.py | https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L180-L199 | def is_console(self, users_text):
"""Return if device is connected over console."""
if users_text is None:
self.log("Console information not collected")
return None
for line in users_text.split('\n'):
if '*' in line:
match = re.search(self.vty... | [
"def",
"is_console",
"(",
"self",
",",
"users_text",
")",
":",
"if",
"users_text",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"Console information not collected\"",
")",
"return",
"None",
"for",
"line",
"in",
"users_text",
".",
"split",
"(",
"'\\n'",
")",... | Return if device is connected over console. | [
"Return",
"if",
"device",
"is",
"connected",
"over",
"console",
"."
] | python | train |
aliyun/aliyun-log-python-sdk | aliyun/log/logclient.py | https://github.com/aliyun/aliyun-log-python-sdk/blob/ac383db0a16abf1e5ef7df36074374184b43516e/aliyun/log/logclient.py#L619-L637 | def get_project_logs(self, request):
""" Get logs from log service.
Unsuccessful opertaion will cause an LogException.
:type request: GetProjectLogsRequest
:param request: the GetProjectLogs request parameters class.
:return: GetLogsResponse
... | [
"def",
"get_project_logs",
"(",
"self",
",",
"request",
")",
":",
"headers",
"=",
"{",
"}",
"params",
"=",
"{",
"}",
"if",
"request",
".",
"get_query",
"(",
")",
"is",
"not",
"None",
":",
"params",
"[",
"'query'",
"]",
"=",
"request",
".",
"get_query... | Get logs from log service.
Unsuccessful opertaion will cause an LogException.
:type request: GetProjectLogsRequest
:param request: the GetProjectLogs request parameters class.
:return: GetLogsResponse
:raise: LogException | [
"Get",
"logs",
"from",
"log",
"service",
".",
"Unsuccessful",
"opertaion",
"will",
"cause",
"an",
"LogException",
".",
":",
"type",
"request",
":",
"GetProjectLogsRequest",
":",
"param",
"request",
":",
"the",
"GetProjectLogs",
"request",
"parameters",
"class",
... | python | train |
Qiskit/qiskit-terra | qiskit/circuit/quantumcircuit.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/quantumcircuit.py#L325-L329 | def _check_dups(self, qubits):
"""Raise exception if list of qubits contains duplicates."""
squbits = set(qubits)
if len(squbits) != len(qubits):
raise QiskitError("duplicate qubit arguments") | [
"def",
"_check_dups",
"(",
"self",
",",
"qubits",
")",
":",
"squbits",
"=",
"set",
"(",
"qubits",
")",
"if",
"len",
"(",
"squbits",
")",
"!=",
"len",
"(",
"qubits",
")",
":",
"raise",
"QiskitError",
"(",
"\"duplicate qubit arguments\"",
")"
] | Raise exception if list of qubits contains duplicates. | [
"Raise",
"exception",
"if",
"list",
"of",
"qubits",
"contains",
"duplicates",
"."
] | python | test |
kytos/python-openflow | pyof/foundation/network_types.py | https://github.com/kytos/python-openflow/blob/4f2d0d08ab28e102ed88fe57a4ee17729f1e1bb7/pyof/foundation/network_types.py#L441-L451 | def get_size(self, value=None):
"""Return struct size.
Returns:
int: Returns the struct size based on inner attributes.
"""
if isinstance(value, type(self)):
return value.get_size()
return 2 + self.length | [
"def",
"get_size",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"type",
"(",
"self",
")",
")",
":",
"return",
"value",
".",
"get_size",
"(",
")",
"return",
"2",
"+",
"self",
".",
"length"
] | Return struct size.
Returns:
int: Returns the struct size based on inner attributes. | [
"Return",
"struct",
"size",
"."
] | python | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/wrappers.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/wrappers.py#L146-L157 | def set_line_width(self, width=1.):
"""Set line width
Parameters
----------
width : float
The line width.
"""
width = float(width)
if width < 0:
raise RuntimeError('Cannot have width < 0')
self.glir.command('FUNC', 'glLineWidth... | [
"def",
"set_line_width",
"(",
"self",
",",
"width",
"=",
"1.",
")",
":",
"width",
"=",
"float",
"(",
"width",
")",
"if",
"width",
"<",
"0",
":",
"raise",
"RuntimeError",
"(",
"'Cannot have width < 0'",
")",
"self",
".",
"glir",
".",
"command",
"(",
"'F... | Set line width
Parameters
----------
width : float
The line width. | [
"Set",
"line",
"width",
"Parameters",
"----------",
"width",
":",
"float",
"The",
"line",
"width",
"."
] | python | train |
petl-developers/petl | petl/transform/joins.py | https://github.com/petl-developers/petl/blob/1d33ca055f7e04e0d28a772041c9fd30c8d415d6/petl/transform/joins.py#L50-L144 | def join(left, right, key=None, lkey=None, rkey=None, presorted=False,
buffersize=None, tempdir=None, cache=True, lprefix=None, rprefix=None):
"""
Perform an equi-join on the given tables. E.g.::
>>> import petl as etl
>>> table1 = [['id', 'colour'],
... [1, 'blue'],
... | [
"def",
"join",
"(",
"left",
",",
"right",
",",
"key",
"=",
"None",
",",
"lkey",
"=",
"None",
",",
"rkey",
"=",
"None",
",",
"presorted",
"=",
"False",
",",
"buffersize",
"=",
"None",
",",
"tempdir",
"=",
"None",
",",
"cache",
"=",
"True",
",",
"l... | Perform an equi-join on the given tables. E.g.::
>>> import petl as etl
>>> table1 = [['id', 'colour'],
... [1, 'blue'],
... [2, 'red'],
... [3, 'purple']]
>>> table2 = [['id', 'shape'],
... [1, 'circle'],
... ... | [
"Perform",
"an",
"equi",
"-",
"join",
"on",
"the",
"given",
"tables",
".",
"E",
".",
"g",
".",
"::"
] | python | train |
dixudx/rtcclient | rtcclient/client.py | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L160-L191 | def getProjectArea(self, projectarea_name, archived=False,
returned_properties=None):
"""Get :class:`rtcclient.project_area.ProjectArea` object by its name
:param projectarea_name: the project area name
:param archived: (default is False) whether the project area
... | [
"def",
"getProjectArea",
"(",
"self",
",",
"projectarea_name",
",",
"archived",
"=",
"False",
",",
"returned_properties",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"projectarea_name",
",",
"six",
".",
"string_types",
")",
"or",
"not",
"projectarea... | Get :class:`rtcclient.project_area.ProjectArea` object by its name
:param projectarea_name: the project area name
:param archived: (default is False) whether the project area
is archived
:param returned_properties: the returned properties that you want.
Refer to :class:`... | [
"Get",
":",
"class",
":",
"rtcclient",
".",
"project_area",
".",
"ProjectArea",
"object",
"by",
"its",
"name"
] | python | train |
IAMconsortium/pyam | pyam/timeseries.py | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/timeseries.py#L89-L123 | def cross_threshold(x, threshold=0, direction=['from above', 'from below']):
"""Returns a list of the years in which a timeseries (indexed over years)
crosses a given threshold
Parameters
----------
x: pandas.Series
a timeseries indexed over years
threshold: float, default 0
the... | [
"def",
"cross_threshold",
"(",
"x",
",",
"threshold",
"=",
"0",
",",
"direction",
"=",
"[",
"'from above'",
",",
"'from below'",
"]",
")",
":",
"prev_yr",
",",
"prev_val",
"=",
"None",
",",
"None",
"years",
"=",
"[",
"]",
"direction",
"=",
"[",
"direct... | Returns a list of the years in which a timeseries (indexed over years)
crosses a given threshold
Parameters
----------
x: pandas.Series
a timeseries indexed over years
threshold: float, default 0
the threshold that the timeseries is checked against
direction: str, optional, defa... | [
"Returns",
"a",
"list",
"of",
"the",
"years",
"in",
"which",
"a",
"timeseries",
"(",
"indexed",
"over",
"years",
")",
"crosses",
"a",
"given",
"threshold"
] | python | train |
marrow/mongo | web/session/mongo.py | https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/web/session/mongo.py#L92-L98 | def persist(self, context):
"""Update or insert the session document into the configured collection"""
D = self._Document
document = context.session[self.name]
D.get_collection().replace_one(D.id == document.id, document, True) | [
"def",
"persist",
"(",
"self",
",",
"context",
")",
":",
"D",
"=",
"self",
".",
"_Document",
"document",
"=",
"context",
".",
"session",
"[",
"self",
".",
"name",
"]",
"D",
".",
"get_collection",
"(",
")",
".",
"replace_one",
"(",
"D",
".",
"id",
"... | Update or insert the session document into the configured collection | [
"Update",
"or",
"insert",
"the",
"session",
"document",
"into",
"the",
"configured",
"collection"
] | python | train |
reingart/pyafipws | wslpg.py | https://github.com/reingart/pyafipws/blob/ee87cfe4ac12285ab431df5fec257f103042d1ab/wslpg.py#L2346-L2357 | def ConsultarCertificacionUltNroOrden(self, pto_emision=1):
"Consulta el último No de orden registrado para CG"
ret = self.client.cgConsultarUltimoNroOrden(
auth={
'token': self.Token, 'sign': self.Sign,
'cuit': self.Cuit, },
... | [
"def",
"ConsultarCertificacionUltNroOrden",
"(",
"self",
",",
"pto_emision",
"=",
"1",
")",
":",
"ret",
"=",
"self",
".",
"client",
".",
"cgConsultarUltimoNroOrden",
"(",
"auth",
"=",
"{",
"'token'",
":",
"self",
".",
"Token",
",",
"'sign'",
":",
"self",
"... | Consulta el último No de orden registrado para CG | [
"Consulta",
"el",
"último",
"No",
"de",
"orden",
"registrado",
"para",
"CG"
] | python | train |
jonathf/chaospy | chaospy/poly/collection/core.py | https://github.com/jonathf/chaospy/blob/25ecfa7bf5608dc10c0b31d142ded0e3755f5d74/chaospy/poly/collection/core.py#L367-L376 | def all(A, ax=None):
"""Test if all values in A evaluate to True """
if isinstance(A, Poly):
out = numpy.zeros(A.shape, dtype=bool)
B = A.A
for key in A.keys:
out += all(B[key], ax)
return out
return numpy.all(A, ax) | [
"def",
"all",
"(",
"A",
",",
"ax",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"A",
",",
"Poly",
")",
":",
"out",
"=",
"numpy",
".",
"zeros",
"(",
"A",
".",
"shape",
",",
"dtype",
"=",
"bool",
")",
"B",
"=",
"A",
".",
"A",
"for",
"key",... | Test if all values in A evaluate to True | [
"Test",
"if",
"all",
"values",
"in",
"A",
"evaluate",
"to",
"True"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.