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 |
|---|---|---|---|---|---|---|---|---|
oscarlazoarjona/fast | build/lib/fast/symbolic.py | https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/build/lib/fast/symbolic.py#L153-L186 | def define_laser_variables(Nl, real_amplitudes=False, variables=None):
r"""Return the amplitudes and frequencies of Nl fields.
>>> E0, omega_laser = define_laser_variables(2)
>>> E0, omega_laser
([E_0^1, E_0^2], [varpi_1, varpi_2])
The amplitudes are complex by default:
>>> conjugate(E0[0])
... | [
"def",
"define_laser_variables",
"(",
"Nl",
",",
"real_amplitudes",
"=",
"False",
",",
"variables",
"=",
"None",
")",
":",
"if",
"variables",
"is",
"None",
":",
"E0",
"=",
"[",
"Symbol",
"(",
"r\"E_0^\"",
"+",
"str",
"(",
"l",
"+",
"1",
")",
",",
"re... | r"""Return the amplitudes and frequencies of Nl fields.
>>> E0, omega_laser = define_laser_variables(2)
>>> E0, omega_laser
([E_0^1, E_0^2], [varpi_1, varpi_2])
The amplitudes are complex by default:
>>> conjugate(E0[0])
conjugate(E_0^1)
But they can optionally be made real:
>>> E0, o... | [
"r",
"Return",
"the",
"amplitudes",
"and",
"frequencies",
"of",
"Nl",
"fields",
"."
] | python | train |
veltzer/pypitools | pypitools/common.py | https://github.com/veltzer/pypitools/blob/5f097be21e9bc65578eed5b6b7855c1945540701/pypitools/common.py#L219-L229 | def register(self):
"""
Register via the method configured
:return:
"""
if self.register_method == "twine":
self.register_by_twine()
if self.register_method == "setup":
self.register_by_setup()
if self.register_method == "upload":
... | [
"def",
"register",
"(",
"self",
")",
":",
"if",
"self",
".",
"register_method",
"==",
"\"twine\"",
":",
"self",
".",
"register_by_twine",
"(",
")",
"if",
"self",
".",
"register_method",
"==",
"\"setup\"",
":",
"self",
".",
"register_by_setup",
"(",
")",
"i... | Register via the method configured
:return: | [
"Register",
"via",
"the",
"method",
"configured",
":",
"return",
":"
] | python | train |
librosa/librosa | librosa/feature/utils.py | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/feature/utils.py#L15-L115 | def delta(data, width=9, order=1, axis=-1, mode='interp', **kwargs):
r'''Compute delta features: local estimate of the derivative
of the input data along the selected axis.
Delta features are computed Savitsky-Golay filtering.
Parameters
----------
data : np.ndarray
the input data... | [
"def",
"delta",
"(",
"data",
",",
"width",
"=",
"9",
",",
"order",
"=",
"1",
",",
"axis",
"=",
"-",
"1",
",",
"mode",
"=",
"'interp'",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"np",
".",
"atleast_1d",
"(",
"data",
")",
"if",
"mode",
"=... | r'''Compute delta features: local estimate of the derivative
of the input data along the selected axis.
Delta features are computed Savitsky-Golay filtering.
Parameters
----------
data : np.ndarray
the input data matrix (eg, spectrogram)
width : int, positive, odd [scalar]
... | [
"r",
"Compute",
"delta",
"features",
":",
"local",
"estimate",
"of",
"the",
"derivative",
"of",
"the",
"input",
"data",
"along",
"the",
"selected",
"axis",
"."
] | python | test |
Azure/azure-sdk-for-python | azure-mgmt-servermanager/azure/mgmt/servermanager/operations/power_shell_operations.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-servermanager/azure/mgmt/servermanager/operations/power_shell_operations.py#L328-L381 | def update_command(
self, resource_group_name, node_name, session, pssession, custom_headers=None, raw=False, polling=True, **operation_config):
"""Updates a running PowerShell command with more data.
:param resource_group_name: The resource group name uniquely
identifies the resou... | [
"def",
"update_command",
"(",
"self",
",",
"resource_group_name",
",",
"node_name",
",",
"session",
",",
"pssession",
",",
"custom_headers",
"=",
"None",
",",
"raw",
"=",
"False",
",",
"polling",
"=",
"True",
",",
"*",
"*",
"operation_config",
")",
":",
"r... | Updates a running PowerShell command with more data.
:param resource_group_name: The resource group name uniquely
identifies the resource group within the user subscriptionId.
:type resource_group_name: str
:param node_name: The node name (256 characters maximum).
:type node_na... | [
"Updates",
"a",
"running",
"PowerShell",
"command",
"with",
"more",
"data",
"."
] | python | test |
pypa/pipenv | pipenv/vendor/pyparsing.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pyparsing.py#L219-L227 | def _xml_escape(data):
"""Escape &, <, >, ", ', etc. in a string of data."""
# ampersand must be replaced first
from_symbols = '&><"\''
to_symbols = ('&'+s+';' for s in "amp gt lt quot apos".split())
for from_,to_ in zip(from_symbols, to_symbols):
data = data.replace(from_, to_)
return ... | [
"def",
"_xml_escape",
"(",
"data",
")",
":",
"# ampersand must be replaced first",
"from_symbols",
"=",
"'&><\"\\''",
"to_symbols",
"=",
"(",
"'&'",
"+",
"s",
"+",
"';'",
"for",
"s",
"in",
"\"amp gt lt quot apos\"",
".",
"split",
"(",
")",
")",
"for",
"from_",... | Escape &, <, >, ", ', etc. in a string of data. | [
"Escape",
"&",
"<",
">",
"etc",
".",
"in",
"a",
"string",
"of",
"data",
"."
] | python | train |
KrzyHonk/bpmn-python | bpmn_python/bpmn_diagram_import.py | https://github.com/KrzyHonk/bpmn-python/blob/6e5e28e3d656dbf5bd3d85d78fe8e3f2fb462629/bpmn_python/bpmn_diagram_import.py#L381-L393 | def import_task_to_graph(diagram_graph, process_id, process_attributes, task_element):
"""
Adds to graph the new element that represents BPMN task.
In our representation tasks have only basic attributes and elements, inherited from Activity type,
so this method only needs to call add_flo... | [
"def",
"import_task_to_graph",
"(",
"diagram_graph",
",",
"process_id",
",",
"process_attributes",
",",
"task_element",
")",
":",
"BpmnDiagramGraphImport",
".",
"import_activity_to_graph",
"(",
"diagram_graph",
",",
"process_id",
",",
"process_attributes",
",",
"task_elem... | Adds to graph the new element that represents BPMN task.
In our representation tasks have only basic attributes and elements, inherited from Activity type,
so this method only needs to call add_flownode_to_graph.
:param diagram_graph: NetworkX graph representing a BPMN process diagram,
... | [
"Adds",
"to",
"graph",
"the",
"new",
"element",
"that",
"represents",
"BPMN",
"task",
".",
"In",
"our",
"representation",
"tasks",
"have",
"only",
"basic",
"attributes",
"and",
"elements",
"inherited",
"from",
"Activity",
"type",
"so",
"this",
"method",
"only"... | python | train |
bububa/pyTOP | pyTOP/packages/requests/hooks.py | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/packages/requests/hooks.py#L28-L40 | def dispatch_hook(key, hooks, hook_data):
"""Dispatches a hook dictionary on a given piece of data."""
hooks = hooks or dict()
if key in hooks:
try:
return hooks.get(key).__call__(hook_data) or hook_data
except Exception, why:
warnings.warn(str(why))
return ho... | [
"def",
"dispatch_hook",
"(",
"key",
",",
"hooks",
",",
"hook_data",
")",
":",
"hooks",
"=",
"hooks",
"or",
"dict",
"(",
")",
"if",
"key",
"in",
"hooks",
":",
"try",
":",
"return",
"hooks",
".",
"get",
"(",
"key",
")",
".",
"__call__",
"(",
"hook_da... | Dispatches a hook dictionary on a given piece of data. | [
"Dispatches",
"a",
"hook",
"dictionary",
"on",
"a",
"given",
"piece",
"of",
"data",
"."
] | python | train |
googleapis/gax-python | google/gax/api_callable.py | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/api_callable.py#L363-L382 | def _catch_errors(a_func, to_catch):
"""Updates a_func to wrap exceptions with GaxError
Args:
a_func (callable): A callable.
to_catch (list[Exception]): Configures the exceptions to wrap.
Returns:
Callable: A function that will wrap certain exceptions with GaxError
"""
def ... | [
"def",
"_catch_errors",
"(",
"a_func",
",",
"to_catch",
")",
":",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Wraps specified exceptions\"\"\"",
"try",
":",
"return",
"a_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")... | Updates a_func to wrap exceptions with GaxError
Args:
a_func (callable): A callable.
to_catch (list[Exception]): Configures the exceptions to wrap.
Returns:
Callable: A function that will wrap certain exceptions with GaxError | [
"Updates",
"a_func",
"to",
"wrap",
"exceptions",
"with",
"GaxError"
] | python | train |
saltstack/salt | salt/modules/grafana4.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grafana4.py#L930-L954 | def get_datasource(name, orgname=None, profile='grafana'):
'''
Show a single datasource in an organisation.
name
Name of the datasource.
orgname
Name of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
... | [
"def",
"get_datasource",
"(",
"name",
",",
"orgname",
"=",
"None",
",",
"profile",
"=",
"'grafana'",
")",
":",
"data",
"=",
"get_datasources",
"(",
"orgname",
"=",
"orgname",
",",
"profile",
"=",
"profile",
")",
"for",
"datasource",
"in",
"data",
":",
"i... | Show a single datasource in an organisation.
name
Name of the datasource.
orgname
Name of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.g... | [
"Show",
"a",
"single",
"datasource",
"in",
"an",
"organisation",
"."
] | python | train |
jbloomlab/phydms | phydmslib/models.py | https://github.com/jbloomlab/phydms/blob/9cdebc10bafbe543c552d79486c7f950780ed3c0/phydmslib/models.py#L790-L808 | def _update_dprx(self):
"""Update `dprx`."""
if 'beta' in self.freeparams:
for r in range(self.nsites):
self.dprx['beta'][r] = self.prx[r] * (self.ln_pi_codon[r]
- scipy.dot(self.ln_pi_codon[r], self.prx[r]))
if 'eta' in self.freeparams:
... | [
"def",
"_update_dprx",
"(",
"self",
")",
":",
"if",
"'beta'",
"in",
"self",
".",
"freeparams",
":",
"for",
"r",
"in",
"range",
"(",
"self",
".",
"nsites",
")",
":",
"self",
".",
"dprx",
"[",
"'beta'",
"]",
"[",
"r",
"]",
"=",
"self",
".",
"prx",
... | Update `dprx`. | [
"Update",
"dprx",
"."
] | python | train |
awslabs/aws-sam-cli | samcli/commands/local/lib/sam_api_provider.py | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L201-L222 | def _normalize_apis(apis):
"""
Normalize the APIs to use standard method name
Parameters
----------
apis : list of samcli.commands.local.lib.provider.Api
List of APIs to replace normalize
Returns
-------
list of samcli.commands.local.lib.prov... | [
"def",
"_normalize_apis",
"(",
"apis",
")",
":",
"result",
"=",
"list",
"(",
")",
"for",
"api",
"in",
"apis",
":",
"for",
"normalized_method",
"in",
"SamApiProvider",
".",
"_normalize_http_methods",
"(",
"api",
".",
"method",
")",
":",
"# _replace returns a co... | Normalize the APIs to use standard method name
Parameters
----------
apis : list of samcli.commands.local.lib.provider.Api
List of APIs to replace normalize
Returns
-------
list of samcli.commands.local.lib.provider.Api
List of normalized APIs | [
"Normalize",
"the",
"APIs",
"to",
"use",
"standard",
"method",
"name"
] | python | train |
dnephin/PyStaticConfiguration | staticconf/config.py | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/config.py#L436-L451 | def build_compare_func(err_logger=None):
"""Returns a compare_func that can be passed to MTimeComparator.
The returned compare_func first tries os.path.getmtime(filename),
then calls err_logger(filename) if that fails. If err_logger is None,
then it does nothing. err_logger is always called within the ... | [
"def",
"build_compare_func",
"(",
"err_logger",
"=",
"None",
")",
":",
"def",
"compare_func",
"(",
"filename",
")",
":",
"try",
":",
"return",
"os",
".",
"path",
".",
"getmtime",
"(",
"filename",
")",
"except",
"OSError",
":",
"if",
"err_logger",
"is",
"... | Returns a compare_func that can be passed to MTimeComparator.
The returned compare_func first tries os.path.getmtime(filename),
then calls err_logger(filename) if that fails. If err_logger is None,
then it does nothing. err_logger is always called within the context of
an OSError raised by os.path.getm... | [
"Returns",
"a",
"compare_func",
"that",
"can",
"be",
"passed",
"to",
"MTimeComparator",
"."
] | python | train |
jealous/stockstats | stockstats.py | https://github.com/jealous/stockstats/blob/a479a504ea1906955feeb8519c34ef40eb48ec9b/stockstats.py#L392-L405 | def _get_tr(cls, df):
""" True Range of the trading
tr = max[(high - low), abs(high - close_prev), abs(low - close_prev)]
:param df: data
:return: None
"""
prev_close = df['close_-1_s']
high = df['high']
low = df['low']
c1 = high - low
... | [
"def",
"_get_tr",
"(",
"cls",
",",
"df",
")",
":",
"prev_close",
"=",
"df",
"[",
"'close_-1_s'",
"]",
"high",
"=",
"df",
"[",
"'high'",
"]",
"low",
"=",
"df",
"[",
"'low'",
"]",
"c1",
"=",
"high",
"-",
"low",
"c2",
"=",
"np",
".",
"abs",
"(",
... | True Range of the trading
tr = max[(high - low), abs(high - close_prev), abs(low - close_prev)]
:param df: data
:return: None | [
"True",
"Range",
"of",
"the",
"trading",
"tr",
"=",
"max",
"[",
"(",
"high",
"-",
"low",
")",
"abs",
"(",
"high",
"-",
"close_prev",
")",
"abs",
"(",
"low",
"-",
"close_prev",
")",
"]",
":",
"param",
"df",
":",
"data",
":",
"return",
":",
"None"
... | python | train |
materialsproject/pymatgen | pymatgen/analysis/gb/grain.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/gb/grain.py#L326-L668 | def gb_from_parameters(self, rotation_axis, rotation_angle, expand_times=4, vacuum_thickness=0.0,
ab_shift=[0, 0], normal=False, ratio=None, plane=None, max_search=20,
tol_coi=1.e-8, rm_ratio=0.7, quick_gen=False):
"""
Args:
rotation_axis... | [
"def",
"gb_from_parameters",
"(",
"self",
",",
"rotation_axis",
",",
"rotation_angle",
",",
"expand_times",
"=",
"4",
",",
"vacuum_thickness",
"=",
"0.0",
",",
"ab_shift",
"=",
"[",
"0",
",",
"0",
"]",
",",
"normal",
"=",
"False",
",",
"ratio",
"=",
"Non... | Args:
rotation_axis (list): Rotation axis of GB in the form of a list of integer
e.g.: [1, 1, 0]
rotation_angle (float, in unit of degree): rotation angle used to generate GB.
Make sure the angle is accurate enough. You can use the enum* functions
in... | [
"Args",
":",
"rotation_axis",
"(",
"list",
")",
":",
"Rotation",
"axis",
"of",
"GB",
"in",
"the",
"form",
"of",
"a",
"list",
"of",
"integer",
"e",
".",
"g",
".",
":",
"[",
"1",
"1",
"0",
"]",
"rotation_angle",
"(",
"float",
"in",
"unit",
"of",
"d... | python | train |
tcalmant/ipopo | pelix/ipopo/handlers/requires.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/requires.py#L492-L500 | def clear(self):
"""
Cleans up the manager. The manager can't be used after this method has
been called
"""
self.services.clear()
self.services = None
self._future_value = None
super(AggregateDependency, self).clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"services",
".",
"clear",
"(",
")",
"self",
".",
"services",
"=",
"None",
"self",
".",
"_future_value",
"=",
"None",
"super",
"(",
"AggregateDependency",
",",
"self",
")",
".",
"clear",
"(",
")"
] | Cleans up the manager. The manager can't be used after this method has
been called | [
"Cleans",
"up",
"the",
"manager",
".",
"The",
"manager",
"can",
"t",
"be",
"used",
"after",
"this",
"method",
"has",
"been",
"called"
] | python | train |
lpantano/seqcluster | seqcluster/libs/thinkbayes.py | https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/thinkbayes.py#L1827-L1838 | def LogBinomialCoef(n, k):
"""Computes the log of the binomial coefficient.
http://math.stackexchange.com/questions/64716/
approximating-the-logarithm-of-the-binomial-coefficient
n: number of trials
k: number of successes
Returns: float
"""
return n * log(n) - k * log(k) - (n - k) * l... | [
"def",
"LogBinomialCoef",
"(",
"n",
",",
"k",
")",
":",
"return",
"n",
"*",
"log",
"(",
"n",
")",
"-",
"k",
"*",
"log",
"(",
"k",
")",
"-",
"(",
"n",
"-",
"k",
")",
"*",
"log",
"(",
"n",
"-",
"k",
")"
] | Computes the log of the binomial coefficient.
http://math.stackexchange.com/questions/64716/
approximating-the-logarithm-of-the-binomial-coefficient
n: number of trials
k: number of successes
Returns: float | [
"Computes",
"the",
"log",
"of",
"the",
"binomial",
"coefficient",
"."
] | python | train |
angr/angr | angr/analyses/vfg.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/vfg.py#L1215-L1259 | def _create_graph(self, return_target_sources=None):
"""
Create a DiGraph out of the existing edge map.
:param return_target_sources: Used for making up those missing returns
:returns: A networkx.DiGraph() object
"""
if return_target_sources is None:
# We set ... | [
"def",
"_create_graph",
"(",
"self",
",",
"return_target_sources",
"=",
"None",
")",
":",
"if",
"return_target_sources",
"is",
"None",
":",
"# We set it to a defaultdict in order to be consistent with the",
"# actual parameter.",
"return_target_sources",
"=",
"defaultdict",
"... | Create a DiGraph out of the existing edge map.
:param return_target_sources: Used for making up those missing returns
:returns: A networkx.DiGraph() object | [
"Create",
"a",
"DiGraph",
"out",
"of",
"the",
"existing",
"edge",
"map",
".",
":",
"param",
"return_target_sources",
":",
"Used",
"for",
"making",
"up",
"those",
"missing",
"returns",
":",
"returns",
":",
"A",
"networkx",
".",
"DiGraph",
"()",
"object"
] | python | train |
manns/pyspread | pyspread/src/lib/vlc.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/vlc.py#L243-L248 | def _Cobject(cls, ctype):
"""(INTERNAL) New instance from ctypes.
"""
o = object.__new__(cls)
o._as_parameter_ = ctype
return o | [
"def",
"_Cobject",
"(",
"cls",
",",
"ctype",
")",
":",
"o",
"=",
"object",
".",
"__new__",
"(",
"cls",
")",
"o",
".",
"_as_parameter_",
"=",
"ctype",
"return",
"o"
] | (INTERNAL) New instance from ctypes. | [
"(",
"INTERNAL",
")",
"New",
"instance",
"from",
"ctypes",
"."
] | python | train |
pandas-dev/pandas | pandas/core/missing.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/missing.py#L445-L460 | def _cast_values_for_fillna(values, dtype):
"""
Cast values to a dtype that algos.pad and algos.backfill can handle.
"""
# TODO: for int-dtypes we make a copy, but for everything else this
# alters the values in-place. Is this intentional?
if (is_datetime64_dtype(dtype) or is_datetime64tz_dty... | [
"def",
"_cast_values_for_fillna",
"(",
"values",
",",
"dtype",
")",
":",
"# TODO: for int-dtypes we make a copy, but for everything else this",
"# alters the values in-place. Is this intentional?",
"if",
"(",
"is_datetime64_dtype",
"(",
"dtype",
")",
"or",
"is_datetime64tz_dtype"... | Cast values to a dtype that algos.pad and algos.backfill can handle. | [
"Cast",
"values",
"to",
"a",
"dtype",
"that",
"algos",
".",
"pad",
"and",
"algos",
".",
"backfill",
"can",
"handle",
"."
] | python | train |
gem/oq-engine | openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py#L80-L93 | def _check_completeness_table(completeness, catalogue):
"""
Generates the completeness table according to different instances
"""
if isinstance(completeness, np.ndarray) and np.shape(completeness)[1] == 2:
return completeness
elif isinstance(completeness, float):
return np.array([[fl... | [
"def",
"_check_completeness_table",
"(",
"completeness",
",",
"catalogue",
")",
":",
"if",
"isinstance",
"(",
"completeness",
",",
"np",
".",
"ndarray",
")",
"and",
"np",
".",
"shape",
"(",
"completeness",
")",
"[",
"1",
"]",
"==",
"2",
":",
"return",
"c... | Generates the completeness table according to different instances | [
"Generates",
"the",
"completeness",
"table",
"according",
"to",
"different",
"instances"
] | python | train |
ssato/python-anyconfig | src/anyconfig/backend/ini.py | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/ini.py#L124-L149 | def _load(stream, container, sep=_SEP, dkey=DEFAULTSECT, **kwargs):
"""
:param stream: File or file-like object provides ini-style conf
:param container: any callable to make container
:param sep: Seprator string
:param dkey: Default section name
:return: Dict or dict-like object represents con... | [
"def",
"_load",
"(",
"stream",
",",
"container",
",",
"sep",
"=",
"_SEP",
",",
"dkey",
"=",
"DEFAULTSECT",
",",
"*",
"*",
"kwargs",
")",
":",
"(",
"kwargs_1",
",",
"psr",
")",
"=",
"_make_parser",
"(",
"*",
"*",
"kwargs",
")",
"if",
"IS_PYTHON_3",
... | :param stream: File or file-like object provides ini-style conf
:param container: any callable to make container
:param sep: Seprator string
:param dkey: Default section name
:return: Dict or dict-like object represents config values | [
":",
"param",
"stream",
":",
"File",
"or",
"file",
"-",
"like",
"object",
"provides",
"ini",
"-",
"style",
"conf",
":",
"param",
"container",
":",
"any",
"callable",
"to",
"make",
"container",
":",
"param",
"sep",
":",
"Seprator",
"string",
":",
"param",... | python | train |
Asana/python-asana | asana/resources/gen/sections.py | https://github.com/Asana/python-asana/blob/6deb7a34495db23f44858e53b6bb2c9eccff7872/asana/resources/gen/sections.py#L11-L23 | def create_in_project(self, project, params={}, **options):
"""Creates a new section in a project.
Returns the full record of the newly created section.
Parameters
----------
project : {Id} The project to create the section in
[data] : {Object} Data for the req... | [
"def",
"create_in_project",
"(",
"self",
",",
"project",
",",
"params",
"=",
"{",
"}",
",",
"*",
"*",
"options",
")",
":",
"path",
"=",
"\"/projects/%s/sections\"",
"%",
"(",
"project",
")",
"return",
"self",
".",
"client",
".",
"post",
"(",
"path",
",... | Creates a new section in a project.
Returns the full record of the newly created section.
Parameters
----------
project : {Id} The project to create the section in
[data] : {Object} Data for the request
- name : {String} The text to be displayed as the section... | [
"Creates",
"a",
"new",
"section",
"in",
"a",
"project",
".",
"Returns",
"the",
"full",
"record",
"of",
"the",
"newly",
"created",
"section",
"."
] | python | train |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L200-L204 | def do_reset(self, line):
"""reset Set all session variables to their default values."""
self._split_args(line, 0, 0)
self._command_processor.get_session().reset()
self._print_info_if_verbose("Successfully reset session variables") | [
"def",
"do_reset",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"reset",
"(",
")",
"self",
".",
"_print_info_if_verbose",
"("... | reset Set all session variables to their default values. | [
"reset",
"Set",
"all",
"session",
"variables",
"to",
"their",
"default",
"values",
"."
] | python | train |
pytest-dev/pytest-xdist | xdist/scheduler/load.py | https://github.com/pytest-dev/pytest-xdist/blob/9fcf8fa636bc69ee6cac9348a6ec20c87f2bb5e4/xdist/scheduler/load.py#L186-L208 | def remove_node(self, node):
"""Remove a node from the scheduler
This should be called either when the node crashed or at
shutdown time. In the former case any pending items assigned
to the node will be re-scheduled. Called by the
``DSession.worker_workerfinished`` and
... | [
"def",
"remove_node",
"(",
"self",
",",
"node",
")",
":",
"pending",
"=",
"self",
".",
"node2pending",
".",
"pop",
"(",
"node",
")",
"if",
"not",
"pending",
":",
"return",
"# The node crashed, reassing pending items",
"crashitem",
"=",
"self",
".",
"collection... | Remove a node from the scheduler
This should be called either when the node crashed or at
shutdown time. In the former case any pending items assigned
to the node will be re-scheduled. Called by the
``DSession.worker_workerfinished`` and
``DSession.worker_errordown`` hooks.
... | [
"Remove",
"a",
"node",
"from",
"the",
"scheduler"
] | python | train |
wonambi-python/wonambi | wonambi/attr/annotations.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/attr/annotations.py#L1501-L1842 | def export_sleep_stats(self, filename, lights_off, lights_on):
"""Create CSV with sleep statistics.
Parameters
----------
filename: str
Filename for csv export
lights_off: float
Initial time when sleeper turns off the light (or their phone) to
... | [
"def",
"export_sleep_stats",
"(",
"self",
",",
"filename",
",",
"lights_off",
",",
"lights_on",
")",
":",
"epochs",
"=",
"self",
".",
"get_epochs",
"(",
")",
"ep_starts",
"=",
"[",
"i",
"[",
"'start'",
"]",
"for",
"i",
"in",
"epochs",
"]",
"hypno",
"="... | Create CSV with sleep statistics.
Parameters
----------
filename: str
Filename for csv export
lights_off: float
Initial time when sleeper turns off the light (or their phone) to
go to sleep, in seconds from recording start
lights_on: float
... | [
"Create",
"CSV",
"with",
"sleep",
"statistics",
"."
] | python | train |
davebridges/mousedb | mousedb/animal/views.py | https://github.com/davebridges/mousedb/blob/2a33f6d15d88b1540b05f7232b154fdbf8568580/mousedb/animal/views.py#L213-L215 | def dispatch(self, *args, **kwargs):
"""This decorator sets this view to have restricted permissions."""
return super(StrainUpdate, self).dispatch(*args, **kwargs) | [
"def",
"dispatch",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"StrainUpdate",
",",
"self",
")",
".",
"dispatch",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | This decorator sets this view to have restricted permissions. | [
"This",
"decorator",
"sets",
"this",
"view",
"to",
"have",
"restricted",
"permissions",
"."
] | python | train |
francois-vincent/clingon | clingon/utils.py | https://github.com/francois-vincent/clingon/blob/afc9db073dbc72b2562ce3e444152986a555dcbf/clingon/utils.py#L10-L34 | def auto_update_attrs_from_kwargs(method):
""" this decorator will update the attributes of an
instance object with all the kwargs of the decorated
method, updated with the kwargs of the actual call.
This saves you from boring typing:
self.xxxx = xxxx
self.yyyy = yyyy
...
in the d... | [
"def",
"auto_update_attrs_from_kwargs",
"(",
"method",
")",
":",
"def",
"wrapped",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# method signature introspection",
"argspec",
"=",
"inspect",
".",
"getargspec",
"(",
"method",
")",
"defaults",
"=",
"argspec",
... | this decorator will update the attributes of an
instance object with all the kwargs of the decorated
method, updated with the kwargs of the actual call.
This saves you from boring typing:
self.xxxx = xxxx
self.yyyy = yyyy
...
in the decorated method (typically __init__) | [
"this",
"decorator",
"will",
"update",
"the",
"attributes",
"of",
"an",
"instance",
"object",
"with",
"all",
"the",
"kwargs",
"of",
"the",
"decorated",
"method",
"updated",
"with",
"the",
"kwargs",
"of",
"the",
"actual",
"call",
".",
"This",
"saves",
"you",
... | python | train |
saltstack/salt | salt/returners/mongo_return.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_return.py#L218-L227 | def get_fun(fun):
'''
Return the most recent jobs that have executed the named function
'''
conn, mdb = _get_conn(ret=None)
ret = {}
rdata = mdb.saltReturns.find_one({'fun': fun}, {'_id': 0})
if rdata:
ret = rdata
return ret | [
"def",
"get_fun",
"(",
"fun",
")",
":",
"conn",
",",
"mdb",
"=",
"_get_conn",
"(",
"ret",
"=",
"None",
")",
"ret",
"=",
"{",
"}",
"rdata",
"=",
"mdb",
".",
"saltReturns",
".",
"find_one",
"(",
"{",
"'fun'",
":",
"fun",
"}",
",",
"{",
"'_id'",
"... | Return the most recent jobs that have executed the named function | [
"Return",
"the",
"most",
"recent",
"jobs",
"that",
"have",
"executed",
"the",
"named",
"function"
] | python | train |
django-haystack/pysolr | pysolr.py | https://github.com/django-haystack/pysolr/blob/ee28b39324fa21a99842d297e313c1759d8adbd2/pysolr.py#L1187-L1193 | def unload(self, core):
"""http://wiki.apache.org/solr/CoreAdmin#head-f5055a885932e2c25096a8856de840b06764d143"""
params = {
'action': 'UNLOAD',
'core': core,
}
return self._get_url(self.url, params=params) | [
"def",
"unload",
"(",
"self",
",",
"core",
")",
":",
"params",
"=",
"{",
"'action'",
":",
"'UNLOAD'",
",",
"'core'",
":",
"core",
",",
"}",
"return",
"self",
".",
"_get_url",
"(",
"self",
".",
"url",
",",
"params",
"=",
"params",
")"
] | http://wiki.apache.org/solr/CoreAdmin#head-f5055a885932e2c25096a8856de840b06764d143 | [
"http",
":",
"//",
"wiki",
".",
"apache",
".",
"org",
"/",
"solr",
"/",
"CoreAdmin#head",
"-",
"f5055a885932e2c25096a8856de840b06764d143"
] | python | train |
inveniosoftware/invenio-pidstore | invenio_pidstore/models.py | https://github.com/inveniosoftware/invenio-pidstore/blob/8bf35f4e62d5dcaf1a2cfe5803245ba5220a9b78/invenio_pidstore/models.py#L291-L318 | def unassign(self):
"""Unassign the registered object.
Note:
Only registered PIDs can be redirected so we set it back to registered.
:returns: `True` if the PID is successfully unassigned.
"""
if self.object_uuid is None and self.object_type is None:
return ... | [
"def",
"unassign",
"(",
"self",
")",
":",
"if",
"self",
".",
"object_uuid",
"is",
"None",
"and",
"self",
".",
"object_type",
"is",
"None",
":",
"return",
"True",
"try",
":",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"if",
"sel... | Unassign the registered object.
Note:
Only registered PIDs can be redirected so we set it back to registered.
:returns: `True` if the PID is successfully unassigned. | [
"Unassign",
"the",
"registered",
"object",
"."
] | python | train |
tanghaibao/jcvi | jcvi/formats/vcf.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/vcf.py#L488-L597 | def summary(args):
"""
%prog summary txtfile fastafile
The txtfile can be generated by: %prog mstmap --noheader --freq=0
Tabulate on all possible combinations of genotypes and provide results
in a nicely-formatted table. Give a fastafile for SNP rate (average
# of SNPs per Kb).
Only three... | [
"def",
"summary",
"(",
"args",
")",
":",
"from",
"jcvi",
".",
"utils",
".",
"cbook",
"import",
"thousands",
"from",
"jcvi",
".",
"utils",
".",
"table",
"import",
"tabulate",
"p",
"=",
"OptionParser",
"(",
"summary",
".",
"__doc__",
")",
"p",
".",
"add_... | %prog summary txtfile fastafile
The txtfile can be generated by: %prog mstmap --noheader --freq=0
Tabulate on all possible combinations of genotypes and provide results
in a nicely-formatted table. Give a fastafile for SNP rate (average
# of SNPs per Kb).
Only three-column file is supported:
... | [
"%prog",
"summary",
"txtfile",
"fastafile"
] | python | train |
saltstack/salt | salt/utils/reactor.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/reactor.py#L510-L514 | def caller(self, fun, **kwargs):
'''
Wrap LocalCaller to execute remote exec functions locally on the Minion
'''
self.client_cache['caller'].cmd(fun, *kwargs['arg'], **kwargs['kwarg']) | [
"def",
"caller",
"(",
"self",
",",
"fun",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"client_cache",
"[",
"'caller'",
"]",
".",
"cmd",
"(",
"fun",
",",
"*",
"kwargs",
"[",
"'arg'",
"]",
",",
"*",
"*",
"kwargs",
"[",
"'kwarg'",
"]",
")"
] | Wrap LocalCaller to execute remote exec functions locally on the Minion | [
"Wrap",
"LocalCaller",
"to",
"execute",
"remote",
"exec",
"functions",
"locally",
"on",
"the",
"Minion"
] | python | train |
CI-WATER/gsshapy | gsshapy/grid/era_to_gssha.py | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/grid/era_to_gssha.py#L149-L283 | def download_interim_for_gssha(main_directory,
start_datetime,
end_datetime,
leftlon=-180,
rightlon=180,
toplat=90,
bottomlat=-90,
... | [
"def",
"download_interim_for_gssha",
"(",
"main_directory",
",",
"start_datetime",
",",
"end_datetime",
",",
"leftlon",
"=",
"-",
"180",
",",
"rightlon",
"=",
"180",
",",
"toplat",
"=",
"90",
",",
"bottomlat",
"=",
"-",
"90",
",",
"precip_only",
"=",
"False"... | Function to download ERA5 data for GSSHA
.. note:: https://software.ecmwf.int/wiki/display/WEBAPI/Access+ECMWF+Public+Datasets
Args:
main_directory(:obj:`str`): Location of the output for the forecast data.
start_datetime(:obj:`str`): Datetime for download start.
end_datetime(:obj:`str... | [
"Function",
"to",
"download",
"ERA5",
"data",
"for",
"GSSHA"
] | python | train |
BDNYC/astrodbkit | astrodbkit/astrodb.py | https://github.com/BDNYC/astrodbkit/blob/02c03c5e91aa7c7b0f3b5fa95bcf71e33ffcee09/astrodbkit/astrodb.py#L1755-L1865 | def search(self, criterion, table, columns='', fetch=False, radius=1/60., use_converters=False, sql_search=False):
"""
General search method for tables. For (ra,dec) input in decimal degrees,
i.e. (12.3456,-65.4321), returns all sources within 1 arcminute, or the specified radius.
For st... | [
"def",
"search",
"(",
"self",
",",
"criterion",
",",
"table",
",",
"columns",
"=",
"''",
",",
"fetch",
"=",
"False",
",",
"radius",
"=",
"1",
"/",
"60.",
",",
"use_converters",
"=",
"False",
",",
"sql_search",
"=",
"False",
")",
":",
"# Get list of col... | General search method for tables. For (ra,dec) input in decimal degrees,
i.e. (12.3456,-65.4321), returns all sources within 1 arcminute, or the specified radius.
For string input, i.e. 'vb10', returns all sources with case-insensitive partial text
matches in columns with 'TEXT' data type. For i... | [
"General",
"search",
"method",
"for",
"tables",
".",
"For",
"(",
"ra",
"dec",
")",
"input",
"in",
"decimal",
"degrees",
"i",
".",
"e",
".",
"(",
"12",
".",
"3456",
"-",
"65",
".",
"4321",
")",
"returns",
"all",
"sources",
"within",
"1",
"arcminute",
... | python | train |
UCL-INGI/INGInious | inginious/common/entrypoints.py | https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/common/entrypoints.py#L20-L48 | def filesystem_from_config_dict(config_fs):
""" Given a dict containing an entry "module" which contains a FSProvider identifier, parse the configuration and returns a fs_provider.
Exits if there is an error.
"""
if "module" not in config_fs:
print("Key 'module' should be defined for the fil... | [
"def",
"filesystem_from_config_dict",
"(",
"config_fs",
")",
":",
"if",
"\"module\"",
"not",
"in",
"config_fs",
":",
"print",
"(",
"\"Key 'module' should be defined for the filesystem provider ('fs' configuration option)\"",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"e... | Given a dict containing an entry "module" which contains a FSProvider identifier, parse the configuration and returns a fs_provider.
Exits if there is an error. | [
"Given",
"a",
"dict",
"containing",
"an",
"entry",
"module",
"which",
"contains",
"a",
"FSProvider",
"identifier",
"parse",
"the",
"configuration",
"and",
"returns",
"a",
"fs_provider",
".",
"Exits",
"if",
"there",
"is",
"an",
"error",
"."
] | python | train |
liftoff/pyminifier | pyminifier/obfuscate.py | https://github.com/liftoff/pyminifier/blob/087ea7b0c8c964f1f907c3f350f5ce281798db86/pyminifier/obfuscate.py#L498-L517 | def remap_name(name_generator, names, table=None):
"""
Produces a series of variable assignments in the form of::
<obfuscated name> = <some identifier>
for each item in *names* using *name_generator* to come up with the
replacement names.
If *table* is provided, replacements will be looke... | [
"def",
"remap_name",
"(",
"name_generator",
",",
"names",
",",
"table",
"=",
"None",
")",
":",
"out",
"=",
"\"\"",
"for",
"name",
"in",
"names",
":",
"if",
"table",
"and",
"name",
"in",
"table",
"[",
"0",
"]",
".",
"keys",
"(",
")",
":",
"replaceme... | Produces a series of variable assignments in the form of::
<obfuscated name> = <some identifier>
for each item in *names* using *name_generator* to come up with the
replacement names.
If *table* is provided, replacements will be looked up there before
generating a new unique name. | [
"Produces",
"a",
"series",
"of",
"variable",
"assignments",
"in",
"the",
"form",
"of",
"::"
] | python | train |
sorgerlab/indra | indra/sources/trips/processor.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/processor.py#L606-L635 | def get_active_forms_state(self):
"""Extract ActiveForm INDRA Statements."""
for term in self._isolated_terms:
act = term.find('features/active')
if act is None:
continue
if act.text == 'TRUE':
is_active = True
elif act.text... | [
"def",
"get_active_forms_state",
"(",
"self",
")",
":",
"for",
"term",
"in",
"self",
".",
"_isolated_terms",
":",
"act",
"=",
"term",
".",
"find",
"(",
"'features/active'",
")",
"if",
"act",
"is",
"None",
":",
"continue",
"if",
"act",
".",
"text",
"==",
... | Extract ActiveForm INDRA Statements. | [
"Extract",
"ActiveForm",
"INDRA",
"Statements",
"."
] | python | train |
googleapis/google-cloud-python | firestore/google/cloud/firestore_v1beta1/client.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/client.py#L294-L340 | def get_all(self, references, field_paths=None, transaction=None):
"""Retrieve a batch of documents.
.. note::
Documents returned by this method are not guaranteed to be
returned in the same order that they are given in ``references``.
.. note::
If multiple `... | [
"def",
"get_all",
"(",
"self",
",",
"references",
",",
"field_paths",
"=",
"None",
",",
"transaction",
"=",
"None",
")",
":",
"document_paths",
",",
"reference_map",
"=",
"_reference_info",
"(",
"references",
")",
"mask",
"=",
"_get_doc_mask",
"(",
"field_path... | Retrieve a batch of documents.
.. note::
Documents returned by this method are not guaranteed to be
returned in the same order that they are given in ``references``.
.. note::
If multiple ``references`` refer to the same document, the server
will only retu... | [
"Retrieve",
"a",
"batch",
"of",
"documents",
"."
] | python | train |
astooke/gtimer | gtimer/public/timedloop.py | https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/timedloop.py#L13-L69 | def timed_loop(name=None,
rgstr_stamps=None,
save_itrs=SET['SI'],
loop_end_stamp=None,
end_stamp_unique=SET['UN'],
keep_prev_subdivisions=SET['KS'],
keep_end_subdivisions=SET['KS'],
quick_print=SET['QP']):
"""
... | [
"def",
"timed_loop",
"(",
"name",
"=",
"None",
",",
"rgstr_stamps",
"=",
"None",
",",
"save_itrs",
"=",
"SET",
"[",
"'SI'",
"]",
",",
"loop_end_stamp",
"=",
"None",
",",
"end_stamp_unique",
"=",
"SET",
"[",
"'UN'",
"]",
",",
"keep_prev_subdivisions",
"=",
... | Instantiate a TimedLoop object for measuring loop iteration timing data.
Can be used with either for or while loops.
Example::
loop = timed_loop()
while x > 0: # or for x in <iterable>:
next(loop) # or loop.next()
<body of loop, with gtimer stamps>
loop.exit()... | [
"Instantiate",
"a",
"TimedLoop",
"object",
"for",
"measuring",
"loop",
"iteration",
"timing",
"data",
".",
"Can",
"be",
"used",
"with",
"either",
"for",
"or",
"while",
"loops",
"."
] | python | train |
Knio/pynmea2 | pynmea2/nmea_file.py | https://github.com/Knio/pynmea2/blob/c4fc66c6a13dd85ad862b15c516245af6e571456/pynmea2/nmea_file.py#L66-L73 | def readline(self):
"""
Return the next NMEASentence in the file object
:return: NMEASentence
"""
data = self._file.readline()
s = self.parse(data)
return s | [
"def",
"readline",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"_file",
".",
"readline",
"(",
")",
"s",
"=",
"self",
".",
"parse",
"(",
"data",
")",
"return",
"s"
] | Return the next NMEASentence in the file object
:return: NMEASentence | [
"Return",
"the",
"next",
"NMEASentence",
"in",
"the",
"file",
"object",
":",
"return",
":",
"NMEASentence"
] | python | train |
alejandrobll/py-sphviewer | sphviewer/Render.py | https://github.com/alejandrobll/py-sphviewer/blob/f198bd9ed5adfb58ebdf66d169206e609fd46e42/sphviewer/Render.py#L164-L314 | def histogram(self,axis=None, **kargs):
"""
- histogram(axis=None, **kargs): It computes and shows the histogram of the image. This is
usefull for choosing a proper scale to the output, or for clipping some values. If
axis is None, it selects the current axis to plot the histogram.
... | [
"def",
"histogram",
"(",
"self",
",",
"axis",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"(",
"axis",
"==",
"None",
")",
":",
"axis",
"=",
"plt",
".",
"gca",
"(",
")",
"axis",
".",
"hist",
"(",
"self",
".",
"__image",
".",
"ravel",
... | - histogram(axis=None, **kargs): It computes and shows the histogram of the image. This is
usefull for choosing a proper scale to the output, or for clipping some values. If
axis is None, it selects the current axis to plot the histogram.
Keyword arguments:
*bins*:
... | [
"-",
"histogram",
"(",
"axis",
"=",
"None",
"**",
"kargs",
")",
":",
"It",
"computes",
"and",
"shows",
"the",
"histogram",
"of",
"the",
"image",
".",
"This",
"is",
"usefull",
"for",
"choosing",
"a",
"proper",
"scale",
"to",
"the",
"output",
"or",
"for"... | python | train |
cokelaer/spectrum | src/spectrum/criteria.py | https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/criteria.py#L219-L229 | def FPE(N,rho, k=None):
r"""Final prediction error criterion
.. math:: FPE(k) = \frac{N + k + 1}{N - k - 1} \rho_k
:validation: double checked versus octave.
"""
#k #todo check convention. agrees with octave
fpe = rho * (N + k + 1.) / (N- k -1)
return fpe | [
"def",
"FPE",
"(",
"N",
",",
"rho",
",",
"k",
"=",
"None",
")",
":",
"#k #todo check convention. agrees with octave",
"fpe",
"=",
"rho",
"*",
"(",
"N",
"+",
"k",
"+",
"1.",
")",
"/",
"(",
"N",
"-",
"k",
"-",
"1",
")",
"return",
"fpe"
] | r"""Final prediction error criterion
.. math:: FPE(k) = \frac{N + k + 1}{N - k - 1} \rho_k
:validation: double checked versus octave. | [
"r",
"Final",
"prediction",
"error",
"criterion"
] | python | valid |
inveniosoftware-attic/invenio-utils | invenio_utils/datacite.py | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/datacite.py#L104-L119 | def get_description(self, description_type='Abstract'):
"""Get DataCite description."""
if 'descriptions' in self.xml:
if isinstance(self.xml['descriptions']['description'], list):
for description in self.xml['descriptions']['description']:
if description_... | [
"def",
"get_description",
"(",
"self",
",",
"description_type",
"=",
"'Abstract'",
")",
":",
"if",
"'descriptions'",
"in",
"self",
".",
"xml",
":",
"if",
"isinstance",
"(",
"self",
".",
"xml",
"[",
"'descriptions'",
"]",
"[",
"'description'",
"]",
",",
"li... | Get DataCite description. | [
"Get",
"DataCite",
"description",
"."
] | python | train |
titusjan/argos | argos/config/stringcti.py | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/config/stringcti.py#L54-L58 | def createEditor(self, delegate, parent, option):
""" Creates a StringCtiEditor.
For the parameters see the AbstractCti constructor documentation.
"""
return StringCtiEditor(self, delegate, parent=parent) | [
"def",
"createEditor",
"(",
"self",
",",
"delegate",
",",
"parent",
",",
"option",
")",
":",
"return",
"StringCtiEditor",
"(",
"self",
",",
"delegate",
",",
"parent",
"=",
"parent",
")"
] | Creates a StringCtiEditor.
For the parameters see the AbstractCti constructor documentation. | [
"Creates",
"a",
"StringCtiEditor",
".",
"For",
"the",
"parameters",
"see",
"the",
"AbstractCti",
"constructor",
"documentation",
"."
] | python | train |
heigeo/climata | climata/acis/__init__.py | https://github.com/heigeo/climata/blob/2028bdbd40e1c8985b0b62f7cb969ce7dfa8f1bd/climata/acis/__init__.py#L80-L93 | def parse(self):
"""
Convert ACIS 'll' value into separate latitude and longitude.
"""
super(AcisIO, self).parse()
# This is more of a "mapping" step than a "parsing" step, but mappers
# only allow one-to-one mapping from input fields to output fields.
for row in... | [
"def",
"parse",
"(",
"self",
")",
":",
"super",
"(",
"AcisIO",
",",
"self",
")",
".",
"parse",
"(",
")",
"# This is more of a \"mapping\" step than a \"parsing\" step, but mappers",
"# only allow one-to-one mapping from input fields to output fields.",
"for",
"row",
"in",
"... | Convert ACIS 'll' value into separate latitude and longitude. | [
"Convert",
"ACIS",
"ll",
"value",
"into",
"separate",
"latitude",
"and",
"longitude",
"."
] | python | train |
neovim/pynvim | pynvim/msgpack_rpc/event_loop/base.py | https://github.com/neovim/pynvim/blob/5e577188e6d7133f597ad0ce60dc6a4b1314064a/pynvim/msgpack_rpc/event_loop/base.py#L129-L149 | def run(self, data_cb):
"""Run the event loop."""
if self._error:
err = self._error
if isinstance(self._error, KeyboardInterrupt):
# KeyboardInterrupt is not destructive(it may be used in
# the REPL).
# After throwing KeyboardInterr... | [
"def",
"run",
"(",
"self",
",",
"data_cb",
")",
":",
"if",
"self",
".",
"_error",
":",
"err",
"=",
"self",
".",
"_error",
"if",
"isinstance",
"(",
"self",
".",
"_error",
",",
"KeyboardInterrupt",
")",
":",
"# KeyboardInterrupt is not destructive(it may be used... | Run the event loop. | [
"Run",
"the",
"event",
"loop",
"."
] | python | train |
dhermes/bezier | src/bezier/surface.py | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/surface.py#L698-L748 | def subdivide(self):
r"""Split the surface into four sub-surfaces.
Does so by taking the unit triangle (i.e. the domain
of the surface) and splitting it into four sub-triangles
.. image:: ../../images/surface_subdivide1.png
:align: center
Then the surface is re-para... | [
"def",
"subdivide",
"(",
"self",
")",
":",
"nodes_a",
",",
"nodes_b",
",",
"nodes_c",
",",
"nodes_d",
"=",
"_surface_helpers",
".",
"subdivide_nodes",
"(",
"self",
".",
"_nodes",
",",
"self",
".",
"_degree",
")",
"return",
"(",
"Surface",
"(",
"nodes_a",
... | r"""Split the surface into four sub-surfaces.
Does so by taking the unit triangle (i.e. the domain
of the surface) and splitting it into four sub-triangles
.. image:: ../../images/surface_subdivide1.png
:align: center
Then the surface is re-parameterized via the map to / fr... | [
"r",
"Split",
"the",
"surface",
"into",
"four",
"sub",
"-",
"surfaces",
"."
] | python | train |
richq/cmake-lint | cmakelint/main.py | https://github.com/richq/cmake-lint/blob/058c6c0ed2536abd3e79a51c38ee6e686568e3b3/cmakelint/main.py#L321-L354 | def CheckCommandSpaces(filename, linenumber, clean_lines, errors):
"""
No extra spaces between command and parenthesis
"""
line = clean_lines.lines[linenumber]
match = ContainsCommand(line)
if match and len(match.group(2)):
errors(filename, linenumber, 'whitespace/extra',
... | [
"def",
"CheckCommandSpaces",
"(",
"filename",
",",
"linenumber",
",",
"clean_lines",
",",
"errors",
")",
":",
"line",
"=",
"clean_lines",
".",
"lines",
"[",
"linenumber",
"]",
"match",
"=",
"ContainsCommand",
"(",
"line",
")",
"if",
"match",
"and",
"len",
... | No extra spaces between command and parenthesis | [
"No",
"extra",
"spaces",
"between",
"command",
"and",
"parenthesis"
] | python | train |
watson-developer-cloud/python-sdk | ibm_watson/discovery_v1.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/discovery_v1.py#L9804-L9809 | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'relations') and self.relations is not None:
_dict['relations'] = [x._to_dict() for x in self.relations]
return _dict | [
"def",
"_to_dict",
"(",
"self",
")",
":",
"_dict",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"self",
",",
"'relations'",
")",
"and",
"self",
".",
"relations",
"is",
"not",
"None",
":",
"_dict",
"[",
"'relations'",
"]",
"=",
"[",
"x",
".",
"_to_dict",
"(... | Return a json dictionary representing this model. | [
"Return",
"a",
"json",
"dictionary",
"representing",
"this",
"model",
"."
] | python | train |
Tanganelli/CoAPthon3 | coapthon/resources/resource.py | https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/resources/resource.py#L110-L118 | def etag(self, etag):
"""
Set the ETag of the resource.
:param etag: the ETag
"""
if not isinstance(etag, bytes):
etag = bytes(etag, "utf-8")
self._etag.append(etag) | [
"def",
"etag",
"(",
"self",
",",
"etag",
")",
":",
"if",
"not",
"isinstance",
"(",
"etag",
",",
"bytes",
")",
":",
"etag",
"=",
"bytes",
"(",
"etag",
",",
"\"utf-8\"",
")",
"self",
".",
"_etag",
".",
"append",
"(",
"etag",
")"
] | Set the ETag of the resource.
:param etag: the ETag | [
"Set",
"the",
"ETag",
"of",
"the",
"resource",
"."
] | python | train |
JoelBender/bacpypes | py25/bacpypes/iocb.py | https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py25/bacpypes/iocb.py#L474-L503 | def get(self, block=1, delay=None):
"""Get a request from a queue, optionally block until a request
is available."""
if _debug: IOQueue._debug("get block=%r delay=%r", block, delay)
# if the queue is empty and we do not block return None
if not block and not self.notempty.isSet(... | [
"def",
"get",
"(",
"self",
",",
"block",
"=",
"1",
",",
"delay",
"=",
"None",
")",
":",
"if",
"_debug",
":",
"IOQueue",
".",
"_debug",
"(",
"\"get block=%r delay=%r\"",
",",
"block",
",",
"delay",
")",
"# if the queue is empty and we do not block return None",
... | Get a request from a queue, optionally block until a request
is available. | [
"Get",
"a",
"request",
"from",
"a",
"queue",
"optionally",
"block",
"until",
"a",
"request",
"is",
"available",
"."
] | python | train |
idlesign/uwsgiconf | uwsgiconf/runtime/monitoring.py | https://github.com/idlesign/uwsgiconf/blob/475407acb44199edbf7e0a66261bfeb51de1afae/uwsgiconf/runtime/monitoring.py#L50-L73 | def set(self, value, mode=None):
"""Sets metric value.
:param int|long value: New value.
:param str|unicode mode: Update mode.
* None - Unconditional update.
* max - Sets metric value if it is greater that the current one.
* min - Sets metric value if it is... | [
"def",
"set",
"(",
"self",
",",
"value",
",",
"mode",
"=",
"None",
")",
":",
"if",
"mode",
"==",
"'max'",
":",
"func",
"=",
"uwsgi",
".",
"metric_set_max",
"elif",
"mode",
"==",
"'min'",
":",
"func",
"=",
"uwsgi",
".",
"metric_set_min",
"else",
":",
... | Sets metric value.
:param int|long value: New value.
:param str|unicode mode: Update mode.
* None - Unconditional update.
* max - Sets metric value if it is greater that the current one.
* min - Sets metric value if it is less that the current one.
:rtype:... | [
"Sets",
"metric",
"value",
"."
] | python | train |
GNS3/gns3-server | gns3server/controller/export_project.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/export_project.py#L202-L227 | def _export_local_images(project, image, z):
"""
Take a project file (.gns3) and export images to the zip
:param image: Image path
:param z: Zipfile instance for the export
"""
from ..compute import MODULES
for module in MODULES:
try:
img_directory = module.instance().g... | [
"def",
"_export_local_images",
"(",
"project",
",",
"image",
",",
"z",
")",
":",
"from",
".",
".",
"compute",
"import",
"MODULES",
"for",
"module",
"in",
"MODULES",
":",
"try",
":",
"img_directory",
"=",
"module",
".",
"instance",
"(",
")",
".",
"get_ima... | Take a project file (.gns3) and export images to the zip
:param image: Image path
:param z: Zipfile instance for the export | [
"Take",
"a",
"project",
"file",
"(",
".",
"gns3",
")",
"and",
"export",
"images",
"to",
"the",
"zip"
] | python | train |
wal-e/wal-e | wal_e/blobstore/__init__.py | https://github.com/wal-e/wal-e/blob/027263860e72a403bc0e1497bb3e67523138e7a2/wal_e/blobstore/__init__.py#L1-L21 | def get_blobstore(layout):
"""Return Blobstore instance for a given storage layout
Args:
layout (StorageLayout): Target storage layout.
"""
if layout.is_s3:
from wal_e.blobstore import s3
blobstore = s3
elif layout.is_wabs:
from wal_e.blobstore import wabs
blo... | [
"def",
"get_blobstore",
"(",
"layout",
")",
":",
"if",
"layout",
".",
"is_s3",
":",
"from",
"wal_e",
".",
"blobstore",
"import",
"s3",
"blobstore",
"=",
"s3",
"elif",
"layout",
".",
"is_wabs",
":",
"from",
"wal_e",
".",
"blobstore",
"import",
"wabs",
"bl... | Return Blobstore instance for a given storage layout
Args:
layout (StorageLayout): Target storage layout. | [
"Return",
"Blobstore",
"instance",
"for",
"a",
"given",
"storage",
"layout",
"Args",
":",
"layout",
"(",
"StorageLayout",
")",
":",
"Target",
"storage",
"layout",
"."
] | python | train |
pywbem/pywbem | try/run_central_instances.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/try/run_central_instances.py#L1096-L1118 | def show_instances(server, cim_class):
"""
Display the instances of the CIM_Class defined by cim_class. If the
namespace is None, use the interop namespace. Search all namespaces for
instances except for CIM_RegisteredProfile
"""
if cim_class == 'CIM_RegisteredProfile':
for inst in serve... | [
"def",
"show_instances",
"(",
"server",
",",
"cim_class",
")",
":",
"if",
"cim_class",
"==",
"'CIM_RegisteredProfile'",
":",
"for",
"inst",
"in",
"server",
".",
"profiles",
":",
"print",
"(",
"inst",
".",
"tomof",
"(",
")",
")",
"return",
"for",
"ns",
"i... | Display the instances of the CIM_Class defined by cim_class. If the
namespace is None, use the interop namespace. Search all namespaces for
instances except for CIM_RegisteredProfile | [
"Display",
"the",
"instances",
"of",
"the",
"CIM_Class",
"defined",
"by",
"cim_class",
".",
"If",
"the",
"namespace",
"is",
"None",
"use",
"the",
"interop",
"namespace",
".",
"Search",
"all",
"namespaces",
"for",
"instances",
"except",
"for",
"CIM_RegisteredProf... | python | train |
phareous/insteonlocal | insteonlocal/Hub.py | https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Hub.py#L155-L159 | def direct_command_hub(self, command):
"""Send direct hub command"""
self.logger.info("direct_command_hub: Command %s", command)
command_url = (self.hub_url + '/3?' + command + "=I=3")
return self.post_direct_command(command_url) | [
"def",
"direct_command_hub",
"(",
"self",
",",
"command",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"direct_command_hub: Command %s\"",
",",
"command",
")",
"command_url",
"=",
"(",
"self",
".",
"hub_url",
"+",
"'/3?'",
"+",
"command",
"+",
"\"=I=... | Send direct hub command | [
"Send",
"direct",
"hub",
"command"
] | python | train |
pypa/pipenv | pipenv/patched/notpip/_internal/download.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/download.py#L950-L971 | def _check_download_dir(link, download_dir, hashes):
# type: (Link, str, Hashes) -> Optional[str]
""" Check download_dir for previously downloaded file with correct hash
If a correct file is found return its path else None
"""
download_path = os.path.join(download_dir, link.filename)
if os.p... | [
"def",
"_check_download_dir",
"(",
"link",
",",
"download_dir",
",",
"hashes",
")",
":",
"# type: (Link, str, Hashes) -> Optional[str]",
"download_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"download_dir",
",",
"link",
".",
"filename",
")",
"if",
"os",
"."... | Check download_dir for previously downloaded file with correct hash
If a correct file is found return its path else None | [
"Check",
"download_dir",
"for",
"previously",
"downloaded",
"file",
"with",
"correct",
"hash",
"If",
"a",
"correct",
"file",
"is",
"found",
"return",
"its",
"path",
"else",
"None"
] | python | train |
ansible/tower-cli | setup.py | https://github.com/ansible/tower-cli/blob/a2b151fed93c47725018d3034848cb3a1814bed7/setup.py#L125-L132 | def combine_files(*args):
"""returns a string of all the strings in *args combined together,
with two line breaks between them"""
file_contents = []
for filename in args:
with codecs.open(filename, mode='r', encoding='utf8') as f:
file_contents.append(f.read())
return "\n\n".join... | [
"def",
"combine_files",
"(",
"*",
"args",
")",
":",
"file_contents",
"=",
"[",
"]",
"for",
"filename",
"in",
"args",
":",
"with",
"codecs",
".",
"open",
"(",
"filename",
",",
"mode",
"=",
"'r'",
",",
"encoding",
"=",
"'utf8'",
")",
"as",
"f",
":",
... | returns a string of all the strings in *args combined together,
with two line breaks between them | [
"returns",
"a",
"string",
"of",
"all",
"the",
"strings",
"in",
"*",
"args",
"combined",
"together",
"with",
"two",
"line",
"breaks",
"between",
"them"
] | python | valid |
gplepage/lsqfit | src/lsqfit/__init__.py | https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/__init__.py#L1261-L1280 | def dump_pmean(self, filename):
""" Dump parameter means (``fit.pmean``) into file ``filename``.
``fit.dump_pmean(filename)`` saves the means of the best-fit
parameter values (``fit.pmean``) from a ``nonlinear_fit`` called
``fit``. These values are recovered using
``p0 = nonline... | [
"def",
"dump_pmean",
"(",
"self",
",",
"filename",
")",
":",
"warnings",
".",
"warn",
"(",
"\"nonlinear_fit.dump_pmean deprecated; use pickle.dump instead\"",
",",
"DeprecationWarning",
",",
")",
"with",
"open",
"(",
"filename",
",",
"\"wb\"",
")",
"as",
"f",
":",... | Dump parameter means (``fit.pmean``) into file ``filename``.
``fit.dump_pmean(filename)`` saves the means of the best-fit
parameter values (``fit.pmean``) from a ``nonlinear_fit`` called
``fit``. These values are recovered using
``p0 = nonlinear_fit.load_parameters(filename)``
w... | [
"Dump",
"parameter",
"means",
"(",
"fit",
".",
"pmean",
")",
"into",
"file",
"filename",
"."
] | python | train |
orsinium/deal | deal/core.py | https://github.com/orsinium/deal/blob/e23c716216543d0080a956250fb45d9e170c3940/deal/core.py#L107-L113 | def patched_function(self, *args, **kwargs):
"""
Step 3. Wrapped function calling.
"""
result = self.function(*args, **kwargs)
self.validate(result)
return result | [
"def",
"patched_function",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"self",
".",
"function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"validate",
"(",
"result",
")",
"return",
"result"
] | Step 3. Wrapped function calling. | [
"Step",
"3",
".",
"Wrapped",
"function",
"calling",
"."
] | python | train |
h2oai/datatable | datatable/utils/terminal.py | https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/datatable/utils/terminal.py#L144-L159 | def wait_for_keypresses(self, refresh_rate=1):
"""
Listen to user's keystrokes and return them to caller one at a time.
The produced values are instances of blessed.keyboard.Keystroke class.
If the user did not press anything with the last `refresh_rate` seconds
the generator wi... | [
"def",
"wait_for_keypresses",
"(",
"self",
",",
"refresh_rate",
"=",
"1",
")",
":",
"if",
"not",
"self",
".",
"_enable_keyboard",
":",
"return",
"with",
"self",
".",
"_blessed_term",
".",
"cbreak",
"(",
")",
":",
"while",
"True",
":",
"yield",
"self",
".... | Listen to user's keystrokes and return them to caller one at a time.
The produced values are instances of blessed.keyboard.Keystroke class.
If the user did not press anything with the last `refresh_rate` seconds
the generator will yield `None`, allowing the caller to perform any
updates... | [
"Listen",
"to",
"user",
"s",
"keystrokes",
"and",
"return",
"them",
"to",
"caller",
"one",
"at",
"a",
"time",
"."
] | python | train |
draios/python-sdc-client | sdcclient/_monitor.py | https://github.com/draios/python-sdc-client/blob/47f83415842048778939b90944f64386a3bcb205/sdcclient/_monitor.py#L36-L69 | def get_notifications(self, from_ts, to_ts, state=None, resolved=None):
'''**Description**
Returns the list of Sysdig Monitor alert notifications.
**Arguments**
- **from_ts**: filter events by start time. Timestamp format is in UTC (seconds).
- **to_ts**: filter even... | [
"def",
"get_notifications",
"(",
"self",
",",
"from_ts",
",",
"to_ts",
",",
"state",
"=",
"None",
",",
"resolved",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"from_ts",
"is",
"not",
"None",
":",
"params",
"[",
"'from'",
"]",
"=",
"from_ts"... | **Description**
Returns the list of Sysdig Monitor alert notifications.
**Arguments**
- **from_ts**: filter events by start time. Timestamp format is in UTC (seconds).
- **to_ts**: filter events by start time. Timestamp format is in UTC (seconds).
- **state**: fi... | [
"**",
"Description",
"**",
"Returns",
"the",
"list",
"of",
"Sysdig",
"Monitor",
"alert",
"notifications",
"."
] | python | test |
h2non/pook | pook/mock.py | https://github.com/h2non/pook/blob/e64094e41e4d89d98d2d29af7608ef27dc50cf19/pook/mock.py#L496-L503 | def persist(self, status=None):
"""
Enables persistent mode for the current mock.
Returns:
self: current Mock instance.
"""
self._persist = status if type(status) is bool else True | [
"def",
"persist",
"(",
"self",
",",
"status",
"=",
"None",
")",
":",
"self",
".",
"_persist",
"=",
"status",
"if",
"type",
"(",
"status",
")",
"is",
"bool",
"else",
"True"
] | Enables persistent mode for the current mock.
Returns:
self: current Mock instance. | [
"Enables",
"persistent",
"mode",
"for",
"the",
"current",
"mock",
"."
] | python | test |
FutunnOpen/futuquant | futuquant/common/event/eventEngine.py | https://github.com/FutunnOpen/futuquant/blob/1512b321845f92ec9c578ce2689aa4e8482669e4/futuquant/common/event/eventEngine.py#L88-L101 | def __process(self, event):
"""处理事件"""
# 检查是否存在对该事件进行监听的处理函数
if event.type_ in self.__handlers:
# 若存在,则按顺序将事件传递给处理函数执行
[handler(event) for handler in self.__handlers[event.type_]]
# 以上语句为Python列表解析方式的写法,对应的常规循环写法为:
#for handler in self... | [
"def",
"__process",
"(",
"self",
",",
"event",
")",
":",
"# 检查是否存在对该事件进行监听的处理函数",
"if",
"event",
".",
"type_",
"in",
"self",
".",
"__handlers",
":",
"# 若存在,则按顺序将事件传递给处理函数执行",
"[",
"handler",
"(",
"event",
")",
"for",
"handler",
"in",
"self",
".",
"__handlers... | 处理事件 | [
"处理事件"
] | python | train |
RJT1990/pyflux | pyflux/garch/garch.py | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/garch/garch.py#L173-L219 | def _mean_prediction(self, sigma2, Y, scores, h, t_params):
""" Creates a h-step ahead mean prediction
Parameters
----------
sigma2 : np.array
The past predicted values
Y : np.array
The past data
scores : np.array
The past scores
... | [
"def",
"_mean_prediction",
"(",
"self",
",",
"sigma2",
",",
"Y",
",",
"scores",
",",
"h",
",",
"t_params",
")",
":",
"# Create arrays to iteratre over",
"sigma2_exp",
"=",
"sigma2",
".",
"copy",
"(",
")",
"scores_exp",
"=",
"scores",
".",
"copy",
"(",
")",... | Creates a h-step ahead mean prediction
Parameters
----------
sigma2 : np.array
The past predicted values
Y : np.array
The past data
scores : np.array
The past scores
h : int
How many steps ahead for the prediction
... | [
"Creates",
"a",
"h",
"-",
"step",
"ahead",
"mean",
"prediction"
] | python | train |
xguse/table_enforcer | table_enforcer/main_classes.py | https://github.com/xguse/table_enforcer/blob/f3137839574bf8ea933a14ea16a8acba45e3e0c3/table_enforcer/main_classes.py#L287-L294 | def recode(self, table: pd.DataFrame, validate=False) -> pd.DataFrame:
"""Pass the appropriate columns through each recoder function sequentially and return the final result.
Args:
table (pd.DataFrame): A dataframe on which to apply recoding logic.
validate (bool): If ``True``, ... | [
"def",
"recode",
"(",
"self",
",",
"table",
":",
"pd",
".",
"DataFrame",
",",
"validate",
"=",
"False",
")",
"->",
"pd",
".",
"DataFrame",
":",
"return",
"self",
".",
"_recode_output",
"(",
"self",
".",
"_recode_input",
"(",
"table",
",",
"validate",
"... | Pass the appropriate columns through each recoder function sequentially and return the final result.
Args:
table (pd.DataFrame): A dataframe on which to apply recoding logic.
validate (bool): If ``True``, recoded table must pass validation tests. | [
"Pass",
"the",
"appropriate",
"columns",
"through",
"each",
"recoder",
"function",
"sequentially",
"and",
"return",
"the",
"final",
"result",
"."
] | python | train |
synw/dataswim | dataswim/data/export.py | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/export.py#L122-L134 | def to_records_(self) -> dict:
"""Returns a list of dictionary records from the main dataframe
:return: a python dictionnary with the data
:rtype: str
:example: ``ds.to_records_()``
"""
try:
dic = self.df.to_dict(orient="records")
return dic
... | [
"def",
"to_records_",
"(",
"self",
")",
"->",
"dict",
":",
"try",
":",
"dic",
"=",
"self",
".",
"df",
".",
"to_dict",
"(",
"orient",
"=",
"\"records\"",
")",
"return",
"dic",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"err",
"(",
"e",
",",... | Returns a list of dictionary records from the main dataframe
:return: a python dictionnary with the data
:rtype: str
:example: ``ds.to_records_()`` | [
"Returns",
"a",
"list",
"of",
"dictionary",
"records",
"from",
"the",
"main",
"dataframe"
] | python | train |
itamarst/crochet | crochet/_resultstore.py | https://github.com/itamarst/crochet/blob/ecfc22cefa90f3dfbafa71883c1470e7294f2b6d/crochet/_resultstore.py#L30-L39 | def store(self, deferred_result):
"""
Store a EventualResult.
Return an integer, a unique identifier that can be used to retrieve
the object.
"""
self._counter += 1
self._stored[self._counter] = deferred_result
return self._counter | [
"def",
"store",
"(",
"self",
",",
"deferred_result",
")",
":",
"self",
".",
"_counter",
"+=",
"1",
"self",
".",
"_stored",
"[",
"self",
".",
"_counter",
"]",
"=",
"deferred_result",
"return",
"self",
".",
"_counter"
] | Store a EventualResult.
Return an integer, a unique identifier that can be used to retrieve
the object. | [
"Store",
"a",
"EventualResult",
"."
] | python | train |
apache/incubator-mxnet | example/deep-embedded-clustering/data.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/deep-embedded-clustering/data.py#L25-L35 | def get_mnist():
""" Gets MNIST dataset """
np.random.seed(1234) # set seed for deterministic ordering
mnist_data = mx.test_utils.get_mnist()
X = np.concatenate([mnist_data['train_data'], mnist_data['test_data']])
Y = np.concatenate([mnist_data['train_label'], mnist_data['test_label']])
p = np.... | [
"def",
"get_mnist",
"(",
")",
":",
"np",
".",
"random",
".",
"seed",
"(",
"1234",
")",
"# set seed for deterministic ordering",
"mnist_data",
"=",
"mx",
".",
"test_utils",
".",
"get_mnist",
"(",
")",
"X",
"=",
"np",
".",
"concatenate",
"(",
"[",
"mnist_dat... | Gets MNIST dataset | [
"Gets",
"MNIST",
"dataset"
] | python | train |
libyal/dtfabric | dtfabric/runtime/data_maps.py | https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L2050-L2065 | def CreateDataTypeMapByType(cls, data_type_definition):
"""Creates a specific data type map by type indicator.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Returns:
DataTypeMap: data type map or None if the date type definition
is not available.
"""
... | [
"def",
"CreateDataTypeMapByType",
"(",
"cls",
",",
"data_type_definition",
")",
":",
"data_type_map_class",
"=",
"cls",
".",
"_MAP_PER_DEFINITION",
".",
"get",
"(",
"data_type_definition",
".",
"TYPE_INDICATOR",
",",
"None",
")",
"if",
"not",
"data_type_map_class",
... | Creates a specific data type map by type indicator.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Returns:
DataTypeMap: data type map or None if the date type definition
is not available. | [
"Creates",
"a",
"specific",
"data",
"type",
"map",
"by",
"type",
"indicator",
"."
] | python | train |
jssimporter/python-jss | jss/jssobject.py | https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jssobject.py#L605-L619 | def add_device(self, device, container):
"""Add a device to a group. Wraps JSSObject.add_object_to_path.
Args:
device: A JSSObject to add (as list data), to this object.
location: Element or a string path argument to find()
"""
# There is a size tag which the JSS... | [
"def",
"add_device",
"(",
"self",
",",
"device",
",",
"container",
")",
":",
"# There is a size tag which the JSS manages for us, so we can",
"# ignore it.",
"if",
"self",
".",
"findtext",
"(",
"\"is_smart\"",
")",
"==",
"\"false\"",
":",
"self",
".",
"add_object_to_p... | Add a device to a group. Wraps JSSObject.add_object_to_path.
Args:
device: A JSSObject to add (as list data), to this object.
location: Element or a string path argument to find() | [
"Add",
"a",
"device",
"to",
"a",
"group",
".",
"Wraps",
"JSSObject",
".",
"add_object_to_path",
"."
] | python | train |
artefactual-labs/agentarchives | agentarchives/atom/client.py | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L370-L395 | def get_resource_component_and_children(
self,
resource_id,
resource_type="collection",
level=1,
sort_data={},
recurse_max_level=False,
sort_by=None,
**kwargs
):
"""
Fetch detailed metadata for the specified resource_id and all of its c... | [
"def",
"get_resource_component_and_children",
"(",
"self",
",",
"resource_id",
",",
"resource_type",
"=",
"\"collection\"",
",",
"level",
"=",
"1",
",",
"sort_data",
"=",
"{",
"}",
",",
"recurse_max_level",
"=",
"False",
",",
"sort_by",
"=",
"None",
",",
"*",
... | Fetch detailed metadata for the specified resource_id and all of its children.
:param str resource_id: The slug for which to fetch description metadata.
:param str resource_type: no-op; not required or used in this implementation.
:param int recurse_max_level: The maximum depth level to fetch w... | [
"Fetch",
"detailed",
"metadata",
"for",
"the",
"specified",
"resource_id",
"and",
"all",
"of",
"its",
"children",
"."
] | python | train |
SheffieldML/GPyOpt | GPyOpt/util/general.py | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/util/general.py#L86-L96 | def get_moments(model,x):
'''
Moments (mean and sdev.) of a GP model at x
'''
input_dim = model.X.shape[1]
x = reshape(x,input_dim)
fmin = min(model.predict(model.X)[0])
m, v = model.predict(x)
s = np.sqrt(np.clip(v, 0, np.inf))
return (m,s, fmin) | [
"def",
"get_moments",
"(",
"model",
",",
"x",
")",
":",
"input_dim",
"=",
"model",
".",
"X",
".",
"shape",
"[",
"1",
"]",
"x",
"=",
"reshape",
"(",
"x",
",",
"input_dim",
")",
"fmin",
"=",
"min",
"(",
"model",
".",
"predict",
"(",
"model",
".",
... | Moments (mean and sdev.) of a GP model at x | [
"Moments",
"(",
"mean",
"and",
"sdev",
".",
")",
"of",
"a",
"GP",
"model",
"at",
"x"
] | python | train |
androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/analysis/analysis.py#L1213-L1318 | def _create_xref(self, current_class):
"""
Create the xref for `current_class`
There are four steps involved in getting the xrefs:
* Xrefs for classes
* for method calls
* for string usage
* for field manipulation
All these information ... | [
"def",
"_create_xref",
"(",
"self",
",",
"current_class",
")",
":",
"cur_cls_name",
"=",
"current_class",
".",
"get_name",
"(",
")",
"log",
".",
"debug",
"(",
"\"Creating XREF/DREF for %s\"",
"%",
"cur_cls_name",
")",
"for",
"current_method",
"in",
"current_class"... | Create the xref for `current_class`
There are four steps involved in getting the xrefs:
* Xrefs for classes
* for method calls
* for string usage
* for field manipulation
All these information are stored in the *Analysis Objects.
Note that thi... | [
"Create",
"the",
"xref",
"for",
"current_class"
] | python | train |
scidash/sciunit | sciunit/utils.py | https://github.com/scidash/sciunit/blob/41b2e38c45c0776727ab1f281a572b65be19cea1/sciunit/utils.py#L334-L339 | def _do_notebook(self, name, convert_notebooks=False):
"""Called by do_notebook to actually run the notebook."""
if convert_notebooks:
self.convert_and_execute_notebook(name)
else:
self.execute_notebook(name) | [
"def",
"_do_notebook",
"(",
"self",
",",
"name",
",",
"convert_notebooks",
"=",
"False",
")",
":",
"if",
"convert_notebooks",
":",
"self",
".",
"convert_and_execute_notebook",
"(",
"name",
")",
"else",
":",
"self",
".",
"execute_notebook",
"(",
"name",
")"
] | Called by do_notebook to actually run the notebook. | [
"Called",
"by",
"do_notebook",
"to",
"actually",
"run",
"the",
"notebook",
"."
] | python | train |
AtomHash/evernode | evernode/classes/app.py | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/app.py#L37-L45 | def __root_path(self):
""" Just checks the root path if set """
if self.root_path is not None:
if os.path.isdir(self.root_path):
sys.path.append(self.root_path)
return
raise RuntimeError('EverNode requires a valid root path.'
... | [
"def",
"__root_path",
"(",
"self",
")",
":",
"if",
"self",
".",
"root_path",
"is",
"not",
"None",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"root_path",
")",
":",
"sys",
".",
"path",
".",
"append",
"(",
"self",
".",
"root_path",... | Just checks the root path if set | [
"Just",
"checks",
"the",
"root",
"path",
"if",
"set"
] | python | train |
CivicSpleen/ambry | ambry/library/__init__.py | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/__init__.py#L411-L419 | def remove(self, bundle):
""" Removes a bundle from the library and deletes the configuration for
it from the library database."""
from six import string_types
if isinstance(bundle, string_types):
bundle = self.bundle(bundle)
self.database.remove_dataset(bundle.data... | [
"def",
"remove",
"(",
"self",
",",
"bundle",
")",
":",
"from",
"six",
"import",
"string_types",
"if",
"isinstance",
"(",
"bundle",
",",
"string_types",
")",
":",
"bundle",
"=",
"self",
".",
"bundle",
"(",
"bundle",
")",
"self",
".",
"database",
".",
"r... | Removes a bundle from the library and deletes the configuration for
it from the library database. | [
"Removes",
"a",
"bundle",
"from",
"the",
"library",
"and",
"deletes",
"the",
"configuration",
"for",
"it",
"from",
"the",
"library",
"database",
"."
] | python | train |
saltstack/salt | salt/modules/yumpkg.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L709-L952 | def list_repo_pkgs(*args, **kwargs):
'''
.. versionadded:: 2014.1.0
.. versionchanged:: 2014.7.0
All available versions of each package are now returned. This required
a slight modification to the structure of the return dict. The return
data shown below reflects the updated return d... | [
"def",
"list_repo_pkgs",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"byrepo",
"=",
"kwargs",
".",
"pop",
"(",
"'byrepo'",
",",
"False",
")",
"cacheonly",
"=",
"kwargs",
".",
"pop",
"(",
"'cacheonly'",
",",
"False",
")",
"fromrepo",
"=",
"kw... | .. versionadded:: 2014.1.0
.. versionchanged:: 2014.7.0
All available versions of each package are now returned. This required
a slight modification to the structure of the return dict. The return
data shown below reflects the updated return dict structure. Note that
packages which a... | [
"..",
"versionadded",
"::",
"2014",
".",
"1",
".",
"0",
"..",
"versionchanged",
"::",
"2014",
".",
"7",
".",
"0",
"All",
"available",
"versions",
"of",
"each",
"package",
"are",
"now",
"returned",
".",
"This",
"required",
"a",
"slight",
"modification",
"... | python | train |
chrisjrn/registrasion | registrasion/controllers/conditions.py | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/conditions.py#L173-L194 | def pre_filter(self, queryset, user):
''' Returns all of the items from queryset where the user has a
product invoking that item's condition in one of their carts. '''
in_user_carts = Q(enabling_products__productitem__cart__user=user)
released = commerce.Cart.STATUS_RELEASED
pai... | [
"def",
"pre_filter",
"(",
"self",
",",
"queryset",
",",
"user",
")",
":",
"in_user_carts",
"=",
"Q",
"(",
"enabling_products__productitem__cart__user",
"=",
"user",
")",
"released",
"=",
"commerce",
".",
"Cart",
".",
"STATUS_RELEASED",
"paid",
"=",
"commerce",
... | Returns all of the items from queryset where the user has a
product invoking that item's condition in one of their carts. | [
"Returns",
"all",
"of",
"the",
"items",
"from",
"queryset",
"where",
"the",
"user",
"has",
"a",
"product",
"invoking",
"that",
"item",
"s",
"condition",
"in",
"one",
"of",
"their",
"carts",
"."
] | python | test |
UUDigitalHumanitieslab/tei_reader | tei_reader/models/element.py | https://github.com/UUDigitalHumanitieslab/tei_reader/blob/7b19c34a9d7cc941a36ecdcf6f361e26c6488697/tei_reader/models/element.py#L32-L51 | def divisions(self):
"""
Recursively get all the text divisions directly part of this element. If an element contains parts or text without tag. Those will be returned in order and wrapped with a TextDivision.
"""
from .placeholder_division import PlaceholderDivision
pl... | [
"def",
"divisions",
"(",
"self",
")",
":",
"from",
".",
"placeholder_division",
"import",
"PlaceholderDivision",
"placeholder",
"=",
"None",
"for",
"item",
"in",
"self",
".",
"__parts_and_divisions",
":",
"if",
"item",
".",
"tag",
"==",
"'part'",
":",
"if",
... | Recursively get all the text divisions directly part of this element. If an element contains parts or text without tag. Those will be returned in order and wrapped with a TextDivision. | [
"Recursively",
"get",
"all",
"the",
"text",
"divisions",
"directly",
"part",
"of",
"this",
"element",
".",
"If",
"an",
"element",
"contains",
"parts",
"or",
"text",
"without",
"tag",
".",
"Those",
"will",
"be",
"returned",
"in",
"order",
"and",
"wrapped",
... | python | train |
Genida/archan | src/archan/config.py | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/config.py#L103-L108 | def from_file(path):
"""Return a ``Config`` instance by reading a configuration file."""
with open(path) as stream:
obj = yaml.safe_load(stream)
Config.lint(obj)
return Config(config_dict=obj) | [
"def",
"from_file",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"stream",
":",
"obj",
"=",
"yaml",
".",
"safe_load",
"(",
"stream",
")",
"Config",
".",
"lint",
"(",
"obj",
")",
"return",
"Config",
"(",
"config_dict",
"=",
"obj",
... | Return a ``Config`` instance by reading a configuration file. | [
"Return",
"a",
"Config",
"instance",
"by",
"reading",
"a",
"configuration",
"file",
"."
] | python | train |
christophertbrown/bioscripts | ctbBio/rRNA_insertions.py | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L104-L126 | def find_orfs(fa, seqs):
"""
find orfs and see if they overlap with insertions
# seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]]
"""
faa = '%s.prodigal.faa' % (fa)
fna = '%s.prodigal.fna' % (fa)
gbk = '%s.prodigal.gbk' % (fa)
if os.path.exist... | [
"def",
"find_orfs",
"(",
"fa",
",",
"seqs",
")",
":",
"faa",
"=",
"'%s.prodigal.faa'",
"%",
"(",
"fa",
")",
"fna",
"=",
"'%s.prodigal.fna'",
"%",
"(",
"fa",
")",
"gbk",
"=",
"'%s.prodigal.gbk'",
"%",
"(",
"fa",
")",
"if",
"os",
".",
"path",
".",
"e... | find orfs and see if they overlap with insertions
# seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]] | [
"find",
"orfs",
"and",
"see",
"if",
"they",
"overlap",
"with",
"insertions",
"#",
"seqs",
"[",
"id",
"]",
"=",
"[",
"gene",
"model",
"[[",
"i",
"-",
"gene_pos",
"i",
"-",
"model_pos",
"i",
"-",
"length",
"iseq",
"[",
"orfs",
"]",
"[",
"introns",
"]... | python | train |
LogicalDash/LiSE | ELiDE/ELiDE/card.py | https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/card.py#L951-L959 | def upd_scroll(self, *args):
"""Update my own ``scroll`` property to where my deck is actually
scrolled.
"""
att = 'deck_{}_hint_offsets'.format(
'x' if self.orientation == 'horizontal' else 'y'
)
self._scroll = getattr(self.deckbuilder, att)[self.deckidx] | [
"def",
"upd_scroll",
"(",
"self",
",",
"*",
"args",
")",
":",
"att",
"=",
"'deck_{}_hint_offsets'",
".",
"format",
"(",
"'x'",
"if",
"self",
".",
"orientation",
"==",
"'horizontal'",
"else",
"'y'",
")",
"self",
".",
"_scroll",
"=",
"getattr",
"(",
"self"... | Update my own ``scroll`` property to where my deck is actually
scrolled. | [
"Update",
"my",
"own",
"scroll",
"property",
"to",
"where",
"my",
"deck",
"is",
"actually",
"scrolled",
"."
] | python | train |
tensorflow/datasets | tensorflow_datasets/core/utils/gcs_utils.py | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/utils/gcs_utils.py#L60-L66 | def gcs_dataset_info_files(dataset_dir):
"""Return paths to GCS files in the given dataset directory."""
prefix = posixpath.join(GCS_DATASET_INFO_DIR, dataset_dir, "")
# Filter for this dataset
filenames = [el for el in gcs_files(prefix_filter=prefix)
if el.startswith(prefix) and len(el) > len(pr... | [
"def",
"gcs_dataset_info_files",
"(",
"dataset_dir",
")",
":",
"prefix",
"=",
"posixpath",
".",
"join",
"(",
"GCS_DATASET_INFO_DIR",
",",
"dataset_dir",
",",
"\"\"",
")",
"# Filter for this dataset",
"filenames",
"=",
"[",
"el",
"for",
"el",
"in",
"gcs_files",
"... | Return paths to GCS files in the given dataset directory. | [
"Return",
"paths",
"to",
"GCS",
"files",
"in",
"the",
"given",
"dataset",
"directory",
"."
] | python | train |
sbarham/dsrt | dsrt/models/Decoder.py | https://github.com/sbarham/dsrt/blob/bc664739f2f52839461d3e72773b71146fd56a9a/dsrt/models/Decoder.py#L34-L81 | def build(self):
"""
The decoder computational graph consists of three components:
(1) the input node `decoder_input`
(2) the embedding node `decoder_embed`
(3) the recurrent (RNN) part `decoder_rnn`
(4) the output of th... | [
"def",
"build",
"(",
"self",
")",
":",
"# Grab hyperparameters from self.config:",
"hidden_dim",
"=",
"self",
".",
"config",
"[",
"'encoding-layer-width'",
"]",
"recurrent_unit",
"=",
"self",
".",
"config",
"[",
"'recurrent-unit-type'",
"]",
"bidirectional",
"=",
"F... | The decoder computational graph consists of three components:
(1) the input node `decoder_input`
(2) the embedding node `decoder_embed`
(3) the recurrent (RNN) part `decoder_rnn`
(4) the output of the decoder RNN `decoder_output`... | [
"The",
"decoder",
"computational",
"graph",
"consists",
"of",
"three",
"components",
":",
"(",
"1",
")",
"the",
"input",
"node",
"decoder_input",
"(",
"2",
")",
"the",
"embedding",
"node",
"decoder_embed",
"(",
"3",
")",
"the",
"recurrent",
"(",
"RNN",
")"... | python | train |
MillionIntegrals/vel | vel/rl/api/replay_buffer.py | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/api/replay_buffer.py#L29-L38 | def sample_forward_transitions(self, batch_size, batch_info, forward_steps: int,
discount_factor: float) -> Transitions:
"""
Sample transitions from replay buffer with _forward steps_.
That is, instead of getting a transition s_t -> s_t+1 with reward r,
... | [
"def",
"sample_forward_transitions",
"(",
"self",
",",
"batch_size",
",",
"batch_info",
",",
"forward_steps",
":",
"int",
",",
"discount_factor",
":",
"float",
")",
"->",
"Transitions",
":",
"raise",
"NotImplementedError"
] | Sample transitions from replay buffer with _forward steps_.
That is, instead of getting a transition s_t -> s_t+1 with reward r,
get a transition s_t -> s_t+n with sum of intermediate rewards.
Used in a variant of Deep Q-Learning | [
"Sample",
"transitions",
"from",
"replay",
"buffer",
"with",
"_forward",
"steps_",
".",
"That",
"is",
"instead",
"of",
"getting",
"a",
"transition",
"s_t",
"-",
">",
"s_t",
"+",
"1",
"with",
"reward",
"r",
"get",
"a",
"transition",
"s_t",
"-",
">",
"s_t"... | python | train |
common-workflow-language/cwltool | cwltool/main.py | https://github.com/common-workflow-language/cwltool/blob/cb81b22abc52838823da9945f04d06739ab32fda/cwltool/main.py#L903-L910 | def run(*args, **kwargs):
# type: (...) -> None
"""Run cwltool."""
signal.signal(signal.SIGTERM, _signal_handler)
try:
sys.exit(main(*args, **kwargs))
finally:
_terminate_processes() | [
"def",
"run",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> None",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGTERM",
",",
"_signal_handler",
")",
"try",
":",
"sys",
".",
"exit",
"(",
"main",
"(",
"*",
"args",
",",
"*",
... | Run cwltool. | [
"Run",
"cwltool",
"."
] | python | train |
hubo1016/vlcp | vlcp/event/future.py | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/future.py#L99-L109 | def set_exception(self, exception):
'''
Set an exception to Future object, wake up all the waiters
:param exception: exception to set
'''
if hasattr(self, '_result'):
raise ValueError('Cannot set the result twice')
self._result = None
self._ex... | [
"def",
"set_exception",
"(",
"self",
",",
"exception",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_result'",
")",
":",
"raise",
"ValueError",
"(",
"'Cannot set the result twice'",
")",
"self",
".",
"_result",
"=",
"None",
"self",
".",
"_exception",
"=",
... | Set an exception to Future object, wake up all the waiters
:param exception: exception to set | [
"Set",
"an",
"exception",
"to",
"Future",
"object",
"wake",
"up",
"all",
"the",
"waiters",
":",
"param",
"exception",
":",
"exception",
"to",
"set"
] | python | train |
Microsoft/nni | examples/trials/sklearn/regression/main.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/sklearn/regression/main.py#L55-L77 | def get_model(PARAMS):
'''Get model according to parameters'''
model_dict = {
'LinearRegression': LinearRegression(),
'SVR': SVR(),
'KNeighborsRegressor': KNeighborsRegressor(),
'DecisionTreeRegressor': DecisionTreeRegressor()
}
if not model_dict.get(PARAMS['model_name'])... | [
"def",
"get_model",
"(",
"PARAMS",
")",
":",
"model_dict",
"=",
"{",
"'LinearRegression'",
":",
"LinearRegression",
"(",
")",
",",
"'SVR'",
":",
"SVR",
"(",
")",
",",
"'KNeighborsRegressor'",
":",
"KNeighborsRegressor",
"(",
")",
",",
"'DecisionTreeRegressor'",
... | Get model according to parameters | [
"Get",
"model",
"according",
"to",
"parameters"
] | python | train |
fishtown-analytics/dbt | core/dbt/adapters/base/impl.py | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/adapters/base/impl.py#L50-L65 | def _catalog_filter_schemas(manifest):
"""Return a function that takes a row and decides if the row should be
included in the catalog output.
"""
schemas = frozenset((d.lower(), s.lower())
for d, s in manifest.get_used_schemas())
def test(row):
table_database = _expe... | [
"def",
"_catalog_filter_schemas",
"(",
"manifest",
")",
":",
"schemas",
"=",
"frozenset",
"(",
"(",
"d",
".",
"lower",
"(",
")",
",",
"s",
".",
"lower",
"(",
")",
")",
"for",
"d",
",",
"s",
"in",
"manifest",
".",
"get_used_schemas",
"(",
")",
")",
... | Return a function that takes a row and decides if the row should be
included in the catalog output. | [
"Return",
"a",
"function",
"that",
"takes",
"a",
"row",
"and",
"decides",
"if",
"the",
"row",
"should",
"be",
"included",
"in",
"the",
"catalog",
"output",
"."
] | python | train |
axiom-data-science/pyaxiom | pyaxiom/utils.py | https://github.com/axiom-data-science/pyaxiom/blob/7ea7626695abf095df6a67f66e5b3e9ae91b16df/pyaxiom/utils.py#L167-L233 | def dictify_urn(urn, combine_interval=True):
"""
By default, this will put the `interval` as part of the `cell_methods`
attribute (NetCDF CF style). To return `interval` as its own key, use
the `combine_interval=False` parameter.
"""
ioos_urn = IoosUrn.from_string(urn)
if ioos_u... | [
"def",
"dictify_urn",
"(",
"urn",
",",
"combine_interval",
"=",
"True",
")",
":",
"ioos_urn",
"=",
"IoosUrn",
".",
"from_string",
"(",
"urn",
")",
"if",
"ioos_urn",
".",
"valid",
"(",
")",
"is",
"False",
":",
"return",
"dict",
"(",
")",
"if",
"ioos_urn... | By default, this will put the `interval` as part of the `cell_methods`
attribute (NetCDF CF style). To return `interval` as its own key, use
the `combine_interval=False` parameter. | [
"By",
"default",
"this",
"will",
"put",
"the",
"interval",
"as",
"part",
"of",
"the",
"cell_methods",
"attribute",
"(",
"NetCDF",
"CF",
"style",
")",
".",
"To",
"return",
"interval",
"as",
"its",
"own",
"key",
"use",
"the",
"combine_interval",
"=",
"False"... | python | valid |
CalebBell/ht | ht/conv_jacket.py | https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conv_jacket.py#L152-L332 | def Stein_Schmidt(m, Dtank, Djacket, H, Dinlet,
rho, Cp, k, mu, muw=None, rhow=None,
inlettype='tangential', inletlocation='auto', roughness=0):
r'''Calculates average heat transfer coefficient for a jacket around a
vessel according to [1]_ as described in [2]_.
.. math:... | [
"def",
"Stein_Schmidt",
"(",
"m",
",",
"Dtank",
",",
"Djacket",
",",
"H",
",",
"Dinlet",
",",
"rho",
",",
"Cp",
",",
"k",
",",
"mu",
",",
"muw",
"=",
"None",
",",
"rhow",
"=",
"None",
",",
"inlettype",
"=",
"'tangential'",
",",
"inletlocation",
"="... | r'''Calculates average heat transfer coefficient for a jacket around a
vessel according to [1]_ as described in [2]_.
.. math::
l_{ch} = \left[\left(\frac{\pi}{2}\right)^2 D_{tank}^2+H^2\right]^{0.5}
d_{ch} = 2\delta
Re_j = \frac{v_{ch}d_{ch}\rho}{\mu}
Gr_J = \frac{g\rho(\rho... | [
"r",
"Calculates",
"average",
"heat",
"transfer",
"coefficient",
"for",
"a",
"jacket",
"around",
"a",
"vessel",
"according",
"to",
"[",
"1",
"]",
"_",
"as",
"described",
"in",
"[",
"2",
"]",
"_",
"."
] | python | train |
bkjones/pyrabbit | pyrabbit/api.py | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L544-L557 | def purge_queues(self, queues):
"""
Purge all messages from one or more queues.
:param list queues: A list of ('qname', 'vhost') tuples.
:returns: True on success
"""
for name, vhost in queues:
vhost = quote(vhost, '')
name = quote(name, '')
... | [
"def",
"purge_queues",
"(",
"self",
",",
"queues",
")",
":",
"for",
"name",
",",
"vhost",
"in",
"queues",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"name",
"=",
"quote",
"(",
"name",
",",
"''",
")",
"path",
"=",
"Client",
".",
"ur... | Purge all messages from one or more queues.
:param list queues: A list of ('qname', 'vhost') tuples.
:returns: True on success | [
"Purge",
"all",
"messages",
"from",
"one",
"or",
"more",
"queues",
"."
] | python | train |
trevisanj/f311 | f311/collaboration.py | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/collaboration.py#L248-L273 | def get_programs_dict(pkgname_only=None, flag_protected=False):
"""
Scans COLLABORATORS_S packages for scripts, eventually filtering if arguments passed
Args:
pkgname_only: name of single package within COLLABORATORS_S
flag_protected: include scripts starting with "_"?
Returns:
... | [
"def",
"get_programs_dict",
"(",
"pkgname_only",
"=",
"None",
",",
"flag_protected",
"=",
"False",
")",
":",
"___ret",
"=",
"_get_programs_dict",
"(",
")",
"__ret",
"=",
"___ret",
"if",
"pkgname_only",
"is",
"None",
"else",
"OrderedDict",
"(",
"(",
"(",
"pkg... | Scans COLLABORATORS_S packages for scripts, eventually filtering if arguments passed
Args:
pkgname_only: name of single package within COLLABORATORS_S
flag_protected: include scripts starting with "_"?
Returns:
dictionary: {"packagename0": {"exeinfo": [ExeInfo00, ...], "description": d... | [
"Scans",
"COLLABORATORS_S",
"packages",
"for",
"scripts",
"eventually",
"filtering",
"if",
"arguments",
"passed"
] | python | train |
DistrictDataLabs/yellowbrick | yellowbrick/utils/nan_warnings.py | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/utils/nan_warnings.py#L56-L66 | def warn_if_nans_exist(X):
"""Warn if nans exist in a numpy array."""
null_count = count_rows_with_nans(X)
total = len(X)
percent = 100 * null_count / total
if null_count > 0:
warning_message = \
'Warning! Found {} rows of {} ({:0.2f}%) with nan values. Only ' \
'com... | [
"def",
"warn_if_nans_exist",
"(",
"X",
")",
":",
"null_count",
"=",
"count_rows_with_nans",
"(",
"X",
")",
"total",
"=",
"len",
"(",
"X",
")",
"percent",
"=",
"100",
"*",
"null_count",
"/",
"total",
"if",
"null_count",
">",
"0",
":",
"warning_message",
"... | Warn if nans exist in a numpy array. | [
"Warn",
"if",
"nans",
"exist",
"in",
"a",
"numpy",
"array",
"."
] | python | train |
jleclanche/fireplace | fireplace/cards/__init__.py | https://github.com/jleclanche/fireplace/blob/d0fc0e97e185c0210de86631be20638659c0609e/fireplace/cards/__init__.py#L96-L125 | def filter(self, **kwargs):
"""
Returns a list of card IDs matching the given filters. Each filter, if not
None, is matched against the registered card database.
cards.
Examples arguments:
\a collectible: Whether the card is collectible or not.
\a type: The type of the card (hearthstone.enums.CardType)
... | [
"def",
"filter",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"initialized",
":",
"self",
".",
"initialize",
"(",
")",
"cards",
"=",
"self",
".",
"values",
"(",
")",
"if",
"\"type\"",
"not",
"in",
"kwargs",
":",
"kwargs... | Returns a list of card IDs matching the given filters. Each filter, if not
None, is matched against the registered card database.
cards.
Examples arguments:
\a collectible: Whether the card is collectible or not.
\a type: The type of the card (hearthstone.enums.CardType)
\a race: The race (tribe) of the car... | [
"Returns",
"a",
"list",
"of",
"card",
"IDs",
"matching",
"the",
"given",
"filters",
".",
"Each",
"filter",
"if",
"not",
"None",
"is",
"matched",
"against",
"the",
"registered",
"card",
"database",
".",
"cards",
".",
"Examples",
"arguments",
":",
"\\",
"a",... | python | train |
GPflow/GPflow | gpflow/actions.py | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/actions.py#L211-L227 | def with_settings(self,
stop: Optional[int] = None,
start: int = 0,
step: int = 1) -> 'Loop':
"""
Set start, stop and step loop configuration.
:param stop: Looop stop iteration integer. If None then loop
becomes infinite.
:para... | [
"def",
"with_settings",
"(",
"self",
",",
"stop",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"start",
":",
"int",
"=",
"0",
",",
"step",
":",
"int",
"=",
"1",
")",
"->",
"'Loop'",
":",
"self",
".",
"start",
"=",
"start",
"self",
".",
"... | Set start, stop and step loop configuration.
:param stop: Looop stop iteration integer. If None then loop
becomes infinite.
:param start: Loop iteration start integer.
:param step: Loop iteration interval integer.
:return: Loop itself. | [
"Set",
"start",
"stop",
"and",
"step",
"loop",
"configuration",
"."
] | python | train |
pycontribs/pyrax | pyrax/utils.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L426-L466 | def _wait_until(obj, att, desired, callback, interval, attempts, verbose,
verbose_atts):
"""
Loops until either the desired value of the attribute is reached, or the
number of attempts is exceeded.
"""
if not isinstance(desired, (list, tuple)):
desired = [desired]
if verbose_atts... | [
"def",
"_wait_until",
"(",
"obj",
",",
"att",
",",
"desired",
",",
"callback",
",",
"interval",
",",
"attempts",
",",
"verbose",
",",
"verbose_atts",
")",
":",
"if",
"not",
"isinstance",
"(",
"desired",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
... | Loops until either the desired value of the attribute is reached, or the
number of attempts is exceeded. | [
"Loops",
"until",
"either",
"the",
"desired",
"value",
"of",
"the",
"attribute",
"is",
"reached",
"or",
"the",
"number",
"of",
"attempts",
"is",
"exceeded",
"."
] | python | train |
dropbox/stone | stone/backends/obj_c_types.py | https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backends/obj_c_types.py#L1265-L1376 | def _generate_route_objects_m(self, route_schema, namespace):
"""Emits implementation files for Route objects which encapsulate information
regarding each route. These objects are passed as parameters when route calls are made."""
output_path = 'Routes/RouteObjects/{}.m'.format(
fmt_... | [
"def",
"_generate_route_objects_m",
"(",
"self",
",",
"route_schema",
",",
"namespace",
")",
":",
"output_path",
"=",
"'Routes/RouteObjects/{}.m'",
".",
"format",
"(",
"fmt_route_obj_class",
"(",
"namespace",
".",
"name",
")",
")",
"with",
"self",
".",
"output_to_... | Emits implementation files for Route objects which encapsulate information
regarding each route. These objects are passed as parameters when route calls are made. | [
"Emits",
"implementation",
"files",
"for",
"Route",
"objects",
"which",
"encapsulate",
"information",
"regarding",
"each",
"route",
".",
"These",
"objects",
"are",
"passed",
"as",
"parameters",
"when",
"route",
"calls",
"are",
"made",
"."
] | python | train |
saltstack/salt | salt/states/postgres_schema.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/postgres_schema.py#L31-L106 | def present(dbname, name,
owner=None, user=None,
db_user=None, db_password=None,
db_host=None, db_port=None):
'''
Ensure that the named schema is present in the database.
dbname
The database's name will work on
name
The name of the schema to manage
... | [
"def",
"present",
"(",
"dbname",
",",
"name",
",",
"owner",
"=",
"None",
",",
"user",
"=",
"None",
",",
"db_user",
"=",
"None",
",",
"db_password",
"=",
"None",
",",
"db_host",
"=",
"None",
",",
"db_port",
"=",
"None",
")",
":",
"ret",
"=",
"{",
... | Ensure that the named schema is present in the database.
dbname
The database's name will work on
name
The name of the schema to manage
user
system user all operations should be performed on behalf of
db_user
database username if different from config or default
d... | [
"Ensure",
"that",
"the",
"named",
"schema",
"is",
"present",
"in",
"the",
"database",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.