repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
Wessie/hurler | hurler/filters.py | https://github.com/Wessie/hurler/blob/5719000237e24df9f24fb8229f1153ebfa684972/hurler/filters.py#L48-L61 | def check_filter(self, args, kwargs):
"""
Calls all filters in the :attr:`_filters` list and if all of them
return :const:`True` will return :const:`True`. If any of the filters
return :const:`False` will return :const:`True` instead.
This method is equal to the following snippe... | [
"def",
"check_filter",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"for",
"f",
"in",
"self",
".",
"_filters",
":",
"if",
"not",
"f",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"False",
"return",
"True"
] | Calls all filters in the :attr:`_filters` list and if all of them
return :const:`True` will return :const:`True`. If any of the filters
return :const:`False` will return :const:`True` instead.
This method is equal to the following snippet:
`all(f(*args, **kwargs) for f in self.filte... | [
"Calls",
"all",
"filters",
"in",
"the",
":",
"attr",
":",
"_filters",
"list",
"and",
"if",
"all",
"of",
"them",
"return",
":",
"const",
":",
"True",
"will",
"return",
":",
"const",
":",
"True",
".",
"If",
"any",
"of",
"the",
"filters",
"return",
":",... | python | train | 35.857143 |
hellysmile/django-activeurl | django_activeurl/templatetags/activeurl.py | https://github.com/hellysmile/django-activeurl/blob/40d7f01b217641705fc5b7fe387e28e48ce332dc/django_activeurl/templatetags/activeurl.py#L27-L53 | def render_tag(self, context, kwargs, nodelist):
'''render content with "active" urls logic'''
# load configuration from passed options
self.load_configuration(**kwargs)
# get request from context
request = context['request']
# get full path from request
self.fu... | [
"def",
"render_tag",
"(",
"self",
",",
"context",
",",
"kwargs",
",",
"nodelist",
")",
":",
"# load configuration from passed options",
"self",
".",
"load_configuration",
"(",
"*",
"*",
"kwargs",
")",
"# get request from context",
"request",
"=",
"context",
"[",
"... | render content with "active" urls logic | [
"render",
"content",
"with",
"active",
"urls",
"logic"
] | python | train | 28.851852 |
aleju/imgaug | imgaug/imgaug.py | https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/imgaug.py#L221-L240 | def is_callable(val):
"""
Checks whether a variable is a callable, e.g. a function.
Parameters
----------
val
The variable to check.
Returns
-------
bool
True if the variable is a callable. Otherwise False.
"""
# python 3.x with x <= 2 does not support callable... | [
"def",
"is_callable",
"(",
"val",
")",
":",
"# python 3.x with x <= 2 does not support callable(), apparently",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"3",
"and",
"sys",
".",
"version_info",
"[",
"1",
"]",
"<=",
"2",
":",
"return",
"hasattr",
"... | Checks whether a variable is a callable, e.g. a function.
Parameters
----------
val
The variable to check.
Returns
-------
bool
True if the variable is a callable. Otherwise False. | [
"Checks",
"whether",
"a",
"variable",
"is",
"a",
"callable",
"e",
".",
"g",
".",
"a",
"function",
"."
] | python | valid | 22.8 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/isoline.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/isoline.py#L214-L222 | def _compute_iso_color(self):
""" compute LineVisual color from level index and corresponding level
color
"""
level_color = []
colors = self._lc
for i, index in enumerate(self._li):
level_color.append(np.zeros((index, 4)) + colors[i])
self._cl = np.vst... | [
"def",
"_compute_iso_color",
"(",
"self",
")",
":",
"level_color",
"=",
"[",
"]",
"colors",
"=",
"self",
".",
"_lc",
"for",
"i",
",",
"index",
"in",
"enumerate",
"(",
"self",
".",
"_li",
")",
":",
"level_color",
".",
"append",
"(",
"np",
".",
"zeros"... | compute LineVisual color from level index and corresponding level
color | [
"compute",
"LineVisual",
"color",
"from",
"level",
"index",
"and",
"corresponding",
"level",
"color"
] | python | train | 36.444444 |
klen/muffin | muffin/app.py | https://github.com/klen/muffin/blob/7bc891e174e08b62d1ae232b5d45f8cd8bc82112/muffin/app.py#L194-L231 | def install(self, plugin, name=None, **opts):
"""Install plugin to the application."""
source = plugin
if isinstance(plugin, str):
module, _, attr = plugin.partition(':')
module = import_module(module)
plugin = getattr(module, attr or 'Plugin', None)
... | [
"def",
"install",
"(",
"self",
",",
"plugin",
",",
"name",
"=",
"None",
",",
"*",
"*",
"opts",
")",
":",
"source",
"=",
"plugin",
"if",
"isinstance",
"(",
"plugin",
",",
"str",
")",
":",
"module",
",",
"_",
",",
"attr",
"=",
"plugin",
".",
"parti... | Install plugin to the application. | [
"Install",
"plugin",
"to",
"the",
"application",
"."
] | python | train | 30.973684 |
CivicSpleen/ambry | ambry/bundle/process.py | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L171-L175 | def update_done(self, *args, **kwargs):
"""Clear out the previous update"""
kwargs['state'] = 'done'
self.update(*args, **kwargs)
self.rec = None | [
"def",
"update_done",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'state'",
"]",
"=",
"'done'",
"self",
".",
"update",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"rec",
"=",
"None"
] | Clear out the previous update | [
"Clear",
"out",
"the",
"previous",
"update"
] | python | train | 34.6 |
googlefonts/ufo2ft | Lib/ufo2ft/util.py | https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/util.py#L221-L229 | def closeGlyphsOverGSUB(gsub, glyphs):
""" Use the FontTools subsetter to perform a closure over the GSUB table
given the initial `glyphs` (set of glyph names, str). Update the set
in-place adding all the glyph names that can be reached via GSUB
substitutions from this initial set.
"""
subsetter... | [
"def",
"closeGlyphsOverGSUB",
"(",
"gsub",
",",
"glyphs",
")",
":",
"subsetter",
"=",
"subset",
".",
"Subsetter",
"(",
")",
"subsetter",
".",
"glyphs",
"=",
"glyphs",
"gsub",
".",
"closure_glyphs",
"(",
"subsetter",
")"
] | Use the FontTools subsetter to perform a closure over the GSUB table
given the initial `glyphs` (set of glyph names, str). Update the set
in-place adding all the glyph names that can be reached via GSUB
substitutions from this initial set. | [
"Use",
"the",
"FontTools",
"subsetter",
"to",
"perform",
"a",
"closure",
"over",
"the",
"GSUB",
"table",
"given",
"the",
"initial",
"glyphs",
"(",
"set",
"of",
"glyph",
"names",
"str",
")",
".",
"Update",
"the",
"set",
"in",
"-",
"place",
"adding",
"all"... | python | train | 44.222222 |
softlayer/softlayer-python | SoftLayer/API.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/API.py#L193-L265 | def call(self, service, method, *args, **kwargs):
"""Make a SoftLayer API call.
:param method: the method to call on the service
:param \\*args: (optional) arguments for the remote call
:param id: (optional) id for the resource
:param mask: (optional) object mask
:param ... | [
"def",
"call",
"(",
"self",
",",
"service",
",",
"method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"pop",
"(",
"'iter'",
",",
"False",
")",
":",
"# Most of the codebase assumes a non-generator will be returned, so casting to lis... | Make a SoftLayer API call.
:param method: the method to call on the service
:param \\*args: (optional) arguments for the remote call
:param id: (optional) id for the resource
:param mask: (optional) object mask
:param dict filter: (optional) filter dict
:param dict heade... | [
"Make",
"a",
"SoftLayer",
"API",
"call",
"."
] | python | train | 40.219178 |
Qiskit/qiskit-terra | qiskit/pulse/channels/pulse_channels.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/channels/pulse_channels.py#L25-L36 | def includes(self, lo_freq: float) -> bool:
"""Whether `lo_freq` is within the `LoRange`.
Args:
lo_freq: LO frequency to be checked
Returns:
bool: True if lo_freq is included in this range, otherwise False
"""
if self._lb <= lo_freq <= self._ub:
... | [
"def",
"includes",
"(",
"self",
",",
"lo_freq",
":",
"float",
")",
"->",
"bool",
":",
"if",
"self",
".",
"_lb",
"<=",
"lo_freq",
"<=",
"self",
".",
"_ub",
":",
"return",
"True",
"return",
"False"
] | Whether `lo_freq` is within the `LoRange`.
Args:
lo_freq: LO frequency to be checked
Returns:
bool: True if lo_freq is included in this range, otherwise False | [
"Whether",
"lo_freq",
"is",
"within",
"the",
"LoRange",
"."
] | python | test | 28.75 |
pyQode/pyqode.core | pyqode/core/api/code_edit.py | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/api/code_edit.py#L1254-L1261 | def _init_settings(self):
""" Init setting """
self._show_whitespaces = False
self._tab_length = 4
self._use_spaces_instead_of_tabs = True
self.setTabStopWidth(self._tab_length *
self.fontMetrics().width(" "))
self._set_whitespaces_flags(self.... | [
"def",
"_init_settings",
"(",
"self",
")",
":",
"self",
".",
"_show_whitespaces",
"=",
"False",
"self",
".",
"_tab_length",
"=",
"4",
"self",
".",
"_use_spaces_instead_of_tabs",
"=",
"True",
"self",
".",
"setTabStopWidth",
"(",
"self",
".",
"_tab_length",
"*",... | Init setting | [
"Init",
"setting"
] | python | train | 41.375 |
EventTeam/beliefs | src/beliefs/beliefstate.py | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/beliefstate.py#L134-L169 | def find_path(self, test_function=None, on_targets=False):
"""
General helper method that iterates breadth-first over the referential_domain's
cells and returns a path where the test_function is True
"""
assert self.has_referential_domain(), "need context set"
if not tes... | [
"def",
"find_path",
"(",
"self",
",",
"test_function",
"=",
"None",
",",
"on_targets",
"=",
"False",
")",
":",
"assert",
"self",
".",
"has_referential_domain",
"(",
")",
",",
"\"need context set\"",
"if",
"not",
"test_function",
":",
"test_function",
"=",
"lam... | General helper method that iterates breadth-first over the referential_domain's
cells and returns a path where the test_function is True | [
"General",
"helper",
"method",
"that",
"iterates",
"breadth",
"-",
"first",
"over",
"the",
"referential_domain",
"s",
"cells",
"and",
"returns",
"a",
"path",
"where",
"the",
"test_function",
"is",
"True"
] | python | train | 39 |
dims/etcd3-gateway | etcd3gw/lease.py | https://github.com/dims/etcd3-gateway/blob/ad566c29cbde135aee20cfd32e0a4815ca3b5ee6/etcd3gw/lease.py#L40-L51 | def ttl(self):
"""LeaseTimeToLive retrieves lease information.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
:return:
"""
result = sel... | [
"def",
"ttl",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"client",
".",
"post",
"(",
"self",
".",
"client",
".",
"get_url",
"(",
"\"/kv/lease/timetolive\"",
")",
",",
"json",
"=",
"{",
"\"ID\"",
":",
"self",
".",
"id",
"}",
")",
"return",
"... | LeaseTimeToLive retrieves lease information.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
:return: | [
"LeaseTimeToLive",
"retrieves",
"lease",
"information",
"."
] | python | train | 38.083333 |
saltstack/salt | salt/modules/boto_iam.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_iam.py#L2006-L2027 | def detach_user_policy(policy_name, user_name,
region=None, key=None, keyid=None, profile=None):
'''
Detach a managed policy to a user.
CLI Example:
.. code-block:: bash
salt myminion boto_iam.detach_user_policy mypolicy myuser
'''
conn = _get_conn(region=region, key... | [
"def",
"detach_user_policy",
"(",
"policy_name",
",",
"user_name",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key"... | Detach a managed policy to a user.
CLI Example:
.. code-block:: bash
salt myminion boto_iam.detach_user_policy mypolicy myuser | [
"Detach",
"a",
"managed",
"policy",
"to",
"a",
"user",
"."
] | python | train | 34.136364 |
HewlettPackard/python-hpOneView | hpOneView/resources/servers/server_profile_templates.py | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_profile_templates.py#L181-L212 | def get_available_networks(self, **kwargs):
"""
Retrieves the list of Ethernet networks, Fibre Channel networks and network sets that are available
to a server profile template along with their respective ports. The scopeUris, serverHardwareTypeUri and
enclosureGroupUri parameters should... | [
"def",
"get_available_networks",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"query_string",
"=",
"'&'",
".",
"join",
"(",
"'{}={}'",
".",
"format",
"(",
"key",
",",
"value",
")",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")"... | Retrieves the list of Ethernet networks, Fibre Channel networks and network sets that are available
to a server profile template along with their respective ports. The scopeUris, serverHardwareTypeUri and
enclosureGroupUri parameters should be specified to get the available networks for a new server pro... | [
"Retrieves",
"the",
"list",
"of",
"Ethernet",
"networks",
"Fibre",
"Channel",
"networks",
"and",
"network",
"sets",
"that",
"are",
"available",
"to",
"a",
"server",
"profile",
"template",
"along",
"with",
"their",
"respective",
"ports",
".",
"The",
"scopeUris",
... | python | train | 68.3125 |
apache/airflow | airflow/contrib/hooks/gcp_vision_hook.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_vision_hook.py#L182-L207 | def update_product_set(
self,
product_set,
location=None,
product_set_id=None,
update_mask=None,
project_id=None,
retry=None,
timeout=None,
metadata=None,
):
"""
For the documentation see:
:class:`~airflow.contrib.operat... | [
"def",
"update_product_set",
"(",
"self",
",",
"product_set",
",",
"location",
"=",
"None",
",",
"product_set_id",
"=",
"None",
",",
"update_mask",
"=",
"None",
",",
"project_id",
"=",
"None",
",",
"retry",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
... | For the documentation see:
:class:`~airflow.contrib.operators.gcp_vision_operator.CloudVisionProductSetUpdateOperator` | [
"For",
"the",
"documentation",
"see",
":",
":",
"class",
":",
"~airflow",
".",
"contrib",
".",
"operators",
".",
"gcp_vision_operator",
".",
"CloudVisionProductSetUpdateOperator"
] | python | test | 37.076923 |
chaoss/grimoirelab-perceval | perceval/backends/core/telegram.py | https://github.com/chaoss/grimoirelab-perceval/blob/41c908605e88b7ebc3a536c643fa0f212eaf9e0e/perceval/backends/core/telegram.py#L312-L329 | def updates(self, offset=None):
"""Fetch the messages that a bot can read.
When the `offset` is given it will retrieve all the messages
that are greater or equal to that offset. Take into account
that, due to how the API works, all previous messages will
be removed from the serv... | [
"def",
"updates",
"(",
"self",
",",
"offset",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"offset",
":",
"params",
"[",
"self",
".",
"OFFSET",
"]",
"=",
"offset",
"response",
"=",
"self",
".",
"_call",
"(",
"self",
".",
"UPDATES_METHOD",
... | Fetch the messages that a bot can read.
When the `offset` is given it will retrieve all the messages
that are greater or equal to that offset. Take into account
that, due to how the API works, all previous messages will
be removed from the server.
:param offset: fetch the messa... | [
"Fetch",
"the",
"messages",
"that",
"a",
"bot",
"can",
"read",
"."
] | python | test | 30.611111 |
ambitioninc/python-logentries-api | logentries_api/resources.py | https://github.com/ambitioninc/python-logentries-api/blob/77ff1a7a2995d7ea2725b74e34c0f880f4ee23bc/logentries_api/resources.py#L112-L126 | def list(self):
"""
Get all current labels
:return: The Logentries API response
:rtype: list of dict
:raises: This will raise a
:class:`ServerException<logentries_api.exceptions.ServerException>`
if there is an error from Logentries
"""
r... | [
"def",
"list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_post",
"(",
"request",
"=",
"'list'",
",",
"uri",
"=",
"ApiUri",
".",
"TAGS",
".",
"value",
",",
")",
".",
"get",
"(",
"'tags'",
")"
] | Get all current labels
:return: The Logentries API response
:rtype: list of dict
:raises: This will raise a
:class:`ServerException<logentries_api.exceptions.ServerException>`
if there is an error from Logentries | [
"Get",
"all",
"current",
"labels"
] | python | test | 27.2 |
quantumlib/Cirq | cirq/sim/simulator.py | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L45-L77 | def run_sweep(
self,
program: Union[circuits.Circuit, schedules.Schedule],
params: study.Sweepable,
repetitions: int = 1,
) -> List[study.TrialResult]:
"""Runs the supplied Circuit or Schedule, mimicking quantum hardware.
In contrast to run, this allows for sweeping ... | [
"def",
"run_sweep",
"(",
"self",
",",
"program",
":",
"Union",
"[",
"circuits",
".",
"Circuit",
",",
"schedules",
".",
"Schedule",
"]",
",",
"params",
":",
"study",
".",
"Sweepable",
",",
"repetitions",
":",
"int",
"=",
"1",
",",
")",
"->",
"List",
"... | Runs the supplied Circuit or Schedule, mimicking quantum hardware.
In contrast to run, this allows for sweeping over different parameter
values.
Args:
program: The circuit or schedule to simulate.
params: Parameters to run with the program.
repetitions: The ... | [
"Runs",
"the",
"supplied",
"Circuit",
"or",
"Schedule",
"mimicking",
"quantum",
"hardware",
"."
] | python | train | 41.363636 |
royi1000/py-libhdate | hdate/date.py | https://github.com/royi1000/py-libhdate/blob/12af759fb69f1d6403abed3762beaf5ace16a34b/hdate/date.py#L243-L246 | def previous_day(self):
"""Return the HDate for the previous day."""
return HDate(self.gdate + datetime.timedelta(-1), self.diaspora,
self.hebrew) | [
"def",
"previous_day",
"(",
"self",
")",
":",
"return",
"HDate",
"(",
"self",
".",
"gdate",
"+",
"datetime",
".",
"timedelta",
"(",
"-",
"1",
")",
",",
"self",
".",
"diaspora",
",",
"self",
".",
"hebrew",
")"
] | Return the HDate for the previous day. | [
"Return",
"the",
"HDate",
"for",
"the",
"previous",
"day",
"."
] | python | train | 45 |
allenai/allennlp | allennlp/semparse/domain_languages/domain_language.py | https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/domain_language.py#L693-L733 | def _construct_node_from_actions(self,
current_node: Tree,
remaining_actions: List[List[str]]) -> List[List[str]]:
"""
Given a current node in the logical form tree, and a list of actions in an action sequence,
this method... | [
"def",
"_construct_node_from_actions",
"(",
"self",
",",
"current_node",
":",
"Tree",
",",
"remaining_actions",
":",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
")",
"->",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
":",
"if",
"not",
"remaining_actions",
"... | Given a current node in the logical form tree, and a list of actions in an action sequence,
this method fills in the children of the current node from the action sequence, then
returns whatever actions are left.
For example, we could get a node with type ``c``, and an action sequence that begin... | [
"Given",
"a",
"current",
"node",
"in",
"the",
"logical",
"form",
"tree",
"and",
"a",
"list",
"of",
"actions",
"in",
"an",
"action",
"sequence",
"this",
"method",
"fills",
"in",
"the",
"children",
"of",
"the",
"current",
"node",
"from",
"the",
"action",
"... | python | train | 67.317073 |
Kortemme-Lab/klab | klab/retrospect.py | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/retrospect.py#L69-L74 | def SymmetricDifference(self, scriptnames):
'''Takes in a set, list, or tuple scriptnames and returns the symmetric difference (as a list)
of scriptnames and the stored names.'''
scriptnames = set(scriptnames)
myscripts = set(self.scripts.keys())
return list(scriptnames.difference(myscripts).union(myscripts.d... | [
"def",
"SymmetricDifference",
"(",
"self",
",",
"scriptnames",
")",
":",
"scriptnames",
"=",
"set",
"(",
"scriptnames",
")",
"myscripts",
"=",
"set",
"(",
"self",
".",
"scripts",
".",
"keys",
"(",
")",
")",
"return",
"list",
"(",
"scriptnames",
".",
"dif... | Takes in a set, list, or tuple scriptnames and returns the symmetric difference (as a list)
of scriptnames and the stored names. | [
"Takes",
"in",
"a",
"set",
"list",
"or",
"tuple",
"scriptnames",
"and",
"returns",
"the",
"symmetric",
"difference",
"(",
"as",
"a",
"list",
")",
"of",
"scriptnames",
"and",
"the",
"stored",
"names",
"."
] | python | train | 56.5 |
gamechanger/dusty | dusty/source.py | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/source.py#L159-L178 | def update_local_repo(self, force=False):
"""Given a remote path (e.g. github.com/gamechanger/gclib), pull the latest
commits from master to bring the local copy up to date."""
self.ensure_local_repo()
logging.info('Updating local repo {}'.format(self.remote_path))
managed_repo... | [
"def",
"update_local_repo",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"self",
".",
"ensure_local_repo",
"(",
")",
"logging",
".",
"info",
"(",
"'Updating local repo {}'",
".",
"format",
"(",
"self",
".",
"remote_path",
")",
")",
"managed_repo",
"=",... | Given a remote path (e.g. github.com/gamechanger/gclib), pull the latest
commits from master to bring the local copy up to date. | [
"Given",
"a",
"remote",
"path",
"(",
"e",
".",
"g",
".",
"github",
".",
"com",
"/",
"gamechanger",
"/",
"gclib",
")",
"pull",
"the",
"latest",
"commits",
"from",
"master",
"to",
"bring",
"the",
"local",
"copy",
"up",
"to",
"date",
"."
] | python | valid | 54.35 |
amzn/ion-python | amazon/ion/reader_text.py | https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_text.py#L585-L594 | def _number_negative_start_handler(c, ctx):
"""Handles numeric values that start with a negative sign. Branches to delegate co-routines according to
_NEGATIVE_TABLE.
"""
assert c == _MINUS
assert len(ctx.value) == 0
ctx.set_ion_type(IonType.INT)
ctx.value.append(c)
c, _ = yield
yield... | [
"def",
"_number_negative_start_handler",
"(",
"c",
",",
"ctx",
")",
":",
"assert",
"c",
"==",
"_MINUS",
"assert",
"len",
"(",
"ctx",
".",
"value",
")",
"==",
"0",
"ctx",
".",
"set_ion_type",
"(",
"IonType",
".",
"INT",
")",
"ctx",
".",
"value",
".",
... | Handles numeric values that start with a negative sign. Branches to delegate co-routines according to
_NEGATIVE_TABLE. | [
"Handles",
"numeric",
"values",
"that",
"start",
"with",
"a",
"negative",
"sign",
".",
"Branches",
"to",
"delegate",
"co",
"-",
"routines",
"according",
"to",
"_NEGATIVE_TABLE",
"."
] | python | train | 36.4 |
googleapis/google-cloud-python | api_core/google/api_core/datetime_helpers.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/api_core/google/api_core/datetime_helpers.py#L282-L303 | def from_timestamp_pb(cls, stamp):
"""Parse RFC 3339-compliant timestamp, preserving nanoseconds.
Args:
stamp (:class:`~google.protobuf.timestamp_pb2.Timestamp`): timestamp message
Returns:
:class:`DatetimeWithNanoseconds`:
an instance matching the times... | [
"def",
"from_timestamp_pb",
"(",
"cls",
",",
"stamp",
")",
":",
"microseconds",
"=",
"int",
"(",
"stamp",
".",
"seconds",
"*",
"1e6",
")",
"bare",
"=",
"from_microseconds",
"(",
"microseconds",
")",
"return",
"cls",
"(",
"bare",
".",
"year",
",",
"bare",... | Parse RFC 3339-compliant timestamp, preserving nanoseconds.
Args:
stamp (:class:`~google.protobuf.timestamp_pb2.Timestamp`): timestamp message
Returns:
:class:`DatetimeWithNanoseconds`:
an instance matching the timestamp message | [
"Parse",
"RFC",
"3339",
"-",
"compliant",
"timestamp",
"preserving",
"nanoseconds",
"."
] | python | train | 29.772727 |
brettcannon/caniusepython3 | caniusepython3/projects.py | https://github.com/brettcannon/caniusepython3/blob/195775d8f1891f73eb90734f3edda0c57e08dbf3/caniusepython3/projects.py#L46-L52 | def projects_from_metadata(metadata):
"""Extract the project dependencies from a metadata spec."""
projects = []
for data in metadata:
meta = distlib.metadata.Metadata(fileobj=io.StringIO(data))
projects.extend(pypi.just_name(project) for project in meta.run_requires)
return frozenset(ma... | [
"def",
"projects_from_metadata",
"(",
"metadata",
")",
":",
"projects",
"=",
"[",
"]",
"for",
"data",
"in",
"metadata",
":",
"meta",
"=",
"distlib",
".",
"metadata",
".",
"Metadata",
"(",
"fileobj",
"=",
"io",
".",
"StringIO",
"(",
"data",
")",
")",
"p... | Extract the project dependencies from a metadata spec. | [
"Extract",
"the",
"project",
"dependencies",
"from",
"a",
"metadata",
"spec",
"."
] | python | train | 51.571429 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/collections/path_collection.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/path_collection.py#L11-L24 | def PathCollection(mode="agg", *args, **kwargs):
"""
mode: string
- "raw" (speed: fastest, size: small, output: ugly, no dash,
no thickness)
- "agg" (speed: medium, size: medium output: nice, some flaws, no dash)
- "agg+" (speed: slow, size: big, output: perfect, no dash)... | [
"def",
"PathCollection",
"(",
"mode",
"=",
"\"agg\"",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"mode",
"==",
"\"raw\"",
":",
"return",
"RawPathCollection",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"elif",
"mode",
"==",
"\"agg... | mode: string
- "raw" (speed: fastest, size: small, output: ugly, no dash,
no thickness)
- "agg" (speed: medium, size: medium output: nice, some flaws, no dash)
- "agg+" (speed: slow, size: big, output: perfect, no dash) | [
"mode",
":",
"string",
"-",
"raw",
"(",
"speed",
":",
"fastest",
"size",
":",
"small",
"output",
":",
"ugly",
"no",
"dash",
"no",
"thickness",
")",
"-",
"agg",
"(",
"speed",
":",
"medium",
"size",
":",
"medium",
"output",
":",
"nice",
"some",
"flaws"... | python | train | 36.642857 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L952-L961 | def get_next_assessment_part_id(self, assessment_part_id=None):
"""This supports the basic simple sequence case. Can be overriden in a record for other cases"""
if assessment_part_id is None:
part_id = self.get_id()
else:
part_id = assessment_part_id
return get_ne... | [
"def",
"get_next_assessment_part_id",
"(",
"self",
",",
"assessment_part_id",
"=",
"None",
")",
":",
"if",
"assessment_part_id",
"is",
"None",
":",
"part_id",
"=",
"self",
".",
"get_id",
"(",
")",
"else",
":",
"part_id",
"=",
"assessment_part_id",
"return",
"g... | This supports the basic simple sequence case. Can be overriden in a record for other cases | [
"This",
"supports",
"the",
"basic",
"simple",
"sequence",
"case",
".",
"Can",
"be",
"overriden",
"in",
"a",
"record",
"for",
"other",
"cases"
] | python | train | 48.9 |
StorjOld/heartbeat | heartbeat/PySwizzle/PySwizzle.py | https://github.com/StorjOld/heartbeat/blob/4d54f2011f1e9f688073d4347bc51bb7bd682718/heartbeat/PySwizzle/PySwizzle.py#L316-L331 | def gen_challenge(self, state):
"""This function generates a challenge for given state. It selects a
random number and sets that as the challenge key. By default, v_max
is set to the prime, and the number of chunks to challenge is the
number of chunks in the file. (this doesn't guaran... | [
"def",
"gen_challenge",
"(",
"self",
",",
"state",
")",
":",
"state",
".",
"decrypt",
"(",
"self",
".",
"key",
")",
"chal",
"=",
"Challenge",
"(",
"state",
".",
"chunks",
",",
"self",
".",
"prime",
",",
"Random",
".",
"new",
"(",
")",
".",
"read",
... | This function generates a challenge for given state. It selects a
random number and sets that as the challenge key. By default, v_max
is set to the prime, and the number of chunks to challenge is the
number of chunks in the file. (this doesn't guarantee that the whole
file will be che... | [
"This",
"function",
"generates",
"a",
"challenge",
"for",
"given",
"state",
".",
"It",
"selects",
"a",
"random",
"number",
"and",
"sets",
"that",
"as",
"the",
"challenge",
"key",
".",
"By",
"default",
"v_max",
"is",
"set",
"to",
"the",
"prime",
"and",
"t... | python | train | 43 |
log2timeline/dfvfs | dfvfs/vfs/fake_file_entry.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/fake_file_entry.py#L17-L44 | def _EntriesGenerator(self):
"""Retrieves directory entries.
Since a directory can contain a vast number of entries using
a generator is more memory efficient.
Yields:
FakePathSpec: a path specification.
"""
location = getattr(self.path_spec, 'location', None)
if location is not None... | [
"def",
"_EntriesGenerator",
"(",
"self",
")",
":",
"location",
"=",
"getattr",
"(",
"self",
".",
"path_spec",
",",
"'location'",
",",
"None",
")",
"if",
"location",
"is",
"not",
"None",
":",
"paths",
"=",
"self",
".",
"_file_system",
".",
"GetPaths",
"("... | Retrieves directory entries.
Since a directory can contain a vast number of entries using
a generator is more memory efficient.
Yields:
FakePathSpec: a path specification. | [
"Retrieves",
"directory",
"entries",
"."
] | python | train | 34.678571 |
SBRG/ssbio | ssbio/biopython/Bio/Struct/Hydrogenate.py | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/biopython/Bio/Struct/Hydrogenate.py#L135-L145 | def _exclude_ss_bonded_cysteines(self):
"""
Pre-compute ss bonds to discard cystines for H-adding.
"""
ss_bonds = self.nh_structure.search_ss_bonds()
for cys_pair in ss_bonds:
cys1, cys2 = cys_pair
cys1.resname = 'CYX'
c... | [
"def",
"_exclude_ss_bonded_cysteines",
"(",
"self",
")",
":",
"ss_bonds",
"=",
"self",
".",
"nh_structure",
".",
"search_ss_bonds",
"(",
")",
"for",
"cys_pair",
"in",
"ss_bonds",
":",
"cys1",
",",
"cys2",
"=",
"cys_pair",
"cys1",
".",
"resname",
"=",
"'CYX'"... | Pre-compute ss bonds to discard cystines for H-adding. | [
"Pre",
"-",
"compute",
"ss",
"bonds",
"to",
"discard",
"cystines",
"for",
"H",
"-",
"adding",
"."
] | python | train | 29.909091 |
danilobellini/audiolazy | docs/make_all_docs.py | https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/docs/make_all_docs.py#L37-L60 | def call_sphinx(out_type, build_dir = "build"):
"""
Call the ``sphinx-build`` for the given output type and the ``make`` when
the target has this possibility.
Parameters
----------
out_type :
A builder name for ``sphinx-build``. See the full list at
`<http://sphinx-doc.org/invocation.html>`_.
bui... | [
"def",
"call_sphinx",
"(",
"out_type",
",",
"build_dir",
"=",
"\"build\"",
")",
":",
"sphinx_string",
"=",
"sphinx_template",
".",
"format",
"(",
"build_dir",
"=",
"build_dir",
",",
"out_type",
"=",
"out_type",
")",
"if",
"sphinx",
".",
"main",
"(",
"shlex",... | Call the ``sphinx-build`` for the given output type and the ``make`` when
the target has this possibility.
Parameters
----------
out_type :
A builder name for ``sphinx-build``. See the full list at
`<http://sphinx-doc.org/invocation.html>`_.
build_dir :
Directory for storing the output. Defaults ... | [
"Call",
"the",
"sphinx",
"-",
"build",
"for",
"the",
"given",
"output",
"type",
"and",
"the",
"make",
"when",
"the",
"target",
"has",
"this",
"possibility",
"."
] | python | train | 37.875 |
numenta/htmresearch | htmresearch/support/neural_correlations_utils.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/support/neural_correlations_utils.py#L42-L65 | def randomizeSequence(sequence, symbolsPerSequence, numColumns, sparsity, p = 0.25):
"""
Takes a sequence as input and randomizes a percentage p of it by choosing
SDRs at random while preserving the remaining invariant.
@param sequence (array) sequence to be randomized
@param symbolsPerSequence (int) numbe... | [
"def",
"randomizeSequence",
"(",
"sequence",
",",
"symbolsPerSequence",
",",
"numColumns",
",",
"sparsity",
",",
"p",
"=",
"0.25",
")",
":",
"randomizedSequence",
"=",
"[",
"]",
"sparseCols",
"=",
"int",
"(",
"numColumns",
"*",
"sparsity",
")",
"numSymbolsToCh... | Takes a sequence as input and randomizes a percentage p of it by choosing
SDRs at random while preserving the remaining invariant.
@param sequence (array) sequence to be randomized
@param symbolsPerSequence (int) number of symbols per sequence
@param numColumns (int) number of columns in the TM
@param spar... | [
"Takes",
"a",
"sequence",
"as",
"input",
"and",
"randomizes",
"a",
"percentage",
"p",
"of",
"it",
"by",
"choosing",
"SDRs",
"at",
"random",
"while",
"preserving",
"the",
"remaining",
"invariant",
"."
] | python | train | 43.333333 |
qubole/qds-sdk-py | qds_sdk/commands.py | https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/commands.py#L257-L333 | def get_results(self, fp=sys.stdout, inline=True, delim=None, fetch=True, qlog=None, arguments=[]):
"""
Fetches the result for the command represented by this object
get_results will retrieve results of the command and write to stdout by default.
Optionally one can write to a filestream... | [
"def",
"get_results",
"(",
"self",
",",
"fp",
"=",
"sys",
".",
"stdout",
",",
"inline",
"=",
"True",
",",
"delim",
"=",
"None",
",",
"fetch",
"=",
"True",
",",
"qlog",
"=",
"None",
",",
"arguments",
"=",
"[",
"]",
")",
":",
"result_path",
"=",
"s... | Fetches the result for the command represented by this object
get_results will retrieve results of the command and write to stdout by default.
Optionally one can write to a filestream specified in `fp`. The `inline` argument
decides whether the result can be returned as a CRLF separated string.... | [
"Fetches",
"the",
"result",
"for",
"the",
"command",
"represented",
"by",
"this",
"object"
] | python | train | 51.454545 |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_sec_services.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_sec_services.py#L243-L254 | def ssh_sa_ssh_client_key_exchange(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
ssh_sa = ET.SubElement(config, "ssh-sa", xmlns="urn:brocade.com:mgmt:brocade-sec-services")
ssh = ET.SubElement(ssh_sa, "ssh")
client = ET.SubElement(ssh, "client"... | [
"def",
"ssh_sa_ssh_client_key_exchange",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"ssh_sa",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"ssh-sa\"",
",",
"xmlns",
"=",
"\"urn:brocad... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 43.083333 |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L105-L110 | def _raiseValidationException(standardExcMsg, customExcMsg=None):
"""Raise ValidationException with standardExcMsg, unless customExcMsg is specified."""
if customExcMsg is None:
raise ValidationException(str(standardExcMsg))
else:
raise ValidationException(str(customExcMsg)) | [
"def",
"_raiseValidationException",
"(",
"standardExcMsg",
",",
"customExcMsg",
"=",
"None",
")",
":",
"if",
"customExcMsg",
"is",
"None",
":",
"raise",
"ValidationException",
"(",
"str",
"(",
"standardExcMsg",
")",
")",
"else",
":",
"raise",
"ValidationException"... | Raise ValidationException with standardExcMsg, unless customExcMsg is specified. | [
"Raise",
"ValidationException",
"with",
"standardExcMsg",
"unless",
"customExcMsg",
"is",
"specified",
"."
] | python | train | 49.666667 |
fhs/pyhdf | pyhdf/SD.py | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2679-L2718 | def setcompress(self, comp_type, value=0, v2=0):
"""Compresses the dataset using a specified compression method.
Args::
comp_type compression type, identified by one of the
SDC.COMP_xxx constants
value,v2 auxiliary value(s) needed by some compression t... | [
"def",
"setcompress",
"(",
"self",
",",
"comp_type",
",",
"value",
"=",
"0",
",",
"v2",
"=",
"0",
")",
":",
"status",
"=",
"_C",
".",
"_SDsetcompress",
"(",
"self",
".",
"_id",
",",
"comp_type",
",",
"value",
",",
"v2",
")",
"_checkErr",
"(",
"'set... | Compresses the dataset using a specified compression method.
Args::
comp_type compression type, identified by one of the
SDC.COMP_xxx constants
value,v2 auxiliary value(s) needed by some compression types
SDC.COMP_SKPHUFF Skipping-Hu... | [
"Compresses",
"the",
"dataset",
"using",
"a",
"specified",
"compression",
"method",
"."
] | python | train | 45.4 |
jborean93/smbprotocol | smbprotocol/open.py | https://github.com/jborean93/smbprotocol/blob/d8eb00fbc824f97d0f4946e3f768c5e6c723499a/smbprotocol/open.py#L1114-L1176 | def write(self, data, offset=0, write_through=False, unbuffered=False,
wait=True, send=True):
"""
Writes data to an opened file.
Supports out of band send function, call this function with send=False
to return a tuple of (SMBWriteRequest, receive_func) instead of
s... | [
"def",
"write",
"(",
"self",
",",
"data",
",",
"offset",
"=",
"0",
",",
"write_through",
"=",
"False",
",",
"unbuffered",
"=",
"False",
",",
"wait",
"=",
"True",
",",
"send",
"=",
"True",
")",
":",
"data_len",
"=",
"len",
"(",
"data",
")",
"if",
... | Writes data to an opened file.
Supports out of band send function, call this function with send=False
to return a tuple of (SMBWriteRequest, receive_func) instead of
sending the the request and waiting for the response. The receive_func
can be used to get the response from the server by... | [
"Writes",
"data",
"to",
"an",
"opened",
"file",
"."
] | python | train | 49.571429 |
Azure/azure-sdk-for-python | azure-mgmt-resource/azure/mgmt/resource/policy/policy_client.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-resource/azure/mgmt/resource/policy/policy_client.py#L183-L199 | def policy_set_definitions(self):
"""Instance depends on the API version:
* 2017-06-01-preview: :class:`PolicySetDefinitionsOperations<azure.mgmt.resource.policy.v2017_06_01_preview.operations.PolicySetDefinitionsOperations>`
* 2018-03-01: :class:`PolicySetDefinitionsOperations<azure.mgmt... | [
"def",
"policy_set_definitions",
"(",
"self",
")",
":",
"api_version",
"=",
"self",
".",
"_get_api_version",
"(",
"'policy_set_definitions'",
")",
"if",
"api_version",
"==",
"'2017-06-01-preview'",
":",
"from",
".",
"v2017_06_01_preview",
".",
"operations",
"import",
... | Instance depends on the API version:
* 2017-06-01-preview: :class:`PolicySetDefinitionsOperations<azure.mgmt.resource.policy.v2017_06_01_preview.operations.PolicySetDefinitionsOperations>`
* 2018-03-01: :class:`PolicySetDefinitionsOperations<azure.mgmt.resource.policy.v2018_03_01.operations.Polic... | [
"Instance",
"depends",
"on",
"the",
"API",
"version",
":"
] | python | test | 75.823529 |
dbrattli/OSlash | oslash/reader.py | https://github.com/dbrattli/OSlash/blob/ffdc714c5d454f7519f740254de89f70850929eb/oslash/reader.py#L85-L92 | def run(self, *args, **kwargs) -> Callable:
"""Return wrapped function.
Haskell: runReader :: Reader r a -> r -> a
This is the inverse of unit and returns the wrapped function.
"""
return self.fn(*args, **kwargs) if args or kwargs else self.fn | [
"def",
"run",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"Callable",
":",
"return",
"self",
".",
"fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"args",
"or",
"kwargs",
"else",
"self",
".",
"fn"
] | Return wrapped function.
Haskell: runReader :: Reader r a -> r -> a
This is the inverse of unit and returns the wrapped function. | [
"Return",
"wrapped",
"function",
"."
] | python | train | 34.75 |
Rapptz/discord.py | discord/abc.py | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L386-L486 | def permissions_for(self, member):
"""Handles permission resolution for the current :class:`Member`.
This function takes into consideration the following cases:
- Guild owner
- Guild roles
- Channel overrides
- Member overrides
Parameters
----------
... | [
"def",
"permissions_for",
"(",
"self",
",",
"member",
")",
":",
"# The current cases can be explained as:",
"# Guild owner get all permissions -- no questions asked. Otherwise...",
"# The @everyone role gets the first application.",
"# After that, the applied roles that the user has in the cha... | Handles permission resolution for the current :class:`Member`.
This function takes into consideration the following cases:
- Guild owner
- Guild roles
- Channel overrides
- Member overrides
Parameters
----------
member: :class:`Member`
The m... | [
"Handles",
"permission",
"resolution",
"for",
"the",
"current",
":",
"class",
":",
"Member",
"."
] | python | train | 36.663366 |
Karaage-Cluster/python-tldap | tldap/transaction.py | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/transaction.py#L64-L76 | def leave_transaction_management(using=None):
"""
Leaves transaction management for a running thread. A dirty flag is carried
over to the surrounding block, as a commit will commit all changes, even
those from outside. (Commits are on connection level.)
"""
if using is None:
for using in... | [
"def",
"leave_transaction_management",
"(",
"using",
"=",
"None",
")",
":",
"if",
"using",
"is",
"None",
":",
"for",
"using",
"in",
"tldap",
".",
"backend",
".",
"connections",
":",
"connection",
"=",
"tldap",
".",
"backend",
".",
"connections",
"[",
"usin... | Leaves transaction management for a running thread. A dirty flag is carried
over to the surrounding block, as a commit will commit all changes, even
those from outside. (Commits are on connection level.) | [
"Leaves",
"transaction",
"management",
"for",
"a",
"running",
"thread",
".",
"A",
"dirty",
"flag",
"is",
"carried",
"over",
"to",
"the",
"surrounding",
"block",
"as",
"a",
"commit",
"will",
"commit",
"all",
"changes",
"even",
"those",
"from",
"outside",
".",... | python | train | 42.923077 |
tensorflow/mesh | mesh_tensorflow/ops.py | https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L5146-L5231 | def serialize_training_step(features, model_fn, batch_dim, num_splits):
"""Break the training batch into multiple microbatches.
Returns two structures:
grads - a list of Tensors corresponding to the gradients on
graph.trainable_variables. These are summed across all microbatches
outputs - a dictionary ... | [
"def",
"serialize_training_step",
"(",
"features",
",",
"model_fn",
",",
"batch_dim",
",",
"num_splits",
")",
":",
"for",
"v",
"in",
"features",
".",
"values",
"(",
")",
":",
"mesh",
"=",
"v",
".",
"mesh",
"graph",
"=",
"v",
".",
"graph",
"microbatch_dim... | Break the training batch into multiple microbatches.
Returns two structures:
grads - a list of Tensors corresponding to the gradients on
graph.trainable_variables. These are summed across all microbatches
outputs - a dictionary of Tensors corresponding to the output dictionary of
model_fn. Each va... | [
"Break",
"the",
"training",
"batch",
"into",
"multiple",
"microbatches",
"."
] | python | train | 37.755814 |
Robpol86/sphinxcontrib-imgur | sphinxcontrib/imgur/cache.py | https://github.com/Robpol86/sphinxcontrib-imgur/blob/5c178481d645147d10acb096793eda41c12c57af/sphinxcontrib/imgur/cache.py#L64-L106 | def update_cache(album_cache, image_cache, app, client_id, ttl, album_whitelist, image_whitelist):
"""Update cache items with expired TTLs.
:param dict album_cache: Cache of Imgur albums to update. Keys are Imgur IDs, values are Album instances.
:param dict image_cache: Cache of Imgur images to update. Key... | [
"def",
"update_cache",
"(",
"album_cache",
",",
"image_cache",
",",
"app",
",",
"client_id",
",",
"ttl",
",",
"album_whitelist",
",",
"image_whitelist",
")",
":",
"if",
"not",
"album_whitelist",
"and",
"not",
"image_whitelist",
":",
"album_whitelist",
"=",
"list... | Update cache items with expired TTLs.
:param dict album_cache: Cache of Imgur albums to update. Keys are Imgur IDs, values are Album instances.
:param dict image_cache: Cache of Imgur images to update. Keys are Imgur IDs, values are Image instances.
:param sphinx.application.Sphinx app: Sphinx application ... | [
"Update",
"cache",
"items",
"with",
"expired",
"TTLs",
"."
] | python | train | 50.767442 |
scraperwiki/data-services-helpers | dshelpers.py | https://github.com/scraperwiki/data-services-helpers/blob/a31ea2f40d20fd99d4c0938b87466330679db2c9/dshelpers.py#L79-L88 | def update_status(table_name="swdata", date_column="date"):
"""
Set the status endpoint on ScraperWiki to the latest entry e.g.
'Latest entry: 2013-10-01'
"""
status_text = 'Latest entry: {}'.format(
_get_most_recent_record(table_name, date_column))
L.info(status_text)
scraperwiki.s... | [
"def",
"update_status",
"(",
"table_name",
"=",
"\"swdata\"",
",",
"date_column",
"=",
"\"date\"",
")",
":",
"status_text",
"=",
"'Latest entry: {}'",
".",
"format",
"(",
"_get_most_recent_record",
"(",
"table_name",
",",
"date_column",
")",
")",
"L",
".",
"info... | Set the status endpoint on ScraperWiki to the latest entry e.g.
'Latest entry: 2013-10-01' | [
"Set",
"the",
"status",
"endpoint",
"on",
"ScraperWiki",
"to",
"the",
"latest",
"entry",
"e",
".",
"g",
".",
"Latest",
"entry",
":",
"2013",
"-",
"10",
"-",
"01"
] | python | train | 33.5 |
radical-cybertools/radical.entk | src/radical/entk/execman/rp/task_processor.py | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/rp/task_processor.py#L156-L265 | def get_input_list_from_task(task, placeholder_dict):
"""
Purpose: Parse a Task object to extract the files to be staged as the output.
Details: The extracted data is then converted into the appropriate RP directive depending on whether the data
is to be copied/downloaded.
:arguments:
:tas... | [
"def",
"get_input_list_from_task",
"(",
"task",
",",
"placeholder_dict",
")",
":",
"try",
":",
"if",
"not",
"isinstance",
"(",
"task",
",",
"Task",
")",
":",
"raise",
"TypeError",
"(",
"expected_type",
"=",
"Task",
",",
"actual_type",
"=",
"type",
"(",
"ta... | Purpose: Parse a Task object to extract the files to be staged as the output.
Details: The extracted data is then converted into the appropriate RP directive depending on whether the data
is to be copied/downloaded.
:arguments:
:task: EnTK Task object
:placeholder_dict: dictionary holding ... | [
"Purpose",
":",
"Parse",
"a",
"Task",
"object",
"to",
"extract",
"the",
"files",
"to",
"be",
"staged",
"as",
"the",
"output",
"."
] | python | train | 31.418182 |
StagPython/StagPy | stagpy/processing.py | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/processing.py#L37-L56 | def dt_dt(sdat, tstart=None, tend=None):
"""Derivative of temperature.
Compute dT/dt as a function of time using an explicit Euler scheme.
Args:
sdat (:class:`~stagpy.stagyydata.StagyyData`): a StagyyData instance.
tstart (float): time at which the computation should start. Use the
... | [
"def",
"dt_dt",
"(",
"sdat",
",",
"tstart",
"=",
"None",
",",
"tend",
"=",
"None",
")",
":",
"tseries",
"=",
"sdat",
".",
"tseries_between",
"(",
"tstart",
",",
"tend",
")",
"time",
"=",
"tseries",
"[",
"'t'",
"]",
".",
"values",
"temp",
"=",
"tser... | Derivative of temperature.
Compute dT/dt as a function of time using an explicit Euler scheme.
Args:
sdat (:class:`~stagpy.stagyydata.StagyyData`): a StagyyData instance.
tstart (float): time at which the computation should start. Use the
beginning of the time series data if set to... | [
"Derivative",
"of",
"temperature",
"."
] | python | train | 39.75 |
wdm0006/git-pandas | gitpandas/project.py | https://github.com/wdm0006/git-pandas/blob/e56b817b1d66b8296d1d5e703d5db0e181d25899/gitpandas/project.py#L673-L737 | def punchcard(self, branch='master', limit=None, days=None, by=None, normalize=None, ignore_globs=None, include_globs=None):
"""
Returns a pandas DataFrame containing all of the data for a punchcard.
* day_of_week
* hour_of_day
* author / committer
* lines
*... | [
"def",
"punchcard",
"(",
"self",
",",
"branch",
"=",
"'master'",
",",
"limit",
"=",
"None",
",",
"days",
"=",
"None",
",",
"by",
"=",
"None",
",",
"normalize",
"=",
"None",
",",
"ignore_globs",
"=",
"None",
",",
"include_globs",
"=",
"None",
")",
":"... | Returns a pandas DataFrame containing all of the data for a punchcard.
* day_of_week
* hour_of_day
* author / committer
* lines
* insertions
* deletions
* net
:param branch: the branch to return commits for
:param limit: (optional, default... | [
"Returns",
"a",
"pandas",
"DataFrame",
"containing",
"all",
"of",
"the",
"data",
"for",
"a",
"punchcard",
"."
] | python | train | 37 |
assamite/creamas | creamas/mp.py | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L96-L104 | def get_agents(self, addr=True, agent_cls=None, as_coro=False):
"""Get agents from the managed environment.
This is a managing function for the
:py:meth:`~creamas.environment.Environment.get_agents`. Returned
agent list excludes the environment's manager agent (this agent) by
de... | [
"def",
"get_agents",
"(",
"self",
",",
"addr",
"=",
"True",
",",
"agent_cls",
"=",
"None",
",",
"as_coro",
"=",
"False",
")",
":",
"return",
"self",
".",
"env",
".",
"get_agents",
"(",
"addr",
"=",
"addr",
",",
"agent_cls",
"=",
"agent_cls",
")"
] | Get agents from the managed environment.
This is a managing function for the
:py:meth:`~creamas.environment.Environment.get_agents`. Returned
agent list excludes the environment's manager agent (this agent) by
design. | [
"Get",
"agents",
"from",
"the",
"managed",
"environment",
"."
] | python | train | 44 |
bwengals/ccsnmultivar | ccsnmultivar/GWUtils.py | https://github.com/bwengals/ccsnmultivar/blob/dbadf52e728e0ce922cbc147864e693c2c2d305c/ccsnmultivar/GWUtils.py#L530-L556 | def LikelihoodFunction(Template, Data, PSD, detRespP, detGCDelay=0):
""" LikelihoodFunction - function to calculate the likelihood of livePoint,
given Data.
Template - (N_fd) complex array containing Fourier domain trial signal.
Data - (N_fd) complex array containing Fourier domain GW data.... | [
"def",
"LikelihoodFunction",
"(",
"Template",
",",
"Data",
",",
"PSD",
",",
"detRespP",
",",
"detGCDelay",
"=",
"0",
")",
":",
"# Correct template for geocenter delay and antenna response function",
"if",
"detGCDelay",
":",
"phaseGCDelay",
"=",
"-",
"2.",
"*",
"np",... | LikelihoodFunction - function to calculate the likelihood of livePoint,
given Data.
Template - (N_fd) complex array containing Fourier domain trial signal.
Data - (N_fd) complex array containing Fourier domain GW data.
PSD - Noise power spectral density for a gravitational wave detector... | [
"LikelihoodFunction",
"-",
"function",
"to",
"calculate",
"the",
"likelihood",
"of",
"livePoint",
"given",
"Data",
"."
] | python | train | 40.148148 |
ChrisBeaumont/smother | smother/control.py | https://github.com/ChrisBeaumont/smother/blob/65d1ea6ae0060d213b0dcbb983c5aa8e7fee07bb/smother/control.py#L174-L214 | def query_context(self, regions, file_factory=PythonFile):
"""
Return which set of test contexts intersect a set of code regions.
Parameters
----------
regions: A sequence of Intervals
file_factory: Callable (optional, default PythonFile)
A callable that ta... | [
"def",
"query_context",
"(",
"self",
",",
"regions",
",",
"file_factory",
"=",
"PythonFile",
")",
":",
"result",
"=",
"set",
"(",
")",
"for",
"region",
"in",
"regions",
":",
"try",
":",
"pf",
"=",
"file_factory",
"(",
"region",
".",
"filename",
")",
"e... | Return which set of test contexts intersect a set of code regions.
Parameters
----------
regions: A sequence of Intervals
file_factory: Callable (optional, default PythonFile)
A callable that takes a filename and
returns a PythonFile object.
Returns
... | [
"Return",
"which",
"set",
"of",
"test",
"contexts",
"intersect",
"a",
"set",
"of",
"code",
"regions",
"."
] | python | train | 29.829268 |
PolyJIT/benchbuild | benchbuild/utils/run.py | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/utils/run.py#L286-L306 | def track_execution(cmd, project, experiment, **kwargs):
"""Guard the execution of the given command.
The given command (`cmd`) will be executed inside a database context.
As soon as you leave the context we will commit the transaction.
Any necessary modifications to the database can be identified insi... | [
"def",
"track_execution",
"(",
"cmd",
",",
"project",
",",
"experiment",
",",
"*",
"*",
"kwargs",
")",
":",
"runner",
"=",
"RunInfo",
"(",
"cmd",
"=",
"cmd",
",",
"project",
"=",
"project",
",",
"experiment",
"=",
"experiment",
",",
"*",
"*",
"kwargs",... | Guard the execution of the given command.
The given command (`cmd`) will be executed inside a database context.
As soon as you leave the context we will commit the transaction.
Any necessary modifications to the database can be identified inside
the context with the RunInfo object.
Args:
c... | [
"Guard",
"the",
"execution",
"of",
"the",
"given",
"command",
"."
] | python | train | 34.047619 |
rocky/python-spark | example/python2/py2_format.py | https://github.com/rocky/python-spark/blob/8899954bcf0e166726841a43e87c23790eb3441f/example/python2/py2_format.py#L686-L707 | def format_python2_stmts(python_stmts, show_tokens=False, showast=False,
showgrammar=False, compile_mode='exec'):
"""
formats python2 statements
"""
parser_debug = {'rules': False, 'transition': False,
'reduce': showgrammar,
'errorstack':... | [
"def",
"format_python2_stmts",
"(",
"python_stmts",
",",
"show_tokens",
"=",
"False",
",",
"showast",
"=",
"False",
",",
"showgrammar",
"=",
"False",
",",
"compile_mode",
"=",
"'exec'",
")",
":",
"parser_debug",
"=",
"{",
"'rules'",
":",
"False",
",",
"'tran... | formats python2 statements | [
"formats",
"python2",
"statements"
] | python | train | 34.227273 |
jut-io/jut-python-tools | jut/api/data_engine.py | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/data_engine.py#L428-L445 | def get_job_details(job_id,
deployment_name,
token_manager=None,
app_url=defaults.APP_URL):
"""
return job details for a specific job id
"""
jobs = get_jobs(deployment_name,
token_manager=token_manager,
... | [
"def",
"get_job_details",
"(",
"job_id",
",",
"deployment_name",
",",
"token_manager",
"=",
"None",
",",
"app_url",
"=",
"defaults",
".",
"APP_URL",
")",
":",
"jobs",
"=",
"get_jobs",
"(",
"deployment_name",
",",
"token_manager",
"=",
"token_manager",
",",
"ap... | return job details for a specific job id | [
"return",
"job",
"details",
"for",
"a",
"specific",
"job",
"id"
] | python | train | 25.833333 |
santoshphilip/eppy | eppy/EPlusInterfaceFunctions/mylib2.py | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/EPlusInterfaceFunctions/mylib2.py#L197-L219 | def mtabstr2doestr(st1):
"""mtabstr2doestr"""
seperator = '$ =============='
alist = st1.split(seperator)
#this removes all the tabs that excel
#puts after the seperator and before the next line
for num in range(0, len(alist)):
alist[num] = alist[num].lstrip()
st2 = ''
for num i... | [
"def",
"mtabstr2doestr",
"(",
"st1",
")",
":",
"seperator",
"=",
"'$ =============='",
"alist",
"=",
"st1",
".",
"split",
"(",
"seperator",
")",
"#this removes all the tabs that excel",
"#puts after the seperator and before the next line",
"for",
"num",
"in",
"range",
"... | mtabstr2doestr | [
"mtabstr2doestr"
] | python | train | 25.826087 |
openstax/cnx-publishing | cnxpublishing/db.py | https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L781-L884 | def poke_publication_state(publication_id, cursor):
"""Invoked to poke at the publication to update and acquire its current
state. This is used to persist the publication to archive.
"""
cursor.execute("""\
SELECT "state", "state_messages", "is_pre_publication", "publisher"
FROM publications
WHERE id = ... | [
"def",
"poke_publication_state",
"(",
"publication_id",
",",
"cursor",
")",
":",
"cursor",
".",
"execute",
"(",
"\"\"\"\\\nSELECT \"state\", \"state_messages\", \"is_pre_publication\", \"publisher\"\nFROM publications\nWHERE id = %s\"\"\"",
",",
"(",
"publication_id",
",",
")",
"... | Invoked to poke at the publication to update and acquire its current
state. This is used to persist the publication to archive. | [
"Invoked",
"to",
"poke",
"at",
"the",
"publication",
"to",
"update",
"and",
"acquire",
"its",
"current",
"state",
".",
"This",
"is",
"used",
"to",
"persist",
"the",
"publication",
"to",
"archive",
"."
] | python | valid | 39.836538 |
raiden-network/raiden | raiden/transfer/mediated_transfer/initiator.py | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/initiator.py#L371-L406 | def handle_offchain_secretreveal(
initiator_state: InitiatorTransferState,
state_change: ReceiveSecretReveal,
channel_state: NettingChannelState,
pseudo_random_generator: random.Random,
) -> TransitionResult[InitiatorTransferState]:
""" Once the next hop proves it knows the secret, t... | [
"def",
"handle_offchain_secretreveal",
"(",
"initiator_state",
":",
"InitiatorTransferState",
",",
"state_change",
":",
"ReceiveSecretReveal",
",",
"channel_state",
":",
"NettingChannelState",
",",
"pseudo_random_generator",
":",
"random",
".",
"Random",
",",
")",
"->",
... | Once the next hop proves it knows the secret, the initiator can unlock
the mediated transfer.
This will validate the secret, and if valid a new balance proof is sent to
the next hop with the current lock removed from the merkle tree and the
transferred amount updated. | [
"Once",
"the",
"next",
"hop",
"proves",
"it",
"knows",
"the",
"secret",
"the",
"initiator",
"can",
"unlock",
"the",
"mediated",
"transfer",
"."
] | python | train | 40.611111 |
spyder-ide/spyder | spyder/api/plugins.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/api/plugins.py#L121-L130 | def register_shortcut(self, qaction_or_qshortcut, context, name,
add_sc_to_tip=False):
"""
Register QAction or QShortcut to Spyder main application.
if add_sc_to_tip is True, the shortcut is added to the
action's tooltip
"""
self.main.register_s... | [
"def",
"register_shortcut",
"(",
"self",
",",
"qaction_or_qshortcut",
",",
"context",
",",
"name",
",",
"add_sc_to_tip",
"=",
"False",
")",
":",
"self",
".",
"main",
".",
"register_shortcut",
"(",
"qaction_or_qshortcut",
",",
"context",
",",
"name",
",",
"add_... | Register QAction or QShortcut to Spyder main application.
if add_sc_to_tip is True, the shortcut is added to the
action's tooltip | [
"Register",
"QAction",
"or",
"QShortcut",
"to",
"Spyder",
"main",
"application",
"."
] | python | train | 40.6 |
bitesofcode/projexui | projexui/widgets/xganttwidget/xganttwidgetitem.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xganttwidget/xganttwidgetitem.py#L84-L99 | def addDependency(self, item):
"""
Creates a dependency for this item to the next item. This item will
be treated as the source, the other as the target.
:param item | <QGanttWidgetItem>
"""
if item in self._dependencies:
return
... | [
"def",
"addDependency",
"(",
"self",
",",
"item",
")",
":",
"if",
"item",
"in",
"self",
".",
"_dependencies",
":",
"return",
"viewItem",
"=",
"XGanttDepItem",
"(",
"self",
",",
"item",
")",
"self",
".",
"_dependencies",
"[",
"item",
"]",
"=",
"viewItem",... | Creates a dependency for this item to the next item. This item will
be treated as the source, the other as the target.
:param item | <QGanttWidgetItem> | [
"Creates",
"a",
"dependency",
"for",
"this",
"item",
"to",
"the",
"next",
"item",
".",
"This",
"item",
"will",
"be",
"treated",
"as",
"the",
"source",
"the",
"other",
"as",
"the",
"target",
".",
":",
"param",
"item",
"|",
"<QGanttWidgetItem",
">"
] | python | train | 31.8125 |
getfleety/coralillo | coralillo/fields.py | https://github.com/getfleety/coralillo/blob/9cac101738a0fa7c1106f129604c00ef703370e1/coralillo/fields.py#L57-L61 | def validate_required(self, value):
''' Validates the given value agains this field's 'required' property
'''
if self.required and (value is None or value==''):
raise MissingFieldError(self.name) | [
"def",
"validate_required",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"required",
"and",
"(",
"value",
"is",
"None",
"or",
"value",
"==",
"''",
")",
":",
"raise",
"MissingFieldError",
"(",
"self",
".",
"name",
")"
] | Validates the given value agains this field's 'required' property | [
"Validates",
"the",
"given",
"value",
"agains",
"this",
"field",
"s",
"required",
"property"
] | python | train | 45.4 |
acorg/dark-matter | dark/aa.py | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/aa.py#L1165-L1241 | def compareAaReads(read1, read2, gapChars='-', offsets=None):
"""
Compare two amino acid sequences.
@param read1: A C{Read} instance or an instance of one of its subclasses.
@param read2: A C{Read} instance or an instance of one of its subclasses.
@param gapChars: An object supporting __contains__ ... | [
"def",
"compareAaReads",
"(",
"read1",
",",
"read2",
",",
"gapChars",
"=",
"'-'",
",",
"offsets",
"=",
"None",
")",
":",
"matchCount",
"=",
"0",
"gapMismatchCount",
"=",
"nonGapMismatchCount",
"=",
"gapGapMismatchCount",
"=",
"0",
"read1ExtraCount",
"=",
"read... | Compare two amino acid sequences.
@param read1: A C{Read} instance or an instance of one of its subclasses.
@param read2: A C{Read} instance or an instance of one of its subclasses.
@param gapChars: An object supporting __contains__ with characters that
should be considered to be gaps.
@param o... | [
"Compare",
"two",
"amino",
"acid",
"sequences",
"."
] | python | train | 38.064935 |
NoneGG/aredis | aredis/commands/keys.py | https://github.com/NoneGG/aredis/blob/204caad740ac13e5760d46444a2ba7632982a046/aredis/commands/keys.py#L155-L220 | async def sort(self, name, start=None, num=None, by=None, get=None,
desc=False, alpha=False, store=None, groups=False):
"""
Sort and return the list, set or sorted set at ``name``.
``start`` and ``num`` allow for paging through the sorted data
``by`` allows using an extern... | [
"async",
"def",
"sort",
"(",
"self",
",",
"name",
",",
"start",
"=",
"None",
",",
"num",
"=",
"None",
",",
"by",
"=",
"None",
",",
"get",
"=",
"None",
",",
"desc",
"=",
"False",
",",
"alpha",
"=",
"False",
",",
"store",
"=",
"None",
",",
"group... | Sort and return the list, set or sorted set at ``name``.
``start`` and ``num`` allow for paging through the sorted data
``by`` allows using an external key to weight and sort the items.
Use an "*" to indicate where in the key the item value is located
``get`` allows for returning ... | [
"Sort",
"and",
"return",
"the",
"list",
"set",
"or",
"sorted",
"set",
"at",
"name",
"."
] | python | train | 39.151515 |
abnerjacobsen/tinydb-jsonorm | src/tinydb_jsonorm/cuid.py | https://github.com/abnerjacobsen/tinydb-jsonorm/blob/704d3f887cc8963769ffbb116eb7e6909deeaecd/src/tinydb_jsonorm/cuid.py#L38-L48 | def _pad(string, size):
"""
'Pad' a string with leading zeroes to fit the given size, truncating
if necessary.
"""
strlen = len(string)
if strlen == size:
return string
if strlen < size:
return _padding[0:size-strlen] + string
return string[-size:] | [
"def",
"_pad",
"(",
"string",
",",
"size",
")",
":",
"strlen",
"=",
"len",
"(",
"string",
")",
"if",
"strlen",
"==",
"size",
":",
"return",
"string",
"if",
"strlen",
"<",
"size",
":",
"return",
"_padding",
"[",
"0",
":",
"size",
"-",
"strlen",
"]",... | 'Pad' a string with leading zeroes to fit the given size, truncating
if necessary. | [
"Pad",
"a",
"string",
"with",
"leading",
"zeroes",
"to",
"fit",
"the",
"given",
"size",
"truncating",
"if",
"necessary",
"."
] | python | train | 26 |
wheerd/multiset | multiset.py | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L797-L822 | def difference_update(self, *others):
r"""Remove all elements contained the others from this multiset.
>>> ms = Multiset('aab')
>>> ms.difference_update('abc')
>>> sorted(ms)
['a']
You can also use the ``-=`` operator for the same effect. However, the operator version
... | [
"def",
"difference_update",
"(",
"self",
",",
"*",
"others",
")",
":",
"for",
"other",
"in",
"map",
"(",
"self",
".",
"_as_multiset",
",",
"others",
")",
":",
"for",
"element",
",",
"multiplicity",
"in",
"other",
".",
"items",
"(",
")",
":",
"self",
... | r"""Remove all elements contained the others from this multiset.
>>> ms = Multiset('aab')
>>> ms.difference_update('abc')
>>> sorted(ms)
['a']
You can also use the ``-=`` operator for the same effect. However, the operator version
will only accept a set as other operato... | [
"r",
"Remove",
"all",
"elements",
"contained",
"the",
"others",
"from",
"this",
"multiset",
"."
] | python | train | 40.730769 |
michaelpb/omnic | omnic/config/settingsmanager.py | https://github.com/michaelpb/omnic/blob/1111cfd73c9dc1955afe42d9cf2a468c46f83cd6/omnic/config/settingsmanager.py#L130-L146 | def load_path_with_default(self, path, default_constructor):
'''
Same as `load_path(path)', except uses default_constructor on import
errors, or if loaded a auto-generated namespace package (e.g. bare
directory).
'''
try:
imported_obj = self.load_path(path)
... | [
"def",
"load_path_with_default",
"(",
"self",
",",
"path",
",",
"default_constructor",
")",
":",
"try",
":",
"imported_obj",
"=",
"self",
".",
"load_path",
"(",
"path",
")",
"except",
"(",
"ImportError",
",",
"ConfigurationError",
")",
":",
"imported_obj",
"="... | Same as `load_path(path)', except uses default_constructor on import
errors, or if loaded a auto-generated namespace package (e.g. bare
directory). | [
"Same",
"as",
"load_path",
"(",
"path",
")",
"except",
"uses",
"default_constructor",
"on",
"import",
"errors",
"or",
"if",
"loaded",
"a",
"auto",
"-",
"generated",
"namespace",
"package",
"(",
"e",
".",
"g",
".",
"bare",
"directory",
")",
"."
] | python | train | 43.176471 |
jjgomera/iapws | iapws/iapws08.py | https://github.com/jjgomera/iapws/blob/1e5812aab38212fb8a63736f61cdcfa427d223b1/iapws/iapws08.py#L244-L257 | def _water(cls, T, P):
"""Get properties of pure water, Table4 pag 8"""
water = IAPWS95(P=P, T=T)
prop = {}
prop["g"] = water.h-T*water.s
prop["gt"] = -water.s
prop["gp"] = 1./water.rho
prop["gtt"] = -water.cp/T
prop["gtp"] = water.betas*water.cp/T
... | [
"def",
"_water",
"(",
"cls",
",",
"T",
",",
"P",
")",
":",
"water",
"=",
"IAPWS95",
"(",
"P",
"=",
"P",
",",
"T",
"=",
"T",
")",
"prop",
"=",
"{",
"}",
"prop",
"[",
"\"g\"",
"]",
"=",
"water",
".",
"h",
"-",
"T",
"*",
"water",
".",
"s",
... | Get properties of pure water, Table4 pag 8 | [
"Get",
"properties",
"of",
"pure",
"water",
"Table4",
"pag",
"8"
] | python | train | 34.214286 |
saltstack/salt | salt/modules/neutronng.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/neutronng.py#L109-L147 | def network_create(auth=None, **kwargs):
'''
Create a network
name
Name of the network being created
shared : False
If ``True``, set the network as shared
admin_state_up : True
If ``True``, Set the network administrative state to "up"
external : False
Control ... | [
"def",
"network_create",
"(",
"auth",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"cloud",
"=",
"get_operator_cloud",
"(",
"auth",
")",
"kwargs",
"=",
"_clean_kwargs",
"(",
"keep_name",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
"return",
"cloud",
... | Create a network
name
Name of the network being created
shared : False
If ``True``, set the network as shared
admin_state_up : True
If ``True``, Set the network administrative state to "up"
external : False
Control whether or not this network is externally accessible
... | [
"Create",
"a",
"network"
] | python | train | 27.051282 |
bioasp/caspo | caspo/core/literal.py | https://github.com/bioasp/caspo/blob/a68d1eace75b9b08f23633d1fb5ce6134403959e/caspo/core/literal.py#L33-L54 | def from_str(cls, string):
"""
Creates a literal from a string
Parameters
----------
string : str
If the string starts with '!', it's interpreted as a negated variable
Returns
-------
caspo.core.literal.Literal
Created object inst... | [
"def",
"from_str",
"(",
"cls",
",",
"string",
")",
":",
"if",
"string",
"[",
"0",
"]",
"==",
"'!'",
":",
"signature",
"=",
"-",
"1",
"variable",
"=",
"string",
"[",
"1",
":",
"]",
"else",
":",
"signature",
"=",
"1",
"variable",
"=",
"string",
"re... | Creates a literal from a string
Parameters
----------
string : str
If the string starts with '!', it's interpreted as a negated variable
Returns
-------
caspo.core.literal.Literal
Created object instance | [
"Creates",
"a",
"literal",
"from",
"a",
"string"
] | python | train | 23.454545 |
UCL-INGI/INGInious | inginious/frontend/tasks.py | https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/tasks.py#L99-L104 | def get_context(self, language):
""" Get the context(description) of this task """
context = self.gettext(language, self._context) if self._context else ""
vals = self._hook_manager.call_hook('task_context', course=self.get_course(), task=self, default=context)
return ParsableText(vals[0... | [
"def",
"get_context",
"(",
"self",
",",
"language",
")",
":",
"context",
"=",
"self",
".",
"gettext",
"(",
"language",
",",
"self",
".",
"_context",
")",
"if",
"self",
".",
"_context",
"else",
"\"\"",
"vals",
"=",
"self",
".",
"_hook_manager",
".",
"ca... | Get the context(description) of this task | [
"Get",
"the",
"context",
"(",
"description",
")",
"of",
"this",
"task"
] | python | train | 84.833333 |
dnanexus/dx-toolkit | src/python/dxpy/workflow_builder.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/workflow_builder.py#L376-L382 | def _build_regular_workflow(json_spec):
"""
Precondition: json_spec must be validated
"""
workflow_id = dxpy.api.workflow_new(json_spec)["id"]
dxpy.api.workflow_close(workflow_id)
return workflow_id | [
"def",
"_build_regular_workflow",
"(",
"json_spec",
")",
":",
"workflow_id",
"=",
"dxpy",
".",
"api",
".",
"workflow_new",
"(",
"json_spec",
")",
"[",
"\"id\"",
"]",
"dxpy",
".",
"api",
".",
"workflow_close",
"(",
"workflow_id",
")",
"return",
"workflow_id"
] | Precondition: json_spec must be validated | [
"Precondition",
":",
"json_spec",
"must",
"be",
"validated"
] | python | train | 30.857143 |
psd-tools/psd-tools | src/psd_tools/api/pil_io.py | https://github.com/psd-tools/psd-tools/blob/4952b57bcf1cf2c1f16fd9d6d51d4fa0b53bce4e/src/psd_tools/api/pil_io.py#L248-L266 | def _remove_white_background(image):
"""Remove white background in the preview image."""
from PIL import ImageMath, Image
if image.mode == "RGBA":
bands = image.split()
a = bands[3]
rgb = [
ImageMath.eval(
'convert('
'float(x + a - 255) * 2... | [
"def",
"_remove_white_background",
"(",
"image",
")",
":",
"from",
"PIL",
"import",
"ImageMath",
",",
"Image",
"if",
"image",
".",
"mode",
"==",
"\"RGBA\"",
":",
"bands",
"=",
"image",
".",
"split",
"(",
")",
"a",
"=",
"bands",
"[",
"3",
"]",
"rgb",
... | Remove white background in the preview image. | [
"Remove",
"white",
"background",
"in",
"the",
"preview",
"image",
"."
] | python | train | 30.473684 |
OCR-D/core | ocrd_utils/ocrd_utils/__init__.py | https://github.com/OCR-D/core/blob/57e68c578526cb955fd2e368207f5386c459d91d/ocrd_utils/ocrd_utils/__init__.py#L154-L178 | def xywh_from_points(points):
"""
Constructs an dict representing a rectangle with keys x, y, w, h
"""
xys = [[int(p) for p in pair.split(',')] for pair in points.split(' ')]
minx = sys.maxsize
miny = sys.maxsize
maxx = 0
maxy = 0
for xy in xys:
if xy[0] < minx:
m... | [
"def",
"xywh_from_points",
"(",
"points",
")",
":",
"xys",
"=",
"[",
"[",
"int",
"(",
"p",
")",
"for",
"p",
"in",
"pair",
".",
"split",
"(",
"','",
")",
"]",
"for",
"pair",
"in",
"points",
".",
"split",
"(",
"' '",
")",
"]",
"minx",
"=",
"sys",... | Constructs an dict representing a rectangle with keys x, y, w, h | [
"Constructs",
"an",
"dict",
"representing",
"a",
"rectangle",
"with",
"keys",
"x",
"y",
"w",
"h"
] | python | train | 22.68 |
marcomusy/vtkplotter | vtkplotter/analysis.py | https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/analysis.py#L633-L657 | def fitLine(points, c="orange", lw=1):
"""
Fits a line through points.
Extra info is stored in ``actor.info['slope']``, ``actor.info['center']``, ``actor.info['variances']``.
.. hint:: |fitline| |fitline.py|_
"""
data = np.array(points)
datamean = data.mean(axis=0)
uu, dd, vv = np.lina... | [
"def",
"fitLine",
"(",
"points",
",",
"c",
"=",
"\"orange\"",
",",
"lw",
"=",
"1",
")",
":",
"data",
"=",
"np",
".",
"array",
"(",
"points",
")",
"datamean",
"=",
"data",
".",
"mean",
"(",
"axis",
"=",
"0",
")",
"uu",
",",
"dd",
",",
"vv",
"=... | Fits a line through points.
Extra info is stored in ``actor.info['slope']``, ``actor.info['center']``, ``actor.info['variances']``.
.. hint:: |fitline| |fitline.py|_ | [
"Fits",
"a",
"line",
"through",
"points",
"."
] | python | train | 33.52 |
Qiskit/qiskit-terra | qiskit/qasm/qasm.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasm.py#L32-L39 | def get_tokens(self):
"""Returns a generator of the tokens."""
if self._filename:
with open(self._filename) as ifile:
self._data = ifile.read()
with QasmParser(self._filename) as qasm_p:
return qasm_p.get_tokens() | [
"def",
"get_tokens",
"(",
"self",
")",
":",
"if",
"self",
".",
"_filename",
":",
"with",
"open",
"(",
"self",
".",
"_filename",
")",
"as",
"ifile",
":",
"self",
".",
"_data",
"=",
"ifile",
".",
"read",
"(",
")",
"with",
"QasmParser",
"(",
"self",
"... | Returns a generator of the tokens. | [
"Returns",
"a",
"generator",
"of",
"the",
"tokens",
"."
] | python | test | 33.875 |
gitpython-developers/GitPython | git/index/typ.py | https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/index/typ.py#L109-L111 | def to_blob(self, repo):
""":return: Blob using the information of this index entry"""
return Blob(repo, self.binsha, self.mode, self.path) | [
"def",
"to_blob",
"(",
"self",
",",
"repo",
")",
":",
"return",
"Blob",
"(",
"repo",
",",
"self",
".",
"binsha",
",",
"self",
".",
"mode",
",",
"self",
".",
"path",
")"
] | :return: Blob using the information of this index entry | [
":",
"return",
":",
"Blob",
"using",
"the",
"information",
"of",
"this",
"index",
"entry"
] | python | train | 51 |
titusjan/argos | argos/qt/registrytable.py | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/qt/registrytable.py#L184-L188 | def itemFromIndex(self, index):
""" Gets the item given the model index
"""
sourceIndex = self.mapToSource(index)
return self.sourceModel().itemFromIndex(sourceIndex) | [
"def",
"itemFromIndex",
"(",
"self",
",",
"index",
")",
":",
"sourceIndex",
"=",
"self",
".",
"mapToSource",
"(",
"index",
")",
"return",
"self",
".",
"sourceModel",
"(",
")",
".",
"itemFromIndex",
"(",
"sourceIndex",
")"
] | Gets the item given the model index | [
"Gets",
"the",
"item",
"given",
"the",
"model",
"index"
] | python | train | 38.8 |
thomasleese/mo | mo/cli.py | https://github.com/thomasleese/mo/blob/b757f52b42e51ad19c14724ceb7c5db5d52abaea/mo/cli.py#L16-L38 | def parse_variables(args):
"""
Parse variables as passed on the command line.
Returns
-------
dict
Mapping variable name to the value.
"""
if args is None:
return {}
def parse_variable(string):
tokens = string.split('=')
name = tokens[0]
value =... | [
"def",
"parse_variables",
"(",
"args",
")",
":",
"if",
"args",
"is",
"None",
":",
"return",
"{",
"}",
"def",
"parse_variable",
"(",
"string",
")",
":",
"tokens",
"=",
"string",
".",
"split",
"(",
"'='",
")",
"name",
"=",
"tokens",
"[",
"0",
"]",
"v... | Parse variables as passed on the command line.
Returns
-------
dict
Mapping variable name to the value. | [
"Parse",
"variables",
"as",
"passed",
"on",
"the",
"command",
"line",
"."
] | python | train | 19.434783 |
daniellawrence/graphitesend | graphitesend/graphitesend.py | https://github.com/daniellawrence/graphitesend/blob/02281263e642f9b6e146886d4544e1d7aebd7753/graphitesend/graphitesend.py#L553-L563 | def send(*args, **kwargs):
""" Make sure that we have an instance of the GraphiteClient.
Then send the metrics to the graphite server.
User consumable method.
"""
if not _module_instance:
raise GraphiteSendException(
"Must call graphitesend.init() before sending")
_module_in... | [
"def",
"send",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"_module_instance",
":",
"raise",
"GraphiteSendException",
"(",
"\"Must call graphitesend.init() before sending\"",
")",
"_module_instance",
".",
"send",
"(",
"*",
"args",
",",
"*",... | Make sure that we have an instance of the GraphiteClient.
Then send the metrics to the graphite server.
User consumable method. | [
"Make",
"sure",
"that",
"we",
"have",
"an",
"instance",
"of",
"the",
"GraphiteClient",
".",
"Then",
"send",
"the",
"metrics",
"to",
"the",
"graphite",
"server",
".",
"User",
"consumable",
"method",
"."
] | python | train | 33.272727 |
DataDog/integrations-core | datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L563-L613 | def _submit(
self,
metric_name,
message,
send_histograms_buckets=True,
send_monotonic_counter=False,
custom_tags=None,
hostname=None,
):
"""
For each metric in the message, report it as a gauge with all labels as tags
except if a labels... | [
"def",
"_submit",
"(",
"self",
",",
"metric_name",
",",
"message",
",",
"send_histograms_buckets",
"=",
"True",
",",
"send_monotonic_counter",
"=",
"False",
",",
"custom_tags",
"=",
"None",
",",
"hostname",
"=",
"None",
",",
")",
":",
"if",
"message",
".",
... | For each metric in the message, report it as a gauge with all labels as tags
except if a labels dict is passed, in which case keys are label names we'll extract
and corresponding values are tag names we'll use (eg: {'node': 'node'}).
Histograms generate a set of values instead of a unique metri... | [
"For",
"each",
"metric",
"in",
"the",
"message",
"report",
"it",
"as",
"a",
"gauge",
"with",
"all",
"labels",
"as",
"tags",
"except",
"if",
"a",
"labels",
"dict",
"is",
"passed",
"in",
"which",
"case",
"keys",
"are",
"label",
"names",
"we",
"ll",
"extr... | python | train | 51.117647 |
pytorch/text | torchtext/data/dataset.py | https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/data/dataset.py#L157-L199 | def download(cls, root, check=None):
"""Download and unzip an online archive (.zip, .gz, or .tgz).
Arguments:
root (str): Folder to download data to.
check (str or None): Folder whose existence indicates
that the dataset has already been downloaded, or
... | [
"def",
"download",
"(",
"cls",
",",
"root",
",",
"check",
"=",
"None",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"cls",
".",
"name",
")",
"check",
"=",
"path",
"if",
"check",
"is",
"None",
"else",
"check",
"if",
"... | Download and unzip an online archive (.zip, .gz, or .tgz).
Arguments:
root (str): Folder to download data to.
check (str or None): Folder whose existence indicates
that the dataset has already been downloaded, or
None to check the existence of root/{cls.n... | [
"Download",
"and",
"unzip",
"an",
"online",
"archive",
"(",
".",
"zip",
".",
"gz",
"or",
".",
"tgz",
")",
"."
] | python | train | 45.418605 |
seperman/deepdiff | deepdiff/search.py | https://github.com/seperman/deepdiff/blob/a66879190fadc671632f154c1fcb82f5c3cef800/deepdiff/search.py#L272-L306 | def __search(self, obj, item, parent="root", parents_ids=frozenset({})):
"""The main search method"""
if self.__skip_this(item, parent):
return
elif isinstance(obj, strings) and isinstance(item, strings):
self.__search_str(obj, item, parent)
elif isinstance(obj... | [
"def",
"__search",
"(",
"self",
",",
"obj",
",",
"item",
",",
"parent",
"=",
"\"root\"",
",",
"parents_ids",
"=",
"frozenset",
"(",
"{",
"}",
")",
")",
":",
"if",
"self",
".",
"__skip_this",
"(",
"item",
",",
"parent",
")",
":",
"return",
"elif",
"... | The main search method | [
"The",
"main",
"search",
"method"
] | python | train | 35.228571 |
saltstack/salt | salt/modules/config.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/config.py#L446-L463 | def gather_bootstrap_script(bootstrap=None):
'''
Download the salt-bootstrap script, and return its location
bootstrap
URL of alternate bootstrap script
CLI Example:
.. code-block:: bash
salt '*' config.gather_bootstrap_script
'''
if not HAS_CLOUD:
return False, '... | [
"def",
"gather_bootstrap_script",
"(",
"bootstrap",
"=",
"None",
")",
":",
"if",
"not",
"HAS_CLOUD",
":",
"return",
"False",
",",
"'config.gather_bootstrap_script is unavailable'",
"ret",
"=",
"salt",
".",
"utils",
".",
"cloud",
".",
"update_bootstrap",
"(",
"__op... | Download the salt-bootstrap script, and return its location
bootstrap
URL of alternate bootstrap script
CLI Example:
.. code-block:: bash
salt '*' config.gather_bootstrap_script | [
"Download",
"the",
"salt",
"-",
"bootstrap",
"script",
"and",
"return",
"its",
"location"
] | python | train | 29.388889 |
PGower/PyCanvas | pycanvas/apis/quiz_submissions.py | https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/quiz_submissions.py#L19-L51 | def get_all_quiz_submissions(self, quiz_id, course_id, include=None):
"""
Get all quiz submissions.
Get a list of all submissions for this quiz. Users who can view or manage
grades for a course will have submissions from multiple users returned. A
user who can only submit ... | [
"def",
"get_all_quiz_submissions",
"(",
"self",
",",
"quiz_id",
",",
"course_id",
",",
"include",
"=",
"None",
")",
":",
"path",
"=",
"{",
"}",
"data",
"=",
"{",
"}",
"params",
"=",
"{",
"}",
"# REQUIRED - PATH - course_id\r",
"\"\"\"ID\"\"\"",
"path",
"[",
... | Get all quiz submissions.
Get a list of all submissions for this quiz. Users who can view or manage
grades for a course will have submissions from multiple users returned. A
user who can only submit will have only their own submissions returned. When
a user has an in-progress submi... | [
"Get",
"all",
"quiz",
"submissions",
".",
"Get",
"a",
"list",
"of",
"all",
"submissions",
"for",
"this",
"quiz",
".",
"Users",
"who",
"can",
"view",
"or",
"manage",
"grades",
"for",
"a",
"course",
"will",
"have",
"submissions",
"from",
"multiple",
"users",... | python | train | 45.424242 |
saltstack/salt | salt/modules/snapper.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/snapper.py#L460-L510 | def modify_snapshot(snapshot_id=None,
description=None,
userdata=None,
cleanup=None,
config="root"):
'''
Modify attributes of an existing snapshot.
config
Configuration name. (Default: root)
snapshot_id
ID ... | [
"def",
"modify_snapshot",
"(",
"snapshot_id",
"=",
"None",
",",
"description",
"=",
"None",
",",
"userdata",
"=",
"None",
",",
"cleanup",
"=",
"None",
",",
"config",
"=",
"\"root\"",
")",
":",
"if",
"not",
"snapshot_id",
":",
"raise",
"CommandExecutionError"... | Modify attributes of an existing snapshot.
config
Configuration name. (Default: root)
snapshot_id
ID of the snapshot to be modified.
cleanup
Change the cleanup method of the snapshot. (str)
description
Change the description of the snapshot. (str)
userdata
... | [
"Modify",
"attributes",
"of",
"an",
"existing",
"snapshot",
"."
] | python | train | 36.098039 |
lmjohns3/downhill | downhill/dataset.py | https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/dataset.py#L183-L205 | def iterate(self, shuffle=True):
'''Iterate over batches in the dataset.
This method generates ``iteration_size`` batches from the dataset and
then returns.
Parameters
----------
shuffle : bool, optional
Shuffle the batches in this dataset if the iteration r... | [
"def",
"iterate",
"(",
"self",
",",
"shuffle",
"=",
"True",
")",
":",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"iteration_size",
")",
":",
"if",
"self",
".",
"_callable",
"is",
"not",
"None",
":",
"yield",
"self",
".",
"_callable",
"(",
")",
"e... | Iterate over batches in the dataset.
This method generates ``iteration_size`` batches from the dataset and
then returns.
Parameters
----------
shuffle : bool, optional
Shuffle the batches in this dataset if the iteration reaches the end
of the batch list... | [
"Iterate",
"over",
"batches",
"in",
"the",
"dataset",
"."
] | python | train | 31.652174 |
echonest/pyechonest | pyechonest/track.py | https://github.com/echonest/pyechonest/blob/d8c7af6c1da699b50b2f4b1bd3c0febe72e7f1ee/pyechonest/track.py#L275-L293 | def track_from_url(url, timeout=DEFAULT_ASYNC_TIMEOUT):
"""
Create a track object from a public http URL.
NOTE: Does not create the detailed analysis for the Track. Call
Track.get_analysis() for that.
Args:
url: A string giving the URL to read from. This must be on a public machine accessi... | [
"def",
"track_from_url",
"(",
"url",
",",
"timeout",
"=",
"DEFAULT_ASYNC_TIMEOUT",
")",
":",
"param_dict",
"=",
"dict",
"(",
"url",
"=",
"url",
")",
"return",
"_upload",
"(",
"param_dict",
",",
"timeout",
",",
"data",
"=",
"None",
")"
] | Create a track object from a public http URL.
NOTE: Does not create the detailed analysis for the Track. Call
Track.get_analysis() for that.
Args:
url: A string giving the URL to read from. This must be on a public machine accessible by HTTP.
Example:
>>> t = track.track_from_url("htt... | [
"Create",
"a",
"track",
"object",
"from",
"a",
"public",
"http",
"URL",
"."
] | python | train | 29.578947 |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/identity/identity_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/identity/identity_client.py#L206-L226 | def read_identity(self, identity_id, query_membership=None, properties=None):
"""ReadIdentity.
:param str identity_id:
:param str query_membership:
:param str properties:
:rtype: :class:`<Identity> <azure.devops.v5_0.identity.models.Identity>`
"""
route_values = {... | [
"def",
"read_identity",
"(",
"self",
",",
"identity_id",
",",
"query_membership",
"=",
"None",
",",
"properties",
"=",
"None",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"identity_id",
"is",
"not",
"None",
":",
"route_values",
"[",
"'identityId'",
"]",
... | ReadIdentity.
:param str identity_id:
:param str query_membership:
:param str properties:
:rtype: :class:`<Identity> <azure.devops.v5_0.identity.models.Identity>` | [
"ReadIdentity",
".",
":",
"param",
"str",
"identity_id",
":",
":",
"param",
"str",
"query_membership",
":",
":",
"param",
"str",
"properties",
":",
":",
"rtype",
":",
":",
"class",
":",
"<Identity",
">",
"<azure",
".",
"devops",
".",
"v5_0",
".",
"identi... | python | train | 52.809524 |
albertz/py_better_exchook | better_exchook.py | https://github.com/albertz/py_better_exchook/blob/3d524a027d7fc4e83e47e39a1978849561da69b3/better_exchook.py#L767-L783 | def fold_text_stream(self, prefix, postfix="", hidden_stream=None, **kwargs):
"""
:param str prefix: always visible
:param str postfix: always visible, right after.
:param io.TextIOBase|io.StringIO hidden_stream: sys.stdout by default.
If this is sys.stdout, it will replace t... | [
"def",
"fold_text_stream",
"(",
"self",
",",
"prefix",
",",
"postfix",
"=",
"\"\"",
",",
"hidden_stream",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"io",
"if",
"hidden_stream",
"is",
"None",
":",
"hidden_stream",
"=",
"sys",
".",
"stdout"... | :param str prefix: always visible
:param str postfix: always visible, right after.
:param io.TextIOBase|io.StringIO hidden_stream: sys.stdout by default.
If this is sys.stdout, it will replace that stream,
and collect the data during the context (in the `with` block). | [
":",
"param",
"str",
"prefix",
":",
"always",
"visible",
":",
"param",
"str",
"postfix",
":",
"always",
"visible",
"right",
"after",
".",
":",
"param",
"io",
".",
"TextIOBase|io",
".",
"StringIO",
"hidden_stream",
":",
"sys",
".",
"stdout",
"by",
"default"... | python | train | 49.411765 |
happyleavesaoc/python-limitlessled | limitlessled/group/rgbw.py | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/rgbw.py#L94-L104 | def hue(self, hue):
""" Set the group hue.
:param hue: Hue in decimal percent (0.0-1.0).
"""
if hue < 0 or hue > 1:
raise ValueError("Hue must be a percentage "
"represented as decimal 0-1.0")
self._hue = hue
cmd = self.command_se... | [
"def",
"hue",
"(",
"self",
",",
"hue",
")",
":",
"if",
"hue",
"<",
"0",
"or",
"hue",
">",
"1",
":",
"raise",
"ValueError",
"(",
"\"Hue must be a percentage \"",
"\"represented as decimal 0-1.0\"",
")",
"self",
".",
"_hue",
"=",
"hue",
"cmd",
"=",
"self",
... | Set the group hue.
:param hue: Hue in decimal percent (0.0-1.0). | [
"Set",
"the",
"group",
"hue",
"."
] | python | train | 31.181818 |
cortical-io/retina-sdk.py | retinasdk/client/retinas_api.py | https://github.com/cortical-io/retina-sdk.py/blob/474c13ad399fe1e974d2650335537608f4456b07/retinasdk/client/retinas_api.py#L19-L35 | def getRetinas(self, retina_name=None):
"""Information about retinas
Args:
retina_name, str: The retina name (optional) (optional)
Returns: Array[Retina]
"""
resourcePath = '/retinas'
method = 'GET'
queryParams = {}
headerParams = {'Accep... | [
"def",
"getRetinas",
"(",
"self",
",",
"retina_name",
"=",
"None",
")",
":",
"resourcePath",
"=",
"'/retinas'",
"method",
"=",
"'GET'",
"queryParams",
"=",
"{",
"}",
"headerParams",
"=",
"{",
"'Accept'",
":",
"'Application/json'",
",",
"'Content-Type'",
":",
... | Information about retinas
Args:
retina_name, str: The retina name (optional) (optional)
Returns: Array[Retina] | [
"Information",
"about",
"retinas",
"Args",
":",
"retina_name",
"str",
":",
"The",
"retina",
"name",
"(",
"optional",
")",
"(",
"optional",
")",
"Returns",
":",
"Array",
"[",
"Retina",
"]"
] | python | train | 35.294118 |
Gorialis/jishaku | jishaku/cog.py | https://github.com/Gorialis/jishaku/blob/fc7c479b9d510ede189a929c8aa6f7c8ef7f9a6e/jishaku/cog.py#L362-L376 | async def jsk_repeat(self, ctx: commands.Context, times: int, *, command_string: str):
"""
Runs a command multiple times in a row.
This acts like the command was invoked several times manually, so it obeys cooldowns.
"""
with self.submit(ctx): # allow repeats to be cancelled
... | [
"async",
"def",
"jsk_repeat",
"(",
"self",
",",
"ctx",
":",
"commands",
".",
"Context",
",",
"times",
":",
"int",
",",
"*",
",",
"command_string",
":",
"str",
")",
":",
"with",
"self",
".",
"submit",
"(",
"ctx",
")",
":",
"# allow repeats to be cancelled... | Runs a command multiple times in a row.
This acts like the command was invoked several times manually, so it obeys cooldowns. | [
"Runs",
"a",
"command",
"multiple",
"times",
"in",
"a",
"row",
"."
] | python | train | 41.666667 |
helixyte/everest | everest/views/base.py | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L276-L292 | def _update_response_location_header(self, resource):
"""
Adds a new or replaces an existing Location header to the response
headers pointing to the URL of the given resource.
"""
location = resource_to_url(resource, request=self.request)
loc_hdr = ('Location', location)
... | [
"def",
"_update_response_location_header",
"(",
"self",
",",
"resource",
")",
":",
"location",
"=",
"resource_to_url",
"(",
"resource",
",",
"request",
"=",
"self",
".",
"request",
")",
"loc_hdr",
"=",
"(",
"'Location'",
",",
"location",
")",
"hdr_names",
"=",... | Adds a new or replaces an existing Location header to the response
headers pointing to the URL of the given resource. | [
"Adds",
"a",
"new",
"or",
"replaces",
"an",
"existing",
"Location",
"header",
"to",
"the",
"response",
"headers",
"pointing",
"to",
"the",
"URL",
"of",
"the",
"given",
"resource",
"."
] | python | train | 46.176471 |
raiden-network/raiden | raiden/network/transport/matrix/utils.py | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/utils.py#L535-L549 | def make_room_alias(chain_id: ChainID, *suffixes: str) -> str:
"""Given a chain_id and any number of suffixes (global room names, pair of addresses),
compose and return the canonical room name for raiden network
network name from raiden_contracts.constants.ID_TO_NETWORKNAME is used for name, if available,
... | [
"def",
"make_room_alias",
"(",
"chain_id",
":",
"ChainID",
",",
"*",
"suffixes",
":",
"str",
")",
"->",
"str",
":",
"network_name",
"=",
"ID_TO_NETWORKNAME",
".",
"get",
"(",
"chain_id",
",",
"str",
"(",
"chain_id",
")",
")",
"return",
"ROOM_NAME_SEPARATOR",... | Given a chain_id and any number of suffixes (global room names, pair of addresses),
compose and return the canonical room name for raiden network
network name from raiden_contracts.constants.ID_TO_NETWORKNAME is used for name, if available,
else numeric id
Params:
chain_id: numeric blockchain i... | [
"Given",
"a",
"chain_id",
"and",
"any",
"number",
"of",
"suffixes",
"(",
"global",
"room",
"names",
"pair",
"of",
"addresses",
")",
"compose",
"and",
"return",
"the",
"canonical",
"room",
"name",
"for",
"raiden",
"network"
] | python | train | 51.066667 |
palantir/python-jsonrpc-server | pyls_jsonrpc/endpoint.py | https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/endpoint.py#L57-L84 | def request(self, method, params=None):
"""Send a JSON RPC request to the client.
Args:
method (str): The method name of the message to send
params (any): The payload of the message
Returns:
Future that will resolve once a response has been received
... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"params",
"=",
"None",
")",
":",
"msg_id",
"=",
"self",
".",
"_id_generator",
"(",
")",
"log",
".",
"debug",
"(",
"'Sending request with id %s: %s %s'",
",",
"msg_id",
",",
"method",
",",
"params",
")",
... | Send a JSON RPC request to the client.
Args:
method (str): The method name of the message to send
params (any): The payload of the message
Returns:
Future that will resolve once a response has been received | [
"Send",
"a",
"JSON",
"RPC",
"request",
"to",
"the",
"client",
"."
] | python | train | 30.392857 |
dacut/python-aws-sig | awssig/sigv4.py | https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L496-L532 | def normalize_query_parameters(query_string):
"""
normalize_query_parameters(query_string) -> dict
Converts a query string into a dictionary mapping parameter names to a
list of the sorted values. This ensurses that the query string follows
% encoding rules according to RFC 3986 and checks for dup... | [
"def",
"normalize_query_parameters",
"(",
"query_string",
")",
":",
"if",
"query_string",
"==",
"\"\"",
":",
"return",
"{",
"}",
"components",
"=",
"query_string",
".",
"split",
"(",
"\"&\"",
")",
"result",
"=",
"{",
"}",
"for",
"component",
"in",
"component... | normalize_query_parameters(query_string) -> dict
Converts a query string into a dictionary mapping parameter names to a
list of the sorted values. This ensurses that the query string follows
% encoding rules according to RFC 3986 and checks for duplicate keys.
A ValueError exception is raised if a pe... | [
"normalize_query_parameters",
"(",
"query_string",
")",
"-",
">",
"dict"
] | python | train | 28.675676 |
gwpy/gwpy | gwpy/io/datafind.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/io/datafind.py#L192-L216 | def find_urls(self, site, frametype, gpsstart, gpsend,
match=None, on_gaps='warn'):
"""Find all files of the given type in the [start, end) GPS interval.
"""
span = Segment(gpsstart, gpsend)
cache = [e for e in self._read_ffl_cache(site, frametype) if
e... | [
"def",
"find_urls",
"(",
"self",
",",
"site",
",",
"frametype",
",",
"gpsstart",
",",
"gpsend",
",",
"match",
"=",
"None",
",",
"on_gaps",
"=",
"'warn'",
")",
":",
"span",
"=",
"Segment",
"(",
"gpsstart",
",",
"gpsend",
")",
"cache",
"=",
"[",
"e",
... | Find all files of the given type in the [start, end) GPS interval. | [
"Find",
"all",
"files",
"of",
"the",
"given",
"type",
"in",
"the",
"[",
"start",
"end",
")",
"GPS",
"interval",
"."
] | python | train | 38.04 |
chaoss/grimoirelab-elk | grimoire_elk/elk.py | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/elk.py#L524-L668 | def enrich_backend(url, clean, backend_name, backend_params, cfg_section_name,
ocean_index=None,
ocean_index_enrich=None,
db_projects_map=None, json_projects_map=None,
db_sortinghat=None,
no_incremental=False, only_identities... | [
"def",
"enrich_backend",
"(",
"url",
",",
"clean",
",",
"backend_name",
",",
"backend_params",
",",
"cfg_section_name",
",",
"ocean_index",
"=",
"None",
",",
"ocean_index_enrich",
"=",
"None",
",",
"db_projects_map",
"=",
"None",
",",
"json_projects_map",
"=",
"... | Enrich Ocean index | [
"Enrich",
"Ocean",
"index"
] | python | train | 46.813793 |
ejeschke/ginga | ginga/ImageView.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/ImageView.py#L2743-L2764 | def transform(self, flip_x, flip_y, swap_xy):
"""Transform view of the image.
.. note::
Transforming the image is generally faster than rotating,
if rotating in 90 degree increments. Also see :meth:`rotate`.
Parameters
----------
flipx, flipy : bool
... | [
"def",
"transform",
"(",
"self",
",",
"flip_x",
",",
"flip_y",
",",
"swap_xy",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"flip_x=%s flip_y=%s swap_xy=%s\"",
"%",
"(",
"flip_x",
",",
"flip_y",
",",
"swap_xy",
")",
")",
"with",
"self",
".",
"su... | Transform view of the image.
.. note::
Transforming the image is generally faster than rotating,
if rotating in 90 degree increments. Also see :meth:`rotate`.
Parameters
----------
flipx, flipy : bool
If `True`, flip the image in the X and Y axes, r... | [
"Transform",
"view",
"of",
"the",
"image",
"."
] | python | train | 29.863636 |
psphere-project/psphere | examples/vmcreate.py | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/examples/vmcreate.py#L28-L180 | def create_vm(client, name, compute_resource, datastore, disksize, nics,
memory, num_cpus, guest_id, host=None):
"""Create a virtual machine using the specified values.
:param name: The name of the VM to create.
:type name: str
:param compute_resource: The name of a ComputeResource in whi... | [
"def",
"create_vm",
"(",
"client",
",",
"name",
",",
"compute_resource",
",",
"datastore",
",",
"disksize",
",",
"nics",
",",
"memory",
",",
"num_cpus",
",",
"guest_id",
",",
"host",
"=",
"None",
")",
":",
"print",
"(",
"\"Creating VM %s\"",
"%",
"name",
... | Create a virtual machine using the specified values.
:param name: The name of the VM to create.
:type name: str
:param compute_resource: The name of a ComputeResource in which to \
create the VM.
:type compute_resource: str
:param datastore: The name of the datastore on which to create ... | [
"Create",
"a",
"virtual",
"machine",
"using",
"the",
"specified",
"values",
"."
] | python | train | 38 |
chimera0/accel-brain-code | Reinforcement-Learning/demo/demo_maze_greedy_q_learning.py | https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Reinforcement-Learning/demo/demo_maze_greedy_q_learning.py#L115-L132 | def visualize_learning_result(self, state_key):
'''
Visualize learning result.
'''
x, y = state_key
map_arr = copy.deepcopy(self.__map_arr)
goal_point_tuple = np.where(map_arr == self.__end_point_label)
goal_x, goal_y = goal_point_tuple
map_arr[y][x] = "@"... | [
"def",
"visualize_learning_result",
"(",
"self",
",",
"state_key",
")",
":",
"x",
",",
"y",
"=",
"state_key",
"map_arr",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"__map_arr",
")",
"goal_point_tuple",
"=",
"np",
".",
"where",
"(",
"map_arr",
"==",
... | Visualize learning result. | [
"Visualize",
"learning",
"result",
"."
] | python | train | 39.777778 |
GoogleCloudPlatform/datastore-ndb-python | ndb/model.py | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L1152-L1159 | def _retrieve_value(self, entity, default=None):
"""Internal helper to retrieve the value for this Property from an entity.
This returns None if no value is set, or the default argument if
given. For a repeated Property this returns a list if a value is
set, otherwise None. No additional transformati... | [
"def",
"_retrieve_value",
"(",
"self",
",",
"entity",
",",
"default",
"=",
"None",
")",
":",
"return",
"entity",
".",
"_values",
".",
"get",
"(",
"self",
".",
"_name",
",",
"default",
")"
] | Internal helper to retrieve the value for this Property from an entity.
This returns None if no value is set, or the default argument if
given. For a repeated Property this returns a list if a value is
set, otherwise None. No additional transformations are applied. | [
"Internal",
"helper",
"to",
"retrieve",
"the",
"value",
"for",
"this",
"Property",
"from",
"an",
"entity",
"."
] | python | train | 48.5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.