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 |
|---|---|---|---|---|---|---|---|---|
wummel/linkchecker | linkcheck/configuration/confparse.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/configuration/confparse.py#L64-L70 | def read_string_option (self, section, option, allowempty=False):
"""Read a string option."""
if self.has_option(section, option):
value = self.get(section, option)
if not allowempty and not value:
raise LinkCheckerError(_("invalid empty value for %s: %s\n") % (op... | [
"def",
"read_string_option",
"(",
"self",
",",
"section",
",",
"option",
",",
"allowempty",
"=",
"False",
")",
":",
"if",
"self",
".",
"has_option",
"(",
"section",
",",
"option",
")",
":",
"value",
"=",
"self",
".",
"get",
"(",
"section",
",",
"option... | Read a string option. | [
"Read",
"a",
"string",
"option",
"."
] | python | train |
PmagPy/PmagPy | pmagpy/pmagplotlib.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmagplotlib.py#L198-L216 | def k_s(X):
"""
Kolmorgorov-Smirnov statistic. Finds the
probability that the data are distributed
as func - used method of Numerical Recipes (Press et al., 1986)
"""
xbar, sigma = pmag.gausspars(X)
d, f = 0, 0.
for i in range(1, len(X) + 1):
b = old_div(float(i), float(len(X)))
... | [
"def",
"k_s",
"(",
"X",
")",
":",
"xbar",
",",
"sigma",
"=",
"pmag",
".",
"gausspars",
"(",
"X",
")",
"d",
",",
"f",
"=",
"0",
",",
"0.",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"X",
")",
"+",
"1",
")",
":",
"b",
"=",
"old... | Kolmorgorov-Smirnov statistic. Finds the
probability that the data are distributed
as func - used method of Numerical Recipes (Press et al., 1986) | [
"Kolmorgorov",
"-",
"Smirnov",
"statistic",
".",
"Finds",
"the",
"probability",
"that",
"the",
"data",
"are",
"distributed",
"as",
"func",
"-",
"used",
"method",
"of",
"Numerical",
"Recipes",
"(",
"Press",
"et",
"al",
".",
"1986",
")"
] | python | train |
acorg/dark-matter | dark/aa.py | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/aa.py#L982-L1022 | def find(s):
"""
Find an amino acid whose name or abbreviation is s.
@param s: A C{str} amino acid specifier. This may be a full name,
a 3-letter abbreviation or a 1-letter abbreviation. Case is ignored.
return: An L{AminoAcid} instance or C{None} if no matching amino acid can
be locate... | [
"def",
"find",
"(",
"s",
")",
":",
"abbrev1",
"=",
"None",
"origS",
"=",
"s",
"if",
"' '",
"in",
"s",
":",
"# Convert first word to title case, others to lower.",
"first",
",",
"rest",
"=",
"s",
".",
"split",
"(",
"' '",
",",
"1",
")",
"s",
"=",
"first... | Find an amino acid whose name or abbreviation is s.
@param s: A C{str} amino acid specifier. This may be a full name,
a 3-letter abbreviation or a 1-letter abbreviation. Case is ignored.
return: An L{AminoAcid} instance or C{None} if no matching amino acid can
be located. | [
"Find",
"an",
"amino",
"acid",
"whose",
"name",
"or",
"abbreviation",
"is",
"s",
"."
] | python | train |
OnroerendErfgoed/crabpy_pyramid | crabpy_pyramid/renderers/capakey.py | https://github.com/OnroerendErfgoed/crabpy_pyramid/blob/b727ea55838d71575db96e987b536a0bac9f6a7a/crabpy_pyramid/renderers/capakey.py#L49-L59 | def list_perceel_adapter(obj, request):
"""
Adapter for rendering a list of
:class: `crabpy.gateway.capakey.Perceel` to json.
"""
return {
'id': obj.id,
'sectie': obj.sectie,
'capakey': obj.capakey,
'percid': obj.percid
} | [
"def",
"list_perceel_adapter",
"(",
"obj",
",",
"request",
")",
":",
"return",
"{",
"'id'",
":",
"obj",
".",
"id",
",",
"'sectie'",
":",
"obj",
".",
"sectie",
",",
"'capakey'",
":",
"obj",
".",
"capakey",
",",
"'percid'",
":",
"obj",
".",
"percid",
"... | Adapter for rendering a list of
:class: `crabpy.gateway.capakey.Perceel` to json. | [
"Adapter",
"for",
"rendering",
"a",
"list",
"of",
":",
"class",
":",
"crabpy",
".",
"gateway",
".",
"capakey",
".",
"Perceel",
"to",
"json",
"."
] | python | train |
tensorflow/probability | tensorflow_probability/python/layers/dense_variational.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/dense_variational.py#L215-L254 | def get_config(self):
"""Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the
configuration of a layer. The same layer can be reinstantiated later
(without its trained weights) from this configuration.
Returns:
config: A Python dictionary of cl... | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"{",
"'units'",
":",
"self",
".",
"units",
",",
"'activation'",
":",
"(",
"tf",
".",
"keras",
".",
"activations",
".",
"serialize",
"(",
"self",
".",
"activation",
")",
"if",
"self",
".",
"ac... | Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the
configuration of a layer. The same layer can be reinstantiated later
(without its trained weights) from this configuration.
Returns:
config: A Python dictionary of class keyword arguments and the... | [
"Returns",
"the",
"config",
"of",
"the",
"layer",
"."
] | python | test |
pkkid/python-plexapi | plexapi/settings.py | https://github.com/pkkid/python-plexapi/blob/9efbde96441c2bfbf410eacfb46e811e108e8bbc/plexapi/settings.py#L32-L40 | def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
for elem in data:
id = utils.lowerFirst(elem.attrib['id'])
if id in self._settings:
self._settings[id]._loadData(elem)
continue
s... | [
"def",
"_loadData",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_data",
"=",
"data",
"for",
"elem",
"in",
"data",
":",
"id",
"=",
"utils",
".",
"lowerFirst",
"(",
"elem",
".",
"attrib",
"[",
"'id'",
"]",
")",
"if",
"id",
"in",
"self",
".",
... | Load attribute values from Plex XML response. | [
"Load",
"attribute",
"values",
"from",
"Plex",
"XML",
"response",
"."
] | python | train |
fkmclane/python-ardrone | ardrone/drone.py | https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L87-L91 | def reset(self):
"""Toggle the drone's emergency state."""
self.at(ardrone.at.ref, False, True)
time.sleep(0.1)
self.at(ardrone.at.ref, False, False) | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"at",
"(",
"ardrone",
".",
"at",
".",
"ref",
",",
"False",
",",
"True",
")",
"time",
".",
"sleep",
"(",
"0.1",
")",
"self",
".",
"at",
"(",
"ardrone",
".",
"at",
".",
"ref",
",",
"False",
",... | Toggle the drone's emergency state. | [
"Toggle",
"the",
"drone",
"s",
"emergency",
"state",
"."
] | python | train |
angr/angr | angr/analyses/forward_analysis.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L800-L812 | def _peek_job(self, pos):
"""
Return the job currently at position `pos`, but still keep it in the job queue. An IndexError will be raised
if that position does not currently exist in the job list.
:param int pos: Position of the job to get.
:return: The job
"""
... | [
"def",
"_peek_job",
"(",
"self",
",",
"pos",
")",
":",
"if",
"pos",
"<",
"len",
"(",
"self",
".",
"_job_info_queue",
")",
":",
"return",
"self",
".",
"_job_info_queue",
"[",
"pos",
"]",
".",
"job",
"raise",
"IndexError",
"(",
")"
] | Return the job currently at position `pos`, but still keep it in the job queue. An IndexError will be raised
if that position does not currently exist in the job list.
:param int pos: Position of the job to get.
:return: The job | [
"Return",
"the",
"job",
"currently",
"at",
"position",
"pos",
"but",
"still",
"keep",
"it",
"in",
"the",
"job",
"queue",
".",
"An",
"IndexError",
"will",
"be",
"raised",
"if",
"that",
"position",
"does",
"not",
"currently",
"exist",
"in",
"the",
"job",
"... | python | train |
AkihikoITOH/capybara | capybara/virtualenv/lib/python2.7/site-packages/werkzeug/contrib/cache.py | https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/werkzeug/contrib/cache.py#L206-L217 | def inc(self, key, delta=1):
"""Increments the value of a key by `delta`. If the key does
not yet exist it is initialized with `delta`.
For supporting caches this is an atomic operation.
:param key: the key to increment.
:param delta: the delta to add.
:returns: The ne... | [
"def",
"inc",
"(",
"self",
",",
"key",
",",
"delta",
"=",
"1",
")",
":",
"value",
"=",
"(",
"self",
".",
"get",
"(",
"key",
")",
"or",
"0",
")",
"+",
"delta",
"return",
"value",
"if",
"self",
".",
"set",
"(",
"key",
",",
"value",
")",
"else",... | Increments the value of a key by `delta`. If the key does
not yet exist it is initialized with `delta`.
For supporting caches this is an atomic operation.
:param key: the key to increment.
:param delta: the delta to add.
:returns: The new value or ``None`` for backend errors. | [
"Increments",
"the",
"value",
"of",
"a",
"key",
"by",
"delta",
".",
"If",
"the",
"key",
"does",
"not",
"yet",
"exist",
"it",
"is",
"initialized",
"with",
"delta",
"."
] | python | test |
dcaune/perseus-lib-python-common | exifread/classes.py | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/exifread/classes.py#L64-L84 | def s2n(self, offset, length, signed=0):
"""
Convert slice to integer, based on sign and endian flags.
Usually this offset is assumed to be relative to the beginning of the
start of the EXIF information.
For some cameras that use relative tags, this offset may be relative
... | [
"def",
"s2n",
"(",
"self",
",",
"offset",
",",
"length",
",",
"signed",
"=",
"0",
")",
":",
"self",
".",
"file",
".",
"seek",
"(",
"self",
".",
"offset",
"+",
"offset",
")",
"sliced",
"=",
"self",
".",
"file",
".",
"read",
"(",
"length",
")",
"... | Convert slice to integer, based on sign and endian flags.
Usually this offset is assumed to be relative to the beginning of the
start of the EXIF information.
For some cameras that use relative tags, this offset may be relative
to some other starting point. | [
"Convert",
"slice",
"to",
"integer",
"based",
"on",
"sign",
"and",
"endian",
"flags",
"."
] | python | train |
NicolasLM/spinach | spinach/brokers/base.py | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/brokers/base.py#L102-L107 | def next_future_job_delta(self) -> Optional[float]:
"""Give the amount of seconds before the next future job is due."""
job = self._get_next_future_job()
if not job:
return None
return (job.at - datetime.now(timezone.utc)).total_seconds() | [
"def",
"next_future_job_delta",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"job",
"=",
"self",
".",
"_get_next_future_job",
"(",
")",
"if",
"not",
"job",
":",
"return",
"None",
"return",
"(",
"job",
".",
"at",
"-",
"datetime",
".",
"no... | Give the amount of seconds before the next future job is due. | [
"Give",
"the",
"amount",
"of",
"seconds",
"before",
"the",
"next",
"future",
"job",
"is",
"due",
"."
] | python | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/descriptor_pool.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/descriptor_pool.py#L963-L983 | def _GetTypeFromScope(self, package, type_name, scope):
"""Finds a given type name in the current scope.
Args:
package: The package the proto should be located in.
type_name: The name of the type to be found in the scope.
scope: Dict mapping short and full symbols to message and enum types.
... | [
"def",
"_GetTypeFromScope",
"(",
"self",
",",
"package",
",",
"type_name",
",",
"scope",
")",
":",
"if",
"type_name",
"not",
"in",
"scope",
":",
"components",
"=",
"_PrefixWithDot",
"(",
"package",
")",
".",
"split",
"(",
"'.'",
")",
"while",
"components",... | Finds a given type name in the current scope.
Args:
package: The package the proto should be located in.
type_name: The name of the type to be found in the scope.
scope: Dict mapping short and full symbols to message and enum types.
Returns:
The descriptor for the requested type. | [
"Finds",
"a",
"given",
"type",
"name",
"in",
"the",
"current",
"scope",
"."
] | python | train |
Jarn/jarn.viewdoc | jarn/viewdoc/viewdoc.py | https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L341-L348 | def publish_string(self, rest, outfile, styles=''):
"""Render a reST string as HTML.
"""
html = self.convert_string(rest)
html = self.strip_xml_header(html)
html = self.apply_styles(html, styles)
self.write_file(html, outfile)
return outfile | [
"def",
"publish_string",
"(",
"self",
",",
"rest",
",",
"outfile",
",",
"styles",
"=",
"''",
")",
":",
"html",
"=",
"self",
".",
"convert_string",
"(",
"rest",
")",
"html",
"=",
"self",
".",
"strip_xml_header",
"(",
"html",
")",
"html",
"=",
"self",
... | Render a reST string as HTML. | [
"Render",
"a",
"reST",
"string",
"as",
"HTML",
"."
] | python | train |
polyaxon/polyaxon-cli | polyaxon_cli/cli/check.py | https://github.com/polyaxon/polyaxon-cli/blob/a7f5eed74d4d909cad79059f3c21c58606881449/polyaxon_cli/cli/check.py#L67-L98 | def check(file, # pylint:disable=redefined-builtin
version,
definition):
"""Check a polyaxonfile."""
file = file or 'polyaxonfile.yaml'
specification = check_polyaxonfile(file).specification
if version:
Printer.decorate_format_value('The version is: {}',
... | [
"def",
"check",
"(",
"file",
",",
"# pylint:disable=redefined-builtin",
"version",
",",
"definition",
")",
":",
"file",
"=",
"file",
"or",
"'polyaxonfile.yaml'",
"specification",
"=",
"check_polyaxonfile",
"(",
"file",
")",
".",
"specification",
"if",
"version",
"... | Check a polyaxonfile. | [
"Check",
"a",
"polyaxonfile",
"."
] | python | valid |
HPCC-Cloud-Computing/CAL | calplus/v1/object_storage/client.py | https://github.com/HPCC-Cloud-Computing/CAL/blob/7134b3dfe9ee3a383506a592765c7a12fa4ca1e9/calplus/v1/object_storage/client.py#L53-L60 | def stat_container(self, container):
"""Stat container metadata
:param container: container name (Container is equivalent to
Bucket term in Amazon).
"""
LOG.debug('stat_container() with %s is success.', self.driver)
return self.driver.stat_container(con... | [
"def",
"stat_container",
"(",
"self",
",",
"container",
")",
":",
"LOG",
".",
"debug",
"(",
"'stat_container() with %s is success.'",
",",
"self",
".",
"driver",
")",
"return",
"self",
".",
"driver",
".",
"stat_container",
"(",
"container",
")"
] | Stat container metadata
:param container: container name (Container is equivalent to
Bucket term in Amazon). | [
"Stat",
"container",
"metadata"
] | python | train |
hadrianl/huobi | huobitrade/service.py | https://github.com/hadrianl/huobi/blob/bbfa2036703ee84a76d5d8e9f89c25fc8a55f2c7/huobitrade/service.py#L76-L86 | def get_last_depth(self, symbol, _type, _async=False):
"""
获取marketdepth
:param symbol
:param type: 可选值:{ percent10, step0, step1, step2, step3, step4, step5 }
:return:
"""
params = {'symbol': symbol, 'type': _type}
url = u.MARKET_URL + '/market/depth'
... | [
"def",
"get_last_depth",
"(",
"self",
",",
"symbol",
",",
"_type",
",",
"_async",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'symbol'",
":",
"symbol",
",",
"'type'",
":",
"_type",
"}",
"url",
"=",
"u",
".",
"MARKET_URL",
"+",
"'/market/depth'",
"retu... | 获取marketdepth
:param symbol
:param type: 可选值:{ percent10, step0, step1, step2, step3, step4, step5 }
:return: | [
"获取marketdepth",
":",
"param",
"symbol",
":",
"param",
"type",
":",
"可选值:",
"{",
"percent10",
"step0",
"step1",
"step2",
"step3",
"step4",
"step5",
"}",
":",
"return",
":"
] | python | train |
jrief/djangocms-cascade | cmsplugin_cascade/plugin_base.py | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/plugin_base.py#L282-L295 | def _get_parent_classes_transparent(cls, slot, page, instance=None):
"""
Return all parent classes including those marked as "transparent".
"""
parent_classes = super(CascadePluginBase, cls).get_parent_classes(slot, page, instance)
if parent_classes is None:
if cls.ge... | [
"def",
"_get_parent_classes_transparent",
"(",
"cls",
",",
"slot",
",",
"page",
",",
"instance",
"=",
"None",
")",
":",
"parent_classes",
"=",
"super",
"(",
"CascadePluginBase",
",",
"cls",
")",
".",
"get_parent_classes",
"(",
"slot",
",",
"page",
",",
"inst... | Return all parent classes including those marked as "transparent". | [
"Return",
"all",
"parent",
"classes",
"including",
"those",
"marked",
"as",
"transparent",
"."
] | python | train |
esterhui/pypu | pypu/service_facebook.py | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L377-L466 | def _upload_or_replace_fb(self,directory,fn,_album_id,\
_megapixels=None,resize_request=None,movealbum_request=None,\
changetitle_request=None,_title=None):
"""Does the actual upload to fb.
if resize_request, will resize picture only if
it already exists and the geometry ... | [
"def",
"_upload_or_replace_fb",
"(",
"self",
",",
"directory",
",",
"fn",
",",
"_album_id",
",",
"_megapixels",
"=",
"None",
",",
"resize_request",
"=",
"None",
",",
"movealbum_request",
"=",
"None",
",",
"changetitle_request",
"=",
"None",
",",
"_title",
"=",... | Does the actual upload to fb.
if resize_request, will resize picture only if
it already exists and the geometry on fb doesn't match
what we want,
returns (status) | [
"Does",
"the",
"actual",
"upload",
"to",
"fb",
".",
"if",
"resize_request",
"will",
"resize",
"picture",
"only",
"if",
"it",
"already",
"exists",
"and",
"the",
"geometry",
"on",
"fb",
"doesn",
"t",
"match",
"what",
"we",
"want",
"returns",
"(",
"status",
... | python | train |
python-xlib/python-xlib | examples/run_examples.py | https://github.com/python-xlib/python-xlib/blob/8901e831737e79fe5645f48089d70e1d1046d2f2/examples/run_examples.py#L34-L41 | def run_example(path):
""" Returns returncode of example """
cmd = "{0} {1}".format(sys.executable, path)
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
res = proc.communicate()
if proc.returncode:
print(res[1].decode())
return proc.returncode | [
"def",
"run_example",
"(",
"path",
")",
":",
"cmd",
"=",
"\"{0} {1}\"",
".",
"format",
"(",
"sys",
".",
"executable",
",",
"path",
")",
"proc",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"shell",
"=",
"True",
",",
"stdout",
"=",
"subprocess",
... | Returns returncode of example | [
"Returns",
"returncode",
"of",
"example"
] | python | train |
Clinical-Genomics/trailblazer | trailblazer/mip/config.py | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/mip/config.py#L65-L79 | def prepare_config(data: dict) -> dict:
"""Prepare the config data."""
data_copy = deepcopy(data)
# handle single sample cases with 'unknown' phenotype
if len(data_copy['samples']) == 1:
if data_copy['samples'][0]['phenotype'] == 'unknown':
LOG.info("setting '... | [
"def",
"prepare_config",
"(",
"data",
":",
"dict",
")",
"->",
"dict",
":",
"data_copy",
"=",
"deepcopy",
"(",
"data",
")",
"# handle single sample cases with 'unknown' phenotype",
"if",
"len",
"(",
"data_copy",
"[",
"'samples'",
"]",
")",
"==",
"1",
":",
"if",... | Prepare the config data. | [
"Prepare",
"the",
"config",
"data",
"."
] | python | train |
hydraplatform/hydra-base | hydra_base/lib/template.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/template.py#L807-L850 | def set_network_template(template_id, network_id, **kwargs):
"""
Apply an existing template to a network. Used when a template has changed, and additional attributes
must be added to the network's elements.
"""
resource_types = []
#There should only ever be one matching type, but if ther... | [
"def",
"set_network_template",
"(",
"template_id",
",",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"resource_types",
"=",
"[",
"]",
"#There should only ever be one matching type, but if there are more,",
"#all we can do is pick the first one.",
"try",
":",
"network_type... | Apply an existing template to a network. Used when a template has changed, and additional attributes
must be added to the network's elements. | [
"Apply",
"an",
"existing",
"template",
"to",
"a",
"network",
".",
"Used",
"when",
"a",
"template",
"has",
"changed",
"and",
"additional",
"attributes",
"must",
"be",
"added",
"to",
"the",
"network",
"s",
"elements",
"."
] | python | train |
OpenGov/carpenter | carpenter/blocks/tableanalyzer.py | https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/tableanalyzer.py#L310-L377 | def _find_block_start(self, table, used_cells, possible_block_start, start_pos, end_pos):
'''
Finds the start of a block from a suggested start location. This location can be at a lower
column but not a lower row. The function traverses columns until it finds a stopping
condition or a re... | [
"def",
"_find_block_start",
"(",
"self",
",",
"table",
",",
"used_cells",
",",
"possible_block_start",
",",
"start_pos",
",",
"end_pos",
")",
":",
"current_col",
"=",
"possible_block_start",
"[",
"1",
"]",
"block_start",
"=",
"list",
"(",
"possible_block_start",
... | Finds the start of a block from a suggested start location. This location can be at a lower
column but not a lower row. The function traverses columns until it finds a stopping
condition or a repeat condition that restarts on the next column.
Note this also finds the lowest row of block_end. | [
"Finds",
"the",
"start",
"of",
"a",
"block",
"from",
"a",
"suggested",
"start",
"location",
".",
"This",
"location",
"can",
"be",
"at",
"a",
"lower",
"column",
"but",
"not",
"a",
"lower",
"row",
".",
"The",
"function",
"traverses",
"columns",
"until",
"i... | python | train |
cloudendpoints/endpoints-python | endpoints/message_parser.py | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/message_parser.py#L154-L227 | def __message_to_schema(self, message_type):
"""Parse a single message into JSON Schema.
Will recursively descend the message structure
and also parse other messages references via MessageFields.
Args:
message_type: protorpc.messages.Message class to parse.
Returns:
An object represen... | [
"def",
"__message_to_schema",
"(",
"self",
",",
"message_type",
")",
":",
"name",
"=",
"self",
".",
"__normalized_name",
"(",
"message_type",
")",
"schema",
"=",
"{",
"'id'",
":",
"name",
",",
"'type'",
":",
"'object'",
",",
"}",
"if",
"message_type",
".",... | Parse a single message into JSON Schema.
Will recursively descend the message structure
and also parse other messages references via MessageFields.
Args:
message_type: protorpc.messages.Message class to parse.
Returns:
An object representation of the schema. | [
"Parse",
"a",
"single",
"message",
"into",
"JSON",
"Schema",
"."
] | python | train |
quantumlib/Cirq | cirq/circuits/circuit.py | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1528-L1542 | def to_qasm(self,
header: Optional[str] = None,
precision: int = 10,
qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT,
) -> str:
"""Returns QASM equivalent to the circuit.
Args:
header: A multi-line string that is pla... | [
"def",
"to_qasm",
"(",
"self",
",",
"header",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"precision",
":",
"int",
"=",
"10",
",",
"qubit_order",
":",
"ops",
".",
"QubitOrderOrList",
"=",
"ops",
".",
"QubitOrder",
".",
"DEFAULT",
",",
")",
"-... | Returns QASM equivalent to the circuit.
Args:
header: A multi-line string that is placed in a comment at the top
of the QASM. Defaults to a cirq version specifier.
precision: Number of digits to use when representing numbers.
qubit_order: Determines how qubit... | [
"Returns",
"QASM",
"equivalent",
"to",
"the",
"circuit",
"."
] | python | train |
google/grr | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L772-L803 | def _ParseShVariables(self, lines):
"""Extract env_var and path values from sh derivative shells.
Iterates over each line, word by word searching for statements that set the
path. These are either variables, or conditions that would allow a variable
to be set later in the line (e.g. export).
Args:... | [
"def",
"_ParseShVariables",
"(",
"self",
",",
"lines",
")",
":",
"paths",
"=",
"{",
"}",
"for",
"line",
"in",
"lines",
":",
"for",
"entry",
"in",
"line",
":",
"if",
"\"=\"",
"in",
"entry",
":",
"# Pad out the list so that it's always 2 elements, even if the spli... | Extract env_var and path values from sh derivative shells.
Iterates over each line, word by word searching for statements that set the
path. These are either variables, or conditions that would allow a variable
to be set later in the line (e.g. export).
Args:
lines: A list of lines, each of whic... | [
"Extract",
"env_var",
"and",
"path",
"values",
"from",
"sh",
"derivative",
"shells",
"."
] | python | train |
ehansis/ozelot | examples/superheroes/superheroes/analysis.py | https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/examples/superheroes/superheroes/analysis.py#L90-L201 | def plots_html_page():
"""Generate general statistics
Output is an html page, rendered to 'plots_html_page.html' in the output directory.
"""
# page template
template = jenv.get_template("plots_html_page.html")
# container for template context
context = dict()
# a database client/sess... | [
"def",
"plots_html_page",
"(",
")",
":",
"# page template",
"template",
"=",
"jenv",
".",
"get_template",
"(",
"\"plots_html_page.html\"",
")",
"# container for template context",
"context",
"=",
"dict",
"(",
")",
"# a database client/session to run queries in",
"cl",
"="... | Generate general statistics
Output is an html page, rendered to 'plots_html_page.html' in the output directory. | [
"Generate",
"general",
"statistics"
] | python | train |
sunlightlabs/name-cleaver | name_cleaver/cleaver.py | https://github.com/sunlightlabs/name-cleaver/blob/48d3838fd9521235bd1586017fa4b31236ffc88e/name_cleaver/cleaver.py#L115-L133 | def reverse_last_first(self, name):
""" Takes a name that is in [last, first] format and returns it in a hopefully [first last] order.
Also extracts the suffix and puts it back on the end, in case it's embedded somewhere in the middle.
"""
# make sure we don't put a suffix in the mid... | [
"def",
"reverse_last_first",
"(",
"self",
",",
"name",
")",
":",
"# make sure we don't put a suffix in the middle, as in \"Smith, Tom II\"",
"name",
",",
"suffix",
"=",
"self",
".",
"extract_suffix",
"(",
"name",
")",
"split",
"=",
"re",
".",
"split",
"(",
"', ?'",
... | Takes a name that is in [last, first] format and returns it in a hopefully [first last] order.
Also extracts the suffix and puts it back on the end, in case it's embedded somewhere in the middle. | [
"Takes",
"a",
"name",
"that",
"is",
"in",
"[",
"last",
"first",
"]",
"format",
"and",
"returns",
"it",
"in",
"a",
"hopefully",
"[",
"first",
"last",
"]",
"order",
".",
"Also",
"extracts",
"the",
"suffix",
"and",
"puts",
"it",
"back",
"on",
"the",
"en... | python | train |
trevisanj/a99 | a99/gui/xmisc.py | https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L424-L430 | def add_signal(self, signal):
"""Adds "input" signal to connected signals.
Internally connects the signal to a control slot."""
self.__signals.append(signal)
if self.__connected:
# Connects signal if the current state is "connected"
self.__connect_signal(sig... | [
"def",
"add_signal",
"(",
"self",
",",
"signal",
")",
":",
"self",
".",
"__signals",
".",
"append",
"(",
"signal",
")",
"if",
"self",
".",
"__connected",
":",
"# Connects signal if the current state is \"connected\"\r",
"self",
".",
"__connect_signal",
"(",
"signa... | Adds "input" signal to connected signals.
Internally connects the signal to a control slot. | [
"Adds",
"input",
"signal",
"to",
"connected",
"signals",
".",
"Internally",
"connects",
"the",
"signal",
"to",
"a",
"control",
"slot",
"."
] | python | train |
scanny/python-pptx | pptx/chart/plot.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/chart/plot.py#L164-L172 | def overlap(self, value):
"""
Set the value of the ``<c:overlap>`` child element to *int_value*,
or remove the overlap element if *int_value* is 0.
"""
if value == 0:
self._element._remove_overlap()
return
self._element.get_or_add_overlap().val = v... | [
"def",
"overlap",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"==",
"0",
":",
"self",
".",
"_element",
".",
"_remove_overlap",
"(",
")",
"return",
"self",
".",
"_element",
".",
"get_or_add_overlap",
"(",
")",
".",
"val",
"=",
"value"
] | Set the value of the ``<c:overlap>`` child element to *int_value*,
or remove the overlap element if *int_value* is 0. | [
"Set",
"the",
"value",
"of",
"the",
"<c",
":",
"overlap",
">",
"child",
"element",
"to",
"*",
"int_value",
"*",
"or",
"remove",
"the",
"overlap",
"element",
"if",
"*",
"int_value",
"*",
"is",
"0",
"."
] | python | train |
obriencj/python-javatools | javatools/report.py | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L123-L143 | def setup(self):
"""
instantiates all report formats that have been added to this
reporter, and calls their setup methods.
"""
if self._formats:
# setup has been run already.
return
basedir = self.basedir
options = self.options
cr... | [
"def",
"setup",
"(",
"self",
")",
":",
"if",
"self",
".",
"_formats",
":",
"# setup has been run already.",
"return",
"basedir",
"=",
"self",
".",
"basedir",
"options",
"=",
"self",
".",
"options",
"crumbs",
"=",
"self",
".",
"get_relative_breadcrumbs",
"(",
... | instantiates all report formats that have been added to this
reporter, and calls their setup methods. | [
"instantiates",
"all",
"report",
"formats",
"that",
"have",
"been",
"added",
"to",
"this",
"reporter",
"and",
"calls",
"their",
"setup",
"methods",
"."
] | python | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/io/datasets.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/datasets.py#L52-L61 | def pack_ieee(value):
"""Packs float ieee binary representation into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel
"""
return np.fromstring(value.tostring(),
np.ubyte).reshape((value.shape + (4,))) | [
"def",
"pack_ieee",
"(",
"value",
")",
":",
"return",
"np",
".",
"fromstring",
"(",
"value",
".",
"tostring",
"(",
")",
",",
"np",
".",
"ubyte",
")",
".",
"reshape",
"(",
"(",
"value",
".",
"shape",
"+",
"(",
"4",
",",
")",
")",
")"
] | Packs float ieee binary representation into 4 unsigned int8
Returns
-------
pack: array
packed interpolation kernel | [
"Packs",
"float",
"ieee",
"binary",
"representation",
"into",
"4",
"unsigned",
"int8"
] | python | train |
davidwtbuxton/notrequests | notrequests.py | https://github.com/davidwtbuxton/notrequests/blob/e48ee6107a58c2f373c33f78e3302608edeba7f3/notrequests.py#L121-L126 | def json(self, **kwargs):
"""Decodes response as JSON."""
encoding = detect_encoding(self.content[:4])
value = self.content.decode(encoding)
return simplejson.loads(value, **kwargs) | [
"def",
"json",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"encoding",
"=",
"detect_encoding",
"(",
"self",
".",
"content",
"[",
":",
"4",
"]",
")",
"value",
"=",
"self",
".",
"content",
".",
"decode",
"(",
"encoding",
")",
"return",
"simplejson"... | Decodes response as JSON. | [
"Decodes",
"response",
"as",
"JSON",
"."
] | python | train |
CalebBell/ht | ht/conv_two_phase.py | https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conv_two_phase.py#L33-L94 | def Davis_David(m, x, D, rhol, rhog, Cpl, kl, mul):
r'''Calculates the two-phase non-boiling heat transfer coefficient of a
liquid and gas flowing inside a tube of any inclination, as in [1]_ and
reviewed in [2]_.
.. math::
\frac{h_{TP} D}{k_l} = 0.060\left(\frac{\rho_L}{\rho_G}\right)^{0.28}... | [
"def",
"Davis_David",
"(",
"m",
",",
"x",
",",
"D",
",",
"rhol",
",",
"rhog",
",",
"Cpl",
",",
"kl",
",",
"mul",
")",
":",
"G",
"=",
"m",
"/",
"(",
"pi",
"/",
"4",
"*",
"D",
"**",
"2",
")",
"Prl",
"=",
"Prandtl",
"(",
"Cp",
"=",
"Cpl",
... | r'''Calculates the two-phase non-boiling heat transfer coefficient of a
liquid and gas flowing inside a tube of any inclination, as in [1]_ and
reviewed in [2]_.
.. math::
\frac{h_{TP} D}{k_l} = 0.060\left(\frac{\rho_L}{\rho_G}\right)^{0.28}
\left(\frac{DG_{TP} x}{\mu_L}\right)^{0.87}
... | [
"r",
"Calculates",
"the",
"two",
"-",
"phase",
"non",
"-",
"boiling",
"heat",
"transfer",
"coefficient",
"of",
"a",
"liquid",
"and",
"gas",
"flowing",
"inside",
"a",
"tube",
"of",
"any",
"inclination",
"as",
"in",
"[",
"1",
"]",
"_",
"and",
"reviewed",
... | python | train |
openvax/varlens | varlens/reads_util.py | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/reads_util.py#L104-L141 | def add_args(parser, positional=False):
"""
Extends a commandline argument parser with arguments for specifying
read sources.
"""
group = parser.add_argument_group("read loading")
group.add_argument("reads" if positional else "--reads",
nargs="+", default=[],
help="Paths to bam f... | [
"def",
"add_args",
"(",
"parser",
",",
"positional",
"=",
"False",
")",
":",
"group",
"=",
"parser",
".",
"add_argument_group",
"(",
"\"read loading\"",
")",
"group",
".",
"add_argument",
"(",
"\"reads\"",
"if",
"positional",
"else",
"\"--reads\"",
",",
"nargs... | Extends a commandline argument parser with arguments for specifying
read sources. | [
"Extends",
"a",
"commandline",
"argument",
"parser",
"with",
"arguments",
"for",
"specifying",
"read",
"sources",
"."
] | python | train |
facetoe/zenpy | zenpy/lib/api.py | https://github.com/facetoe/zenpy/blob/34c54c7e408b9ed01604ddf8b3422204c8bf31ea/zenpy/lib/api.py#L1727-L1735 | def create(self, section, article):
"""
Create (POST) an Article - See: Zendesk API `Reference
<https://developer.zendesk.com/rest_api/docs/help_center/articles#create-article>`__.
:param section: Section ID or object
:param article: Article to create
"""
return ... | [
"def",
"create",
"(",
"self",
",",
"section",
",",
"article",
")",
":",
"return",
"CRUDRequest",
"(",
"self",
")",
".",
"post",
"(",
"article",
",",
"create",
"=",
"True",
",",
"id",
"=",
"section",
")"
] | Create (POST) an Article - See: Zendesk API `Reference
<https://developer.zendesk.com/rest_api/docs/help_center/articles#create-article>`__.
:param section: Section ID or object
:param article: Article to create | [
"Create",
"(",
"POST",
")",
"an",
"Article",
"-",
"See",
":",
"Zendesk",
"API",
"Reference",
"<https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"help_center",
"/",
"articles#create",
"-",
"article",
">",
"__"... | python | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/image_processing.py | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/image_processing.py#L107-L137 | def distorted_inputs(dataset, batch_size=None, num_preprocess_threads=None):
"""Generate batches of distorted versions of ImageNet images.
Use this function as the inputs for training a network.
Distorting images provides a useful technique for augmenting the data
set during training in order to make the netw... | [
"def",
"distorted_inputs",
"(",
"dataset",
",",
"batch_size",
"=",
"None",
",",
"num_preprocess_threads",
"=",
"None",
")",
":",
"if",
"not",
"batch_size",
":",
"batch_size",
"=",
"FLAGS",
".",
"batch_size",
"# Force all input processing onto CPU in order to reserve the... | Generate batches of distorted versions of ImageNet images.
Use this function as the inputs for training a network.
Distorting images provides a useful technique for augmenting the data
set during training in order to make the network invariant to aspects
of the image that do not effect the label.
Args:
... | [
"Generate",
"batches",
"of",
"distorted",
"versions",
"of",
"ImageNet",
"images",
"."
] | python | train |
aouyar/PyMunin | pysysinfo/system.py | https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pysysinfo/system.py#L78-L96 | def getCPUuse(self):
"""Return cpu time utilization in seconds.
@return: Dictionary of stats.
"""
hz = os.sysconf('SC_CLK_TCK')
info_dict = {}
try:
fp = open(cpustatFile, 'r')
line = fp.readline()
fp.close()
ex... | [
"def",
"getCPUuse",
"(",
"self",
")",
":",
"hz",
"=",
"os",
".",
"sysconf",
"(",
"'SC_CLK_TCK'",
")",
"info_dict",
"=",
"{",
"}",
"try",
":",
"fp",
"=",
"open",
"(",
"cpustatFile",
",",
"'r'",
")",
"line",
"=",
"fp",
".",
"readline",
"(",
")",
"f... | Return cpu time utilization in seconds.
@return: Dictionary of stats. | [
"Return",
"cpu",
"time",
"utilization",
"in",
"seconds",
"."
] | python | train |
poppy-project/pypot | pypot/vrep/io.py | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L255-L261 | def change_object_name(self, old_name, new_name):
""" Change object name """
h = self._get_object_handle(old_name)
if old_name in self._object_handles:
self._object_handles.pop(old_name)
lua_code = "simSetObjectName({}, '{}')".format(h, new_name)
self._inject_lua_code... | [
"def",
"change_object_name",
"(",
"self",
",",
"old_name",
",",
"new_name",
")",
":",
"h",
"=",
"self",
".",
"_get_object_handle",
"(",
"old_name",
")",
"if",
"old_name",
"in",
"self",
".",
"_object_handles",
":",
"self",
".",
"_object_handles",
".",
"pop",
... | Change object name | [
"Change",
"object",
"name"
] | python | train |
bwohlberg/sporco | sporco/dictlrn/cbpdndl.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/dictlrn/cbpdndl.py#L140-L154 | def ConvCnstrMODOptionsDefaults(method='fista'):
"""Get defaults dict for the ConvCnstrMOD class specified by the
``method`` parameter.
"""
dflt = copy.deepcopy(ccmod_class_label_lookup(method).Options.defaults)
if method == 'fista':
dflt.update({'MaxMainIter': 1, 'BackTrack':
... | [
"def",
"ConvCnstrMODOptionsDefaults",
"(",
"method",
"=",
"'fista'",
")",
":",
"dflt",
"=",
"copy",
".",
"deepcopy",
"(",
"ccmod_class_label_lookup",
"(",
"method",
")",
".",
"Options",
".",
"defaults",
")",
"if",
"method",
"==",
"'fista'",
":",
"dflt",
".",... | Get defaults dict for the ConvCnstrMOD class specified by the
``method`` parameter. | [
"Get",
"defaults",
"dict",
"for",
"the",
"ConvCnstrMOD",
"class",
"specified",
"by",
"the",
"method",
"parameter",
"."
] | python | train |
ABI-Software/MeshParser | src/meshparser/base/parser.py | https://github.com/ABI-Software/MeshParser/blob/08dc0ce7c44d0149b443261ff6d3708e28a928e7/src/meshparser/base/parser.py#L41-L69 | def getElements(self, zero_based=True, pared=False):
"""
Get the elements of the mesh as a list of point index list.
:param zero_based: use zero based index of points if true otherwise use 1-based index of points.
:param pared: use the pared down list of points
:return: A list of... | [
"def",
"getElements",
"(",
"self",
",",
"zero_based",
"=",
"True",
",",
"pared",
"=",
"False",
")",
":",
"points",
"=",
"self",
".",
"_points",
"[",
":",
"]",
"elements",
"=",
"self",
".",
"_elements",
"[",
":",
"]",
"offset",
"=",
"0",
"if",
"not"... | Get the elements of the mesh as a list of point index list.
:param zero_based: use zero based index of points if true otherwise use 1-based index of points.
:param pared: use the pared down list of points
:return: A list of point index lists | [
"Get",
"the",
"elements",
"of",
"the",
"mesh",
"as",
"a",
"list",
"of",
"point",
"index",
"list",
".",
":",
"param",
"zero_based",
":",
"use",
"zero",
"based",
"index",
"of",
"points",
"if",
"true",
"otherwise",
"use",
"1",
"-",
"based",
"index",
"of",... | python | train |
vertexproject/synapse | synapse/lib/dyndeps.py | https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/dyndeps.py#L40-L50 | def getDynMeth(name):
'''
Retrieve and return an unbound method by python path.
'''
cname, fname = name.rsplit('.', 1)
clas = getDynLocal(cname)
if clas is None:
return None
return getattr(clas, fname, None) | [
"def",
"getDynMeth",
"(",
"name",
")",
":",
"cname",
",",
"fname",
"=",
"name",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"clas",
"=",
"getDynLocal",
"(",
"cname",
")",
"if",
"clas",
"is",
"None",
":",
"return",
"None",
"return",
"getattr",
"(",
"c... | Retrieve and return an unbound method by python path. | [
"Retrieve",
"and",
"return",
"an",
"unbound",
"method",
"by",
"python",
"path",
"."
] | python | train |
crytic/slither | slither/printers/summary/function.py | https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/printers/summary/function.py#L24-L64 | def output(self, _filename):
"""
_filename is not used
Args:
_filename(string)
"""
for c in self.contracts:
(name, inheritance, var, func_summaries, modif_summaries) = c.get_summary()
txt = "\nContract %s"%name
txt += '... | [
"def",
"output",
"(",
"self",
",",
"_filename",
")",
":",
"for",
"c",
"in",
"self",
".",
"contracts",
":",
"(",
"name",
",",
"inheritance",
",",
"var",
",",
"func_summaries",
",",
"modif_summaries",
")",
"=",
"c",
".",
"get_summary",
"(",
")",
"txt",
... | _filename is not used
Args:
_filename(string) | [
"_filename",
"is",
"not",
"used",
"Args",
":",
"_filename",
"(",
"string",
")"
] | python | train |
svinota/mdns | mdns/zeroconf.py | https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L751-L758 | def read_string(self, len):
"""Reads a string of a given length from the packet"""
format = '!' + str(len) + 's'
length = struct.calcsize(format)
info = struct.unpack(format,
self.data[self.offset:self.offset + length])
self.offset += length
return info[0] | [
"def",
"read_string",
"(",
"self",
",",
"len",
")",
":",
"format",
"=",
"'!'",
"+",
"str",
"(",
"len",
")",
"+",
"'s'",
"length",
"=",
"struct",
".",
"calcsize",
"(",
"format",
")",
"info",
"=",
"struct",
".",
"unpack",
"(",
"format",
",",
"self",
... | Reads a string of a given length from the packet | [
"Reads",
"a",
"string",
"of",
"a",
"given",
"length",
"from",
"the",
"packet"
] | python | train |
chemlab/chemlab | chemlab/io/datafile.py | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/io/datafile.py#L102-L140 | def datafile(filename, mode="rb", format=None):
"""Initialize the appropriate
:py:class:`~chemlab.io.iohandler.IOHandler` for a given file
extension or file format.
The *datafile* function can be conveniently used to quickly read
or write data in a certain format::
>>> handler = datafile("... | [
"def",
"datafile",
"(",
"filename",
",",
"mode",
"=",
"\"rb\"",
",",
"format",
"=",
"None",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"filename",
")",
"base",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"fi... | Initialize the appropriate
:py:class:`~chemlab.io.iohandler.IOHandler` for a given file
extension or file format.
The *datafile* function can be conveniently used to quickly read
or write data in a certain format::
>>> handler = datafile("molecule.pdb")
>>> mol = handler.read("molecule... | [
"Initialize",
"the",
"appropriate",
":",
"py",
":",
"class",
":",
"~chemlab",
".",
"io",
".",
"iohandler",
".",
"IOHandler",
"for",
"a",
"given",
"file",
"extension",
"or",
"file",
"format",
"."
] | python | train |
waqasbhatti/astrobase | astrobase/services/simbad.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/services/simbad.py#L105-L857 | def tap_query(querystr,
simbad_mirror='simbad',
returnformat='csv',
forcefetch=False,
cachedir='~/.astrobase/simbad-cache',
verbose=True,
timeout=10.0,
refresh=2.0,
maxtimeout=90.0,
maxtries=3,
... | [
"def",
"tap_query",
"(",
"querystr",
",",
"simbad_mirror",
"=",
"'simbad'",
",",
"returnformat",
"=",
"'csv'",
",",
"forcefetch",
"=",
"False",
",",
"cachedir",
"=",
"'~/.astrobase/simbad-cache'",
",",
"verbose",
"=",
"True",
",",
"timeout",
"=",
"10.0",
",",
... | This queries the SIMBAD TAP service using the ADQL query string provided.
Parameters
----------
querystr : str
This is the ADQL query string. See:
http://www.ivoa.net/documents/ADQL/2.0 for the specification.
simbad_mirror : str
This is the key used to select a SIMBAD mirror f... | [
"This",
"queries",
"the",
"SIMBAD",
"TAP",
"service",
"using",
"the",
"ADQL",
"query",
"string",
"provided",
"."
] | python | valid |
rstoneback/pysat | pysat/instruments/omni_hro.py | https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/instruments/omni_hro.py#L141-L186 | def time_shift_to_magnetic_poles(inst):
""" OMNI data is time-shifted to bow shock. Time shifted again
to intersections with magnetic pole.
Parameters
-----------
inst : Instrument class object
Instrument with OMNI HRO data
Notes
---------
Time shift calculated using distance t... | [
"def",
"time_shift_to_magnetic_poles",
"(",
"inst",
")",
":",
"# need to fill in Vx to get an estimate of what is going on",
"inst",
"[",
"'Vx'",
"]",
"=",
"inst",
"[",
"'Vx'",
"]",
".",
"interpolate",
"(",
"'nearest'",
")",
"inst",
"[",
"'Vx'",
"]",
"=",
"inst",
... | OMNI data is time-shifted to bow shock. Time shifted again
to intersections with magnetic pole.
Parameters
-----------
inst : Instrument class object
Instrument with OMNI HRO data
Notes
---------
Time shift calculated using distance to bow shock nose (BSN)
and velocity of solar... | [
"OMNI",
"data",
"is",
"time",
"-",
"shifted",
"to",
"bow",
"shock",
".",
"Time",
"shifted",
"again",
"to",
"intersections",
"with",
"magnetic",
"pole",
"."
] | python | train |
bykof/billomapy | billomapy/billomapy.py | https://github.com/bykof/billomapy/blob/a28ba69fd37654fa145d0411d52c200e7f8984ab/billomapy/billomapy.py#L2744-L2757 | def get_all_payments_of_credit_note(self, credit_note_id):
"""
Get all payments of credit note
This will iterate over all pages until it gets all elements.
So if the rate limit exceeded it will throw an Exception and you will get nothing
:param credit_note_id: the credit note id... | [
"def",
"get_all_payments_of_credit_note",
"(",
"self",
",",
"credit_note_id",
")",
":",
"return",
"self",
".",
"_iterate_through_pages",
"(",
"get_function",
"=",
"self",
".",
"get_payments_of_credit_note_per_page",
",",
"resource",
"=",
"CREDIT_NOTE_PAYMENTS",
",",
"*"... | Get all payments of credit note
This will iterate over all pages until it gets all elements.
So if the rate limit exceeded it will throw an Exception and you will get nothing
:param credit_note_id: the credit note id
:return: list | [
"Get",
"all",
"payments",
"of",
"credit",
"note",
"This",
"will",
"iterate",
"over",
"all",
"pages",
"until",
"it",
"gets",
"all",
"elements",
".",
"So",
"if",
"the",
"rate",
"limit",
"exceeded",
"it",
"will",
"throw",
"an",
"Exception",
"and",
"you",
"w... | python | train |
CalebBell/thermo | thermo/phase_change.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/phase_change.py#L500-L570 | def MK(T, Tc, omega):
r'''Calculates enthalpy of vaporization at arbitrary temperatures using a
the work of [1]_; requires a chemical's critical temperature and
acentric factor.
The enthalpy of vaporization is given by:
.. math::
\Delta H_{vap} = \Delta H_{vap}^{(0)} + \omega \Delta H_{va... | [
"def",
"MK",
"(",
"T",
",",
"Tc",
",",
"omega",
")",
":",
"bs",
"=",
"[",
"[",
"5.2804",
",",
"0.080022",
",",
"7.2543",
"]",
",",
"[",
"12.8650",
",",
"273.23",
",",
"-",
"346.45",
"]",
",",
"[",
"1.1710",
",",
"465.08",
",",
"-",
"610.48",
... | r'''Calculates enthalpy of vaporization at arbitrary temperatures using a
the work of [1]_; requires a chemical's critical temperature and
acentric factor.
The enthalpy of vaporization is given by:
.. math::
\Delta H_{vap} = \Delta H_{vap}^{(0)} + \omega \Delta H_{vap}^{(1)} + \omega^2 \Delta... | [
"r",
"Calculates",
"enthalpy",
"of",
"vaporization",
"at",
"arbitrary",
"temperatures",
"using",
"a",
"the",
"work",
"of",
"[",
"1",
"]",
"_",
";",
"requires",
"a",
"chemical",
"s",
"critical",
"temperature",
"and",
"acentric",
"factor",
"."
] | python | valid |
ManiacalLabs/BiblioPixel | bibliopixel/control/routing.py | https://github.com/ManiacalLabs/BiblioPixel/blob/fd97e6c651a4bbcade64733847f4eec8f7704b7c/bibliopixel/control/routing.py#L53-L70 | def receive(self, msg):
"""
Returns a (receiver, msg) pair, where receiver is `None` if no route for
the message was found, or otherwise an object with a `receive` method
that can accept that `msg`.
"""
x = self.routing
while not isinstance(x, ActionList):
... | [
"def",
"receive",
"(",
"self",
",",
"msg",
")",
":",
"x",
"=",
"self",
".",
"routing",
"while",
"not",
"isinstance",
"(",
"x",
",",
"ActionList",
")",
":",
"if",
"not",
"x",
"or",
"not",
"msg",
":",
"return",
"None",
",",
"msg",
"if",
"not",
"isi... | Returns a (receiver, msg) pair, where receiver is `None` if no route for
the message was found, or otherwise an object with a `receive` method
that can accept that `msg`. | [
"Returns",
"a",
"(",
"receiver",
"msg",
")",
"pair",
"where",
"receiver",
"is",
"None",
"if",
"no",
"route",
"for",
"the",
"message",
"was",
"found",
"or",
"otherwise",
"an",
"object",
"with",
"a",
"receive",
"method",
"that",
"can",
"accept",
"that",
"m... | python | valid |
klorenz/python-argdeco | argdeco/config.py | https://github.com/klorenz/python-argdeco/blob/8d01acef8c19d6883873689d017b14857876412d/argdeco/config.py#L134-L163 | def update(self, E=None, **F):
'''flatten nested dictionaries to update pathwise
>>> Config({'foo': {'bar': 'glork'}}).update({'foo': {'blub': 'bla'}})
{'foo': {'bar': 'glork', 'blub': 'bla'}
In contrast to:
>>> {'foo': {'bar': 'glork'}}.update({'foo': {'blub': 'bla'}})
... | [
"def",
"update",
"(",
"self",
",",
"E",
"=",
"None",
",",
"*",
"*",
"F",
")",
":",
"def",
"_update",
"(",
"D",
")",
":",
"for",
"k",
",",
"v",
"in",
"D",
".",
"items",
"(",
")",
":",
"if",
"super",
"(",
"ConfigDict",
",",
"self",
")",
".",
... | flatten nested dictionaries to update pathwise
>>> Config({'foo': {'bar': 'glork'}}).update({'foo': {'blub': 'bla'}})
{'foo': {'bar': 'glork', 'blub': 'bla'}
In contrast to:
>>> {'foo': {'bar': 'glork'}}.update({'foo': {'blub': 'bla'}})
{'foo: {'blub': 'bla'}'} | [
"flatten",
"nested",
"dictionaries",
"to",
"update",
"pathwise"
] | python | train |
willkg/markus | markus/backends/logging.py | https://github.com/willkg/markus/blob/0cfbe67fb7ccfa7488b0120d21ddc0cdc1f8ed33/markus/backends/logging.py#L219-L224 | def gauge(self, stat, value, tags=None):
"""Set a gauge."""
self.rollup()
# FIXME(willkg): what to do with tags?
self.gauge_stats.setdefault(stat, []).append(value) | [
"def",
"gauge",
"(",
"self",
",",
"stat",
",",
"value",
",",
"tags",
"=",
"None",
")",
":",
"self",
".",
"rollup",
"(",
")",
"# FIXME(willkg): what to do with tags?",
"self",
".",
"gauge_stats",
".",
"setdefault",
"(",
"stat",
",",
"[",
"]",
")",
".",
... | Set a gauge. | [
"Set",
"a",
"gauge",
"."
] | python | test |
azraq27/neural | neural/stats.py | https://github.com/azraq27/neural/blob/fe91bfeecbf73ad99708cf5dca66cb61fcd529f5/neural/stats.py#L62-L66 | def mask_average(dset,mask):
'''Returns average of voxels in ``dset`` within non-zero voxels of ``mask``'''
o = nl.run(['3dmaskave','-q','-mask',mask,dset])
if o:
return float(o.output.split()[-1]) | [
"def",
"mask_average",
"(",
"dset",
",",
"mask",
")",
":",
"o",
"=",
"nl",
".",
"run",
"(",
"[",
"'3dmaskave'",
",",
"'-q'",
",",
"'-mask'",
",",
"mask",
",",
"dset",
"]",
")",
"if",
"o",
":",
"return",
"float",
"(",
"o",
".",
"output",
".",
"s... | Returns average of voxels in ``dset`` within non-zero voxels of ``mask`` | [
"Returns",
"average",
"of",
"voxels",
"in",
"dset",
"within",
"non",
"-",
"zero",
"voxels",
"of",
"mask"
] | python | train |
maxpumperla/elephas | elephas/utils/sockets.py | https://github.com/maxpumperla/elephas/blob/84605acdc9564673c487637dcb27f5def128bcc7/elephas/utils/sockets.py#L58-L71 | def send(socket, data, num_bytes=20):
"""Send data to specified socket.
:param socket: open socket instance
:param data: data to send
:param num_bytes: number of bytes to read
:return: received data
"""
pickled_data = pickle.dumps(data, -1)
length = str(len(pickled_data)).zfill(num_by... | [
"def",
"send",
"(",
"socket",
",",
"data",
",",
"num_bytes",
"=",
"20",
")",
":",
"pickled_data",
"=",
"pickle",
".",
"dumps",
"(",
"data",
",",
"-",
"1",
")",
"length",
"=",
"str",
"(",
"len",
"(",
"pickled_data",
")",
")",
".",
"zfill",
"(",
"n... | Send data to specified socket.
:param socket: open socket instance
:param data: data to send
:param num_bytes: number of bytes to read
:return: received data | [
"Send",
"data",
"to",
"specified",
"socket",
"."
] | python | train |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/network/vnic/vnic_service.py | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/network/vnic/vnic_service.py#L270-L278 | def map_vnics(vm):
"""
maps the vnic on the vm by name
:param vm: virtual machine
:return: dictionary: {'vnic_name': vnic}
"""
return {device.deviceInfo.label: device
for device in vm.config.hardware.device
if isinstance(device, vim.vm.devi... | [
"def",
"map_vnics",
"(",
"vm",
")",
":",
"return",
"{",
"device",
".",
"deviceInfo",
".",
"label",
":",
"device",
"for",
"device",
"in",
"vm",
".",
"config",
".",
"hardware",
".",
"device",
"if",
"isinstance",
"(",
"device",
",",
"vim",
".",
"vm",
".... | maps the vnic on the vm by name
:param vm: virtual machine
:return: dictionary: {'vnic_name': vnic} | [
"maps",
"the",
"vnic",
"on",
"the",
"vm",
"by",
"name",
":",
"param",
"vm",
":",
"virtual",
"machine",
":",
"return",
":",
"dictionary",
":",
"{",
"vnic_name",
":",
"vnic",
"}"
] | python | train |
Dallinger/Dallinger | dallinger/models.py | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/models.py#L1022-L1038 | def transformations(self, type=None, failed=False):
"""
Get Transformations done by this Node.
type must be a type of Transformation (defaults to Transformation)
Failed can be True, False or "all"
"""
if failed not in ["all", False, True]:
raise ValueError("{... | [
"def",
"transformations",
"(",
"self",
",",
"type",
"=",
"None",
",",
"failed",
"=",
"False",
")",
":",
"if",
"failed",
"not",
"in",
"[",
"\"all\"",
",",
"False",
",",
"True",
"]",
":",
"raise",
"ValueError",
"(",
"\"{} is not a valid transmission failed\"",... | Get Transformations done by this Node.
type must be a type of Transformation (defaults to Transformation)
Failed can be True, False or "all" | [
"Get",
"Transformations",
"done",
"by",
"this",
"Node",
"."
] | python | train |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10541-L10560 | def camera_feedback_send(self, time_usec, target_system, cam_idx, img_idx, lat, lng, alt_msl, alt_rel, roll, pitch, yaw, foc_len, flags, force_mavlink1=False):
'''
Camera Capture Feedback
time_usec : Image timestamp (microseconds since UNIX epoch), as pas... | [
"def",
"camera_feedback_send",
"(",
"self",
",",
"time_usec",
",",
"target_system",
",",
"cam_idx",
",",
"img_idx",
",",
"lat",
",",
"lng",
",",
"alt_msl",
",",
"alt_rel",
",",
"roll",
",",
"pitch",
",",
"yaw",
",",
"foc_len",
",",
"flags",
",",
"force_m... | Camera Capture Feedback
time_usec : Image timestamp (microseconds since UNIX epoch), as passed in by CAMERA_STATUS message (or autopilot if no CCB) (uint64_t)
target_system : System ID (uint8_t)
cam_idx : Camera ID (uint8_t)
... | [
"Camera",
"Capture",
"Feedback"
] | python | train |
saltstack/salt | salt/fileserver/svnfs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/svnfs.py#L591-L635 | def find_file(path, tgt_env='base', **kwargs): # pylint: disable=W0613
'''
Find the first file to match the path and ref. This operates similarly to
the roots file sever but with assumptions of the directory structure
based on svn standard practices.
'''
fnd = {'path': '',
'rel': ''}... | [
"def",
"find_file",
"(",
"path",
",",
"tgt_env",
"=",
"'base'",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=W0613",
"fnd",
"=",
"{",
"'path'",
":",
"''",
",",
"'rel'",
":",
"''",
"}",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"path",
")... | Find the first file to match the path and ref. This operates similarly to
the roots file sever but with assumptions of the directory structure
based on svn standard practices. | [
"Find",
"the",
"first",
"file",
"to",
"match",
"the",
"path",
"and",
"ref",
".",
"This",
"operates",
"similarly",
"to",
"the",
"roots",
"file",
"sever",
"but",
"with",
"assumptions",
"of",
"the",
"directory",
"structure",
"based",
"on",
"svn",
"standard",
... | python | train |
linnarsson-lab/loompy | loompy/loompy.py | https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loompy.py#L708-L762 | def batch_scan_layers(self, cells: np.ndarray = None, genes: np.ndarray = None, axis: int = 0, batch_size: int = 1000, layers: Iterable = None) -> Iterable[Tuple[int, np.ndarray, Dict]]:
"""
**DEPRECATED** - Use `scan` instead
"""
deprecated("'batch_scan_layers' is deprecated. Use 'scan' instead")
if cells is... | [
"def",
"batch_scan_layers",
"(",
"self",
",",
"cells",
":",
"np",
".",
"ndarray",
"=",
"None",
",",
"genes",
":",
"np",
".",
"ndarray",
"=",
"None",
",",
"axis",
":",
"int",
"=",
"0",
",",
"batch_size",
":",
"int",
"=",
"1000",
",",
"layers",
":",
... | **DEPRECATED** - Use `scan` instead | [
"**",
"DEPRECATED",
"**",
"-",
"Use",
"scan",
"instead"
] | python | train |
peri-source/peri | peri/opt/optimize.py | https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L735-L777 | def _run1(self):
"""workhorse for do_run_1"""
if self.check_update_J():
self.update_J()
else:
if self.check_Broyden_J():
self.update_Broyden_J()
if self.check_update_eig_J():
self.update_eig_J()
#1. Assuming that J star... | [
"def",
"_run1",
"(",
"self",
")",
":",
"if",
"self",
".",
"check_update_J",
"(",
")",
":",
"self",
".",
"update_J",
"(",
")",
"else",
":",
"if",
"self",
".",
"check_Broyden_J",
"(",
")",
":",
"self",
".",
"update_Broyden_J",
"(",
")",
"if",
"self",
... | workhorse for do_run_1 | [
"workhorse",
"for",
"do_run_1"
] | python | valid |
jobovy/galpy | galpy/potential/Potential.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/Potential.py#L2678-L2681 | def _rlfunc(rl,lz,pot):
"""Function that gives rvc-lz"""
thisvcirc= vcirc(pot,rl,use_physical=False)
return rl*thisvcirc-lz | [
"def",
"_rlfunc",
"(",
"rl",
",",
"lz",
",",
"pot",
")",
":",
"thisvcirc",
"=",
"vcirc",
"(",
"pot",
",",
"rl",
",",
"use_physical",
"=",
"False",
")",
"return",
"rl",
"*",
"thisvcirc",
"-",
"lz"
] | Function that gives rvc-lz | [
"Function",
"that",
"gives",
"rvc",
"-",
"lz"
] | python | train |
SpriteLink/NIPAP | pynipap/pynipap.py | https://github.com/SpriteLink/NIPAP/blob/f96069f11ab952d80b13cab06e0528f2d24b3de9/pynipap/pynipap.py#L1145-L1256 | def save(self, args=None):
""" Save prefix to NIPAP.
If the object represents a new prefix unknown to NIPAP (attribute
`id` is `None`) this function maps to the function
:py:func:`nipap.backend.Nipap.add_prefix` in the backend, used to
create a new prefix. Otherw... | [
"def",
"save",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"{",
"}",
"xmlrpc",
"=",
"XMLRPCConnection",
"(",
")",
"data",
"=",
"{",
"'description'",
":",
"self",
".",
"description",
",",
"'comment'",... | Save prefix to NIPAP.
If the object represents a new prefix unknown to NIPAP (attribute
`id` is `None`) this function maps to the function
:py:func:`nipap.backend.Nipap.add_prefix` in the backend, used to
create a new prefix. Otherwise it maps to the function
... | [
"Save",
"prefix",
"to",
"NIPAP",
"."
] | python | train |
codelv/enaml-native | src/enamlnative/android/android_list_view.py | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_list_view.py#L201-L208 | def get_declared_items(self):
""" Override to do it manually
"""
for k, v in super(AndroidListView, self).get_declared_items():
if k == 'layout':
yield k, v
break | [
"def",
"get_declared_items",
"(",
"self",
")",
":",
"for",
"k",
",",
"v",
"in",
"super",
"(",
"AndroidListView",
",",
"self",
")",
".",
"get_declared_items",
"(",
")",
":",
"if",
"k",
"==",
"'layout'",
":",
"yield",
"k",
",",
"v",
"break"
] | Override to do it manually | [
"Override",
"to",
"do",
"it",
"manually"
] | python | train |
saltstack/salt | salt/fileclient.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L960-L989 | def hash_and_stat_file(self, path, saltenv='base'):
'''
Return the hash of a file, to get the hash of a file in the pillar_roots
prepend the path with salt://<file on server> otherwise, prepend the
file with / for a local file.
Additionally, return the stat result of the file, o... | [
"def",
"hash_and_stat_file",
"(",
"self",
",",
"path",
",",
"saltenv",
"=",
"'base'",
")",
":",
"ret",
"=",
"{",
"}",
"fnd",
"=",
"self",
".",
"__get_file_path",
"(",
"path",
",",
"saltenv",
")",
"if",
"fnd",
"is",
"None",
":",
"return",
"ret",
",",
... | Return the hash of a file, to get the hash of a file in the pillar_roots
prepend the path with salt://<file on server> otherwise, prepend the
file with / for a local file.
Additionally, return the stat result of the file, or None if no stat
results were found. | [
"Return",
"the",
"hash",
"of",
"a",
"file",
"to",
"get",
"the",
"hash",
"of",
"a",
"file",
"in",
"the",
"pillar_roots",
"prepend",
"the",
"path",
"with",
"salt",
":",
"//",
"<file",
"on",
"server",
">",
"otherwise",
"prepend",
"the",
"file",
"with",
"/... | python | train |
aws/sagemaker-python-sdk | src/sagemaker/local/utils.py | https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/utils.py#L22-L40 | def copy_directory_structure(destination_directory, relative_path):
"""Create all the intermediate directories required for relative_path to exist within destination_directory.
This assumes that relative_path is a directory located within root_dir.
Examples:
destination_directory: /tmp/destination
... | [
"def",
"copy_directory_structure",
"(",
"destination_directory",
",",
"relative_path",
")",
":",
"full_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"destination_directory",
",",
"relative_path",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"full_path",
... | Create all the intermediate directories required for relative_path to exist within destination_directory.
This assumes that relative_path is a directory located within root_dir.
Examples:
destination_directory: /tmp/destination
relative_path: test/unit/
will create: /tmp/destination/t... | [
"Create",
"all",
"the",
"intermediate",
"directories",
"required",
"for",
"relative_path",
"to",
"exist",
"within",
"destination_directory",
".",
"This",
"assumes",
"that",
"relative_path",
"is",
"a",
"directory",
"located",
"within",
"root_dir",
"."
] | python | train |
biolink/ontobio | ontobio/config.py | https://github.com/biolink/ontobio/blob/4e512a7831cfe6bc1b32f2c3be2ba41bc5cf7345/ontobio/config.py#L195-L212 | def get_config():
"""
Return configuration for current session.
When called for the first time, this will create a config object, using
whatever is the default load path to find the config yaml
"""
if session.config is None:
path = session.default_config_path
if os.path.isfile(p... | [
"def",
"get_config",
"(",
")",
":",
"if",
"session",
".",
"config",
"is",
"None",
":",
"path",
"=",
"session",
".",
"default_config_path",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"logging",
".",
"info",
"(",
"\"LOADING FROM: {}\"",... | Return configuration for current session.
When called for the first time, this will create a config object, using
whatever is the default load path to find the config yaml | [
"Return",
"configuration",
"for",
"current",
"session",
"."
] | python | train |
TheRealLink/pylgtv | pylgtv/webos_client.py | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L283-L286 | def get_inputs(self):
"""Get all inputs."""
self.request(EP_GET_INPUTS)
return {} if self.last_response is None else self.last_response.get('payload').get('devices') | [
"def",
"get_inputs",
"(",
"self",
")",
":",
"self",
".",
"request",
"(",
"EP_GET_INPUTS",
")",
"return",
"{",
"}",
"if",
"self",
".",
"last_response",
"is",
"None",
"else",
"self",
".",
"last_response",
".",
"get",
"(",
"'payload'",
")",
".",
"get",
"(... | Get all inputs. | [
"Get",
"all",
"inputs",
"."
] | python | train |
swisscom/cleanerversion | versions/fields.py | https://github.com/swisscom/cleanerversion/blob/becadbab5d7b474a0e9a596b99e97682402d2f2c/versions/fields.py#L345-L368 | def _set_child_joined_alias_using_join_map(child, join_map, alias_map):
"""
Set the joined alias on the child, for Django <= 1.7.x.
:param child:
:param join_map:
:param alias_map:
"""
for lhs, table, join_cols in join_map:
if lhs is None:
... | [
"def",
"_set_child_joined_alias_using_join_map",
"(",
"child",
",",
"join_map",
",",
"alias_map",
")",
":",
"for",
"lhs",
",",
"table",
",",
"join_cols",
"in",
"join_map",
":",
"if",
"lhs",
"is",
"None",
":",
"continue",
"if",
"lhs",
"==",
"child",
".",
"a... | Set the joined alias on the child, for Django <= 1.7.x.
:param child:
:param join_map:
:param alias_map: | [
"Set",
"the",
"joined",
"alias",
"on",
"the",
"child",
"for",
"Django",
"<",
"=",
"1",
".",
"7",
".",
"x",
".",
":",
"param",
"child",
":",
":",
"param",
"join_map",
":",
":",
"param",
"alias_map",
":"
] | python | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/graphs/layouts/circular.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/graphs/layouts/circular.py#L16-L49 | def circular(adjacency_mat, directed=False):
"""Places all nodes on a single circle.
Parameters
----------
adjacency_mat : matrix or sparse
The graph adjacency matrix
directed : bool
Whether the graph is directed. If this is True, is will also
generate the vertices for arrow... | [
"def",
"circular",
"(",
"adjacency_mat",
",",
"directed",
"=",
"False",
")",
":",
"if",
"issparse",
"(",
"adjacency_mat",
")",
":",
"adjacency_mat",
"=",
"adjacency_mat",
".",
"tocoo",
"(",
")",
"num_nodes",
"=",
"adjacency_mat",
".",
"shape",
"[",
"0",
"]... | Places all nodes on a single circle.
Parameters
----------
adjacency_mat : matrix or sparse
The graph adjacency matrix
directed : bool
Whether the graph is directed. If this is True, is will also
generate the vertices for arrows, which can be passed to an
ArrowVisual.
... | [
"Places",
"all",
"nodes",
"on",
"a",
"single",
"circle",
"."
] | python | train |
onnx/onnxmltools | onnxmltools/convert/libsvm/convert.py | https://github.com/onnx/onnxmltools/blob/d4e4c31990fc2d9fd1f92139f497d360914c9df2/onnxmltools/convert/libsvm/convert.py#L17-L48 | def convert(model, name=None, initial_types=None, doc_string='', target_opset=None,
targeted_onnx=onnx.__version__, custom_conversion_functions=None, custom_shape_calculators=None):
"""
:param model: a libsvm model
:param initial_types: a python list. Each element is a tuple of a variable name a... | [
"def",
"convert",
"(",
"model",
",",
"name",
"=",
"None",
",",
"initial_types",
"=",
"None",
",",
"doc_string",
"=",
"''",
",",
"target_opset",
"=",
"None",
",",
"targeted_onnx",
"=",
"onnx",
".",
"__version__",
",",
"custom_conversion_functions",
"=",
"None... | :param model: a libsvm model
:param initial_types: a python list. Each element is a tuple of a variable name and a type defined in data_types.py
:param name: The name of the graph (type: GraphProto) in the produced ONNX model (type: ModelProto)
:param doc_string: A string attached onto the produced ONNX mod... | [
":",
"param",
"model",
":",
"a",
"libsvm",
"model",
":",
"param",
"initial_types",
":",
"a",
"python",
"list",
".",
"Each",
"element",
"is",
"a",
"tuple",
"of",
"a",
"variable",
"name",
"and",
"a",
"type",
"defined",
"in",
"data_types",
".",
"py",
":",... | python | train |
facetoe/zenpy | zenpy/lib/api.py | https://github.com/facetoe/zenpy/blob/34c54c7e408b9ed01604ddf8b3422204c8bf31ea/zenpy/lib/api.py#L1756-L1762 | def comments(self, article):
"""
Retrieve comments for an article
:param article: Article ID or object
"""
return self._query_zendesk(self.endpoint.comments, object_type='comment', id=article) | [
"def",
"comments",
"(",
"self",
",",
"article",
")",
":",
"return",
"self",
".",
"_query_zendesk",
"(",
"self",
".",
"endpoint",
".",
"comments",
",",
"object_type",
"=",
"'comment'",
",",
"id",
"=",
"article",
")"
] | Retrieve comments for an article
:param article: Article ID or object | [
"Retrieve",
"comments",
"for",
"an",
"article"
] | python | train |
balloob/pychromecast | pychromecast/socket_client.py | https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/socket_client.py#L95-L101 | def _message_to_string(message, data=None):
""" Gives a string representation of a PB2 message. """
if data is None:
data = _json_from_message(message)
return "Message {} from {} to {}: {}".format(
message.namespace, message.source_id, message.destination_id, data) | [
"def",
"_message_to_string",
"(",
"message",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"_json_from_message",
"(",
"message",
")",
"return",
"\"Message {} from {} to {}: {}\"",
".",
"format",
"(",
"message",
".",
"namespa... | Gives a string representation of a PB2 message. | [
"Gives",
"a",
"string",
"representation",
"of",
"a",
"PB2",
"message",
"."
] | python | train |
NoneGG/aredis | aredis/sentinel.py | https://github.com/NoneGG/aredis/blob/204caad740ac13e5760d46444a2ba7632982a046/aredis/sentinel.py#L276-L299 | def slave_for(self, service_name, redis_class=StrictRedis,
connection_pool_class=SentinelConnectionPool, **kwargs):
"""
Returns redis client instance for the ``service_name`` slave(s).
A SentinelConnectionPool class is used to retrive the slave's
address before establi... | [
"def",
"slave_for",
"(",
"self",
",",
"service_name",
",",
"redis_class",
"=",
"StrictRedis",
",",
"connection_pool_class",
"=",
"SentinelConnectionPool",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'is_master'",
"]",
"=",
"False",
"connection_kwargs",
"=... | Returns redis client instance for the ``service_name`` slave(s).
A SentinelConnectionPool class is used to retrive the slave's
address before establishing a new connection.
By default clients will be a redis.StrictRedis instance. Specify a
different class to the ``redis_class`` argumen... | [
"Returns",
"redis",
"client",
"instance",
"for",
"the",
"service_name",
"slave",
"(",
"s",
")",
"."
] | python | train |
google/grr | grr/server/grr_response_server/databases/mysql_flows.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_flows.py#L49-L66 | def ReadMessageHandlerRequests(self, cursor=None):
"""Reads all message handler requests from the database."""
query = ("SELECT UNIX_TIMESTAMP(timestamp), request,"
" UNIX_TIMESTAMP(leased_until), leased_by "
"FROM message_handler_requests "
"ORDER BY timestamp DESC... | [
"def",
"ReadMessageHandlerRequests",
"(",
"self",
",",
"cursor",
"=",
"None",
")",
":",
"query",
"=",
"(",
"\"SELECT UNIX_TIMESTAMP(timestamp), request,\"",
"\" UNIX_TIMESTAMP(leased_until), leased_by \"",
"\"FROM message_handler_requests \"",
"\"ORDER BY timestamp DESC\"",
"... | Reads all message handler requests from the database. | [
"Reads",
"all",
"message",
"handler",
"requests",
"from",
"the",
"database",
"."
] | python | train |
peri-source/peri | scripts/tutorial.py | https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/scripts/tutorial.py#L82-L88 | def scramble_positions(p, delete_frac=0.1):
"""randomly deletes particles and adds 1-px noise for a realistic
initial featuring guess"""
probs = [1-delete_frac, delete_frac]
m = np.random.choice([True, False], p.shape[0], p=probs)
jumble = np.random.randn(m.sum(), 3)
return p[m] + jumble | [
"def",
"scramble_positions",
"(",
"p",
",",
"delete_frac",
"=",
"0.1",
")",
":",
"probs",
"=",
"[",
"1",
"-",
"delete_frac",
",",
"delete_frac",
"]",
"m",
"=",
"np",
".",
"random",
".",
"choice",
"(",
"[",
"True",
",",
"False",
"]",
",",
"p",
".",
... | randomly deletes particles and adds 1-px noise for a realistic
initial featuring guess | [
"randomly",
"deletes",
"particles",
"and",
"adds",
"1",
"-",
"px",
"noise",
"for",
"a",
"realistic",
"initial",
"featuring",
"guess"
] | python | valid |
ARMmbed/icetea | icetea_lib/CliResponse.py | https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/CliResponse.py#L68-L88 | def verify_message(self, expected_response, break_in_fail=True):
"""
Verifies that expected_response is found in self.lines.
:param expected_response: response or responses to look for. Must be list or str.
:param break_in_fail: If set to True,
re-raises exceptions caught or if ... | [
"def",
"verify_message",
"(",
"self",
",",
"expected_response",
",",
"break_in_fail",
"=",
"True",
")",
":",
"ok",
"=",
"True",
"try",
":",
"ok",
"=",
"verify_message",
"(",
"self",
".",
"lines",
",",
"expected_response",
")",
"except",
"(",
"TypeError",
"... | Verifies that expected_response is found in self.lines.
:param expected_response: response or responses to look for. Must be list or str.
:param break_in_fail: If set to True,
re-raises exceptions caught or if message was not found
:return: True or False
:raises: LookupError if ... | [
"Verifies",
"that",
"expected_response",
"is",
"found",
"in",
"self",
".",
"lines",
"."
] | python | train |
OpenAgInitiative/openag_python | openag/cli/firmware/__init__.py | https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/cli/firmware/__init__.py#L343-L356 | def flash(
categories, param_file, project_dir, plugin, target,
status_update_interval, board
):
"""
Flashes firmware to device (init + run).
Initializes a pio project and runs the result, flashing it to the device.
"""
_init(board, project_dir)
_run(
categories, param_file, proj... | [
"def",
"flash",
"(",
"categories",
",",
"param_file",
",",
"project_dir",
",",
"plugin",
",",
"target",
",",
"status_update_interval",
",",
"board",
")",
":",
"_init",
"(",
"board",
",",
"project_dir",
")",
"_run",
"(",
"categories",
",",
"param_file",
",",
... | Flashes firmware to device (init + run).
Initializes a pio project and runs the result, flashing it to the device. | [
"Flashes",
"firmware",
"to",
"device",
"(",
"init",
"+",
"run",
")",
".",
"Initializes",
"a",
"pio",
"project",
"and",
"runs",
"the",
"result",
"flashing",
"it",
"to",
"the",
"device",
"."
] | python | train |
mbj4668/pyang | pyang/translators/dsdl.py | https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L557-L562 | def dc_element(self, parent, name, text):
"""Add DC element `name` containing `text` to `parent`."""
if self.dc_uri in self.namespaces:
dcel = SchemaNode(self.namespaces[self.dc_uri] + ":" + name,
text=text)
parent.children.insert(0,dcel) | [
"def",
"dc_element",
"(",
"self",
",",
"parent",
",",
"name",
",",
"text",
")",
":",
"if",
"self",
".",
"dc_uri",
"in",
"self",
".",
"namespaces",
":",
"dcel",
"=",
"SchemaNode",
"(",
"self",
".",
"namespaces",
"[",
"self",
".",
"dc_uri",
"]",
"+",
... | Add DC element `name` containing `text` to `parent`. | [
"Add",
"DC",
"element",
"name",
"containing",
"text",
"to",
"parent",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/io/abinit/tasks.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/tasks.py#L1670-L1679 | def wait(self):
"""Wait for child process to terminate. Set and return returncode attribute."""
self._returncode = self.process.wait()
try:
self.process.stderr.close()
except:
pass
self.set_status(self.S_DONE, "status set to Done")
return self._re... | [
"def",
"wait",
"(",
"self",
")",
":",
"self",
".",
"_returncode",
"=",
"self",
".",
"process",
".",
"wait",
"(",
")",
"try",
":",
"self",
".",
"process",
".",
"stderr",
".",
"close",
"(",
")",
"except",
":",
"pass",
"self",
".",
"set_status",
"(",
... | Wait for child process to terminate. Set and return returncode attribute. | [
"Wait",
"for",
"child",
"process",
"to",
"terminate",
".",
"Set",
"and",
"return",
"returncode",
"attribute",
"."
] | python | train |
programa-stic/barf-project | barf/core/smt/smttranslator.py | https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/core/smt/smttranslator.py#L162-L173 | def reset(self):
"""Reset internal state.
"""
self._solver.reset()
# Memory versioning.
self._mem_instance = 0
self._mem_init = smtsymbol.BitVecArray(self._address_size, 8, "MEM_{}".format(self._mem_instance))
self._mem_curr = self.make_array(self._address_size,... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_solver",
".",
"reset",
"(",
")",
"# Memory versioning.",
"self",
".",
"_mem_instance",
"=",
"0",
"self",
".",
"_mem_init",
"=",
"smtsymbol",
".",
"BitVecArray",
"(",
"self",
".",
"_address_size",
",",
... | Reset internal state. | [
"Reset",
"internal",
"state",
"."
] | python | train |
anomaly/prestans | prestans/types/array.py | https://github.com/anomaly/prestans/blob/13f5b2467bfd403dcd2d085f15cbf4644044f105/prestans/types/array.py#L112-L121 | def is_scalar(self):
"""
:return:
:rtype: bool
"""
return \
isinstance(self._element_template, Boolean) or \
isinstance(self._element_template, Float) or \
isinstance(self._element_template, Integer) or \
isinstance(self._element_t... | [
"def",
"is_scalar",
"(",
"self",
")",
":",
"return",
"isinstance",
"(",
"self",
".",
"_element_template",
",",
"Boolean",
")",
"or",
"isinstance",
"(",
"self",
".",
"_element_template",
",",
"Float",
")",
"or",
"isinstance",
"(",
"self",
".",
"_element_templ... | :return:
:rtype: bool | [
":",
"return",
":",
":",
"rtype",
":",
"bool"
] | python | train |
lorien/grab | grab/deprecated.py | https://github.com/lorien/grab/blob/8b301db2a08c830245b61c589e58af6234f4db79/grab/deprecated.py#L230-L236 | def strip_tags(self, content, smart=False):
"""
Strip tags from the HTML content.
"""
from lxml.html import fromstring
return get_node_text(fromstring(content), smart=smart) | [
"def",
"strip_tags",
"(",
"self",
",",
"content",
",",
"smart",
"=",
"False",
")",
":",
"from",
"lxml",
".",
"html",
"import",
"fromstring",
"return",
"get_node_text",
"(",
"fromstring",
"(",
"content",
")",
",",
"smart",
"=",
"smart",
")"
] | Strip tags from the HTML content. | [
"Strip",
"tags",
"from",
"the",
"HTML",
"content",
"."
] | python | train |
raiden-network/raiden | raiden/tasks.py | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/tasks.py#L76-L98 | def check_gas_reserve(raiden):
""" Check periodically for gas reserve in the account """
while True:
has_enough_balance, estimated_required_balance = gas_reserve.has_enough_gas_reserve(
raiden,
channels_to_open=1,
)
estimated_required_balance_eth = Web3.fromWei(es... | [
"def",
"check_gas_reserve",
"(",
"raiden",
")",
":",
"while",
"True",
":",
"has_enough_balance",
",",
"estimated_required_balance",
"=",
"gas_reserve",
".",
"has_enough_gas_reserve",
"(",
"raiden",
",",
"channels_to_open",
"=",
"1",
",",
")",
"estimated_required_balan... | Check periodically for gas reserve in the account | [
"Check",
"periodically",
"for",
"gas",
"reserve",
"in",
"the",
"account"
] | python | train |
pyGrowler/Growler | growler/core/application.py | https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/application.py#L318-L329 | def router(self):
"""
Property returning the router at the top of the middleware
chain's stack (the last item in the list). If the list is empty
OR the item is not an instance of growler.Router, one is created
and added to the middleware chain, matching all requests.
"""
... | [
"def",
"router",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"has_root_router",
":",
"self",
".",
"middleware",
".",
"add",
"(",
"HTTPMethod",
".",
"ALL",
",",
"MiddlewareChain",
".",
"ROOT_PATTERN",
",",
"Router",
"(",
")",
")",
"return",
"self",
... | Property returning the router at the top of the middleware
chain's stack (the last item in the list). If the list is empty
OR the item is not an instance of growler.Router, one is created
and added to the middleware chain, matching all requests. | [
"Property",
"returning",
"the",
"router",
"at",
"the",
"top",
"of",
"the",
"middleware",
"chain",
"s",
"stack",
"(",
"the",
"last",
"item",
"in",
"the",
"list",
")",
".",
"If",
"the",
"list",
"is",
"empty",
"OR",
"the",
"item",
"is",
"not",
"an",
"in... | python | train |
pydata/xarray | xarray/plot/utils.py | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L441-L455 | def _resolve_intervals_2dplot(val, func_name):
"""
Helper function to replace the values of a coordinate array containing
pd.Interval with their mid-points or - for pcolormesh - boundaries which
increases length by 1.
"""
label_extra = ''
if _valid_other_type(val, [pd.Interval]):
if ... | [
"def",
"_resolve_intervals_2dplot",
"(",
"val",
",",
"func_name",
")",
":",
"label_extra",
"=",
"''",
"if",
"_valid_other_type",
"(",
"val",
",",
"[",
"pd",
".",
"Interval",
"]",
")",
":",
"if",
"func_name",
"==",
"'pcolormesh'",
":",
"val",
"=",
"_interva... | Helper function to replace the values of a coordinate array containing
pd.Interval with their mid-points or - for pcolormesh - boundaries which
increases length by 1. | [
"Helper",
"function",
"to",
"replace",
"the",
"values",
"of",
"a",
"coordinate",
"array",
"containing",
"pd",
".",
"Interval",
"with",
"their",
"mid",
"-",
"points",
"or",
"-",
"for",
"pcolormesh",
"-",
"boundaries",
"which",
"increases",
"length",
"by",
"1"... | python | train |
phoebe-project/phoebe2 | phoebe/algorithms/interp_nDgrid.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/algorithms/interp_nDgrid.py#L104-L121 | def cinterpolate(p, axis_values, pixelgrid):
"""
Interpolates in a grid prepared by create_pixeltypegrid().
Does a similar thing as :py:func:`interpolate`, but does everything in C.
p is an array of parameter arrays.
Careful, the shape of input :envvar:`p` and output is the transpose ... | [
"def",
"cinterpolate",
"(",
"p",
",",
"axis_values",
",",
"pixelgrid",
")",
":",
"res",
"=",
"libphoebe",
".",
"interp",
"(",
"p",
",",
"axis_values",
",",
"pixelgrid",
")",
"return",
"res"
] | Interpolates in a grid prepared by create_pixeltypegrid().
Does a similar thing as :py:func:`interpolate`, but does everything in C.
p is an array of parameter arrays.
Careful, the shape of input :envvar:`p` and output is the transpose of
:py:func:`interpolate`.
@param p: Ninterp... | [
"Interpolates",
"in",
"a",
"grid",
"prepared",
"by",
"create_pixeltypegrid",
"()",
".",
"Does",
"a",
"similar",
"thing",
"as",
":",
"py",
":",
"func",
":",
"interpolate",
"but",
"does",
"everything",
"in",
"C",
".",
"p",
"is",
"an",
"array",
"of",
"param... | python | train |
pypa/setuptools | setuptools/command/easy_install.py | https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L1458-L1496 | def expand_paths(inputs):
"""Yield sys.path directories that might contain "old-style" packages"""
seen = {}
for dirname in inputs:
dirname = normalize_path(dirname)
if dirname in seen:
continue
seen[dirname] = 1
if not os.path.isdir(dirname):
conti... | [
"def",
"expand_paths",
"(",
"inputs",
")",
":",
"seen",
"=",
"{",
"}",
"for",
"dirname",
"in",
"inputs",
":",
"dirname",
"=",
"normalize_path",
"(",
"dirname",
")",
"if",
"dirname",
"in",
"seen",
":",
"continue",
"seen",
"[",
"dirname",
"]",
"=",
"1",
... | Yield sys.path directories that might contain "old-style" packages | [
"Yield",
"sys",
".",
"path",
"directories",
"that",
"might",
"contain",
"old",
"-",
"style",
"packages"
] | python | train |
lobeck/flask-bower | flask_bower/__init__.py | https://github.com/lobeck/flask-bower/blob/3ebe08a0931d07e82cb57998db3390d2b5921444/flask_bower/__init__.py#L100-L157 | def build_url(component, filename, **values):
"""
search bower asset and build url
:param component: bower component (package)
:type component: str
:param filename: filename in bower component - can contain directories (like dist/jquery.js)
:type filename: str
:param values: additional url ... | [
"def",
"build_url",
"(",
"component",
",",
"filename",
",",
"*",
"*",
"values",
")",
":",
"root",
"=",
"current_app",
".",
"config",
"[",
"'BOWER_COMPONENTS_ROOT'",
"]",
"bower_data",
"=",
"None",
"package_data",
"=",
"None",
"# check if component exists in bower_... | search bower asset and build url
:param component: bower component (package)
:type component: str
:param filename: filename in bower component - can contain directories (like dist/jquery.js)
:type filename: str
:param values: additional url parameters
:type values: dict[str, str]
:return: u... | [
"search",
"bower",
"asset",
"and",
"build",
"url"
] | python | train |
jobovy/galpy | galpy/potential/SCFPotential.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/SCFPotential.py#L695-L774 | def scf_compute_coeffs(dens, N, L, a=1., radial_order=None, costheta_order=None, phi_order=None):
"""
NAME:
scf_compute_coeffs
PURPOSE:
Numerically compute the expansion coefficients for a given triaxial density
INPUT:
dens - A density functi... | [
"def",
"scf_compute_coeffs",
"(",
"dens",
",",
"N",
",",
"L",
",",
"a",
"=",
"1.",
",",
"radial_order",
"=",
"None",
",",
"costheta_order",
"=",
"None",
",",
"phi_order",
"=",
"None",
")",
":",
"def",
"integrand",
"(",
"xi",
",",
"costheta",
",",
"ph... | NAME:
scf_compute_coeffs
PURPOSE:
Numerically compute the expansion coefficients for a given triaxial density
INPUT:
dens - A density function that takes a parameter R, z and phi
N - size of the Nth dimension of the expansion coefficients
L -... | [
"NAME",
":"
] | python | train |
sebdah/dynamic-dynamodb | dynamic_dynamodb/aws/cloudwatch.py | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/aws/cloudwatch.py#L9-L36 | def __get_connection_cloudwatch():
""" Ensure connection to CloudWatch """
region = get_global_option('region')
try:
if (get_global_option('aws_access_key_id') and
get_global_option('aws_secret_access_key')):
logger.debug(
'Authenticating to CloudWatch usi... | [
"def",
"__get_connection_cloudwatch",
"(",
")",
":",
"region",
"=",
"get_global_option",
"(",
"'region'",
")",
"try",
":",
"if",
"(",
"get_global_option",
"(",
"'aws_access_key_id'",
")",
"and",
"get_global_option",
"(",
"'aws_secret_access_key'",
")",
")",
":",
"... | Ensure connection to CloudWatch | [
"Ensure",
"connection",
"to",
"CloudWatch"
] | python | train |
JarryShaw/PyPCAPKit | src/protocols/transport/transport.py | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/transport.py#L65-L90 | def _import_next_layer(self, proto, length):
"""Import next layer extractor.
Positional arguments:
* proto -- str, next layer protocol name
* length -- int, valid (not padding) length
Returns:
* bool -- flag if extraction of next layer succeeded
... | [
"def",
"_import_next_layer",
"(",
"self",
",",
"proto",
",",
"length",
")",
":",
"if",
"self",
".",
"_exproto",
"==",
"'null'",
"and",
"self",
".",
"_exlayer",
"==",
"'None'",
":",
"from",
"pcapkit",
".",
"protocols",
".",
"raw",
"import",
"Raw",
"as",
... | Import next layer extractor.
Positional arguments:
* proto -- str, next layer protocol name
* length -- int, valid (not padding) length
Returns:
* bool -- flag if extraction of next layer succeeded
* Info -- info of next layer
* ProtoChain --... | [
"Import",
"next",
"layer",
"extractor",
"."
] | python | train |
python-gitlab/python-gitlab | gitlab/v4/objects.py | https://github.com/python-gitlab/python-gitlab/blob/16de1b03fde3dbbe8f851614dd1d8c09de102fe5/gitlab/v4/objects.py#L2012-L2044 | def set_release_description(self, description, **kwargs):
"""Set the release notes on the tag.
If the release doesn't exist yet, it will be created. If it already
exists, its description will be updated.
Args:
description (str): Description of the release.
**kwa... | [
"def",
"set_release_description",
"(",
"self",
",",
"description",
",",
"*",
"*",
"kwargs",
")",
":",
"id",
"=",
"self",
".",
"get_id",
"(",
")",
".",
"replace",
"(",
"'/'",
",",
"'%2F'",
")",
"path",
"=",
"'%s/%s/release'",
"%",
"(",
"self",
".",
"m... | Set the release notes on the tag.
If the release doesn't exist yet, it will be created. If it already
exists, its description will be updated.
Args:
description (str): Description of the release.
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:... | [
"Set",
"the",
"release",
"notes",
"on",
"the",
"tag",
"."
] | python | train |
LudovicRousseau/pyscard | smartcard/pcsc/PCSCCardConnection.py | https://github.com/LudovicRousseau/pyscard/blob/62e675028086c75656444cc21d563d9f08ebf8e7/smartcard/pcsc/PCSCCardConnection.py#L211-L227 | def doControl(self, controlCode, bytes=[]):
"""Transmit a control command to the reader and return response.
controlCode: control command
bytes: command data to transmit (list of bytes)
return: response are the response bytes (if any)
"""
CardConnection.doCo... | [
"def",
"doControl",
"(",
"self",
",",
"controlCode",
",",
"bytes",
"=",
"[",
"]",
")",
":",
"CardConnection",
".",
"doControl",
"(",
"self",
",",
"controlCode",
",",
"bytes",
")",
"hresult",
",",
"response",
"=",
"SCardControl",
"(",
"self",
".",
"hcard"... | Transmit a control command to the reader and return response.
controlCode: control command
bytes: command data to transmit (list of bytes)
return: response are the response bytes (if any) | [
"Transmit",
"a",
"control",
"command",
"to",
"the",
"reader",
"and",
"return",
"response",
"."
] | python | train |
neuropsychology/NeuroKit.py | examples/UnderDev/eeg/eeg_time_frequency.py | https://github.com/neuropsychology/NeuroKit.py/blob/c9589348fbbde0fa7e986048c48f38e6b488adfe/examples/UnderDev/eeg/eeg_time_frequency.py#L99-L176 | def eeg_psd(raw, sensors_include="all", sensors_exclude=None, fmin=0.016, fmax=60, method="multitaper", proj=False):
"""
Compute Power-Spectral Density (PSD).
Parameters
----------
raw : mne.io.Raw
Raw EEG data.
sensors_include : str
Sensor area to include. See :func:`neurokit.e... | [
"def",
"eeg_psd",
"(",
"raw",
",",
"sensors_include",
"=",
"\"all\"",
",",
"sensors_exclude",
"=",
"None",
",",
"fmin",
"=",
"0.016",
",",
"fmax",
"=",
"60",
",",
"method",
"=",
"\"multitaper\"",
",",
"proj",
"=",
"False",
")",
":",
"picks",
"=",
"mne"... | Compute Power-Spectral Density (PSD).
Parameters
----------
raw : mne.io.Raw
Raw EEG data.
sensors_include : str
Sensor area to include. See :func:`neurokit.eeg_select_sensors()`.
sensors_exclude : str
Sensor area to exclude. See :func:`neurokit.eeg_select_sensors()`.
fm... | [
"Compute",
"Power",
"-",
"Spectral",
"Density",
"(",
"PSD",
")",
"."
] | python | train |
gholt/swiftly | swiftly/cli/encrypt.py | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/encrypt.py#L31-L47 | def cli_encrypt(context, key):
"""
Encrypts context.io_manager's stdin and sends that to
context.io_manager's stdout.
This can be useful to encrypt to disk before attempting to
upload, allowing uploads retries and segmented encrypted objects.
See :py:mod:`swiftly.cli.encrypt` for context usage... | [
"def",
"cli_encrypt",
"(",
"context",
",",
"key",
")",
":",
"with",
"context",
".",
"io_manager",
".",
"with_stdout",
"(",
")",
"as",
"stdout",
":",
"with",
"context",
".",
"io_manager",
".",
"with_stdin",
"(",
")",
"as",
"stdin",
":",
"for",
"chunk",
... | Encrypts context.io_manager's stdin and sends that to
context.io_manager's stdout.
This can be useful to encrypt to disk before attempting to
upload, allowing uploads retries and segmented encrypted objects.
See :py:mod:`swiftly.cli.encrypt` for context usage information.
See :py:class:`CLIEncryp... | [
"Encrypts",
"context",
".",
"io_manager",
"s",
"stdin",
"and",
"sends",
"that",
"to",
"context",
".",
"io_manager",
"s",
"stdout",
"."
] | python | test |
xlzd/xtls | xtls/timeparser.py | https://github.com/xlzd/xtls/blob/b3cc0ab24197ecaa39adcad7cd828cada9c04a4e/xtls/timeparser.py#L48-L54 | def _build_str_from_chinese(chinese_items):
"""
根据解析出的中文时间字符串的关键字返回对应的标准格式字符串
"""
year, month, day = chinese_items
year = reduce(lambda a, b: a*10+b, map(CHINESE_NUMS.find, year))
return '%04d-%02d-%02d 00:00:00' % (year, _parse_chinese_field(month), _parse_chinese_field(day)) | [
"def",
"_build_str_from_chinese",
"(",
"chinese_items",
")",
":",
"year",
",",
"month",
",",
"day",
"=",
"chinese_items",
"year",
"=",
"reduce",
"(",
"lambda",
"a",
",",
"b",
":",
"a",
"*",
"10",
"+",
"b",
",",
"map",
"(",
"CHINESE_NUMS",
".",
"find",
... | 根据解析出的中文时间字符串的关键字返回对应的标准格式字符串 | [
"根据解析出的中文时间字符串的关键字返回对应的标准格式字符串"
] | python | train |
pandas-dev/pandas | pandas/core/panel.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L834-L866 | def xs(self, key, axis=1):
"""
Return slice of panel along selected axis.
Parameters
----------
key : object
Label
axis : {'items', 'major', 'minor}, default 1/'major'
Returns
-------
y : ndim(self)-1
Notes
-----
... | [
"def",
"xs",
"(",
"self",
",",
"key",
",",
"axis",
"=",
"1",
")",
":",
"axis",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"if",
"axis",
"==",
"0",
":",
"return",
"self",
"[",
"key",
"]",
"self",
".",
"_consolidate_inplace",
"(",
")",
... | Return slice of panel along selected axis.
Parameters
----------
key : object
Label
axis : {'items', 'major', 'minor}, default 1/'major'
Returns
-------
y : ndim(self)-1
Notes
-----
xs is only for getting, not setting values.... | [
"Return",
"slice",
"of",
"panel",
"along",
"selected",
"axis",
"."
] | python | train |
rcsb/mmtf-python | mmtf/converters/converters.py | https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/converters/converters.py#L22-L32 | def convert_ints_to_bytes(in_ints, num):
"""Convert an integer array into a byte arrays. The number of bytes forming an integer
is defined by num
:param in_ints: the input integers
:param num: the number of bytes per int
:return the integer array"""
out_bytes= b""
for val in in_ints:
... | [
"def",
"convert_ints_to_bytes",
"(",
"in_ints",
",",
"num",
")",
":",
"out_bytes",
"=",
"b\"\"",
"for",
"val",
"in",
"in_ints",
":",
"out_bytes",
"+=",
"struct",
".",
"pack",
"(",
"mmtf",
".",
"utils",
".",
"constants",
".",
"NUM_DICT",
"[",
"num",
"]",
... | Convert an integer array into a byte arrays. The number of bytes forming an integer
is defined by num
:param in_ints: the input integers
:param num: the number of bytes per int
:return the integer array | [
"Convert",
"an",
"integer",
"array",
"into",
"a",
"byte",
"arrays",
".",
"The",
"number",
"of",
"bytes",
"forming",
"an",
"integer",
"is",
"defined",
"by",
"num"
] | python | train |
gem/oq-engine | openquake/risklib/asset.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/asset.py#L792-L836 | def read(fnames, calculation_mode='', region_constraint='',
ignore_missing_costs=(), asset_nodes=False, check_dupl=True,
tagcol=None, by_country=False):
"""
Call `Exposure.read(fname)` to get an :class:`Exposure` instance
keeping all the assets in memory or
`Exp... | [
"def",
"read",
"(",
"fnames",
",",
"calculation_mode",
"=",
"''",
",",
"region_constraint",
"=",
"''",
",",
"ignore_missing_costs",
"=",
"(",
")",
",",
"asset_nodes",
"=",
"False",
",",
"check_dupl",
"=",
"True",
",",
"tagcol",
"=",
"None",
",",
"by_countr... | Call `Exposure.read(fname)` to get an :class:`Exposure` instance
keeping all the assets in memory or
`Exposure.read(fname, asset_nodes=True)` to get an iterator over
Node objects (one Node for each asset). | [
"Call",
"Exposure",
".",
"read",
"(",
"fname",
")",
"to",
"get",
"an",
":",
"class",
":",
"Exposure",
"instance",
"keeping",
"all",
"the",
"assets",
"in",
"memory",
"or",
"Exposure",
".",
"read",
"(",
"fname",
"asset_nodes",
"=",
"True",
")",
"to",
"ge... | python | train |
SeleniumHQ/selenium | py/selenium/webdriver/remote/mobile.py | https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/mobile.py#L52-L64 | def set_network_connection(self, network):
"""
Set the network connection for the remote device.
Example of setting airplane mode::
driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE)
"""
mode = network.mask if isinstance(network, self.ConnectionType) ... | [
"def",
"set_network_connection",
"(",
"self",
",",
"network",
")",
":",
"mode",
"=",
"network",
".",
"mask",
"if",
"isinstance",
"(",
"network",
",",
"self",
".",
"ConnectionType",
")",
"else",
"network",
"return",
"self",
".",
"ConnectionType",
"(",
"self",... | Set the network connection for the remote device.
Example of setting airplane mode::
driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE) | [
"Set",
"the",
"network",
"connection",
"for",
"the",
"remote",
"device",
"."
] | python | train |
knagra/farnsworth | base/redirects.py | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/base/redirects.py#L11-L21 | def red_ext(request, message=None):
'''
The external landing.
Also a convenience function for redirecting users who don't have site access to the external page.
Parameters:
request - the request in the calling function
message - a message from the caller function
'''
if message:
... | [
"def",
"red_ext",
"(",
"request",
",",
"message",
"=",
"None",
")",
":",
"if",
"message",
":",
"messages",
".",
"add_message",
"(",
"request",
",",
"messages",
".",
"ERROR",
",",
"message",
")",
"return",
"HttpResponseRedirect",
"(",
"reverse",
"(",
"'exte... | The external landing.
Also a convenience function for redirecting users who don't have site access to the external page.
Parameters:
request - the request in the calling function
message - a message from the caller function | [
"The",
"external",
"landing",
".",
"Also",
"a",
"convenience",
"function",
"for",
"redirecting",
"users",
"who",
"don",
"t",
"have",
"site",
"access",
"to",
"the",
"external",
"page",
".",
"Parameters",
":",
"request",
"-",
"the",
"request",
"in",
"the",
"... | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.