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 |
|---|---|---|---|---|---|---|---|---|---|
abe-winter/pg13-py | pg13/sqex.py | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/sqex.py#L16-L37 | def evalop(op,left,right):
"this takes evaluated left and right (i.e. values not expressions)"
if op in ('=','!=','>','<'): return threevl.ThreeVL.compare(op,left,right)
elif op in ('+','-','*','/'): # todo: does arithmetic require threevl?
if op=='/': raise NotImplementedError('todo: spec about int/float div... | [
"def",
"evalop",
"(",
"op",
",",
"left",
",",
"right",
")",
":",
"if",
"op",
"in",
"(",
"'='",
",",
"'!='",
",",
"'>'",
",",
"'<'",
")",
":",
"return",
"threevl",
".",
"ThreeVL",
".",
"compare",
"(",
"op",
",",
"left",
",",
"right",
")",
"elif"... | this takes evaluated left and right (i.e. values not expressions) | [
"this",
"takes",
"evaluated",
"left",
"and",
"right",
"(",
"i",
".",
"e",
".",
"values",
"not",
"expressions",
")"
] | python | train | 64.545455 |
jciskey/pygraph | pygraph/classes/directed_graph.py | https://github.com/jciskey/pygraph/blob/037bb2f32503fecb60d62921f9766d54109f15e2/pygraph/classes/directed_graph.py#L201-L215 | def move_edge_source(self, edge_id, node_a, node_b):
"""Moves an edge originating from node_a so that it originates from node_b."""
# Grab the edge
edge = self.get_edge(edge_id)
# Alter the vertices
edge['vertices'] = (node_b, edge['vertices'][1])
# Remove the edge from... | [
"def",
"move_edge_source",
"(",
"self",
",",
"edge_id",
",",
"node_a",
",",
"node_b",
")",
":",
"# Grab the edge",
"edge",
"=",
"self",
".",
"get_edge",
"(",
"edge_id",
")",
"# Alter the vertices",
"edge",
"[",
"'vertices'",
"]",
"=",
"(",
"node_b",
",",
"... | Moves an edge originating from node_a so that it originates from node_b. | [
"Moves",
"an",
"edge",
"originating",
"from",
"node_a",
"so",
"that",
"it",
"originates",
"from",
"node_b",
"."
] | python | train | 33.133333 |
Ceasar/twosheds | twosheds/completer.py | https://github.com/Ceasar/twosheds/blob/55b0a207e3a06b85e9a9567069b3822a651501a7/twosheds/completer.py#L155-L172 | def gen_matches(self, word):
"""Generate a sequence of possible completions for ``word``.
:param word: the word to complete
"""
if word.startswith("$"):
for match in self.gen_variable_completions(word, os.environ):
yield match
else:
head,... | [
"def",
"gen_matches",
"(",
"self",
",",
"word",
")",
":",
"if",
"word",
".",
"startswith",
"(",
"\"$\"",
")",
":",
"for",
"match",
"in",
"self",
".",
"gen_variable_completions",
"(",
"word",
",",
"os",
".",
"environ",
")",
":",
"yield",
"match",
"else"... | Generate a sequence of possible completions for ``word``.
:param word: the word to complete | [
"Generate",
"a",
"sequence",
"of",
"possible",
"completions",
"for",
"word",
"."
] | python | train | 36.055556 |
InfoAgeTech/django-core | django_core/utils/loading.py | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/utils/loading.py#L135-L162 | def get_function_from_settings(settings_key):
"""Gets a function from the string path defined in a settings file.
Example:
# my_app/my_file.py
def some_function():
# do something
pass
# settings.py
SOME_FUNCTION = 'my_app.my_file.some_function'
> get_function_from_setting... | [
"def",
"get_function_from_settings",
"(",
"settings_key",
")",
":",
"renderer_func_str",
"=",
"getattr",
"(",
"settings",
",",
"settings_key",
",",
"None",
")",
"if",
"not",
"renderer_func_str",
":",
"return",
"None",
"module_str",
",",
"renderer_func_name",
"=",
... | Gets a function from the string path defined in a settings file.
Example:
# my_app/my_file.py
def some_function():
# do something
pass
# settings.py
SOME_FUNCTION = 'my_app.my_file.some_function'
> get_function_from_settings('SOME_FUNCTION')
<function my_app.my_file.some_... | [
"Gets",
"a",
"function",
"from",
"the",
"string",
"path",
"defined",
"in",
"a",
"settings",
"file",
"."
] | python | train | 24.892857 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/productversions_api.py | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/productversions_api.py#L598-L621 | def update_build_configuration_sets(self, id, **kwargs):
"""
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.
>>> def callback_function(response):
... | [
"def",
"update_build_configuration_sets",
"(",
"self",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"update_build_co... | 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.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.update_build_co... | [
"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",
".",
... | python | train | 44.291667 |
Neurosim-lab/netpyne | netpyne/network/conn.py | https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/network/conn.py#L469-L508 | def divConn (self, preCellsTags, postCellsTags, connParam):
from .. import sim
''' Generates connections between all pre and post-syn cells based on probability values'''
if sim.cfg.verbose: print('Generating set of divergent connections (rule: %s) ...' % (connParam['label']))
# get list of param... | [
"def",
"divConn",
"(",
"self",
",",
"preCellsTags",
",",
"postCellsTags",
",",
"connParam",
")",
":",
"from",
".",
".",
"import",
"sim",
"if",
"sim",
".",
"cfg",
".",
"verbose",
":",
"print",
"(",
"'Generating set of divergent connections (rule: %s) ...'",
"%",
... | Generates connections between all pre and post-syn cells based on probability values | [
"Generates",
"connections",
"between",
"all",
"pre",
"and",
"post",
"-",
"syn",
"cells",
"based",
"on",
"probability",
"values"
] | python | train | 64.875 |
sentinel-hub/sentinelhub-py | sentinelhub/geopedia.py | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/geopedia.py#L388-L398 | def _fetch_features(self):
""" Retrieves a new page of features from Geopedia
"""
if self.next_page_url is None:
return
response = get_json(self.next_page_url, post_values=self.query, headers=self.gpd_session.session_headers)
self.features.extend(response['features'... | [
"def",
"_fetch_features",
"(",
"self",
")",
":",
"if",
"self",
".",
"next_page_url",
"is",
"None",
":",
"return",
"response",
"=",
"get_json",
"(",
"self",
".",
"next_page_url",
",",
"post_values",
"=",
"self",
".",
"query",
",",
"headers",
"=",
"self",
... | Retrieves a new page of features from Geopedia | [
"Retrieves",
"a",
"new",
"page",
"of",
"features",
"from",
"Geopedia"
] | python | train | 39.090909 |
emory-libraries/eulfedora | eulfedora/api.py | https://github.com/emory-libraries/eulfedora/blob/161826f3fdcdab4007f6fa7dfd9f1ecabc4bcbe4/eulfedora/api.py#L458-L479 | def getDatastream(self, pid, dsID, asOfDateTime=None, validateChecksum=False):
"""Get information about a single datastream on a Fedora object; optionally,
get information for the version of the datastream as of a particular date time.
:param pid: object pid
:param dsID: datastream id
... | [
"def",
"getDatastream",
"(",
"self",
",",
"pid",
",",
"dsID",
",",
"asOfDateTime",
"=",
"None",
",",
"validateChecksum",
"=",
"False",
")",
":",
"# /objects/{pid}/datastreams/{dsID} ? [asOfDateTime] [format] [validateChecksum]",
"http_args",
"=",
"{",
"}",
"if",
"vali... | Get information about a single datastream on a Fedora object; optionally,
get information for the version of the datastream as of a particular date time.
:param pid: object pid
:param dsID: datastream id
:param asOfDateTime: optional datetime; ``must`` be a non-naive datetime
... | [
"Get",
"information",
"about",
"a",
"single",
"datastream",
"on",
"a",
"Fedora",
"object",
";",
"optionally",
"get",
"information",
"for",
"the",
"version",
"of",
"the",
"datastream",
"as",
"of",
"a",
"particular",
"date",
"time",
"."
] | python | train | 55.636364 |
UDST/osmnet | osmnet/load.py | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L514-L539 | def process_node(e):
"""
Process a node element entry into a dict suitable for going into a
Pandas DataFrame.
Parameters
----------
e : dict
individual node element in downloaded OSM json
Returns
-------
node : dict
"""
node = {'id': e['id'],
'lat': e['... | [
"def",
"process_node",
"(",
"e",
")",
":",
"node",
"=",
"{",
"'id'",
":",
"e",
"[",
"'id'",
"]",
",",
"'lat'",
":",
"e",
"[",
"'lat'",
"]",
",",
"'lon'",
":",
"e",
"[",
"'lon'",
"]",
"}",
"if",
"'tags'",
"in",
"e",
":",
"if",
"e",
"[",
"'ta... | Process a node element entry into a dict suitable for going into a
Pandas DataFrame.
Parameters
----------
e : dict
individual node element in downloaded OSM json
Returns
-------
node : dict | [
"Process",
"a",
"node",
"element",
"entry",
"into",
"a",
"dict",
"suitable",
"for",
"going",
"into",
"a",
"Pandas",
"DataFrame",
"."
] | python | train | 20.769231 |
ensime/ensime-vim | ensime_shared/client.py | https://github.com/ensime/ensime-vim/blob/caa734e84f002b25446c615706283a74edd4ecfe/ensime_shared/client.py#L532-L546 | def send_refactor_request(self, ref_type, ref_params, ref_options):
"""Send a refactor request to the Ensime server.
The `ref_params` field will always have a field `type`.
"""
request = {
"typehint": ref_type,
"procId": self.refactor_id,
"params": re... | [
"def",
"send_refactor_request",
"(",
"self",
",",
"ref_type",
",",
"ref_params",
",",
"ref_options",
")",
":",
"request",
"=",
"{",
"\"typehint\"",
":",
"ref_type",
",",
"\"procId\"",
":",
"self",
".",
"refactor_id",
",",
"\"params\"",
":",
"ref_params",
"}",
... | Send a refactor request to the Ensime server.
The `ref_params` field will always have a field `type`. | [
"Send",
"a",
"refactor",
"request",
"to",
"the",
"Ensime",
"server",
"."
] | python | train | 33.6 |
klen/pylama | pylama/libs/inirama.py | https://github.com/klen/pylama/blob/f436ccc6b55b33381a295ded753e467953cf4379/pylama/libs/inirama.py#L109-L149 | def scan(self):
""" Scan source and grab tokens. """
self.pre_scan()
token = None
end = len(self.source)
while self.pos < end:
best_pat = None
best_pat_len = 0
# Check patterns
for p, regexp in self.patterns:
m ... | [
"def",
"scan",
"(",
"self",
")",
":",
"self",
".",
"pre_scan",
"(",
")",
"token",
"=",
"None",
"end",
"=",
"len",
"(",
"self",
".",
"source",
")",
"while",
"self",
".",
"pos",
"<",
"end",
":",
"best_pat",
"=",
"None",
"best_pat_len",
"=",
"0",
"#... | Scan source and grab tokens. | [
"Scan",
"source",
"and",
"grab",
"tokens",
"."
] | python | train | 25.707317 |
craffel/mir_eval | mir_eval/chord.py | https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L523-L556 | def encode_many(chord_labels, reduce_extended_chords=False):
"""Translate a set of chord labels to numerical representations for sane
evaluation.
Parameters
----------
chord_labels : list
Set of chord labels to encode.
reduce_extended_chords : bool
Whether to map the upper voici... | [
"def",
"encode_many",
"(",
"chord_labels",
",",
"reduce_extended_chords",
"=",
"False",
")",
":",
"num_items",
"=",
"len",
"(",
"chord_labels",
")",
"roots",
",",
"basses",
"=",
"np",
".",
"zeros",
"(",
"[",
"2",
",",
"num_items",
"]",
",",
"dtype",
"=",... | Translate a set of chord labels to numerical representations for sane
evaluation.
Parameters
----------
chord_labels : list
Set of chord labels to encode.
reduce_extended_chords : bool
Whether to map the upper voicings of extended chords (9's, 11's, 13's)
to semitone extensi... | [
"Translate",
"a",
"set",
"of",
"chord",
"labels",
"to",
"numerical",
"representations",
"for",
"sane",
"evaluation",
"."
] | python | train | 35.294118 |
petl-developers/petl | petl/io/whoosh.py | https://github.com/petl-developers/petl/blob/1d33ca055f7e04e0d28a772041c9fd30c8d415d6/petl/io/whoosh.py#L13-L62 | def fromtextindex(index_or_dirname, indexname=None, docnum_field=None):
"""
Extract all documents from a Whoosh index. E.g.::
>>> import petl as etl
>>> import os
>>> # set up an index and load some documents via the Whoosh API
... from whoosh.index import create_in
>>> ... | [
"def",
"fromtextindex",
"(",
"index_or_dirname",
",",
"indexname",
"=",
"None",
",",
"docnum_field",
"=",
"None",
")",
":",
"return",
"TextIndexView",
"(",
"index_or_dirname",
",",
"indexname",
"=",
"indexname",
",",
"docnum_field",
"=",
"docnum_field",
")"
] | Extract all documents from a Whoosh index. E.g.::
>>> import petl as etl
>>> import os
>>> # set up an index and load some documents via the Whoosh API
... from whoosh.index import create_in
>>> from whoosh.fields import *
>>> schema = Schema(title=TEXT(stored=True), pat... | [
"Extract",
"all",
"documents",
"from",
"a",
"Whoosh",
"index",
".",
"E",
".",
"g",
".",
"::"
] | python | train | 39.62 |
cozy/python_cozy_management | cozy_management/weboob.py | https://github.com/cozy/python_cozy_management/blob/820cea58458ae3e067fa8cc2da38edbda4681dac/cozy_management/weboob.py#L32-L72 | def install():
'''
Install weboob system-wide
'''
tmp_weboob_dir = '/tmp/weboob'
# Check that the directory does not already exists
while (os.path.exists(tmp_weboob_dir)):
tmp_weboob_dir += '1'
# Clone the repository
print 'Fetching sources in temporary dir {}'.format(tmp_w... | [
"def",
"install",
"(",
")",
":",
"tmp_weboob_dir",
"=",
"'/tmp/weboob'",
"# Check that the directory does not already exists",
"while",
"(",
"os",
".",
"path",
".",
"exists",
"(",
"tmp_weboob_dir",
")",
")",
":",
"tmp_weboob_dir",
"+=",
"'1'",
"# Clone the repository"... | Install weboob system-wide | [
"Install",
"weboob",
"system",
"-",
"wide"
] | python | train | 28.756098 |
MisterWil/abodepy | abodepy/__init__.py | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L264-L300 | def get_automations(self, refresh=False, generic_type=None):
"""Get all automations."""
if refresh or self._automations is None:
if self._automations is None:
# Set up the device libraries
self._automations = {}
_LOGGER.info("Updating all automati... | [
"def",
"get_automations",
"(",
"self",
",",
"refresh",
"=",
"False",
",",
"generic_type",
"=",
"None",
")",
":",
"if",
"refresh",
"or",
"self",
".",
"_automations",
"is",
"None",
":",
"if",
"self",
".",
"_automations",
"is",
"None",
":",
"# Set up the devi... | Get all automations. | [
"Get",
"all",
"automations",
"."
] | python | train | 41.459459 |
zetaops/zengine | zengine/views/permissions.py | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L110-L196 | def edit_permissions(self):
"""Creates the view used to edit permissions.
To create the view, data in the following format is passed to the UI
in the objects field:
.. code-block:: python
{
"type": "tree-toggle",
"action": "set_permission",
... | [
"def",
"edit_permissions",
"(",
"self",
")",
":",
"# Get the role that was selected in the CRUD view",
"key",
"=",
"self",
".",
"current",
".",
"input",
"[",
"'object_id'",
"]",
"self",
".",
"current",
".",
"task_data",
"[",
"'role_id'",
"]",
"=",
"key",
"role",... | Creates the view used to edit permissions.
To create the view, data in the following format is passed to the UI
in the objects field:
.. code-block:: python
{
"type": "tree-toggle",
"action": "set_permission",
"tree": [
... | [
"Creates",
"the",
"view",
"used",
"to",
"edit",
"permissions",
"."
] | python | train | 43.068966 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/transforms/transform_system.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/transform_system.py#L313-L335 | def get_transform(self, map_from='visual', map_to='render'):
"""Return a transform mapping between any two coordinate systems.
Parameters
----------
map_from : str
The starting coordinate system to map from. Must be one of: visual,
scene, document, canvas... | [
"def",
"get_transform",
"(",
"self",
",",
"map_from",
"=",
"'visual'",
",",
"map_to",
"=",
"'render'",
")",
":",
"tr",
"=",
"[",
"'visual'",
",",
"'scene'",
",",
"'document'",
",",
"'canvas'",
",",
"'framebuffer'",
",",
"'render'",
"]",
"ifrom",
"=",
"tr... | Return a transform mapping between any two coordinate systems.
Parameters
----------
map_from : str
The starting coordinate system to map from. Must be one of: visual,
scene, document, canvas, framebuffer, or render.
map_to : str
The ending co... | [
"Return",
"a",
"transform",
"mapping",
"between",
"any",
"two",
"coordinate",
"systems",
".",
"Parameters",
"----------",
"map_from",
":",
"str",
"The",
"starting",
"coordinate",
"system",
"to",
"map",
"from",
".",
"Must",
"be",
"one",
"of",
":",
"visual",
"... | python | train | 40.695652 |
timothycrosley/connectable | connectable/base.py | https://github.com/timothycrosley/connectable/blob/d5958d974c04b16f410c602786809d0e2a6665d2/connectable/base.py#L22-L57 | def emit(self, signal, value=None, gather=False):
"""Emits a signal, causing all slot methods connected with the signal to be called (optionally w/ related value)
signal: the name of the signal to emit, must be defined in the classes 'signals' list.
value: the value to pass to all connect... | [
"def",
"emit",
"(",
"self",
",",
"signal",
",",
"value",
"=",
"None",
",",
"gather",
"=",
"False",
")",
":",
"results",
"=",
"[",
"]",
"if",
"gather",
"else",
"True",
"if",
"hasattr",
"(",
"self",
",",
"'connections'",
")",
"and",
"signal",
"in",
"... | Emits a signal, causing all slot methods connected with the signal to be called (optionally w/ related value)
signal: the name of the signal to emit, must be defined in the classes 'signals' list.
value: the value to pass to all connected slot methods.
gather: if set, causes emit to re... | [
"Emits",
"a",
"signal",
"causing",
"all",
"slot",
"methods",
"connected",
"with",
"the",
"signal",
"to",
"be",
"called",
"(",
"optionally",
"w",
"/",
"related",
"value",
")"
] | python | train | 48.472222 |
Yelp/kafka-utils | kafka_utils/util/validation.py | https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/util/validation.py#L85-L152 | def _validate_plan_base(
new_plan,
base_plan,
is_partition_subset=True,
allow_rf_change=False,
):
"""Validate if given plan is valid comparing with given base-plan.
Validate following assertions:
- Partition-check: New partition-set should be subset of base-partition set
- Replica-count... | [
"def",
"_validate_plan_base",
"(",
"new_plan",
",",
"base_plan",
",",
"is_partition_subset",
"=",
"True",
",",
"allow_rf_change",
"=",
"False",
",",
")",
":",
"# Verify that partitions in plan are subset of base plan.",
"new_partitions",
"=",
"set",
"(",
"[",
"(",
"p_... | Validate if given plan is valid comparing with given base-plan.
Validate following assertions:
- Partition-check: New partition-set should be subset of base-partition set
- Replica-count check: Replication-factor for each partition remains same
- Broker-check: New broker-set should be subset of base br... | [
"Validate",
"if",
"given",
"plan",
"is",
"valid",
"comparing",
"with",
"given",
"base",
"-",
"plan",
"."
] | python | train | 35.308824 |
vallis/libstempo | libstempo/toasim.py | https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L153-L176 | def add_efac(psr, efac=1.0, flagid=None, flags=None, seed=None):
"""Add nominal TOA errors, multiplied by `efac` factor.
Optionally take a pseudorandom-number-generator seed."""
if seed is not None:
N.random.seed(seed)
# default efacvec
efacvec = N.ones(psr.nobs)
# check that efac... | [
"def",
"add_efac",
"(",
"psr",
",",
"efac",
"=",
"1.0",
",",
"flagid",
"=",
"None",
",",
"flags",
"=",
"None",
",",
"seed",
"=",
"None",
")",
":",
"if",
"seed",
"is",
"not",
"None",
":",
"N",
".",
"random",
".",
"seed",
"(",
"seed",
")",
"# def... | Add nominal TOA errors, multiplied by `efac` factor.
Optionally take a pseudorandom-number-generator seed. | [
"Add",
"nominal",
"TOA",
"errors",
"multiplied",
"by",
"efac",
"factor",
".",
"Optionally",
"take",
"a",
"pseudorandom",
"-",
"number",
"-",
"generator",
"seed",
"."
] | python | train | 35.833333 |
fananimi/pyzk | zk/base.py | https://github.com/fananimi/pyzk/blob/1a765d616526efdcb4c9adfcc9b1d10f6ed8b938/zk/base.py#L178-L184 | def __create_tcp_top(self, packet):
"""
witch the complete packet set top header
"""
length = len(packet)
top = pack('<HHI', const.MACHINE_PREPARE_DATA_1, const.MACHINE_PREPARE_DATA_2, length)
return top + packet | [
"def",
"__create_tcp_top",
"(",
"self",
",",
"packet",
")",
":",
"length",
"=",
"len",
"(",
"packet",
")",
"top",
"=",
"pack",
"(",
"'<HHI'",
",",
"const",
".",
"MACHINE_PREPARE_DATA_1",
",",
"const",
".",
"MACHINE_PREPARE_DATA_2",
",",
"length",
")",
"ret... | witch the complete packet set top header | [
"witch",
"the",
"complete",
"packet",
"set",
"top",
"header"
] | python | train | 36.285714 |
dpgaspar/Flask-AppBuilder | flask_appbuilder/baseviews.py | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L172-L184 | def render_template(self, template, **kwargs):
"""
Use this method on your own endpoints, will pass the extra_args
to the templates.
:param template: The template relative path
:param kwargs: arguments to be passed to the template
"""
kwargs["base... | [
"def",
"render_template",
"(",
"self",
",",
"template",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"\"base_template\"",
"]",
"=",
"self",
".",
"appbuilder",
".",
"base_template",
"kwargs",
"[",
"\"appbuilder\"",
"]",
"=",
"self",
".",
"appbuilder",
... | Use this method on your own endpoints, will pass the extra_args
to the templates.
:param template: The template relative path
:param kwargs: arguments to be passed to the template | [
"Use",
"this",
"method",
"on",
"your",
"own",
"endpoints",
"will",
"pass",
"the",
"extra_args",
"to",
"the",
"templates",
"."
] | python | train | 40.230769 |
sethmlarson/virtualbox-python | virtualbox/library.py | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L25437-L25450 | def set_seamless_mode(self, enabled):
"""Enables or disables seamless guest display rendering (seamless desktop
integration) mode.
Calling this method has no effect if :py:func:`IGuest.get_facility_status` with facility @c Seamless
does not return @c Active.
in enabled... | [
"def",
"set_seamless_mode",
"(",
"self",
",",
"enabled",
")",
":",
"if",
"not",
"isinstance",
"(",
"enabled",
",",
"bool",
")",
":",
"raise",
"TypeError",
"(",
"\"enabled can only be an instance of type bool\"",
")",
"self",
".",
"_call",
"(",
"\"setSeamlessMode\"... | Enables or disables seamless guest display rendering (seamless desktop
integration) mode.
Calling this method has no effect if :py:func:`IGuest.get_facility_status` with facility @c Seamless
does not return @c Active.
in enabled of type bool | [
"Enables",
"or",
"disables",
"seamless",
"guest",
"display",
"rendering",
"(",
"seamless",
"desktop",
"integration",
")",
"mode",
".",
"Calling",
"this",
"method",
"has",
"no",
"effect",
"if",
":",
"py",
":",
"func",
":",
"IGuest",
".",
"get_facility_status",
... | python | train | 37.571429 |
LasLabs/python-helpscout | helpscout/base_model.py | https://github.com/LasLabs/python-helpscout/blob/84bf669417d72ca19641a02c9a660e1ae4271de4/helpscout/base_model.py#L96-L102 | def _parse_api_value_list(self, values):
"""Return a list field compatible with the API."""
try:
return [v.to_api() for v in values]
# Not models
except AttributeError:
return list(values) | [
"def",
"_parse_api_value_list",
"(",
"self",
",",
"values",
")",
":",
"try",
":",
"return",
"[",
"v",
".",
"to_api",
"(",
")",
"for",
"v",
"in",
"values",
"]",
"# Not models",
"except",
"AttributeError",
":",
"return",
"list",
"(",
"values",
")"
] | Return a list field compatible with the API. | [
"Return",
"a",
"list",
"field",
"compatible",
"with",
"the",
"API",
"."
] | python | train | 34 |
okfn/ofs | ofs/local/zipfile.py | https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipfile.py#L1118-L1146 | def remove(self, member):
"""Remove a member from the archive."""
# Make sure we have an info object
if isinstance(member, ZipInfo):
# 'member' is already an info object
zinfo = member
else:
# Get info object for name
zinfo = self.getinfo(m... | [
"def",
"remove",
"(",
"self",
",",
"member",
")",
":",
"# Make sure we have an info object",
"if",
"isinstance",
"(",
"member",
",",
"ZipInfo",
")",
":",
"# 'member' is already an info object",
"zinfo",
"=",
"member",
"else",
":",
"# Get info object for name",
"zinfo"... | Remove a member from the archive. | [
"Remove",
"a",
"member",
"from",
"the",
"archive",
"."
] | python | train | 33.965517 |
stan-dev/pystan | pystan/misc.py | https://github.com/stan-dev/pystan/blob/57bdccea11888157e7aaafba083003080a934805/pystan/misc.py#L1088-L1110 | def _remove_empty_pars(pars, pars_oi, dims_oi):
"""
Remove parameters that are actually empty. For example, the parameter
y would be removed with the following model code:
transformed data { int n; n <- 0; }
parameters { real y[n]; }
Parameters
----------
pars: iterable of str
... | [
"def",
"_remove_empty_pars",
"(",
"pars",
",",
"pars_oi",
",",
"dims_oi",
")",
":",
"pars",
"=",
"list",
"(",
"pars",
")",
"for",
"par",
",",
"dim",
"in",
"zip",
"(",
"pars_oi",
",",
"dims_oi",
")",
":",
"if",
"par",
"in",
"pars",
"and",
"np",
".",... | Remove parameters that are actually empty. For example, the parameter
y would be removed with the following model code:
transformed data { int n; n <- 0; }
parameters { real y[n]; }
Parameters
----------
pars: iterable of str
pars_oi: list of str
dims_oi: list of list of int
... | [
"Remove",
"parameters",
"that",
"are",
"actually",
"empty",
".",
"For",
"example",
"the",
"parameter",
"y",
"would",
"be",
"removed",
"with",
"the",
"following",
"model",
"code",
":"
] | python | train | 25.347826 |
libtcod/python-tcod | tcod/libtcodpy.py | https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2372-L2391 | def heightmap_lerp_hm(
hm1: np.ndarray, hm2: np.ndarray, hm3: np.ndarray, coef: float
) -> None:
"""Perform linear interpolation between two heightmaps storing the result
in ``hm3``.
This is the same as doing ``hm3[:] = hm1[:] + (hm2[:] - hm1[:]) * coef``
Args:
hm1 (numpy.ndarray): The fir... | [
"def",
"heightmap_lerp_hm",
"(",
"hm1",
":",
"np",
".",
"ndarray",
",",
"hm2",
":",
"np",
".",
"ndarray",
",",
"hm3",
":",
"np",
".",
"ndarray",
",",
"coef",
":",
"float",
")",
"->",
"None",
":",
"lib",
".",
"TCOD_heightmap_lerp_hm",
"(",
"_heightmap_c... | Perform linear interpolation between two heightmaps storing the result
in ``hm3``.
This is the same as doing ``hm3[:] = hm1[:] + (hm2[:] - hm1[:]) * coef``
Args:
hm1 (numpy.ndarray): The first heightmap.
hm2 (numpy.ndarray): The second heightmap to add to the first.
hm3 (numpy.ndar... | [
"Perform",
"linear",
"interpolation",
"between",
"two",
"heightmaps",
"storing",
"the",
"result",
"in",
"hm3",
"."
] | python | train | 33.6 |
ricequant/rqalpha | rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py#L285-L304 | def sell_close(id_or_ins, amount, price=None, style=None, close_today=False):
"""
平买仓
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`]
:param int amount: 下单手数
:param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主... | [
"def",
"sell_close",
"(",
"id_or_ins",
",",
"amount",
",",
"price",
"=",
"None",
",",
"style",
"=",
"None",
",",
"close_today",
"=",
"False",
")",
":",
"position_effect",
"=",
"POSITION_EFFECT",
".",
"CLOSE_TODAY",
"if",
"close_today",
"else",
"POSITION_EFFECT... | 平买仓
:param id_or_ins: 下单标的物
:type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`]
:param int amount: 下单手数
:param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `style` 参数。
:param style: 下单类型, 默认是市价单。目前支持的订单类型有 :class:`~LimitOrder` 和 :class... | [
"平买仓"
] | python | train | 37.75 |
textX/textX | textx/metamodel.py | https://github.com/textX/textX/blob/5796ac38116ad86584392dbecdbf923ede746361/textx/metamodel.py#L243-L277 | def _new_import(self, import_name):
"""
Starts a new import.
Args:
import_name(str): A relative import in the dot syntax
(e.g. "first.second.expressions")
"""
# Import can't be used if meta-model is loaded from string
assert self.root_path is ... | [
"def",
"_new_import",
"(",
"self",
",",
"import_name",
")",
":",
"# Import can't be used if meta-model is loaded from string",
"assert",
"self",
".",
"root_path",
"is",
"not",
"None",
",",
"'\"import\" statement can not be used if meta-model is '",
"'loaded from string.'",
"# F... | Starts a new import.
Args:
import_name(str): A relative import in the dot syntax
(e.g. "first.second.expressions") | [
"Starts",
"a",
"new",
"import",
".",
"Args",
":",
"import_name",
"(",
"str",
")",
":",
"A",
"relative",
"import",
"in",
"the",
"dot",
"syntax",
"(",
"e",
".",
"g",
".",
"first",
".",
"second",
".",
"expressions",
")"
] | python | train | 41.857143 |
cs50/check50 | check50/api.py | https://github.com/cs50/check50/blob/42c1f0c36baa6a24f69742d74551a9ea7a5ceb33/check50/api.py#L400-L413 | def _raw(s):
"""Get raw representation of s, truncating if too long."""
if isinstance(s, list):
s = "\n".join(_raw(item) for item in s)
if s == EOF:
return "EOF"
s = repr(s) # Get raw representation of string
s = s[1:-1] # Strip away quotation marks
if len(s) > 15:
s... | [
"def",
"_raw",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"list",
")",
":",
"s",
"=",
"\"\\n\"",
".",
"join",
"(",
"_raw",
"(",
"item",
")",
"for",
"item",
"in",
"s",
")",
"if",
"s",
"==",
"EOF",
":",
"return",
"\"EOF\"",
"s",
"="... | Get raw representation of s, truncating if too long. | [
"Get",
"raw",
"representation",
"of",
"s",
"truncating",
"if",
"too",
"long",
"."
] | python | train | 25.785714 |
hubo1016/vlcp | vlcp/utils/http.py | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L197-L205 | def bufferoutput(self):
"""
Buffer the whole output until write EOF or flushed.
"""
new_stream = Stream(writebufferlimit=None)
if self._sendHeaders:
# An extra copy
self.container.subroutine(new_stream.copy_to(self.outputstream, self.container, buffering=F... | [
"def",
"bufferoutput",
"(",
"self",
")",
":",
"new_stream",
"=",
"Stream",
"(",
"writebufferlimit",
"=",
"None",
")",
"if",
"self",
".",
"_sendHeaders",
":",
"# An extra copy",
"self",
".",
"container",
".",
"subroutine",
"(",
"new_stream",
".",
"copy_to",
"... | Buffer the whole output until write EOF or flushed. | [
"Buffer",
"the",
"whole",
"output",
"until",
"write",
"EOF",
"or",
"flushed",
"."
] | python | train | 41.777778 |
maaku/python-bitcoin | bitcoin/merkle.py | https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/merkle.py#L42-L76 | def merkle(hashes, func=_merkle_hash256):
"""Convert an iterable of hashes or hashable objects into a binary tree,
construct the interior values using a passed-in constructor or compression
function, and return the root value of the tree. The default compressor is
the hash256 function, resulting in root... | [
"def",
"merkle",
"(",
"hashes",
",",
"func",
"=",
"_merkle_hash256",
")",
":",
"# We use append to duplicate the final item in the iterable of hashes, so",
"# we need hashes to be a list-like object, regardless of what we were",
"# passed.",
"hashes",
"=",
"list",
"(",
"iter",
"(... | Convert an iterable of hashes or hashable objects into a binary tree,
construct the interior values using a passed-in constructor or compression
function, and return the root value of the tree. The default compressor is
the hash256 function, resulting in root-hash for the entire tree. | [
"Convert",
"an",
"iterable",
"of",
"hashes",
"or",
"hashable",
"objects",
"into",
"a",
"binary",
"tree",
"construct",
"the",
"interior",
"values",
"using",
"a",
"passed",
"-",
"in",
"constructor",
"or",
"compression",
"function",
"and",
"return",
"the",
"root"... | python | train | 55.114286 |
docker/docker-py | docker/utils/proxy.py | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/utils/proxy.py#L40-L54 | def get_environment(self):
'''
Return a dictionary representing the environment variables used to
set the proxy settings.
'''
env = {}
if self.http:
env['http_proxy'] = env['HTTP_PROXY'] = self.http
if self.https:
env['https_proxy'] = env['... | [
"def",
"get_environment",
"(",
"self",
")",
":",
"env",
"=",
"{",
"}",
"if",
"self",
".",
"http",
":",
"env",
"[",
"'http_proxy'",
"]",
"=",
"env",
"[",
"'HTTP_PROXY'",
"]",
"=",
"self",
".",
"http",
"if",
"self",
".",
"https",
":",
"env",
"[",
"... | Return a dictionary representing the environment variables used to
set the proxy settings. | [
"Return",
"a",
"dictionary",
"representing",
"the",
"environment",
"variables",
"used",
"to",
"set",
"the",
"proxy",
"settings",
"."
] | python | train | 34.6 |
assemblerflow/flowcraft | flowcraft/templates/assembly_report.py | https://github.com/assemblerflow/flowcraft/blob/fc3f4bddded1efc76006600016dc71a06dd908c0/flowcraft/templates/assembly_report.py#L284-L315 | def _get_window_labels(self, window):
"""Returns the mapping between sliding window points and their contigs,
and the x-axis position of contig
Parameters
----------
window : int
Size of the window.
Returns
-------
xbars : list
Th... | [
"def",
"_get_window_labels",
"(",
"self",
",",
"window",
")",
":",
"# Get summary stats, if they have not yet been triggered",
"if",
"not",
"self",
".",
"summary_info",
":",
"self",
".",
"get_summary_stats",
"(",
")",
"# Get contig boundary positon",
"c",
"=",
"0",
"x... | Returns the mapping between sliding window points and their contigs,
and the x-axis position of contig
Parameters
----------
window : int
Size of the window.
Returns
-------
xbars : list
The x-axis position of the ending for each contig.
... | [
"Returns",
"the",
"mapping",
"between",
"sliding",
"window",
"points",
"and",
"their",
"contigs",
"and",
"the",
"x",
"-",
"axis",
"position",
"of",
"contig"
] | python | test | 28.65625 |
huge-success/sanic | sanic/router.py | https://github.com/huge-success/sanic/blob/6a4a3f617fdbe1d3ee8bdc9d1b12ad2d0b34acdd/sanic/router.py#L428-L478 | def _get(self, url, method, host):
"""Get a request handler based on the URL of the request, or raises an
error. Internal method for caching.
:param url: request URL
:param method: request method
:return: handler, arguments, keyword arguments
"""
url = unquote(h... | [
"def",
"_get",
"(",
"self",
",",
"url",
",",
"method",
",",
"host",
")",
":",
"url",
"=",
"unquote",
"(",
"host",
"+",
"url",
")",
"# Check against known static routes",
"route",
"=",
"self",
".",
"routes_static",
".",
"get",
"(",
"url",
")",
"method_not... | Get a request handler based on the URL of the request, or raises an
error. Internal method for caching.
:param url: request URL
:param method: request method
:return: handler, arguments, keyword arguments | [
"Get",
"a",
"request",
"handler",
"based",
"on",
"the",
"URL",
"of",
"the",
"request",
"or",
"raises",
"an",
"error",
".",
"Internal",
"method",
"for",
"caching",
"."
] | python | train | 41.254902 |
quantmind/pulsar | examples/calculator/manage.py | https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/examples/calculator/manage.py#L72-L80 | def setup(self, environ):
'''Called once to setup the list of wsgi middleware.'''
json_handler = Root().putSubHandler('calc', Calculator())
middleware = wsgi.Router('/', post=json_handler,
accept_content_types=JSON_CONTENT_TYPES)
response = [wsgi.GZipMidd... | [
"def",
"setup",
"(",
"self",
",",
"environ",
")",
":",
"json_handler",
"=",
"Root",
"(",
")",
".",
"putSubHandler",
"(",
"'calc'",
",",
"Calculator",
"(",
")",
")",
"middleware",
"=",
"wsgi",
".",
"Router",
"(",
"'/'",
",",
"post",
"=",
"json_handler",... | Called once to setup the list of wsgi middleware. | [
"Called",
"once",
"to",
"setup",
"the",
"list",
"of",
"wsgi",
"middleware",
"."
] | python | train | 57.555556 |
juju/python-libjuju | juju/model.py | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/model.py#L759-L797 | def add_observer(
self, callable_, entity_type=None, action=None, entity_id=None,
predicate=None):
"""Register an "on-model-change" callback
Once the model is connected, ``callable_``
will be called each time the model changes. ``callable_`` should
be Awaitable a... | [
"def",
"add_observer",
"(",
"self",
",",
"callable_",
",",
"entity_type",
"=",
"None",
",",
"action",
"=",
"None",
",",
"entity_id",
"=",
"None",
",",
"predicate",
"=",
"None",
")",
":",
"observer",
"=",
"_Observer",
"(",
"callable_",
",",
"entity_type",
... | Register an "on-model-change" callback
Once the model is connected, ``callable_``
will be called each time the model changes. ``callable_`` should
be Awaitable and accept the following positional arguments:
delta - An instance of :class:`juju.delta.EntityDelta`
cont... | [
"Register",
"an",
"on",
"-",
"model",
"-",
"change",
"callback"
] | python | train | 41.871795 |
jaredLunde/redis_structures | redis_structures/__init__.py | https://github.com/jaredLunde/redis_structures/blob/b9cce5f5c85db5e12c292633ff8d04e3ae053294/redis_structures/__init__.py#L1402-L1409 | def extend(self, items):
""" Adds @items to the end of the list
-> #int length of list after operation
"""
if items:
if self.serialized:
items = list(map(self._dumps, items))
self._client.rpush(self.key_prefix, *items) | [
"def",
"extend",
"(",
"self",
",",
"items",
")",
":",
"if",
"items",
":",
"if",
"self",
".",
"serialized",
":",
"items",
"=",
"list",
"(",
"map",
"(",
"self",
".",
"_dumps",
",",
"items",
")",
")",
"self",
".",
"_client",
".",
"rpush",
"(",
"self... | Adds @items to the end of the list
-> #int length of list after operation | [
"Adds"
] | python | train | 35.875 |
choderalab/pymbar | pymbar/bar.py | https://github.com/choderalab/pymbar/blob/69d1f0ff680e9ac1c6a51a5a207ea28f3ed86740/pymbar/bar.py#L150-L495 | def BAR(w_F, w_R, DeltaF=0.0, compute_uncertainty=True, uncertainty_method='BAR',maximum_iterations=500, relative_tolerance=1.0e-12, verbose=False, method='false-position', iterated_solution=True):
"""Compute free energy difference using the Bennett acceptance ratio (BAR) method.
Parameters
----------
... | [
"def",
"BAR",
"(",
"w_F",
",",
"w_R",
",",
"DeltaF",
"=",
"0.0",
",",
"compute_uncertainty",
"=",
"True",
",",
"uncertainty_method",
"=",
"'BAR'",
",",
"maximum_iterations",
"=",
"500",
",",
"relative_tolerance",
"=",
"1.0e-12",
",",
"verbose",
"=",
"False",... | Compute free energy difference using the Bennett acceptance ratio (BAR) method.
Parameters
----------
w_F : np.ndarray
w_F[t] is the forward work value from snapshot t.
t = 0...(T_F-1) Length T_F is deduced from vector.
w_R : np.ndarray
w_R[t] is the reverse work value from sna... | [
"Compute",
"free",
"energy",
"difference",
"using",
"the",
"Bennett",
"acceptance",
"ratio",
"(",
"BAR",
")",
"method",
"."
] | python | train | 42.066474 |
AdvancedClimateSystems/uModbus | umodbus/functions.py | https://github.com/AdvancedClimateSystems/uModbus/blob/0560a42308003f4072d988f28042b8d55b694ad4/umodbus/functions.py#L726-L743 | def create_from_response_pdu(resp_pdu, req_pdu):
""" Create instance from response PDU.
Response PDU is required together with the number of registers read.
:param resp_pdu: Byte array with request PDU.
:param quantity: Number of coils read.
:return: Instance of :class:`ReadCoi... | [
"def",
"create_from_response_pdu",
"(",
"resp_pdu",
",",
"req_pdu",
")",
":",
"read_holding_registers",
"=",
"ReadHoldingRegisters",
"(",
")",
"read_holding_registers",
".",
"quantity",
"=",
"struct",
".",
"unpack",
"(",
"'>H'",
",",
"req_pdu",
"[",
"-",
"2",
":... | Create instance from response PDU.
Response PDU is required together with the number of registers read.
:param resp_pdu: Byte array with request PDU.
:param quantity: Number of coils read.
:return: Instance of :class:`ReadCoils`. | [
"Create",
"instance",
"from",
"response",
"PDU",
"."
] | python | train | 41 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/logging.py | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/logging.py#L185-L209 | def gridLog(**kw):
"""Send GLRecord, Distributed Logging Utilities
If the scheme is passed as a keyword parameter
the value is expected to be a callable function
that takes 2 parameters: url, outputStr
GRIDLOG_ON -- turn grid logging on
GRIDLOG_DEST -- provide URL destination
"""
impo... | [
"def",
"gridLog",
"(",
"*",
"*",
"kw",
")",
":",
"import",
"os",
"if",
"not",
"bool",
"(",
"int",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'GRIDLOG_ON'",
",",
"0",
")",
")",
")",
":",
"return",
"url",
"=",
"os",
".",
"environ",
".",
"get",
... | Send GLRecord, Distributed Logging Utilities
If the scheme is passed as a keyword parameter
the value is expected to be a callable function
that takes 2 parameters: url, outputStr
GRIDLOG_ON -- turn grid logging on
GRIDLOG_DEST -- provide URL destination | [
"Send",
"GLRecord",
"Distributed",
"Logging",
"Utilities",
"If",
"the",
"scheme",
"is",
"passed",
"as",
"a",
"keyword",
"parameter",
"the",
"value",
"is",
"expected",
"to",
"be",
"a",
"callable",
"function",
"that",
"takes",
"2",
"parameters",
":",
"url",
"o... | python | train | 28.84 |
nmohoric/nypl-digital-collections | nyplcollections/nyplcollections.py | https://github.com/nmohoric/nypl-digital-collections/blob/f66cd0a11e7ea2b6c3c327d2693211e2c4609231/nyplcollections/nyplcollections.py#L42-L58 | def _get(self, components, picker, **params):
"""Generic get which handles call to api and setting of results
Return: Results object"""
url = '/'.join((self.base,) + components)
headers = {"Authorization": "Token token=" + self._token}
params['page'] = params.get('page') or sel... | [
"def",
"_get",
"(",
"self",
",",
"components",
",",
"picker",
",",
"*",
"*",
"params",
")",
":",
"url",
"=",
"'/'",
".",
"join",
"(",
"(",
"self",
".",
"base",
",",
")",
"+",
"components",
")",
"headers",
"=",
"{",
"\"Authorization\"",
":",
"\"Toke... | Generic get which handles call to api and setting of results
Return: Results object | [
"Generic",
"get",
"which",
"handles",
"call",
"to",
"api",
"and",
"setting",
"of",
"results",
"Return",
":",
"Results",
"object"
] | python | train | 36.294118 |
nefarioustim/parker | parker/client.py | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/client.py#L23-L40 | def get_instance():
"""Return an instance of Client."""
global _instances
user_agents = _config['user-agents']
user_agent = user_agents[
random.randint(0, len(user_agents) - 1)
] if len(user_agents) > 0 else DEFAULT_UA
instance_key = user_agent
try:
instance = _instances[i... | [
"def",
"get_instance",
"(",
")",
":",
"global",
"_instances",
"user_agents",
"=",
"_config",
"[",
"'user-agents'",
"]",
"user_agent",
"=",
"user_agents",
"[",
"random",
".",
"randint",
"(",
"0",
",",
"len",
"(",
"user_agents",
")",
"-",
"1",
")",
"]",
"i... | Return an instance of Client. | [
"Return",
"an",
"instance",
"of",
"Client",
"."
] | python | train | 25 |
ontio/ontology-python-sdk | ontology/network/rpc.py | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L320-L335 | def get_allowance(self, asset_name: str, from_address: str, to_address: str, is_full: bool = False) -> str:
"""
This interface is used to get the the allowance
from transfer-from account to transfer-to account in current network.
:param asset_name:
:param from_address: a base58 ... | [
"def",
"get_allowance",
"(",
"self",
",",
"asset_name",
":",
"str",
",",
"from_address",
":",
"str",
",",
"to_address",
":",
"str",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
... | This interface is used to get the the allowance
from transfer-from account to transfer-to account in current network.
:param asset_name:
:param from_address: a base58 encoded account address.
:param to_address: a base58 encoded account address.
:param is_full:
:return: t... | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"the",
"allowance",
"from",
"transfer",
"-",
"from",
"account",
"to",
"transfer",
"-",
"to",
"account",
"in",
"current",
"network",
"."
] | python | train | 46.25 |
wdecoster/nanoplotter | nanoplotter/compplots.py | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/compplots.py#L13-L68 | def violin_or_box_plot(df, y, figformat, path, y_name,
title=None, plot="violin", log=False, palette=None):
"""Create a violin or boxplot from the received DataFrame.
The x-axis should be divided based on the 'dataset' column,
the y-axis is specified in the arguments
"""
comp... | [
"def",
"violin_or_box_plot",
"(",
"df",
",",
"y",
",",
"figformat",
",",
"path",
",",
"y_name",
",",
"title",
"=",
"None",
",",
"plot",
"=",
"\"violin\"",
",",
"log",
"=",
"False",
",",
"palette",
"=",
"None",
")",
":",
"comp",
"=",
"Plot",
"(",
"p... | Create a violin or boxplot from the received DataFrame.
The x-axis should be divided based on the 'dataset' column,
the y-axis is specified in the arguments | [
"Create",
"a",
"violin",
"or",
"boxplot",
"from",
"the",
"received",
"DataFrame",
"."
] | python | train | 48.375 |
ayoungprogrammer/Lango | lango/matcher.py | https://github.com/ayoungprogrammer/Lango/blob/0c4284c153abc2d8de4b03a86731bd84385e6afa/lango/matcher.py#L274-L288 | def get_raw(tree):
"""Get the exact words in lowercase in the tree object.
Args:
tree (Tree): Parsed tree structure
Returns:
Resulting string of tree ``(Ex: "The red car")``
"""
if isinstance(tree, Tree):
words = []
for child in tree:
words.append(get... | [
"def",
"get_raw",
"(",
"tree",
")",
":",
"if",
"isinstance",
"(",
"tree",
",",
"Tree",
")",
":",
"words",
"=",
"[",
"]",
"for",
"child",
"in",
"tree",
":",
"words",
".",
"append",
"(",
"get_raw",
"(",
"child",
")",
")",
"return",
"' '",
".",
"joi... | Get the exact words in lowercase in the tree object.
Args:
tree (Tree): Parsed tree structure
Returns:
Resulting string of tree ``(Ex: "The red car")`` | [
"Get",
"the",
"exact",
"words",
"in",
"lowercase",
"in",
"the",
"tree",
"object",
".",
"Args",
":",
"tree",
"(",
"Tree",
")",
":",
"Parsed",
"tree",
"structure",
"Returns",
":",
"Resulting",
"string",
"of",
"tree",
"(",
"Ex",
":",
"The",
"red",
"car",
... | python | train | 25.266667 |
EmbodiedCognition/pagoda | pagoda/physics.py | https://github.com/EmbodiedCognition/pagoda/blob/8892f847026d98aba8646ecbc4589397e6dec7bd/pagoda/physics.py#L532-L534 | def position_rates(self):
'''List of position rates for linear degrees of freedom.'''
return [self.ode_obj.getPositionRate(i) for i in range(self.LDOF)] | [
"def",
"position_rates",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"ode_obj",
".",
"getPositionRate",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"LDOF",
")",
"]"
] | List of position rates for linear degrees of freedom. | [
"List",
"of",
"position",
"rates",
"for",
"linear",
"degrees",
"of",
"freedom",
"."
] | python | valid | 55.333333 |
ihmeuw/vivarium | src/vivarium/framework/event.py | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/event.py#L150-L165 | def get_emitter(self, name: str) -> Callable[[Event], Event]:
"""Gets and emitter for a named event.
Parameters
----------
name :
The name of the event he requested emitter will emit.
Users may provide their own named events by requesting an emitter with this fun... | [
"def",
"get_emitter",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"Callable",
"[",
"[",
"Event",
"]",
",",
"Event",
"]",
":",
"return",
"self",
".",
"_event_manager",
".",
"get_emitter",
"(",
"name",
")"
] | Gets and emitter for a named event.
Parameters
----------
name :
The name of the event he requested emitter will emit.
Users may provide their own named events by requesting an emitter with this function,
but should do so with caution as it makes time much mo... | [
"Gets",
"and",
"emitter",
"for",
"a",
"named",
"event",
"."
] | python | train | 41.9375 |
opencobra/cobrapy | cobra/manipulation/delete.py | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/manipulation/delete.py#L94-L121 | def find_gene_knockout_reactions(cobra_model, gene_list,
compiled_gene_reaction_rules=None):
"""identify reactions which will be disabled when the genes are knocked out
cobra_model: :class:`~cobra.core.Model.Model`
gene_list: iterable of :class:`~cobra.core.Gene.Gene`
... | [
"def",
"find_gene_knockout_reactions",
"(",
"cobra_model",
",",
"gene_list",
",",
"compiled_gene_reaction_rules",
"=",
"None",
")",
":",
"potential_reactions",
"=",
"set",
"(",
")",
"for",
"gene",
"in",
"gene_list",
":",
"if",
"isinstance",
"(",
"gene",
",",
"st... | identify reactions which will be disabled when the genes are knocked out
cobra_model: :class:`~cobra.core.Model.Model`
gene_list: iterable of :class:`~cobra.core.Gene.Gene`
compiled_gene_reaction_rules: dict of {reaction_id: compiled_string}
If provided, this gives pre-compiled gene_reaction_rule... | [
"identify",
"reactions",
"which",
"will",
"be",
"disabled",
"when",
"the",
"genes",
"are",
"knocked",
"out"
] | python | valid | 46.142857 |
senaite/senaite.core | bika/lims/browser/workflow/__init__.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/workflow/__init__.py#L162-L174 | def do_action(self, action, objects):
"""Performs the workflow transition passed in and returns the list of
objects that have been successfully transitioned
"""
transitioned = []
ActionHandlerPool.get_instance().queue_pool()
for obj in objects:
obj = api.get_o... | [
"def",
"do_action",
"(",
"self",
",",
"action",
",",
"objects",
")",
":",
"transitioned",
"=",
"[",
"]",
"ActionHandlerPool",
".",
"get_instance",
"(",
")",
".",
"queue_pool",
"(",
")",
"for",
"obj",
"in",
"objects",
":",
"obj",
"=",
"api",
".",
"get_o... | Performs the workflow transition passed in and returns the list of
objects that have been successfully transitioned | [
"Performs",
"the",
"workflow",
"transition",
"passed",
"in",
"and",
"returns",
"the",
"list",
"of",
"objects",
"that",
"have",
"been",
"successfully",
"transitioned"
] | python | train | 39.923077 |
foremast/foremast | src/foremast/autoscaling_policy/__main__.py | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/autoscaling_policy/__main__.py#L29-L48 | def main():
"""CLI entrypoint for scaling policy creation"""
logging.basicConfig(format=LOGGING_FORMAT)
log = logging.getLogger(__name__)
parser = argparse.ArgumentParser()
add_debug(parser)
add_app(parser)
add_properties(parser)
add_env(parser)
add_region(parser)
args = parser.... | [
"def",
"main",
"(",
")",
":",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"LOGGING_FORMAT",
")",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"add_debug",
"(",
"parser",
... | CLI entrypoint for scaling policy creation | [
"CLI",
"entrypoint",
"for",
"scaling",
"policy",
"creation"
] | python | train | 28.5 |
edx/django-config-models | config_models/admin.py | https://github.com/edx/django-config-models/blob/f22c05fe3ccb182a6be4dbe313e9d6749dffd3e4/config_models/admin.py#L89-L110 | def revert(self, request, queryset):
"""
Admin action to revert a configuration back to the selected value
"""
if queryset.count() != 1:
self.message_user(request, _("Please select a single configuration to revert to."))
return
target = queryset[0]
... | [
"def",
"revert",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"if",
"queryset",
".",
"count",
"(",
")",
"!=",
"1",
":",
"self",
".",
"message_user",
"(",
"request",
",",
"_",
"(",
"\"Please select a single configuration to revert to.\"",
")",
")",... | Admin action to revert a configuration back to the selected value | [
"Admin",
"action",
"to",
"revert",
"a",
"configuration",
"back",
"to",
"the",
"selected",
"value"
] | python | train | 32.5 |
planetarypy/pvl | pvl/__init__.py | https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/__init__.py#L137-L153 | def dumps(module, cls=PVLEncoder, **kwargs):
"""Serialize ``module`` as a pvl module formated byte string.
:param module: a ```PVLModule``` or ```dict``` like object to serialize
:param cls: the encoder class used to serialize the pvl module. You may use
the default ``PVLEncoder`` class or provide... | [
"def",
"dumps",
"(",
"module",
",",
"cls",
"=",
"PVLEncoder",
",",
"*",
"*",
"kwargs",
")",
":",
"stream",
"=",
"io",
".",
"BytesIO",
"(",
")",
"cls",
"(",
"*",
"*",
"kwargs",
")",
".",
"encode",
"(",
"module",
",",
"stream",
")",
"return",
"stre... | Serialize ``module`` as a pvl module formated byte string.
:param module: a ```PVLModule``` or ```dict``` like object to serialize
:param cls: the encoder class used to serialize the pvl module. You may use
the default ``PVLEncoder`` class or provided encoder formats such as the
```IsisCubeLab... | [
"Serialize",
"module",
"as",
"a",
"pvl",
"module",
"formated",
"byte",
"string",
"."
] | python | train | 41.470588 |
AustralianSynchrotron/lightflow | lightflow/scripts/cli.py | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/scripts/cli.py#L163-L185 | def workflow_start(obj, queue, keep_data, name, workflow_args):
""" Send a workflow to the queue.
\b
NAME: The name of the workflow that should be started.
WORKFLOW_ARGS: Workflow arguments in the form key1=value1 key2=value2.
"""
try:
start_workflow(name=name,
co... | [
"def",
"workflow_start",
"(",
"obj",
",",
"queue",
",",
"keep_data",
",",
"name",
",",
"workflow_args",
")",
":",
"try",
":",
"start_workflow",
"(",
"name",
"=",
"name",
",",
"config",
"=",
"obj",
"[",
"'config'",
"]",
",",
"queue",
"=",
"queue",
",",
... | Send a workflow to the queue.
\b
NAME: The name of the workflow that should be started.
WORKFLOW_ARGS: Workflow arguments in the form key1=value1 key2=value2. | [
"Send",
"a",
"workflow",
"to",
"the",
"queue",
"."
] | python | train | 46.782609 |
Karaage-Cluster/karaage | karaage/datastores/ldap.py | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/ldap.py#L241-L244 | def set_group_name(self, group, old_name, new_name):
""" Group was renamed. """
lgroup = self._get_group(old_name)
rename(lgroup, database=self._database, cn=new_name) | [
"def",
"set_group_name",
"(",
"self",
",",
"group",
",",
"old_name",
",",
"new_name",
")",
":",
"lgroup",
"=",
"self",
".",
"_get_group",
"(",
"old_name",
")",
"rename",
"(",
"lgroup",
",",
"database",
"=",
"self",
".",
"_database",
",",
"cn",
"=",
"ne... | Group was renamed. | [
"Group",
"was",
"renamed",
"."
] | python | train | 47 |
pypa/pipenv | pipenv/vendor/click/types.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/types.py#L67-L69 | def fail(self, message, param=None, ctx=None):
"""Helper method to fail with an invalid value message."""
raise BadParameter(message, ctx=ctx, param=param) | [
"def",
"fail",
"(",
"self",
",",
"message",
",",
"param",
"=",
"None",
",",
"ctx",
"=",
"None",
")",
":",
"raise",
"BadParameter",
"(",
"message",
",",
"ctx",
"=",
"ctx",
",",
"param",
"=",
"param",
")"
] | Helper method to fail with an invalid value message. | [
"Helper",
"method",
"to",
"fail",
"with",
"an",
"invalid",
"value",
"message",
"."
] | python | train | 56.333333 |
gawel/aiocron | aiocron/__init__.py | https://github.com/gawel/aiocron/blob/949870b2f7fe1e10e4220f3243c9d4237255d203/aiocron/__init__.py#L71-L73 | def get_next(self):
"""Return next iteration time related to loop time"""
return self.loop_time + (self.croniter.get_next(float) - self.time) | [
"def",
"get_next",
"(",
"self",
")",
":",
"return",
"self",
".",
"loop_time",
"+",
"(",
"self",
".",
"croniter",
".",
"get_next",
"(",
"float",
")",
"-",
"self",
".",
"time",
")"
] | Return next iteration time related to loop time | [
"Return",
"next",
"iteration",
"time",
"related",
"to",
"loop",
"time"
] | python | train | 51.666667 |
seomoz/shovel | shovel/tasks.py | https://github.com/seomoz/shovel/blob/fc29232b2b8be33972f8fb498a91a67e334f057f/shovel/tasks.py#L44-L48 | def load(cls, path, base=None):
'''Either load a path and return a shovel object or return None'''
obj = cls()
obj.read(path, base)
return obj | [
"def",
"load",
"(",
"cls",
",",
"path",
",",
"base",
"=",
"None",
")",
":",
"obj",
"=",
"cls",
"(",
")",
"obj",
".",
"read",
"(",
"path",
",",
"base",
")",
"return",
"obj"
] | Either load a path and return a shovel object or return None | [
"Either",
"load",
"a",
"path",
"and",
"return",
"a",
"shovel",
"object",
"or",
"return",
"None"
] | python | train | 34 |
relwell/corenlp-xml-lib | corenlp_xml/dependencies.py | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/dependencies.py#L155-L168 | def governor(self, dep_type, node):
"""
Registers a node as governing this node
:param dep_type: The dependency type
:type dep_type: str
:param node:
:return: self, provides fluent interface
:rtype: corenlp_xml.dependencies.DependencyNode
"""
se... | [
"def",
"governor",
"(",
"self",
",",
"dep_type",
",",
"node",
")",
":",
"self",
".",
"_governors",
"[",
"dep_type",
"]",
"=",
"self",
".",
"_governors",
".",
"get",
"(",
"dep_type",
",",
"[",
"]",
")",
"+",
"[",
"node",
"]",
"return",
"self"
] | Registers a node as governing this node
:param dep_type: The dependency type
:type dep_type: str
:param node:
:return: self, provides fluent interface
:rtype: corenlp_xml.dependencies.DependencyNode | [
"Registers",
"a",
"node",
"as",
"governing",
"this",
"node"
] | python | train | 28.214286 |
myint/rstcheck | rstcheck.py | https://github.com/myint/rstcheck/blob/2f975906b75f3b88d501ef3b13d213815cf7079a/rstcheck.py#L290-L302 | def check_json(code):
"""Yield errors."""
try:
json.loads(code)
except ValueError as exception:
message = '{}'.format(exception)
line_number = 0
found = re.search(r': line\s+([0-9]+)[^:]*$', message)
if found:
line_number = int(found.group(1))
yi... | [
"def",
"check_json",
"(",
"code",
")",
":",
"try",
":",
"json",
".",
"loads",
"(",
"code",
")",
"except",
"ValueError",
"as",
"exception",
":",
"message",
"=",
"'{}'",
".",
"format",
"(",
"exception",
")",
"line_number",
"=",
"0",
"found",
"=",
"re",
... | Yield errors. | [
"Yield",
"errors",
"."
] | python | train | 26.076923 |
bast/flanders | cmake/update.py | https://github.com/bast/flanders/blob/792f9eed8511cb553e67a25b6c5ce60fd6ae97bc/cmake/update.py#L286-L313 | def fetch_url(src, dst):
"""
Fetch file from URL src and save it to dst.
"""
# we do not use the nicer sys.version_info.major
# for compatibility with Python < 2.7
if sys.version_info[0] > 2:
import urllib.request
class URLopener(urllib.request.FancyURLopener):
def h... | [
"def",
"fetch_url",
"(",
"src",
",",
"dst",
")",
":",
"# we do not use the nicer sys.version_info.major",
"# for compatibility with Python < 2.7",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
">",
"2",
":",
"import",
"urllib",
".",
"request",
"class",
"URLopener... | Fetch file from URL src and save it to dst. | [
"Fetch",
"file",
"from",
"URL",
"src",
"and",
"save",
"it",
"to",
"dst",
"."
] | python | train | 32.428571 |
google/prettytensor | prettytensor/recurrent_networks.py | https://github.com/google/prettytensor/blob/75daa0b11252590f548da5647addc0ea610c4c45/prettytensor/recurrent_networks.py#L51-L55 | def flatten(self):
"""Create a flattened version by putting output first and then states."""
ls = [self.output]
ls.extend(self.state)
return ls | [
"def",
"flatten",
"(",
"self",
")",
":",
"ls",
"=",
"[",
"self",
".",
"output",
"]",
"ls",
".",
"extend",
"(",
"self",
".",
"state",
")",
"return",
"ls"
] | Create a flattened version by putting output first and then states. | [
"Create",
"a",
"flattened",
"version",
"by",
"putting",
"output",
"first",
"and",
"then",
"states",
"."
] | python | train | 31 |
siznax/wptools | wptools/core.py | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/core.py#L232-L238 | def _request(self, proxy, timeout):
"""
Returns WPToolsRequest object
"""
return request.WPToolsRequest(self.flags['silent'],
self.flags['verbose'],
proxy, timeout) | [
"def",
"_request",
"(",
"self",
",",
"proxy",
",",
"timeout",
")",
":",
"return",
"request",
".",
"WPToolsRequest",
"(",
"self",
".",
"flags",
"[",
"'silent'",
"]",
",",
"self",
".",
"flags",
"[",
"'verbose'",
"]",
",",
"proxy",
",",
"timeout",
")"
] | Returns WPToolsRequest object | [
"Returns",
"WPToolsRequest",
"object"
] | python | train | 38 |
ARMmbed/mbed-cloud-sdk-python | scripts/generate_ci_config.py | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/scripts/generate_ci_config.py#L209-L261 | def new_build(py_ver: PyVer):
"""Job for building/caching different docker images"""
cache_file = f'app_{py_ver.name}.tar'
cache_path = f'{cache_dir}/{cache_file}'
cache_key = f'v3-{py_ver.name}-{{{{ .Branch }}}}'
template = yaml.safe_load(f"""
machine:
image: 'circleci/classic:201710-02'
... | [
"def",
"new_build",
"(",
"py_ver",
":",
"PyVer",
")",
":",
"cache_file",
"=",
"f'app_{py_ver.name}.tar'",
"cache_path",
"=",
"f'{cache_dir}/{cache_file}'",
"cache_key",
"=",
"f'v3-{py_ver.name}-{{{{ .Branch }}}}'",
"template",
"=",
"yaml",
".",
"safe_load",
"(",
"f\"\"\... | Job for building/caching different docker images | [
"Job",
"for",
"building",
"/",
"caching",
"different",
"docker",
"images"
] | python | train | 35.471698 |
OTL/jps | jps/launcher.py | https://github.com/OTL/jps/blob/2c5a438d59611fffca6853072c822ef22665ed87/jps/launcher.py#L32-L49 | def launch_modules_with_names(modules_with_names, module_args={}, kill_before_launch=True):
'''launch module.main functions in another process'''
processes = []
if kill_before_launch:
for module_name, name in modules_with_names:
kill_module(name)
for module_name, name in modules_with... | [
"def",
"launch_modules_with_names",
"(",
"modules_with_names",
",",
"module_args",
"=",
"{",
"}",
",",
"kill_before_launch",
"=",
"True",
")",
":",
"processes",
"=",
"[",
"]",
"if",
"kill_before_launch",
":",
"for",
"module_name",
",",
"name",
"in",
"modules_wit... | launch module.main functions in another process | [
"launch",
"module",
".",
"main",
"functions",
"in",
"another",
"process"
] | python | train | 39.277778 |
PyCQA/pylint | pylint/checkers/variables.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/variables.py#L1336-L1371 | def _ignore_class_scope(self, node):
"""
Return True if the node is in a local class scope, as an assignment.
:param node: Node considered
:type node: astroid.Node
:return: True if the node is in a local class scope, as an assignment. False otherwise.
:rtype: bool
... | [
"def",
"_ignore_class_scope",
"(",
"self",
",",
"node",
")",
":",
"# Detect if we are in a local class scope, as an assignment.",
"# For example, the following is fair game.",
"#",
"# class A:",
"# b = 1",
"# c = lambda b=b: b * b",
"#",
"# class B:",
"# tp = 1",
"# def... | Return True if the node is in a local class scope, as an assignment.
:param node: Node considered
:type node: astroid.Node
:return: True if the node is in a local class scope, as an assignment. False otherwise.
:rtype: bool | [
"Return",
"True",
"if",
"the",
"node",
"is",
"in",
"a",
"local",
"class",
"scope",
"as",
"an",
"assignment",
"."
] | python | test | 31.722222 |
neurodata/ndio | ndio/utils/mesh.py | https://github.com/neurodata/ndio/blob/792dd5816bc770b05a3db2f4327da42ff6253531/ndio/utils/mesh.py#L43-L77 | def export_ply(filename, cutout, level=0):
"""
Converts a dense annotation to a .PLY, using Marching Cubes (PyMCubes).
Arguments:
filename (str): The filename to write out to
cutout (numpy.ndarray): The dense annotation
level (int): The level at which to run mcubes
Returns:
... | [
"def",
"export_ply",
"(",
"filename",
",",
"cutout",
",",
"level",
"=",
"0",
")",
":",
"if",
"\".ply\"",
"not",
"in",
"filename",
":",
"filename",
"=",
"filename",
"+",
"\".ply\"",
"vs",
",",
"fs",
"=",
"mcubes",
".",
"marching_cubes",
"(",
"cutout",
"... | Converts a dense annotation to a .PLY, using Marching Cubes (PyMCubes).
Arguments:
filename (str): The filename to write out to
cutout (numpy.ndarray): The dense annotation
level (int): The level at which to run mcubes
Returns:
boolean success | [
"Converts",
"a",
"dense",
"annotation",
"to",
"a",
".",
"PLY",
"using",
"Marching",
"Cubes",
"(",
"PyMCubes",
")",
"."
] | python | test | 29.971429 |
llazzaro/analyzerdam | analyzerdam/sqlDAM.py | https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/sqlDAM.py#L101-L126 | def readBatchTupleQuotes(self, symbols, start, end):
'''
read batch quotes as tuple to save memory
'''
if end is None:
end=sys.maxint
ret={}
session=self.getReadSession()()
try:
symbolChunks=splitListEqually(symbols, 100)
... | [
"def",
"readBatchTupleQuotes",
"(",
"self",
",",
"symbols",
",",
"start",
",",
"end",
")",
":",
"if",
"end",
"is",
"None",
":",
"end",
"=",
"sys",
".",
"maxint",
"ret",
"=",
"{",
"}",
"session",
"=",
"self",
".",
"getReadSession",
"(",
")",
"(",
")... | read batch quotes as tuple to save memory | [
"read",
"batch",
"quotes",
"as",
"tuple",
"to",
"save",
"memory"
] | python | train | 38.692308 |
guyskk/flask-restaction | flask_restaction/api.py | https://github.com/guyskk/flask-restaction/blob/17db010b0cbba16bbc2408081975955b03553eb7/flask_restaction/api.py#L385-L394 | def authorize(self, role):
"""Check permission"""
resource, action = parse_request()
roles = self.meta.get("$roles", {})
message = "%s can't access %s.%s" % (role, resource, action)
try:
if action not in roles[role][resource]:
abort(403, "PermissionDen... | [
"def",
"authorize",
"(",
"self",
",",
"role",
")",
":",
"resource",
",",
"action",
"=",
"parse_request",
"(",
")",
"roles",
"=",
"self",
".",
"meta",
".",
"get",
"(",
"\"$roles\"",
",",
"{",
"}",
")",
"message",
"=",
"\"%s can't access %s.%s\"",
"%",
"... | Check permission | [
"Check",
"permission"
] | python | train | 39.8 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Vlan.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L895-L916 | def check_number_available(self, id_environment, num_vlan, id_vlan):
"""Checking if environment has a number vlan available
:param id_environment: Identifier of environment
:param num_vlan: Vlan number
:param id_vlan: Vlan indentifier (False if inserting a vlan)
:return: True i... | [
"def",
"check_number_available",
"(",
"self",
",",
"id_environment",
",",
"num_vlan",
",",
"id_vlan",
")",
":",
"url",
"=",
"'vlan/check_number_available/'",
"+",
"str",
"(",
"id_environment",
")",
"+",
"'/'",
"+",
"str",
"(",
"num_vlan",
")",
"+",
"'/'",
"+... | Checking if environment has a number vlan available
:param id_environment: Identifier of environment
:param num_vlan: Vlan number
:param id_vlan: Vlan indentifier (False if inserting a vlan)
:return: True is has number available, False if hasn't
:raise AmbienteNaoExisteError: ... | [
"Checking",
"if",
"environment",
"has",
"a",
"number",
"vlan",
"available"
] | python | train | 40.318182 |
klahnakoski/mo-files | mo_files/__init__.py | https://github.com/klahnakoski/mo-files/blob/f6974a997cdc9fdabccb60c19edee13356a5787a/mo_files/__init__.py#L223-L232 | def read_zipfile(self, encoding='utf8'):
"""
READ FIRST FILE IN ZIP FILE
:param encoding:
:return: STRING
"""
from zipfile import ZipFile
with ZipFile(self.abspath) as zipped:
for num, zip_name in enumerate(zipped.namelist()):
return zi... | [
"def",
"read_zipfile",
"(",
"self",
",",
"encoding",
"=",
"'utf8'",
")",
":",
"from",
"zipfile",
"import",
"ZipFile",
"with",
"ZipFile",
"(",
"self",
".",
"abspath",
")",
"as",
"zipped",
":",
"for",
"num",
",",
"zip_name",
"in",
"enumerate",
"(",
"zipped... | READ FIRST FILE IN ZIP FILE
:param encoding:
:return: STRING | [
"READ",
"FIRST",
"FILE",
"IN",
"ZIP",
"FILE",
":",
"param",
"encoding",
":",
":",
"return",
":",
"STRING"
] | python | train | 35.4 |
arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tree.py | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tree.py#L112-L139 | def get_parents(docgraph, child_node, strict=True):
"""Return a list of parent nodes that dominate this child.
In a 'syntax tree' a node never has more than one parent node
dominating it. To enforce this, set strict=True.
Parameters
----------
docgraph : DiscourseDocumentGraph
a docume... | [
"def",
"get_parents",
"(",
"docgraph",
",",
"child_node",
",",
"strict",
"=",
"True",
")",
":",
"parents",
"=",
"[",
"]",
"for",
"src",
",",
"_",
",",
"edge_attrs",
"in",
"docgraph",
".",
"in_edges",
"(",
"child_node",
",",
"data",
"=",
"True",
")",
... | Return a list of parent nodes that dominate this child.
In a 'syntax tree' a node never has more than one parent node
dominating it. To enforce this, set strict=True.
Parameters
----------
docgraph : DiscourseDocumentGraph
a document graph
strict : bool
If True, raise a ValueEr... | [
"Return",
"a",
"list",
"of",
"parent",
"nodes",
"that",
"dominate",
"this",
"child",
"."
] | python | train | 31.535714 |
jobovy/galpy | galpy/potential/SpiralArmsPotential.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/SpiralArmsPotential.py#L562-L564 | def _K(self, R):
"""Return numpy array from K1 up to and including Kn. (eqn. 5)"""
return self._ns * self._N / R / self._sin_alpha | [
"def",
"_K",
"(",
"self",
",",
"R",
")",
":",
"return",
"self",
".",
"_ns",
"*",
"self",
".",
"_N",
"/",
"R",
"/",
"self",
".",
"_sin_alpha"
] | Return numpy array from K1 up to and including Kn. (eqn. 5) | [
"Return",
"numpy",
"array",
"from",
"K1",
"up",
"to",
"and",
"including",
"Kn",
".",
"(",
"eqn",
".",
"5",
")"
] | python | train | 48 |
CitrineInformatics/pypif-sdk | pypif_sdk/readview/core.py | https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/readview/core.py#L17-L36 | def new_keypair(key, value, ambig, unambig):
"""
Check new keypair against existing unambiguous dict
:param key: of pair
:param value: of pair
:param ambig: set of keys with ambig decoding
:param unambig: set of keys with unambig decoding
:return:
"""
if key in ambig:
return... | [
"def",
"new_keypair",
"(",
"key",
",",
"value",
",",
"ambig",
",",
"unambig",
")",
":",
"if",
"key",
"in",
"ambig",
":",
"return",
"if",
"key",
"in",
"unambig",
"and",
"value",
"!=",
"unambig",
"[",
"key",
"]",
":",
"ambig",
".",
"add",
"(",
"key",... | Check new keypair against existing unambiguous dict
:param key: of pair
:param value: of pair
:param ambig: set of keys with ambig decoding
:param unambig: set of keys with unambig decoding
:return: | [
"Check",
"new",
"keypair",
"against",
"existing",
"unambiguous",
"dict"
] | python | train | 23.15 |
pypa/pipenv | pipenv/patched/notpip/_internal/cli/cmdoptions.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/cmdoptions.py#L727-L742 | def _merge_hash(option, opt_str, value, parser):
# type: (Option, str, str, OptionParser) -> None
"""Given a value spelled "algo:digest", append the digest to a list
pointed to in a dict by the algo name."""
if not parser.values.hashes:
parser.values.hashes = {} # type: ignore
try:
... | [
"def",
"_merge_hash",
"(",
"option",
",",
"opt_str",
",",
"value",
",",
"parser",
")",
":",
"# type: (Option, str, str, OptionParser) -> None",
"if",
"not",
"parser",
".",
"values",
".",
"hashes",
":",
"parser",
".",
"values",
".",
"hashes",
"=",
"{",
"}",
"... | Given a value spelled "algo:digest", append the digest to a list
pointed to in a dict by the algo name. | [
"Given",
"a",
"value",
"spelled",
"algo",
":",
"digest",
"append",
"the",
"digest",
"to",
"a",
"list",
"pointed",
"to",
"in",
"a",
"dict",
"by",
"the",
"algo",
"name",
"."
] | python | train | 46.4375 |
wearpants/instrument | instrument/__init__.py | https://github.com/wearpants/instrument/blob/a0f6103574ab58a82361a951e5e56b69aedfe294/instrument/__init__.py#L137-L147 | def first(iterable = None, *, name = None, metric = call_default):
"""Measure time elapsed to produce first item of an iterable
:arg iterable: any iterable
:arg function metric: f(name, 1, time)
:arg str name: name for the metric
"""
if iterable is None:
return _first_decorator(name, me... | [
"def",
"first",
"(",
"iterable",
"=",
"None",
",",
"*",
",",
"name",
"=",
"None",
",",
"metric",
"=",
"call_default",
")",
":",
"if",
"iterable",
"is",
"None",
":",
"return",
"_first_decorator",
"(",
"name",
",",
"metric",
")",
"else",
":",
"return",
... | Measure time elapsed to produce first item of an iterable
:arg iterable: any iterable
:arg function metric: f(name, 1, time)
:arg str name: name for the metric | [
"Measure",
"time",
"elapsed",
"to",
"produce",
"first",
"item",
"of",
"an",
"iterable"
] | python | train | 34 |
CSchoel/nolds | nolds/examples.py | https://github.com/CSchoel/nolds/blob/8a5ecc472d67ac08b571bd68967287668ca9058e/nolds/examples.py#L190-L235 | def hurst_compare_nvals(data, nvals=None):
"""
Creates a plot that compares the results of different choices for nvals
for the function hurst_rs.
Args:
data (array-like of float):
the input data from which the hurst exponent should be estimated
Kwargs:
nvals (array of int):
a manually se... | [
"def",
"hurst_compare_nvals",
"(",
"data",
",",
"nvals",
"=",
"None",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"data",
"=",
"np",
".",
"asarray",
"(",
"data",
")",
"n_all",
"=",
"np",
".",
"arange",
"(",
"2",
",",
"len",
"(",
"... | Creates a plot that compares the results of different choices for nvals
for the function hurst_rs.
Args:
data (array-like of float):
the input data from which the hurst exponent should be estimated
Kwargs:
nvals (array of int):
a manually selected value for the nvals parameter that should be... | [
"Creates",
"a",
"plot",
"that",
"compares",
"the",
"results",
"of",
"different",
"choices",
"for",
"nvals",
"for",
"the",
"function",
"hurst_rs",
"."
] | python | train | 36.673913 |
saltstack/salt | salt/transport/zeromq.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/zeromq.py#L847-L955 | def _publish_daemon(self, log_queue=None):
'''
Bind to the interface specified in the configuration file
'''
salt.utils.process.appendproctitle(self.__class__.__name__)
if log_queue:
salt.log.setup.set_multiprocessing_logging_queue(log_queue)
salt.log.setu... | [
"def",
"_publish_daemon",
"(",
"self",
",",
"log_queue",
"=",
"None",
")",
":",
"salt",
".",
"utils",
".",
"process",
".",
"appendproctitle",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
"if",
"log_queue",
":",
"salt",
".",
"log",
".",
"setup",
... | Bind to the interface specified in the configuration file | [
"Bind",
"to",
"the",
"interface",
"specified",
"in",
"the",
"configuration",
"file"
] | python | train | 49.027523 |
bitesofcode/projexui | projexui/widgets/xpopupwidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xpopupwidget.py#L1052-L1068 | def setDirection( self, direction ):
"""
Sets the direction for this widget to the inputed direction.
:param direction | <XPopupWidget.Direction>
"""
if ( direction == XPopupWidget.Direction.North ):
self.setAnchor(XPopupWidget.Anchor.TopCenter)
... | [
"def",
"setDirection",
"(",
"self",
",",
"direction",
")",
":",
"if",
"(",
"direction",
"==",
"XPopupWidget",
".",
"Direction",
".",
"North",
")",
":",
"self",
".",
"setAnchor",
"(",
"XPopupWidget",
".",
"Anchor",
".",
"TopCenter",
")",
"elif",
"(",
"dir... | Sets the direction for this widget to the inputed direction.
:param direction | <XPopupWidget.Direction> | [
"Sets",
"the",
"direction",
"for",
"this",
"widget",
"to",
"the",
"inputed",
"direction",
".",
":",
"param",
"direction",
"|",
"<XPopupWidget",
".",
"Direction",
">"
] | python | train | 38.294118 |
litl/backoff | backoff/_wait_gen.py | https://github.com/litl/backoff/blob/229d30adce4128f093550a1761c49594c78df4b4/backoff/_wait_gen.py#L44-L56 | def constant(interval=1):
"""Generator for constant intervals.
Args:
interval: A constant value to yield or an iterable of such values.
"""
try:
itr = iter(interval)
except TypeError:
itr = itertools.repeat(interval)
for val in itr:
yield val | [
"def",
"constant",
"(",
"interval",
"=",
"1",
")",
":",
"try",
":",
"itr",
"=",
"iter",
"(",
"interval",
")",
"except",
"TypeError",
":",
"itr",
"=",
"itertools",
".",
"repeat",
"(",
"interval",
")",
"for",
"val",
"in",
"itr",
":",
"yield",
"val"
] | Generator for constant intervals.
Args:
interval: A constant value to yield or an iterable of such values. | [
"Generator",
"for",
"constant",
"intervals",
"."
] | python | train | 22.153846 |
materialsproject/pymatgen | pymatgen/analysis/structure_matcher.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/structure_matcher.py#L466-L476 | def _cmp_fstruct(self, s1, s2, frac_tol, mask):
"""
Returns true if a matching exists between s2 and s2
under frac_tol. s2 should be a subset of s1
"""
if len(s2) > len(s1):
raise ValueError("s1 must be larger than s2")
if mask.shape != (len(s2), len(s1)):
... | [
"def",
"_cmp_fstruct",
"(",
"self",
",",
"s1",
",",
"s2",
",",
"frac_tol",
",",
"mask",
")",
":",
"if",
"len",
"(",
"s2",
")",
">",
"len",
"(",
"s1",
")",
":",
"raise",
"ValueError",
"(",
"\"s1 must be larger than s2\"",
")",
"if",
"mask",
".",
"shap... | Returns true if a matching exists between s2 and s2
under frac_tol. s2 should be a subset of s1 | [
"Returns",
"true",
"if",
"a",
"matching",
"exists",
"between",
"s2",
"and",
"s2",
"under",
"frac_tol",
".",
"s2",
"should",
"be",
"a",
"subset",
"of",
"s1"
] | python | train | 38.454545 |
staugur/Flask-PluginKit | setup.py | https://github.com/staugur/Flask-PluginKit/blob/512aabf87fa13f4dc1082abd08d1d1dcf3b03f16/setup.py#L57-L62 | def finalize_options(self):
"""Post-process options."""
if self.test:
print("V%s will publish to the test.pypi.org" % version)
elif self.release:
print("V%s will publish to the pypi.org" % version) | [
"def",
"finalize_options",
"(",
"self",
")",
":",
"if",
"self",
".",
"test",
":",
"print",
"(",
"\"V%s will publish to the test.pypi.org\"",
"%",
"version",
")",
"elif",
"self",
".",
"release",
":",
"print",
"(",
"\"V%s will publish to the pypi.org\"",
"%",
"versi... | Post-process options. | [
"Post",
"-",
"process",
"options",
"."
] | python | train | 40 |
anrosent/LT-code | lt/sampler.py | https://github.com/anrosent/LT-code/blob/e13a4c927effc90f9d41ab3884f9fcbd95b9450d/lt/sampler.py#L74-L80 | def _get_next(self):
"""Executes the next iteration of the PRNG
evolution process, and returns the result
"""
self.state = PRNG_A * self.state % PRNG_M
return self.state | [
"def",
"_get_next",
"(",
"self",
")",
":",
"self",
".",
"state",
"=",
"PRNG_A",
"*",
"self",
".",
"state",
"%",
"PRNG_M",
"return",
"self",
".",
"state"
] | Executes the next iteration of the PRNG
evolution process, and returns the result | [
"Executes",
"the",
"next",
"iteration",
"of",
"the",
"PRNG",
"evolution",
"process",
"and",
"returns",
"the",
"result"
] | python | train | 29.142857 |
numenta/nupic | src/nupic/algorithms/spatial_pooler.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1529-L1545 | def _calculateOverlap(self, inputVector):
"""
This function determines each column's overlap with the current input
vector. The overlap of a column is the number of synapses for that column
that are connected (permanence value is greater than '_synPermConnected')
to input bits which are turned on. T... | [
"def",
"_calculateOverlap",
"(",
"self",
",",
"inputVector",
")",
":",
"overlaps",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
"_numColumns",
",",
"dtype",
"=",
"realDType",
")",
"self",
".",
"_connectedSynapses",
".",
"rightVecSumAtNZ_fast",
"(",
"inputVect... | This function determines each column's overlap with the current input
vector. The overlap of a column is the number of synapses for that column
that are connected (permanence value is greater than '_synPermConnected')
to input bits which are turned on. The implementation takes advantage of
the SparseBin... | [
"This",
"function",
"determines",
"each",
"column",
"s",
"overlap",
"with",
"the",
"current",
"input",
"vector",
".",
"The",
"overlap",
"of",
"a",
"column",
"is",
"the",
"number",
"of",
"synapses",
"for",
"that",
"column",
"that",
"are",
"connected",
"(",
... | python | valid | 47.882353 |
apache/incubator-superset | superset/views/core.py | https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1826-L1872 | def recent_activity(self, user_id):
"""Recent activity (actions) for a given user"""
M = models # noqa
if request.args.get('limit'):
limit = int(request.args.get('limit'))
else:
limit = 1000
qry = (
db.session.query(M.Log, M.Dashboard, M.Sli... | [
"def",
"recent_activity",
"(",
"self",
",",
"user_id",
")",
":",
"M",
"=",
"models",
"# noqa",
"if",
"request",
".",
"args",
".",
"get",
"(",
"'limit'",
")",
":",
"limit",
"=",
"int",
"(",
"request",
".",
"args",
".",
"get",
"(",
"'limit'",
")",
")... | Recent activity (actions) for a given user | [
"Recent",
"activity",
"(",
"actions",
")",
"for",
"a",
"given",
"user"
] | python | train | 30.957447 |
icometrix/dicom2nifti | dicom2nifti/common.py | https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L359-L368 | def set_ss_value(tag, value):
"""
Setter for data that also work with implicit transfersyntax
:param value: the value to set on the tag
:param tag: the tag to read
"""
if tag.VR == 'OB' or tag.VR == 'UN':
value = struct.pack('h', value)
tag.value = value | [
"def",
"set_ss_value",
"(",
"tag",
",",
"value",
")",
":",
"if",
"tag",
".",
"VR",
"==",
"'OB'",
"or",
"tag",
".",
"VR",
"==",
"'UN'",
":",
"value",
"=",
"struct",
".",
"pack",
"(",
"'h'",
",",
"value",
")",
"tag",
".",
"value",
"=",
"value"
] | Setter for data that also work with implicit transfersyntax
:param value: the value to set on the tag
:param tag: the tag to read | [
"Setter",
"for",
"data",
"that",
"also",
"work",
"with",
"implicit",
"transfersyntax"
] | python | train | 28.2 |
ska-sa/purr | Purr/Render.py | https://github.com/ska-sa/purr/blob/4c848768d0485d0f88b30850d0d5372221b21b66/Purr/Render.py#L243-L260 | def getRenderers(filename):
"""For a given DP, returns a list of renderer ids giving
the renderers that support the source file type"""
global available_renderers
renderers = []
for rdrid, (renderer, module) in available_renderers.items():
try:
priority = renderer.canRender(filen... | [
"def",
"getRenderers",
"(",
"filename",
")",
":",
"global",
"available_renderers",
"renderers",
"=",
"[",
"]",
"for",
"rdrid",
",",
"(",
"renderer",
",",
"module",
")",
"in",
"available_renderers",
".",
"items",
"(",
")",
":",
"try",
":",
"priority",
"=",
... | For a given DP, returns a list of renderer ids giving
the renderers that support the source file type | [
"For",
"a",
"given",
"DP",
"returns",
"a",
"list",
"of",
"renderer",
"ids",
"giving",
"the",
"renderers",
"that",
"support",
"the",
"source",
"file",
"type"
] | python | train | 41.166667 |
RusticiSoftware/TinCanPython | tincan/remote_lrs.py | https://github.com/RusticiSoftware/TinCanPython/blob/424eedaa6d19221efb1108edb915fc332abbb317/tincan/remote_lrs.py#L89-L160 | def _send_request(self, request):
"""Establishes connection and returns http response based off of request.
:param request: HTTPRequest object
:type request: :class:`tincan.http_request.HTTPRequest`
:returns: LRS Response object
:rtype: :class:`tincan.lrs_response.LRSResponse`
... | [
"def",
"_send_request",
"(",
"self",
",",
"request",
")",
":",
"headers",
"=",
"{",
"\"X-Experience-API-Version\"",
":",
"self",
".",
"version",
"}",
"if",
"self",
".",
"auth",
"is",
"not",
"None",
":",
"headers",
"[",
"\"Authorization\"",
"]",
"=",
"self"... | Establishes connection and returns http response based off of request.
:param request: HTTPRequest object
:type request: :class:`tincan.http_request.HTTPRequest`
:returns: LRS Response object
:rtype: :class:`tincan.lrs_response.LRSResponse` | [
"Establishes",
"connection",
"and",
"returns",
"http",
"response",
"based",
"off",
"of",
"request",
"."
] | python | train | 29.375 |
SatelliteQE/nailgun | nailgun/entities.py | https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/nailgun/entities.py#L621-L633 | def read(self, entity=None, attrs=None, ignore=None, params=None):
"""Do not read the ``account_password`` attribute. Work around a bug.
For more information, see `Bugzilla #1243036
<https://bugzilla.redhat.com/show_bug.cgi?id=1243036>`_.
"""
if attrs is None:
attrs... | [
"def",
"read",
"(",
"self",
",",
"entity",
"=",
"None",
",",
"attrs",
"=",
"None",
",",
"ignore",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"attrs",
"is",
"None",
":",
"attrs",
"=",
"self",
".",
"update_json",
"(",
"[",
"]",
")",
... | Do not read the ``account_password`` attribute. Work around a bug.
For more information, see `Bugzilla #1243036
<https://bugzilla.redhat.com/show_bug.cgi?id=1243036>`_. | [
"Do",
"not",
"read",
"the",
"account_password",
"attribute",
".",
"Work",
"around",
"a",
"bug",
"."
] | python | train | 38.692308 |
klmitch/tendril | tendril/tcp.py | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L234-L240 | def send_frame(self, frame):
"""
Sends a frame to the other end of the connection.
"""
self._sendbuf += self._send_streamify(frame)
self._sendbuf_event.set() | [
"def",
"send_frame",
"(",
"self",
",",
"frame",
")",
":",
"self",
".",
"_sendbuf",
"+=",
"self",
".",
"_send_streamify",
"(",
"frame",
")",
"self",
".",
"_sendbuf_event",
".",
"set",
"(",
")"
] | Sends a frame to the other end of the connection. | [
"Sends",
"a",
"frame",
"to",
"the",
"other",
"end",
"of",
"the",
"connection",
"."
] | python | train | 27.428571 |
atlassian-api/atlassian-python-api | atlassian/jira.py | https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/jira.py#L1082-L1089 | def tempo_account_delete_customer_by_id(self, customer_id=1):
"""
Delete an Attribute. Caller must have Manage Account Permission. Attribute can be a Category or Customer.
:param customer_id: id of Customer record
:return: Customer info
"""
url = 'rest/tempo-accounts/1/cu... | [
"def",
"tempo_account_delete_customer_by_id",
"(",
"self",
",",
"customer_id",
"=",
"1",
")",
":",
"url",
"=",
"'rest/tempo-accounts/1/customer/{id}'",
".",
"format",
"(",
"id",
"=",
"customer_id",
")",
"return",
"self",
".",
"delete",
"(",
"url",
")"
] | Delete an Attribute. Caller must have Manage Account Permission. Attribute can be a Category or Customer.
:param customer_id: id of Customer record
:return: Customer info | [
"Delete",
"an",
"Attribute",
".",
"Caller",
"must",
"have",
"Manage",
"Account",
"Permission",
".",
"Attribute",
"can",
"be",
"a",
"Category",
"or",
"Customer",
".",
":",
"param",
"customer_id",
":",
"id",
"of",
"Customer",
"record",
":",
"return",
":",
"C... | python | train | 47.5 |
mvn23/pyotgw | pyotgw/pyotgw.py | https://github.com/mvn23/pyotgw/blob/7612378ef4332b250176505af33e7536d6c9da78/pyotgw/pyotgw.py#L510-L526 | async def set_setback_temp(self, sb_temp, timeout=OTGW_DEFAULT_TIMEOUT):
"""
Configure the setback temperature to use in combination with
GPIO functions HOME (5) and AWAY (6).
Return the new setback temperature, or None on failure.
This method is a coroutine
"""
... | [
"async",
"def",
"set_setback_temp",
"(",
"self",
",",
"sb_temp",
",",
"timeout",
"=",
"OTGW_DEFAULT_TIMEOUT",
")",
":",
"cmd",
"=",
"OTGW_CMD_SETBACK",
"status",
"=",
"{",
"}",
"ret",
"=",
"await",
"self",
".",
"_wait_for_cmd",
"(",
"cmd",
",",
"sb_temp",
... | Configure the setback temperature to use in combination with
GPIO functions HOME (5) and AWAY (6).
Return the new setback temperature, or None on failure.
This method is a coroutine | [
"Configure",
"the",
"setback",
"temperature",
"to",
"use",
"in",
"combination",
"with",
"GPIO",
"functions",
"HOME",
"(",
"5",
")",
"and",
"AWAY",
"(",
"6",
")",
".",
"Return",
"the",
"new",
"setback",
"temperature",
"or",
"None",
"on",
"failure",
"."
] | python | train | 33.294118 |
TylerTemp/docpie | docpie/pie.py | https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/pie.py#L547-L597 | def to_dict(self): # cls, self):
"""Convert Docpie into a JSONlizable dict.
Use it in this way:
pie = Docpie(__doc__)
json.dumps(pie.convert_2_dict())
Note the `extra` info will be lost if you costomize that,
because a function is not JSONlizable.
You can use `... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"# cls, self):",
"config",
"=",
"{",
"'stdopt'",
":",
"self",
".",
"stdopt",
",",
"'attachopt'",
":",
"self",
".",
"attachopt",
",",
"'attachvalue'",
":",
"self",
".",
"attachvalue",
",",
"'auto2dashes'",
":",
"self... | Convert Docpie into a JSONlizable dict.
Use it in this way:
pie = Docpie(__doc__)
json.dumps(pie.convert_2_dict())
Note the `extra` info will be lost if you costomize that,
because a function is not JSONlizable.
You can use `set_config(extra={...})` to set it back. | [
"Convert",
"Docpie",
"into",
"a",
"JSONlizable",
"dict",
"."
] | python | train | 32.823529 |
crate/crash | src/crate/crash/command.py | https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/command.py#L336-L339 | def _quit(self, *args):
""" quit crash """
self.logger.warn('Bye!')
sys.exit(self.exit()) | [
"def",
"_quit",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"logger",
".",
"warn",
"(",
"'Bye!'",
")",
"sys",
".",
"exit",
"(",
"self",
".",
"exit",
"(",
")",
")"
] | quit crash | [
"quit",
"crash"
] | python | train | 27.5 |
scanny/python-pptx | pptx/package.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/package.py#L207-L217 | def get_or_add_media_part(self, media):
"""Return a |MediaPart| object containing the media in *media*.
If this package already contains a media part for the same
bytestream, that instance is returned, otherwise a new media part is
created.
"""
media_part = self._find_by... | [
"def",
"get_or_add_media_part",
"(",
"self",
",",
"media",
")",
":",
"media_part",
"=",
"self",
".",
"_find_by_sha1",
"(",
"media",
".",
"sha1",
")",
"if",
"media_part",
"is",
"None",
":",
"media_part",
"=",
"MediaPart",
".",
"new",
"(",
"self",
".",
"_p... | Return a |MediaPart| object containing the media in *media*.
If this package already contains a media part for the same
bytestream, that instance is returned, otherwise a new media part is
created. | [
"Return",
"a",
"|MediaPart|",
"object",
"containing",
"the",
"media",
"in",
"*",
"media",
"*",
"."
] | python | train | 40.454545 |
malramsay64/experi | src/experi/run.py | https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L289-L295 | def read_file(filename: PathLike = "experiment.yml") -> Dict[str, Any]:
"""Read and parse yaml file."""
logger.debug("Input file: %s", filename)
with open(filename, "r") as stream:
structure = yaml.safe_load(stream)
return structure | [
"def",
"read_file",
"(",
"filename",
":",
"PathLike",
"=",
"\"experiment.yml\"",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"logger",
".",
"debug",
"(",
"\"Input file: %s\"",
",",
"filename",
")",
"with",
"open",
"(",
"filename",
",",
"\"r\"",
... | Read and parse yaml file. | [
"Read",
"and",
"parse",
"yaml",
"file",
"."
] | python | train | 35.857143 |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/breakpoint.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/breakpoint.py#L1331-L1344 | def __push_params(self, tid, params):
"""
Remembers the arguments tuple for the last call to the hooked function
from this thread.
@type tid: int
@param tid: Thread global ID.
@type params: tuple( arg, arg, arg... )
@param params: Tuple of arguments.
"... | [
"def",
"__push_params",
"(",
"self",
",",
"tid",
",",
"params",
")",
":",
"stack",
"=",
"self",
".",
"__paramStack",
".",
"get",
"(",
"tid",
",",
"[",
"]",
")",
"stack",
".",
"append",
"(",
"params",
")",
"self",
".",
"__paramStack",
"[",
"tid",
"]... | Remembers the arguments tuple for the last call to the hooked function
from this thread.
@type tid: int
@param tid: Thread global ID.
@type params: tuple( arg, arg, arg... )
@param params: Tuple of arguments. | [
"Remembers",
"the",
"arguments",
"tuple",
"for",
"the",
"last",
"call",
"to",
"the",
"hooked",
"function",
"from",
"this",
"thread",
"."
] | python | train | 30.428571 |
cgrok/clashroyale | clashroyale/royaleapi/client.py | https://github.com/cgrok/clashroyale/blob/2618f4da22a84ad3e36d2446e23436d87c423163/clashroyale/royaleapi/client.py#L740-L758 | def get_popular_decks(self, **params: keys):
"""Get a list of most queried decks
\*\*keys: Optional[list] = None
Filter which keys should be included in the
response
\*\*exclude: Optional[list] = None
Filter which keys should be excluded from the
... | [
"def",
"get_popular_decks",
"(",
"self",
",",
"*",
"*",
"params",
":",
"keys",
")",
":",
"url",
"=",
"self",
".",
"api",
".",
"POPULAR",
"+",
"'/decks'",
"return",
"self",
".",
"_get_model",
"(",
"url",
",",
"*",
"*",
"params",
")"
] | Get a list of most queried decks
\*\*keys: Optional[list] = None
Filter which keys should be included in the
response
\*\*exclude: Optional[list] = None
Filter which keys should be excluded from the
response
\*\*max: Optional[int] = None
... | [
"Get",
"a",
"list",
"of",
"most",
"queried",
"decks"
] | python | valid | 38.052632 |
datamachine/twx.botapi | twx/botapi/botapi.py | https://github.com/datamachine/twx.botapi/blob/c85184da738169e8f9d6d8e62970540f427c486e/twx/botapi/botapi.py#L3698-L3749 | def edit_message_text(text, chat_id=None, message_id=None, inline_message_id=None,
parse_mode=None, disable_web_page_preview=None, reply_markup=None, **kwargs):
"""
Use this method to edit text messages sent by the bot or via the bot (for inline bots).
:param text: New text of the mes... | [
"def",
"edit_message_text",
"(",
"text",
",",
"chat_id",
"=",
"None",
",",
"message_id",
"=",
"None",
",",
"inline_message_id",
"=",
"None",
",",
"parse_mode",
"=",
"None",
",",
"disable_web_page_preview",
"=",
"None",
",",
"reply_markup",
"=",
"None",
",",
... | Use this method to edit text messages sent by the bot or via the bot (for inline bots).
:param text: New text of the message
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
the target channel (in the format @channeluse... | [
"Use",
"this",
"method",
"to",
"edit",
"text",
"messages",
"sent",
"by",
"the",
"bot",
"or",
"via",
"the",
"bot",
"(",
"for",
"inline",
"bots",
")",
"."
] | python | train | 44.692308 |
jspricke/python-abook | abook.py | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L58-L72 | def append_vobject(self, vcard, filename=None):
"""Appends an address to the Abook addressbook
vcard -- vCard to append
filename -- unused
return the new UID of the appended vcard
"""
book = ConfigParser(default_section='format')
with self._lock:
book.... | [
"def",
"append_vobject",
"(",
"self",
",",
"vcard",
",",
"filename",
"=",
"None",
")",
":",
"book",
"=",
"ConfigParser",
"(",
"default_section",
"=",
"'format'",
")",
"with",
"self",
".",
"_lock",
":",
"book",
".",
"read",
"(",
"self",
".",
"_filename",
... | Appends an address to the Abook addressbook
vcard -- vCard to append
filename -- unused
return the new UID of the appended vcard | [
"Appends",
"an",
"address",
"to",
"the",
"Abook",
"addressbook",
"vcard",
"--",
"vCard",
"to",
"append",
"filename",
"--",
"unused",
"return",
"the",
"new",
"UID",
"of",
"the",
"appended",
"vcard"
] | python | train | 40.133333 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.