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 |
|---|---|---|---|---|---|---|---|---|---|
rocky/python-filecache | pyficache/main.py | https://github.com/rocky/python-filecache/blob/60709ccd837ef5df001faf3cb02d4979ba342a23/pyficache/main.py#L230-L267 | def checkcache(filename=None, opts=False):
"""Discard cache entries that are out of date. If *filename* is *None*
all entries in the file cache *file_cache* are checked. If we do not
have stat information about a file it will be kept. Return a list of
invalidated filenames. None is returned if a filen... | [
"def",
"checkcache",
"(",
"filename",
"=",
"None",
",",
"opts",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"opts",
",",
"dict",
")",
":",
"use_linecache_lines",
"=",
"opts",
"[",
"'use_linecache_lines'",
"]",
"else",
":",
"use_linecache_lines",
"=",
... | Discard cache entries that are out of date. If *filename* is *None*
all entries in the file cache *file_cache* are checked. If we do not
have stat information about a file it will be kept. Return a list of
invalidated filenames. None is returned if a filename was given but
not found cached. | [
"Discard",
"cache",
"entries",
"that",
"are",
"out",
"of",
"date",
".",
"If",
"*",
"filename",
"*",
"is",
"*",
"None",
"*",
"all",
"entries",
"in",
"the",
"file",
"cache",
"*",
"file_cache",
"*",
"are",
"checked",
".",
"If",
"we",
"do",
"not",
"have"... | python | train | 33.815789 |
DreamLab/VmShepherd | src/vmshepherd/iaas/dummy_driver.py | https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/iaas/dummy_driver.py#L72-L76 | async def get_vm(self, vm_id):
""" Dummy get_vm func """
if vm_id not in self._vms:
raise DummyIaasVmNotFound()
return self._vms[vm_id] | [
"async",
"def",
"get_vm",
"(",
"self",
",",
"vm_id",
")",
":",
"if",
"vm_id",
"not",
"in",
"self",
".",
"_vms",
":",
"raise",
"DummyIaasVmNotFound",
"(",
")",
"return",
"self",
".",
"_vms",
"[",
"vm_id",
"]"
] | Dummy get_vm func | [
"Dummy",
"get_vm",
"func"
] | python | train | 33.4 |
elifesciences/elife-tools | elifetools/parseJATS.py | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L47-L51 | def title_prefix_json(soup):
"titlePrefix with capitalisation changed"
prefix = title_prefix(soup)
prefix_rewritten = elifetools.json_rewrite.rewrite_json("title_prefix_json", soup, prefix)
return prefix_rewritten | [
"def",
"title_prefix_json",
"(",
"soup",
")",
":",
"prefix",
"=",
"title_prefix",
"(",
"soup",
")",
"prefix_rewritten",
"=",
"elifetools",
".",
"json_rewrite",
".",
"rewrite_json",
"(",
"\"title_prefix_json\"",
",",
"soup",
",",
"prefix",
")",
"return",
"prefix_... | titlePrefix with capitalisation changed | [
"titlePrefix",
"with",
"capitalisation",
"changed"
] | python | train | 45 |
googleapis/dialogflow-python-client-v2 | dialogflow_v2/gapic/intents_client.py | https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/intents_client.py#L134-L140 | def agent_path(cls, project, agent):
"""Return a fully-qualified agent string."""
return google.api_core.path_template.expand(
'projects/{project}/agents/{agent}',
project=project,
agent=agent,
) | [
"def",
"agent_path",
"(",
"cls",
",",
"project",
",",
"agent",
")",
":",
"return",
"google",
".",
"api_core",
".",
"path_template",
".",
"expand",
"(",
"'projects/{project}/agents/{agent}'",
",",
"project",
"=",
"project",
",",
"agent",
"=",
"agent",
",",
")... | Return a fully-qualified agent string. | [
"Return",
"a",
"fully",
"-",
"qualified",
"agent",
"string",
"."
] | python | train | 35.571429 |
thombashi/pytablereader | pytablereader/json/formatter.py | https://github.com/thombashi/pytablereader/blob/bc3c057a2cc775bcce690e0e9019c2907b638101/pytablereader/json/formatter.py#L265-L283 | def to_table_data(self):
"""
:raises ValueError:
:raises pytablereader.error.ValidationError:
"""
self._validate_source_data()
for table_key, json_records in six.iteritems(self._buffer):
self._loader.inc_table_count()
self._table_key = table_key
... | [
"def",
"to_table_data",
"(",
"self",
")",
":",
"self",
".",
"_validate_source_data",
"(",
")",
"for",
"table_key",
",",
"json_records",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_buffer",
")",
":",
"self",
".",
"_loader",
".",
"inc_table_count",
"(... | :raises ValueError:
:raises pytablereader.error.ValidationError: | [
":",
"raises",
"ValueError",
":",
":",
"raises",
"pytablereader",
".",
"error",
".",
"ValidationError",
":"
] | python | train | 31.157895 |
justquick/django-native-tags | native_tags/contrib/generic_markup.py | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/generic_markup.py#L12-L21 | def apply_markup(value, arg=None):
"""
Applies text-to-HTML conversion.
Takes an optional argument to specify the name of a filter to use.
"""
if arg is not None:
return formatter(value, filter_name=arg)
return formatter(value) | [
"def",
"apply_markup",
"(",
"value",
",",
"arg",
"=",
"None",
")",
":",
"if",
"arg",
"is",
"not",
"None",
":",
"return",
"formatter",
"(",
"value",
",",
"filter_name",
"=",
"arg",
")",
"return",
"formatter",
"(",
"value",
")"
] | Applies text-to-HTML conversion.
Takes an optional argument to specify the name of a filter to use. | [
"Applies",
"text",
"-",
"to",
"-",
"HTML",
"conversion",
".",
"Takes",
"an",
"optional",
"argument",
"to",
"specify",
"the",
"name",
"of",
"a",
"filter",
"to",
"use",
"."
] | python | train | 26 |
ralphbean/bugwarrior | bugwarrior/services/trello.py | https://github.com/ralphbean/bugwarrior/blob/b2a5108f7b40cb0c437509b64eaa28f941f7ac8b/bugwarrior/services/trello.py#L190-L199 | def api_request(self, url, **params):
"""
Make a trello API request. This takes an absolute url (without protocol
and host) and a list of argumnets and return a GET request with the
key and token from the configuration
"""
params['key'] = self.config.get('api_key'),
... | [
"def",
"api_request",
"(",
"self",
",",
"url",
",",
"*",
"*",
"params",
")",
":",
"params",
"[",
"'key'",
"]",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'api_key'",
")",
",",
"params",
"[",
"'token'",
"]",
"=",
"self",
".",
"config",
".",
"ge... | Make a trello API request. This takes an absolute url (without protocol
and host) and a list of argumnets and return a GET request with the
key and token from the configuration | [
"Make",
"a",
"trello",
"API",
"request",
".",
"This",
"takes",
"an",
"absolute",
"url",
"(",
"without",
"protocol",
"and",
"host",
")",
"and",
"a",
"list",
"of",
"argumnets",
"and",
"return",
"a",
"GET",
"request",
"with",
"the",
"key",
"and",
"token",
... | python | test | 47 |
ultrabug/py3status | py3status/py3.py | https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/py3.py#L531-L536 | def trigger_event(self, module_name, event):
"""
Trigger an event on a named module.
"""
if module_name:
self._py3_wrapper.events_thread.process_event(module_name, event) | [
"def",
"trigger_event",
"(",
"self",
",",
"module_name",
",",
"event",
")",
":",
"if",
"module_name",
":",
"self",
".",
"_py3_wrapper",
".",
"events_thread",
".",
"process_event",
"(",
"module_name",
",",
"event",
")"
] | Trigger an event on a named module. | [
"Trigger",
"an",
"event",
"on",
"a",
"named",
"module",
"."
] | python | train | 34.833333 |
googleapis/oauth2client | oauth2client/contrib/appengine.py | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L401-L411 | def locked_put(self, credentials):
"""Write a Credentials to the datastore.
Args:
credentials: Credentials, the credentials to store.
"""
entity = self._model.get_or_insert(self._key_name)
setattr(entity, self._property_name, credentials)
entity.put()
... | [
"def",
"locked_put",
"(",
"self",
",",
"credentials",
")",
":",
"entity",
"=",
"self",
".",
"_model",
".",
"get_or_insert",
"(",
"self",
".",
"_key_name",
")",
"setattr",
"(",
"entity",
",",
"self",
".",
"_property_name",
",",
"credentials",
")",
"entity",... | Write a Credentials to the datastore.
Args:
credentials: Credentials, the credentials to store. | [
"Write",
"a",
"Credentials",
"to",
"the",
"datastore",
"."
] | python | valid | 35.727273 |
saltstack/salt | salt/loader.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1015-L1039 | def clouds(opts):
'''
Return the cloud functions
'''
# Let's bring __active_provider_name__, defaulting to None, to all cloud
# drivers. This will get temporarily updated/overridden with a context
# manager when needed.
functions = LazyLoader(
_module_dirs(opts,
... | [
"def",
"clouds",
"(",
"opts",
")",
":",
"# Let's bring __active_provider_name__, defaulting to None, to all cloud",
"# drivers. This will get temporarily updated/overridden with a context",
"# manager when needed.",
"functions",
"=",
"LazyLoader",
"(",
"_module_dirs",
"(",
"opts",
",... | Return the cloud functions | [
"Return",
"the",
"cloud",
"functions"
] | python | train | 34.36 |
pywbem/pywbem | pywbem/_subscription_manager.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/_subscription_manager.py#L863-L913 | def remove_filter(self, server_id, filter_path):
"""
Remove an indication filter from a WBEM server, by deleting the
indication filter instance in the WBEM server.
The indication filter must be owned or permanent (i.e. not static).
This method verifies that there are not curren... | [
"def",
"remove_filter",
"(",
"self",
",",
"server_id",
",",
"filter_path",
")",
":",
"# Validate server_id",
"server",
"=",
"self",
".",
"_get_server",
"(",
"server_id",
")",
"conn_id",
"=",
"server",
".",
"conn",
".",
"conn_id",
"if",
"server",
".",
"conn",... | Remove an indication filter from a WBEM server, by deleting the
indication filter instance in the WBEM server.
The indication filter must be owned or permanent (i.e. not static).
This method verifies that there are not currently any subscriptions on
the specified indication filter, in ... | [
"Remove",
"an",
"indication",
"filter",
"from",
"a",
"WBEM",
"server",
"by",
"deleting",
"the",
"indication",
"filter",
"instance",
"in",
"the",
"WBEM",
"server",
"."
] | python | train | 38.215686 |
wickman/pystachio | pystachio/typing.py | https://github.com/wickman/pystachio/blob/601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f/pystachio/typing.py#L97-L107 | def load(type_tuple, into=None):
"""
Determine all types touched by loading the type and deposit them into
the particular namespace.
"""
type_dict = {}
TypeFactory.new(type_dict, *type_tuple)
deposit = into if (into is not None and isinstance(into, dict)) else {}
for reified_type in ... | [
"def",
"load",
"(",
"type_tuple",
",",
"into",
"=",
"None",
")",
":",
"type_dict",
"=",
"{",
"}",
"TypeFactory",
".",
"new",
"(",
"type_dict",
",",
"*",
"type_tuple",
")",
"deposit",
"=",
"into",
"if",
"(",
"into",
"is",
"not",
"None",
"and",
"isinst... | Determine all types touched by loading the type and deposit them into
the particular namespace. | [
"Determine",
"all",
"types",
"touched",
"by",
"loading",
"the",
"type",
"and",
"deposit",
"them",
"into",
"the",
"particular",
"namespace",
"."
] | python | train | 36.363636 |
wilson-eft/wilson | wilson/run/smeft/classes.py | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/smeft/classes.py#L144-L162 | def _run_sm_scale_in(self, C_out, scale_sm=91.1876):
"""Get the SM parameters at the EW scale, using an estimate `C_out`
of the Wilson coefficients at that scale, and run them to the
input scale."""
# initialize an empty SMEFT instance
smeft_sm = SMEFT(wc=None)
C_in_sm = ... | [
"def",
"_run_sm_scale_in",
"(",
"self",
",",
"C_out",
",",
"scale_sm",
"=",
"91.1876",
")",
":",
"# initialize an empty SMEFT instance",
"smeft_sm",
"=",
"SMEFT",
"(",
"wc",
"=",
"None",
")",
"C_in_sm",
"=",
"smeftutil",
".",
"C_array2dict",
"(",
"np",
".",
... | Get the SM parameters at the EW scale, using an estimate `C_out`
of the Wilson coefficients at that scale, and run them to the
input scale. | [
"Get",
"the",
"SM",
"parameters",
"at",
"the",
"EW",
"scale",
"using",
"an",
"estimate",
"C_out",
"of",
"the",
"Wilson",
"coefficients",
"at",
"that",
"scale",
"and",
"run",
"them",
"to",
"the",
"input",
"scale",
"."
] | python | train | 56.526316 |
rosenbrockc/fortpy | fortpy/printing/docs.py | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/printing/docs.py#L6-L20 | def format(element):
"""Formats all of the docstrings in the specified element and its
children into a user-friendly paragraph format for printing.
:arg element: an instance of fortpy.element.CodeElement.
"""
result = []
if type(element).__name__ in ["Subroutine", "Function"]:
_format_e... | [
"def",
"format",
"(",
"element",
")",
":",
"result",
"=",
"[",
"]",
"if",
"type",
"(",
"element",
")",
".",
"__name__",
"in",
"[",
"\"Subroutine\"",
",",
"\"Function\"",
"]",
":",
"_format_executable",
"(",
"result",
",",
"element",
")",
"elif",
"type",
... | Formats all of the docstrings in the specified element and its
children into a user-friendly paragraph format for printing.
:arg element: an instance of fortpy.element.CodeElement. | [
"Formats",
"all",
"of",
"the",
"docstrings",
"in",
"the",
"specified",
"element",
"and",
"its",
"children",
"into",
"a",
"user",
"-",
"friendly",
"paragraph",
"format",
"for",
"printing",
"."
] | python | train | 36 |
apple/turicreate | deps/src/libxml2-2.9.1/python/libxml2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L6623-L6626 | def GetParserProp(self, prop):
"""Read the parser internal property. """
ret = libxml2mod.xmlTextReaderGetParserProp(self._o, prop)
return ret | [
"def",
"GetParserProp",
"(",
"self",
",",
"prop",
")",
":",
"ret",
"=",
"libxml2mod",
".",
"xmlTextReaderGetParserProp",
"(",
"self",
".",
"_o",
",",
"prop",
")",
"return",
"ret"
] | Read the parser internal property. | [
"Read",
"the",
"parser",
"internal",
"property",
"."
] | python | train | 40.75 |
zsethna/OLGA | olga/load_model.py | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/load_model.py#L291-L309 | def generate_cutD_genomic_CDR3_segs(self):
"""Add palindromic inserted nucleotides to germline V sequences.
The maximum number of palindromic insertions are appended to the
germline D segments so that delDl and delDr can index directly for number
of nucleotides to delete from a... | [
"def",
"generate_cutD_genomic_CDR3_segs",
"(",
"self",
")",
":",
"max_palindrome_L",
"=",
"self",
".",
"max_delDl_palindrome",
"max_palindrome_R",
"=",
"self",
".",
"max_delDr_palindrome",
"self",
".",
"cutD_genomic_CDR3_segs",
"=",
"[",
"]",
"for",
"CDR3_D_seg",
"in"... | Add palindromic inserted nucleotides to germline V sequences.
The maximum number of palindromic insertions are appended to the
germline D segments so that delDl and delDr can index directly for number
of nucleotides to delete from a segment.
Sets the attribute cutV_gen... | [
"Add",
"palindromic",
"inserted",
"nucleotides",
"to",
"germline",
"V",
"sequences",
".",
"The",
"maximum",
"number",
"of",
"palindromic",
"insertions",
"are",
"appended",
"to",
"the",
"germline",
"D",
"segments",
"so",
"that",
"delDl",
"and",
"delDr",
"can",
... | python | train | 48.789474 |
tcalmant/ipopo | pelix/rsa/edef.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/rsa/edef.py#L182-L203 | def _parse_property(self, node):
# type: (ElementTree.Element) -> Tuple[str, Any]
"""
Parses a property node
:param node: The property node
:return: A (name, value) tuple
:raise KeyError: Attribute missing
"""
# Get information
name = node.attrib[... | [
"def",
"_parse_property",
"(",
"self",
",",
"node",
")",
":",
"# type: (ElementTree.Element) -> Tuple[str, Any]",
"# Get information",
"name",
"=",
"node",
".",
"attrib",
"[",
"ATTR_NAME",
"]",
"vtype",
"=",
"node",
".",
"attrib",
".",
"get",
"(",
"ATTR_VALUE_TYPE... | Parses a property node
:param node: The property node
:return: A (name, value) tuple
:raise KeyError: Attribute missing | [
"Parses",
"a",
"property",
"node"
] | python | train | 32.045455 |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/event.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/event.py#L246-L262 | def get_thread(self):
"""
@see: L{get_tid}
@rtype: L{Thread}
@return: Thread where the event occured.
"""
tid = self.get_tid()
process = self.get_process()
if process.has_thread(tid):
thread = process.get_thread(tid)
else:
... | [
"def",
"get_thread",
"(",
"self",
")",
":",
"tid",
"=",
"self",
".",
"get_tid",
"(",
")",
"process",
"=",
"self",
".",
"get_process",
"(",
")",
"if",
"process",
".",
"has_thread",
"(",
"tid",
")",
":",
"thread",
"=",
"process",
".",
"get_thread",
"("... | @see: L{get_tid}
@rtype: L{Thread}
@return: Thread where the event occured. | [
"@see",
":",
"L",
"{",
"get_tid",
"}"
] | python | train | 29.058824 |
google/brotli | research/brotlidump.py | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L978-L983 | def value(self, index, extra):
"""Give count and value."""
index = index
if index==0: return 1, 0
if index<=self.RLEMAX: return (1<<index)+extra, 0
return 1, index-self.RLEMAX | [
"def",
"value",
"(",
"self",
",",
"index",
",",
"extra",
")",
":",
"index",
"=",
"index",
"if",
"index",
"==",
"0",
":",
"return",
"1",
",",
"0",
"if",
"index",
"<=",
"self",
".",
"RLEMAX",
":",
"return",
"(",
"1",
"<<",
"index",
")",
"+",
"ext... | Give count and value. | [
"Give",
"count",
"and",
"value",
"."
] | python | test | 35 |
apache/spark | python/pyspark/sql/functions.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L645-L652 | def shiftLeft(col, numBits):
"""Shift the given value numBits left.
>>> spark.createDataFrame([(21,)], ['a']).select(shiftLeft('a', 1).alias('r')).collect()
[Row(r=42)]
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.functions.shiftLeft(_to_java_column(col), numBits)) | [
"def",
"shiftLeft",
"(",
"col",
",",
"numBits",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"shiftLeft",
"(",
"_to_java_column",
"(",
"col",
")",
",",
"numBits",
")",... | Shift the given value numBits left.
>>> spark.createDataFrame([(21,)], ['a']).select(shiftLeft('a', 1).alias('r')).collect()
[Row(r=42)] | [
"Shift",
"the",
"given",
"value",
"numBits",
"left",
"."
] | python | train | 38 |
PyCQA/astroid | astroid/brain/brain_builtin_inference.py | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/brain/brain_builtin_inference.py#L512-L536 | def infer_slice(node, context=None):
"""Understand `slice` calls."""
args = node.args
if not 0 < len(args) <= 3:
raise UseInferenceDefault
infer_func = partial(helpers.safe_infer, context=context)
args = [infer_func(arg) for arg in args]
for arg in args:
if not arg or arg is uti... | [
"def",
"infer_slice",
"(",
"node",
",",
"context",
"=",
"None",
")",
":",
"args",
"=",
"node",
".",
"args",
"if",
"not",
"0",
"<",
"len",
"(",
"args",
")",
"<=",
"3",
":",
"raise",
"UseInferenceDefault",
"infer_func",
"=",
"partial",
"(",
"helpers",
... | Understand `slice` calls. | [
"Understand",
"slice",
"calls",
"."
] | python | train | 32.04 |
memphis-iis/GLUDB | gludb/versioning.py | https://github.com/memphis-iis/GLUDB/blob/25692528ff6fe8184a3570f61f31f1a90088a388/gludb/versioning.py#L37-L43 | def record_diff(old, new):
"""Return a JSON-compatible structure capable turn the `new` record back
into the `old` record. The parameters must be structures compatible with
json.dumps *or* strings compatible with json.loads. Note that by design,
`old == record_patch(new, record_diff(old, new))`"""
o... | [
"def",
"record_diff",
"(",
"old",
",",
"new",
")",
":",
"old",
",",
"new",
"=",
"_norm_json_params",
"(",
"old",
",",
"new",
")",
"return",
"json_delta",
".",
"diff",
"(",
"new",
",",
"old",
",",
"verbose",
"=",
"False",
")"
] | Return a JSON-compatible structure capable turn the `new` record back
into the `old` record. The parameters must be structures compatible with
json.dumps *or* strings compatible with json.loads. Note that by design,
`old == record_patch(new, record_diff(old, new))` | [
"Return",
"a",
"JSON",
"-",
"compatible",
"structure",
"capable",
"turn",
"the",
"new",
"record",
"back",
"into",
"the",
"old",
"record",
".",
"The",
"parameters",
"must",
"be",
"structures",
"compatible",
"with",
"json",
".",
"dumps",
"*",
"or",
"*",
"str... | python | train | 57.571429 |
ccubed/PyMoe | Pymoe/VNDB/__init__.py | https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/VNDB/__init__.py#L34-L80 | def get(self, stype, flags, filters, options=None):
"""
Send a request to the API to return results related to Visual Novels.
:param str stype: What are we searching for? One of: vn, release, producer, character, votelist, vnlist, wishlist
:param flags: See the D11 docs. A comma separat... | [
"def",
"get",
"(",
"self",
",",
"stype",
",",
"flags",
",",
"filters",
",",
"options",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"flags",
",",
"str",
")",
":",
"if",
"isinstance",
"(",
"flags",
",",
"list",
")",
":",
"finflags",
"=",
... | Send a request to the API to return results related to Visual Novels.
:param str stype: What are we searching for? One of: vn, release, producer, character, votelist, vnlist, wishlist
:param flags: See the D11 docs. A comma separated list of flags for what data to return. Can be list or str.
:p... | [
"Send",
"a",
"request",
"to",
"the",
"API",
"to",
"return",
"results",
"related",
"to",
"Visual",
"Novels",
"."
] | python | train | 60.340426 |
Rapptz/discord.py | discord/gateway.py | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/gateway.py#L259-L282 | def wait_for(self, event, predicate, result=None):
"""Waits for a DISPATCH'd event that meets the predicate.
Parameters
-----------
event: :class:`str`
The event name in all upper case to wait for.
predicate
A function that takes a data parameter to check... | [
"def",
"wait_for",
"(",
"self",
",",
"event",
",",
"predicate",
",",
"result",
"=",
"None",
")",
":",
"future",
"=",
"self",
".",
"loop",
".",
"create_future",
"(",
")",
"entry",
"=",
"EventListener",
"(",
"event",
"=",
"event",
",",
"predicate",
"=",
... | Waits for a DISPATCH'd event that meets the predicate.
Parameters
-----------
event: :class:`str`
The event name in all upper case to wait for.
predicate
A function that takes a data parameter to check for event
properties. The data parameter is the '... | [
"Waits",
"for",
"a",
"DISPATCH",
"d",
"event",
"that",
"meets",
"the",
"predicate",
"."
] | python | train | 35.625 |
JinnLynn/genpac | genpac/pysocks/socks.py | https://github.com/JinnLynn/genpac/blob/2f466d28f403a9a5624e02edcd538475fe475fc8/genpac/pysocks/socks.py#L184-L241 | def create_connection(dest_pair, proxy_type=None, proxy_addr=None,
proxy_port=None, proxy_rdns=True,
proxy_username=None, proxy_password=None,
timeout=None, source_address=None,
socket_options=None):
"""create_connection(dest_pa... | [
"def",
"create_connection",
"(",
"dest_pair",
",",
"proxy_type",
"=",
"None",
",",
"proxy_addr",
"=",
"None",
",",
"proxy_port",
"=",
"None",
",",
"proxy_rdns",
"=",
"True",
",",
"proxy_username",
"=",
"None",
",",
"proxy_password",
"=",
"None",
",",
"timeou... | create_connection(dest_pair, *[, timeout], **proxy_args) -> socket object
Like socket.create_connection(), but connects to proxy
before returning the socket object.
dest_pair - 2-tuple of (IP/hostname, port).
**proxy_args - Same args passed to socksocket.set_proxy() if present.
timeout - Optional ... | [
"create_connection",
"(",
"dest_pair",
"*",
"[",
"timeout",
"]",
"**",
"proxy_args",
")",
"-",
">",
"socket",
"object"
] | python | train | 36.068966 |
offu/WeRoBot | werobot/client.py | https://github.com/offu/WeRoBot/blob/fd42109105b03f9acf45ebd9dcabb9d5cff98f3c/werobot/client.py#L188-L238 | def create_custom_menu(self, menu_data, matchrule):
"""
创建个性化菜单::
button = [
{
"type":"click",
"name":"今日歌曲",
"key":"V1001_TODAY_MUSIC"
},
{
"name":"菜单",
... | [
"def",
"create_custom_menu",
"(",
"self",
",",
"menu_data",
",",
"matchrule",
")",
":",
"return",
"self",
".",
"post",
"(",
"url",
"=",
"\"https://api.weixin.qq.com/cgi-bin/menu/addconditional\"",
",",
"data",
"=",
"{",
"\"button\"",
":",
"menu_data",
",",
"\"matc... | 创建个性化菜单::
button = [
{
"type":"click",
"name":"今日歌曲",
"key":"V1001_TODAY_MUSIC"
},
{
"name":"菜单",
"sub_button":[
{
... | [
"创建个性化菜单",
"::"
] | python | train | 29.254902 |
DLR-RM/RAFCON | source/rafcon/core/states/container_state.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/states/container_state.py#L2246-L2261 | def start_state_id(self):
""" The start state is the state to which the first transition goes to.
The setter-method creates a unique first transition to the state with the given id.
Existing first transitions are removed. If the given state id is None, the first transition is removed.
... | [
"def",
"start_state_id",
"(",
"self",
")",
":",
"for",
"transition_id",
"in",
"self",
".",
"transitions",
":",
"if",
"self",
".",
"transitions",
"[",
"transition_id",
"]",
".",
"from_state",
"is",
"None",
":",
"to_state",
"=",
"self",
".",
"transitions",
"... | The start state is the state to which the first transition goes to.
The setter-method creates a unique first transition to the state with the given id.
Existing first transitions are removed. If the given state id is None, the first transition is removed.
:return: The id of the start state | [
"The",
"start",
"state",
"is",
"the",
"state",
"to",
"which",
"the",
"first",
"transition",
"goes",
"to",
"."
] | python | train | 43.3125 |
ethereum/eth-hash | eth_hash/main.py | https://github.com/ethereum/eth-hash/blob/d05c8ac0710e2dc16aae2c8a1e406ee7cbe78871/eth_hash/main.py#L16-L25 | def _hasher_first_run(self, preimage):
'''
Invoke the backend on-demand, and check an expected hash result,
then replace this first run with the new hasher method.
This is a bit of a hacky way to minimize overhead on hash calls after this first one.
'''
new_hasher = self.... | [
"def",
"_hasher_first_run",
"(",
"self",
",",
"preimage",
")",
":",
"new_hasher",
"=",
"self",
".",
"_backend",
".",
"keccak256",
"assert",
"new_hasher",
"(",
"b''",
")",
"==",
"b\"\\xc5\\xd2F\\x01\\x86\\xf7#<\\x92~}\\xb2\\xdc\\xc7\\x03\\xc0\\xe5\\x00\\xb6S\\xca\\x82';\\x7b... | Invoke the backend on-demand, and check an expected hash result,
then replace this first run with the new hasher method.
This is a bit of a hacky way to minimize overhead on hash calls after this first one. | [
"Invoke",
"the",
"backend",
"on",
"-",
"demand",
"and",
"check",
"an",
"expected",
"hash",
"result",
"then",
"replace",
"this",
"first",
"run",
"with",
"the",
"new",
"hasher",
"method",
".",
"This",
"is",
"a",
"bit",
"of",
"a",
"hacky",
"way",
"to",
"m... | python | train | 54.8 |
bunq/sdk_python | bunq/sdk/model/generated/object_.py | https://github.com/bunq/sdk_python/blob/da6c9b83e6d83ee8062617f53c6eb7293c0d863d/bunq/sdk/model/generated/object_.py#L2707-L2721 | def is_all_field_none(self):
"""
:rtype: bool
"""
if self._share_detail is not None:
return False
if self._start_date is not None:
return False
if self._end_date is not None:
return False
return True | [
"def",
"is_all_field_none",
"(",
"self",
")",
":",
"if",
"self",
".",
"_share_detail",
"is",
"not",
"None",
":",
"return",
"False",
"if",
"self",
".",
"_start_date",
"is",
"not",
"None",
":",
"return",
"False",
"if",
"self",
".",
"_end_date",
"is",
"not"... | :rtype: bool | [
":",
"rtype",
":",
"bool"
] | python | train | 18.733333 |
christophertbrown/bioscripts | ctbBio/16SfromHMM.py | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/16SfromHMM.py#L103-L126 | def find_coordinates(hmms, bit_thresh):
"""
find 16S rRNA gene sequence coordinates
"""
# get coordinates from cmsearch output
seq2hmm = parse_hmm(hmms, bit_thresh)
seq2hmm = best_model(seq2hmm)
group2hmm = {} # group2hmm[seq][group] = [model, strand, coordinates, matches, gaps]
for seq,... | [
"def",
"find_coordinates",
"(",
"hmms",
",",
"bit_thresh",
")",
":",
"# get coordinates from cmsearch output",
"seq2hmm",
"=",
"parse_hmm",
"(",
"hmms",
",",
"bit_thresh",
")",
"seq2hmm",
"=",
"best_model",
"(",
"seq2hmm",
")",
"group2hmm",
"=",
"{",
"}",
"# gro... | find 16S rRNA gene sequence coordinates | [
"find",
"16S",
"rRNA",
"gene",
"sequence",
"coordinates"
] | python | train | 47.875 |
ev3dev/ev3dev-lang-python | ev3dev2/motor.py | https://github.com/ev3dev/ev3dev-lang-python/blob/afc98d35004b533dc161a01f7c966e78607d7c1e/ev3dev2/motor.py#L990-L1005 | def on_to_position(self, speed, position, brake=True, block=True):
"""
Rotate the motor at ``speed`` to ``position``
``speed`` can be a percentage or a :class:`ev3dev2.motor.SpeedValue`
object, enabling use of other units.
"""
speed = self._speed_native_units(speed)
... | [
"def",
"on_to_position",
"(",
"self",
",",
"speed",
",",
"position",
",",
"brake",
"=",
"True",
",",
"block",
"=",
"True",
")",
":",
"speed",
"=",
"self",
".",
"_speed_native_units",
"(",
"speed",
")",
"self",
".",
"speed_sp",
"=",
"int",
"(",
"round",... | Rotate the motor at ``speed`` to ``position``
``speed`` can be a percentage or a :class:`ev3dev2.motor.SpeedValue`
object, enabling use of other units. | [
"Rotate",
"the",
"motor",
"at",
"speed",
"to",
"position"
] | python | train | 35.5 |
sdispater/orator | orator/dbal/table.py | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/table.py#L457-L469 | def remove_foreign_key(self, name):
"""
Removes the foreign key constraint with the given name.
:param name: The constraint name
:type name: str
"""
name = self._normalize_identifier(name)
if not self.has_foreign_key(name):
raise ForeignKeyDoesNotExi... | [
"def",
"remove_foreign_key",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"_normalize_identifier",
"(",
"name",
")",
"if",
"not",
"self",
".",
"has_foreign_key",
"(",
"name",
")",
":",
"raise",
"ForeignKeyDoesNotExist",
"(",
"name",
",",
"... | Removes the foreign key constraint with the given name.
:param name: The constraint name
:type name: str | [
"Removes",
"the",
"foreign",
"key",
"constraint",
"with",
"the",
"given",
"name",
"."
] | python | train | 28.307692 |
pypa/pipenv | tasks/vendoring/__init__.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/tasks/vendoring/__init__.py#L603-L610 | def libname_from_dir(dirname):
"""Reconstruct the library name without it's version"""
parts = []
for part in dirname.split('-'):
if part[0].isdigit():
break
parts.append(part)
return '-'.join(parts) | [
"def",
"libname_from_dir",
"(",
"dirname",
")",
":",
"parts",
"=",
"[",
"]",
"for",
"part",
"in",
"dirname",
".",
"split",
"(",
"'-'",
")",
":",
"if",
"part",
"[",
"0",
"]",
".",
"isdigit",
"(",
")",
":",
"break",
"parts",
".",
"append",
"(",
"pa... | Reconstruct the library name without it's version | [
"Reconstruct",
"the",
"library",
"name",
"without",
"it",
"s",
"version"
] | python | train | 29.5 |
kummahiih/python-category-equations | category_equations/terms.py | https://github.com/kummahiih/python-category-equations/blob/4e4f6b2f03f3d4c1b2059f4c2dd7c5badb15a2c4/category_equations/terms.py#L473-L669 | def from_operator(operation=debug):
"""# python-category-equations
With the tools provided here you can create category like equations for the given operator.
On the equations the underlaying '+' and '-' operations are basic set operations
called union and discard and the multiplication operator '*' connects... | [
"def",
"from_operator",
"(",
"operation",
"=",
"debug",
")",
":",
"_I",
",",
"_O",
"=",
"get_I_and_O",
"(",
"operation",
")",
"def",
"_C",
"(",
"*",
"things",
")",
":",
"return",
"Adder",
"(",
"operator",
"=",
"operation",
",",
"items",
"=",
"set",
"... | # python-category-equations
With the tools provided here you can create category like equations for the given operator.
On the equations the underlaying '+' and '-' operations are basic set operations
called union and discard and the multiplication operator '*' connects sources to sinks.
The equation system also... | [
"#",
"python",
"-",
"category",
"-",
"equations",
"With",
"the",
"tools",
"provided",
"here",
"you",
"can",
"create",
"category",
"like",
"equations",
"for",
"the",
"given",
"operator",
".",
"On",
"the",
"equations",
"the",
"underlaying",
"+",
"and",
"-",
... | python | train | 19.050761 |
numenta/nupic | src/nupic/encoders/coordinate.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/coordinate.py#L139-L152 | def _topWCoordinates(cls, coordinates, w):
"""
Returns the top W coordinates by order.
@param coordinates (numpy.array) A 2D numpy array, where each element
is a coordinate
@param w (int) Number of top coordinates to return
@return (numpy.array) A subset of `coo... | [
"def",
"_topWCoordinates",
"(",
"cls",
",",
"coordinates",
",",
"w",
")",
":",
"orders",
"=",
"numpy",
".",
"array",
"(",
"[",
"cls",
".",
"_orderForCoordinate",
"(",
"c",
")",
"for",
"c",
"in",
"coordinates",
".",
"tolist",
"(",
")",
"]",
")",
"indi... | Returns the top W coordinates by order.
@param coordinates (numpy.array) A 2D numpy array, where each element
is a coordinate
@param w (int) Number of top coordinates to return
@return (numpy.array) A subset of `coordinates`, containing only the
... | [
"Returns",
"the",
"top",
"W",
"coordinates",
"by",
"order",
"."
] | python | valid | 40.928571 |
bram85/topydo | topydo/lib/ChangeSet.py | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/ChangeSet.py#L77-L86 | def _write(self):
"""
Writes data from backup_dict property in serialized and compressed form
to backup file pointed in json_file property.
"""
self.json_file.seek(0)
self.json_file.truncate()
dump = json.dumps(self.backup_dict)
dump_c = zlib.compress(dump... | [
"def",
"_write",
"(",
"self",
")",
":",
"self",
".",
"json_file",
".",
"seek",
"(",
"0",
")",
"self",
".",
"json_file",
".",
"truncate",
"(",
")",
"dump",
"=",
"json",
".",
"dumps",
"(",
"self",
".",
"backup_dict",
")",
"dump_c",
"=",
"zlib",
".",
... | Writes data from backup_dict property in serialized and compressed form
to backup file pointed in json_file property. | [
"Writes",
"data",
"from",
"backup_dict",
"property",
"in",
"serialized",
"and",
"compressed",
"form",
"to",
"backup",
"file",
"pointed",
"in",
"json_file",
"property",
"."
] | python | train | 36.5 |
iotile/coretools | iotilecore/iotile/core/utilities/schema_verify/bool_verify.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/schema_verify/bool_verify.py#L38-L53 | def format(self, indent_level, indent_size=4):
"""Format this verifier
Returns:
string: A formatted string
"""
name = self.format_name('Boolean', indent_size)
if self._require_value is not None:
if self.long_desc is not None:
name += '\n... | [
"def",
"format",
"(",
"self",
",",
"indent_level",
",",
"indent_size",
"=",
"4",
")",
":",
"name",
"=",
"self",
".",
"format_name",
"(",
"'Boolean'",
",",
"indent_size",
")",
"if",
"self",
".",
"_require_value",
"is",
"not",
"None",
":",
"if",
"self",
... | Format this verifier
Returns:
string: A formatted string | [
"Format",
"this",
"verifier"
] | python | train | 29.6875 |
MolSSI-BSE/basis_set_exchange | basis_set_exchange/sort.py | https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/sort.py#L16-L78 | def sort_basis_dict(bs):
"""Sorts a basis set dictionary into a standard order
This, for example, allows the written file to be more easily read by humans by,
for example, putting the name and description before more detailed fields.
This is generally for cosmetic reasons. However, users will generall... | [
"def",
"sort_basis_dict",
"(",
"bs",
")",
":",
"# yapf: disable",
"_keyorder",
"=",
"[",
"# Schema stuff",
"'molssi_bse_schema'",
",",
"'schema_type'",
",",
"'schema_version'",
",",
"# Auxiliary block",
"'jkfit'",
",",
"'jfit'",
",",
"'rifit'",
",",
"'admmfit'",
","... | Sorts a basis set dictionary into a standard order
This, for example, allows the written file to be more easily read by humans by,
for example, putting the name and description before more detailed fields.
This is generally for cosmetic reasons. However, users will generally like things
in a consisten... | [
"Sorts",
"a",
"basis",
"set",
"dictionary",
"into",
"a",
"standard",
"order"
] | python | train | 34.047619 |
gqmelo/exec-wrappers | exec_wrappers/create_wrappers.py | https://github.com/gqmelo/exec-wrappers/blob/0faf892a103cf03d005f1dbdc71ca52d279b4e3b/exec_wrappers/create_wrappers.py#L300-L302 | def _make_executable(path):
"""Make the file at path executable."""
os.chmod(path, os.stat(path).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) | [
"def",
"_make_executable",
"(",
"path",
")",
":",
"os",
".",
"chmod",
"(",
"path",
",",
"os",
".",
"stat",
"(",
"path",
")",
".",
"st_mode",
"|",
"stat",
".",
"S_IXUSR",
"|",
"stat",
".",
"S_IXGRP",
"|",
"stat",
".",
"S_IXOTH",
")"
] | Make the file at path executable. | [
"Make",
"the",
"file",
"at",
"path",
"executable",
"."
] | python | train | 52 |
deepmipt/DeepPavlov | deeppavlov/core/layers/tf_layers.py | https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/core/layers/tf_layers.py#L447-L472 | def additive_self_attention(units, n_hidden=None, n_output_features=None, activation=None):
""" Computes additive self attention for time series of vectors (with batch dimension)
the formula: score(h_i, h_j) = <v, tanh(W_1 h_i + W_2 h_j)>
v is a learnable vector of n_hidden dimensionality,
W... | [
"def",
"additive_self_attention",
"(",
"units",
",",
"n_hidden",
"=",
"None",
",",
"n_output_features",
"=",
"None",
",",
"activation",
"=",
"None",
")",
":",
"n_input_features",
"=",
"units",
".",
"get_shape",
"(",
")",
".",
"as_list",
"(",
")",
"[",
"2",... | Computes additive self attention for time series of vectors (with batch dimension)
the formula: score(h_i, h_j) = <v, tanh(W_1 h_i + W_2 h_j)>
v is a learnable vector of n_hidden dimensionality,
W_1 and W_2 are learnable [n_hidden, n_input_features] matrices
Args:
units: tf tensor w... | [
"Computes",
"additive",
"self",
"attention",
"for",
"time",
"series",
"of",
"vectors",
"(",
"with",
"batch",
"dimension",
")",
"the",
"formula",
":",
"score",
"(",
"h_i",
"h_j",
")",
"=",
"<v",
"tanh",
"(",
"W_1",
"h_i",
"+",
"W_2",
"h_j",
")",
">",
... | python | test | 54.653846 |
trailofbits/manticore | manticore/native/cpu/x86.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/x86.py#L2846-L2853 | def SETNZ(cpu, dest):
"""
Sets byte if not zero.
:param cpu: current CPU.
:param dest: destination operand.
"""
dest.write(Operators.ITEBV(dest.size, cpu.ZF == False, 1, 0)) | [
"def",
"SETNZ",
"(",
"cpu",
",",
"dest",
")",
":",
"dest",
".",
"write",
"(",
"Operators",
".",
"ITEBV",
"(",
"dest",
".",
"size",
",",
"cpu",
".",
"ZF",
"==",
"False",
",",
"1",
",",
"0",
")",
")"
] | Sets byte if not zero.
:param cpu: current CPU.
:param dest: destination operand. | [
"Sets",
"byte",
"if",
"not",
"zero",
"."
] | python | valid | 26.875 |
anrosent/cli | cli.py | https://github.com/anrosent/cli/blob/8f89df4564c5124c95aaa288441f9d574dfa89a3/cli.py#L52-L64 | def add_cli(self, prefix, other_cli):
"""Adds the functionality of the other CLI to this one, where all
commands to the other CLI are prefixed by the given prefix plus a hyphen.
e.g. To execute command `greet anson 5` on other cli given prefix cli2, you
can execute the following with th... | [
"def",
"add_cli",
"(",
"self",
",",
"prefix",
",",
"other_cli",
")",
":",
"if",
"prefix",
"not",
"in",
"self",
".",
"clis",
"and",
"prefix",
"not",
"in",
"self",
".",
"cmds",
":",
"self",
".",
"clis",
"[",
"prefix",
"]",
"=",
"other_cli",
"else",
"... | Adds the functionality of the other CLI to this one, where all
commands to the other CLI are prefixed by the given prefix plus a hyphen.
e.g. To execute command `greet anson 5` on other cli given prefix cli2, you
can execute the following with this CLI:
cli2 greet anson 5 | [
"Adds",
"the",
"functionality",
"of",
"the",
"other",
"CLI",
"to",
"this",
"one",
"where",
"all",
"commands",
"to",
"the",
"other",
"CLI",
"are",
"prefixed",
"by",
"the",
"given",
"prefix",
"plus",
"a",
"hyphen",
"."
] | python | train | 43.538462 |
pyQode/pyqode.python | examples/pynotepad/pynotepad/main_window.py | https://github.com/pyQode/pyqode.python/blob/821e000ea2e2638a82ce095a559e69afd9bd4f38/examples/pynotepad/pynotepad/main_window.py#L181-L195 | def on_save_as(self):
"""
Save the current editor document as.
"""
path = self.tabWidget.current_widget().file.path
path = os.path.dirname(path) if path else ''
filename, filter = QtWidgets.QFileDialog.getSaveFileName(
self, 'Save', path)
if filename:
... | [
"def",
"on_save_as",
"(",
"self",
")",
":",
"path",
"=",
"self",
".",
"tabWidget",
".",
"current_widget",
"(",
")",
".",
"file",
".",
"path",
"path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
"if",
"path",
"else",
"''",
"filename",
... | Save the current editor document as. | [
"Save",
"the",
"current",
"editor",
"document",
"as",
"."
] | python | valid | 41.8 |
onecodex/onecodex | onecodex/lib/auth.py | https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/auth.py#L43-L88 | def check_version(version, server):
"""Check if the current CLI version is supported by the One Codex backend.
Parameters
----------
version : `string`
Current version of the One Codex client library
server : `string`
Complete URL to One Codex server, e.g., https://app.onecodex.com
... | [
"def",
"check_version",
"(",
"version",
",",
"server",
")",
":",
"def",
"version_inadequate",
"(",
"client_version",
",",
"server_version",
")",
":",
"\"\"\"Simple, fast check for version inequality.\n\n Could use python package `semver` if we need more precise checks in\n ... | Check if the current CLI version is supported by the One Codex backend.
Parameters
----------
version : `string`
Current version of the One Codex client library
server : `string`
Complete URL to One Codex server, e.g., https://app.onecodex.com
Returns
-------
`tuple` contai... | [
"Check",
"if",
"the",
"current",
"CLI",
"version",
"is",
"supported",
"by",
"the",
"One",
"Codex",
"backend",
"."
] | python | train | 34.869565 |
openstack/proliantutils | proliantutils/redfish/resources/system/system.py | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/system.py#L354-L391 | def create_raid(self, raid_config):
"""Create the raid configuration on the hardware.
:param raid_config: A dictionary containing target raid configuration
data. This data stucture should be as follows:
raid_config = {'logical_disks': [{'raid_leve... | [
"def",
"create_raid",
"(",
"self",
",",
"raid_config",
")",
":",
"self",
".",
"check_smart_storage_config_ids",
"(",
")",
"any_exceptions",
"=",
"[",
"]",
"controllers",
"=",
"self",
".",
"_parse_raid_config_data",
"(",
"raid_config",
")",
"# Creating raid on rest o... | Create the raid configuration on the hardware.
:param raid_config: A dictionary containing target raid configuration
data. This data stucture should be as follows:
raid_config = {'logical_disks': [{'raid_level': 1,
'size_gb': 1... | [
"Create",
"the",
"raid",
"configuration",
"on",
"the",
"hardware",
"."
] | python | train | 49.421053 |
pandas-dev/pandas | pandas/core/sorting.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sorting.py#L406-L507 | def safe_sort(values, labels=None, na_sentinel=-1, assume_unique=False):
"""
Sort ``values`` and reorder corresponding ``labels``.
``values`` should be unique if ``labels`` is not None.
Safe for use with mixed types (int, str), orders ints before strs.
.. versionadded:: 0.19.0
Parameters
-... | [
"def",
"safe_sort",
"(",
"values",
",",
"labels",
"=",
"None",
",",
"na_sentinel",
"=",
"-",
"1",
",",
"assume_unique",
"=",
"False",
")",
":",
"if",
"not",
"is_list_like",
"(",
"values",
")",
":",
"raise",
"TypeError",
"(",
"\"Only list-like objects are all... | Sort ``values`` and reorder corresponding ``labels``.
``values`` should be unique if ``labels`` is not None.
Safe for use with mixed types (int, str), orders ints before strs.
.. versionadded:: 0.19.0
Parameters
----------
values : list-like
Sequence; must be unique if ``labels`` is no... | [
"Sort",
"values",
"and",
"reorder",
"corresponding",
"labels",
".",
"values",
"should",
"be",
"unique",
"if",
"labels",
"is",
"not",
"None",
".",
"Safe",
"for",
"use",
"with",
"mixed",
"types",
"(",
"int",
"str",
")",
"orders",
"ints",
"before",
"strs",
... | python | train | 34.117647 |
volafiled/python-volapi | volapi/user.py | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/user.py#L93-L101 | def __verify_username(self, username):
"""Raises an exception if the given username is not valid."""
if len(username) > self.__max_length or len(username) < 3:
raise ValueError(
f"Username must be between 3 and {self.__max_length} characters."
)
if any(c ... | [
"def",
"__verify_username",
"(",
"self",
",",
"username",
")",
":",
"if",
"len",
"(",
"username",
")",
">",
"self",
".",
"__max_length",
"or",
"len",
"(",
"username",
")",
"<",
"3",
":",
"raise",
"ValueError",
"(",
"f\"Username must be between 3 and {self.__ma... | Raises an exception if the given username is not valid. | [
"Raises",
"an",
"exception",
"if",
"the",
"given",
"username",
"is",
"not",
"valid",
"."
] | python | train | 51 |
ajenhl/tacl | tacl/highlighter.py | https://github.com/ajenhl/tacl/blob/b8a343248e77f1c07a5a4ac133a9ad6e0b4781c2/tacl/highlighter.py#L52-L66 | def _prepare_text(self, text):
"""Returns `text` with each consituent token wrapped in HTML markup
for later match annotation.
:param text: text to be marked up
:type text: `str`
:rtype: `str`
"""
# Remove characters that should be escaped for XML input (but
... | [
"def",
"_prepare_text",
"(",
"self",
",",
"text",
")",
":",
"# Remove characters that should be escaped for XML input (but",
"# which cause problems when escaped, since they become",
"# tokens).",
"text",
"=",
"re",
".",
"sub",
"(",
"r'[<>&]'",
",",
"''",
",",
"text",
")"... | Returns `text` with each consituent token wrapped in HTML markup
for later match annotation.
:param text: text to be marked up
:type text: `str`
:rtype: `str` | [
"Returns",
"text",
"with",
"each",
"consituent",
"token",
"wrapped",
"in",
"HTML",
"markup",
"for",
"later",
"match",
"annotation",
"."
] | python | train | 36.4 |
Scoppio/RagnarokEngine3 | RagnarokEngine3/RE3.py | https://github.com/Scoppio/RagnarokEngine3/blob/4395d419ccd64fe9327c41f200b72ee0176ad896/RagnarokEngine3/RE3.py#L213-L219 | def angle(vec1, vec2):
"""Calculate the angle between two Vector2's"""
dotp = Vector2.dot(vec1, vec2)
mag1 = vec1.length()
mag2 = vec2.length()
result = dotp / (mag1 * mag2)
return math.acos(result) | [
"def",
"angle",
"(",
"vec1",
",",
"vec2",
")",
":",
"dotp",
"=",
"Vector2",
".",
"dot",
"(",
"vec1",
",",
"vec2",
")",
"mag1",
"=",
"vec1",
".",
"length",
"(",
")",
"mag2",
"=",
"vec2",
".",
"length",
"(",
")",
"result",
"=",
"dotp",
"/",
"(",
... | Calculate the angle between two Vector2's | [
"Calculate",
"the",
"angle",
"between",
"two",
"Vector2",
"s"
] | python | train | 34.285714 |
StackStorm/pybind | pybind/slxos/v17s_1_02/mpls_config/router/mpls/mpls_cmds_holder/bfd/bfd_sub_cmds/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/mpls_config/router/mpls/mpls_cmds_holder/bfd/bfd_sub_cmds/__init__.py#L92-L113 | def _set_bfd_min_tx(self, v, load=False):
"""
Setter method for bfd_min_tx, mapped from YANG variable /mpls_config/router/mpls/mpls_cmds_holder/bfd/bfd_sub_cmds/bfd_min_tx (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_bfd_min_tx is considered as a private
... | [
"def",
"_set_bfd_min_tx",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"bas... | Setter method for bfd_min_tx, mapped from YANG variable /mpls_config/router/mpls/mpls_cmds_holder/bfd/bfd_sub_cmds/bfd_min_tx (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_bfd_min_tx is considered as a private
method. Backends looking to populate this variable ... | [
"Setter",
"method",
"for",
"bfd_min_tx",
"mapped",
"from",
"YANG",
"variable",
"/",
"mpls_config",
"/",
"router",
"/",
"mpls",
"/",
"mpls_cmds_holder",
"/",
"bfd",
"/",
"bfd_sub_cmds",
"/",
"bfd_min_tx",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
... | python | train | 82.181818 |
EntilZha/PyFunctional | functional/pipeline.py | https://github.com/EntilZha/PyFunctional/blob/ac04e4a8552b0c464a7f492f7c9862424867b63e/functional/pipeline.py#L350-L364 | def cartesian(self, *iterables, **kwargs):
"""
Returns the cartesian product of the passed iterables with the specified number of
repetitions.
The keyword argument `repeat` is read from kwargs to pass to itertools.cartesian.
>>> seq.range(2).cartesian(range(2))
[(0, 0),... | [
"def",
"cartesian",
"(",
"self",
",",
"*",
"iterables",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_transform",
"(",
"transformations",
".",
"cartesian_t",
"(",
"iterables",
",",
"kwargs",
".",
"get",
"(",
"'repeat'",
",",
"1",
")",
")"... | Returns the cartesian product of the passed iterables with the specified number of
repetitions.
The keyword argument `repeat` is read from kwargs to pass to itertools.cartesian.
>>> seq.range(2).cartesian(range(2))
[(0, 0), (0, 1), (1, 0), (1, 1)]
:param iterables: elements fo... | [
"Returns",
"the",
"cartesian",
"product",
"of",
"the",
"passed",
"iterables",
"with",
"the",
"specified",
"number",
"of",
"repetitions",
"."
] | python | train | 39.733333 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L382-L476 | def get_bonds(self,
self_bonding_allowed=False,
offset=3,
modified_properties=None,
use_lookup=False,
set_lookup=True,
atomic_radius_data=None
):
"""Return a dictionary representing the ... | [
"def",
"get_bonds",
"(",
"self",
",",
"self_bonding_allowed",
"=",
"False",
",",
"offset",
"=",
"3",
",",
"modified_properties",
"=",
"None",
",",
"use_lookup",
"=",
"False",
",",
"set_lookup",
"=",
"True",
",",
"atomic_radius_data",
"=",
"None",
")",
":",
... | Return a dictionary representing the bonds.
.. warning:: This function is **not sideeffect free**, since it
assigns the output to a variable ``self._metadata['bond_dict']`` if
``set_lookup`` is ``True`` (which is the default). This is
necessary for performance reasons.
... | [
"Return",
"a",
"dictionary",
"representing",
"the",
"bonds",
"."
] | python | train | 41.410526 |
google/apitools | apitools/base/py/encoding_helper.py | https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/py/encoding_helper.py#L638-L642 | def GetCustomJsonFieldMapping(message_type, python_name=None, json_name=None):
"""Return the appropriate remapping for the given field, or None."""
return _FetchRemapping(message_type, 'field',
python_name=python_name, json_name=json_name,
mappings=_JSON_FIE... | [
"def",
"GetCustomJsonFieldMapping",
"(",
"message_type",
",",
"python_name",
"=",
"None",
",",
"json_name",
"=",
"None",
")",
":",
"return",
"_FetchRemapping",
"(",
"message_type",
",",
"'field'",
",",
"python_name",
"=",
"python_name",
",",
"json_name",
"=",
"j... | Return the appropriate remapping for the given field, or None. | [
"Return",
"the",
"appropriate",
"remapping",
"for",
"the",
"given",
"field",
"or",
"None",
"."
] | python | train | 65.6 |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L1201-L1251 | def do_objs(kbos):
"""Draw the actual plot"""
import orbfit, ephem, math
import re
re_string=w.FilterVar.get()
vlist=[]
for name in kbos:
if not re.search(re_string,name):
continue
vlist.append(name)
if type(kbos[name])==type(ephem.EllipticalBody()):
kbo... | [
"def",
"do_objs",
"(",
"kbos",
")",
":",
"import",
"orbfit",
",",
"ephem",
",",
"math",
"import",
"re",
"re_string",
"=",
"w",
".",
"FilterVar",
".",
"get",
"(",
")",
"vlist",
"=",
"[",
"]",
"for",
"name",
"in",
"kbos",
":",
"if",
"not",
"re",
".... | Draw the actual plot | [
"Draw",
"the",
"actual",
"plot"
] | python | train | 26.470588 |
xiaocong/uiautomator | uiautomator/__init__.py | https://github.com/xiaocong/uiautomator/blob/9a0c892ffd056713f91aa2153d1533c5b0553a1c/uiautomator/__init__.py#L963-L976 | def drag(self):
'''
Drag the ui object to other point or ui object.
Usage:
d(text="Clock").drag.to(x=100, y=100) # drag to point (x,y)
d(text="Clock").drag.to(text="Remove") # drag to another object
'''
def to(obj, *args, **kwargs):
if len(args) >= 2 ... | [
"def",
"drag",
"(",
"self",
")",
":",
"def",
"to",
"(",
"obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">=",
"2",
"or",
"\"x\"",
"in",
"kwargs",
"or",
"\"y\"",
"in",
"kwargs",
":",
"drag_to",
"=",
"... | Drag the ui object to other point or ui object.
Usage:
d(text="Clock").drag.to(x=100, y=100) # drag to point (x,y)
d(text="Clock").drag.to(text="Remove") # drag to another object | [
"Drag",
"the",
"ui",
"object",
"to",
"other",
"point",
"or",
"ui",
"object",
".",
"Usage",
":",
"d",
"(",
"text",
"=",
"Clock",
")",
".",
"drag",
".",
"to",
"(",
"x",
"=",
"100",
"y",
"=",
"100",
")",
"#",
"drag",
"to",
"point",
"(",
"x",
"y"... | python | train | 47.857143 |
galactics/beyond | beyond/dates/eop.py | https://github.com/galactics/beyond/blob/7a7590ff0fd4c0bac3e8e383ecca03caa98e5742/beyond/dates/eop.py#L282-L293 | def register(cls, klass, name=DEFAULT_DBNAME):
"""Register an Eop Database
The only requirement of this database is that it should have ``__getitem__``
method accepting MJD as float.
"""
if name in cls._dbs:
msg = "'{}' is already registered for an Eop database. Ski... | [
"def",
"register",
"(",
"cls",
",",
"klass",
",",
"name",
"=",
"DEFAULT_DBNAME",
")",
":",
"if",
"name",
"in",
"cls",
".",
"_dbs",
":",
"msg",
"=",
"\"'{}' is already registered for an Eop database. Skipping\"",
".",
"format",
"(",
"name",
")",
"log",
".",
"... | Register an Eop Database
The only requirement of this database is that it should have ``__getitem__``
method accepting MJD as float. | [
"Register",
"an",
"Eop",
"Database"
] | python | train | 33.833333 |
googlefonts/fontbakery | Lib/fontbakery/profiles/googlefonts.py | https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/googlefonts.py#L2259-L2299 | def com_google_fonts_check_metadata_match_weight_postscript(font_metadata):
"""METADATA.pb weight matches postScriptName."""
WEIGHTS = {
"Thin": 100,
"ThinItalic": 100,
"ExtraLight": 200,
"ExtraLightItalic": 200,
"Light": 300,
"LightItalic": 300,
"Regular": 400,
"Italic": 400,
"M... | [
"def",
"com_google_fonts_check_metadata_match_weight_postscript",
"(",
"font_metadata",
")",
":",
"WEIGHTS",
"=",
"{",
"\"Thin\"",
":",
"100",
",",
"\"ThinItalic\"",
":",
"100",
",",
"\"ExtraLight\"",
":",
"200",
",",
"\"ExtraLightItalic\"",
":",
"200",
",",
"\"Ligh... | METADATA.pb weight matches postScriptName. | [
"METADATA",
".",
"pb",
"weight",
"matches",
"postScriptName",
"."
] | python | train | 32.219512 |
yoavaviram/python-amazon-simple-product-api | amazon/api.py | https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L687-L724 | def price_and_currency(self):
"""Get Offer Price and Currency.
Return price according to the following process:
* If product has a sale return Sales Price, otherwise,
* Return Price, otherwise,
* Return lowest offer price, otherwise,
* Return None.
:return:
... | [
"def",
"price_and_currency",
"(",
"self",
")",
":",
"price",
"=",
"self",
".",
"_safe_get_element_text",
"(",
"'Offers.Offer.OfferListing.SalePrice.Amount'",
")",
"if",
"price",
":",
"currency",
"=",
"self",
".",
"_safe_get_element_text",
"(",
"'Offers.Offer.OfferListin... | Get Offer Price and Currency.
Return price according to the following process:
* If product has a sale return Sales Price, otherwise,
* Return Price, otherwise,
* Return lowest offer price, otherwise,
* Return None.
:return:
A tuple containing:
... | [
"Get",
"Offer",
"Price",
"and",
"Currency",
"."
] | python | train | 36.421053 |
w1ll1am23/pubnubsub-handler | pubnubsubhandler.py | https://github.com/w1ll1am23/pubnubsub-handler/blob/0283c191d6042727f55a748f69a485d751f4cacb/pubnubsubhandler.py#L168-L185 | def message(self, pubnub, message):
"""
Called when a new message is recevied on one of the subscribed
to channels.
Proccess the message and call the channels callback function(s).
"""
try:
json_data = json.dumps(message.message.get('data'))
except Att... | [
"def",
"message",
"(",
"self",
",",
"pubnub",
",",
"message",
")",
":",
"try",
":",
"json_data",
"=",
"json",
".",
"dumps",
"(",
"message",
".",
"message",
".",
"get",
"(",
"'data'",
")",
")",
"except",
"AttributeError",
":",
"json_data",
"=",
"message... | Called when a new message is recevied on one of the subscribed
to channels.
Proccess the message and call the channels callback function(s). | [
"Called",
"when",
"a",
"new",
"message",
"is",
"recevied",
"on",
"one",
"of",
"the",
"subscribed",
"to",
"channels",
".",
"Proccess",
"the",
"message",
"and",
"call",
"the",
"channels",
"callback",
"function",
"(",
"s",
")",
"."
] | python | train | 42.444444 |
biocore/burrito-fillings | bfillings/rdp_classifier.py | https://github.com/biocore/burrito-fillings/blob/02ab71a46119b40793bd56a4ae00ca15f6dc3329/bfillings/rdp_classifier.py#L197-L203 | def _get_result_paths(self, data):
""" Return a dict of ResultPath objects representing all possible output
"""
assignment_fp = str(self.Parameters['-o'].Value).strip('"')
if not os.path.isabs(assignment_fp):
assignment_fp = os.path.relpath(assignment_fp, self.WorkingDir)
... | [
"def",
"_get_result_paths",
"(",
"self",
",",
"data",
")",
":",
"assignment_fp",
"=",
"str",
"(",
"self",
".",
"Parameters",
"[",
"'-o'",
"]",
".",
"Value",
")",
".",
"strip",
"(",
"'\"'",
")",
"if",
"not",
"os",
".",
"path",
".",
"isabs",
"(",
"as... | Return a dict of ResultPath objects representing all possible output | [
"Return",
"a",
"dict",
"of",
"ResultPath",
"objects",
"representing",
"all",
"possible",
"output"
] | python | train | 54.857143 |
googlefonts/fontbakery | Lib/fontbakery/profiles/googlefonts.py | https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/googlefonts.py#L1501-L1513 | def com_google_fonts_check_metadata_copyright(family_metadata):
"""METADATA.pb: Copyright notice is the same in all fonts?"""
copyright = None
fail = False
for f in family_metadata.fonts:
if copyright and f.copyright != copyright:
fail = True
copyright = f.copyright
if fail:
yield FAIL, ("ME... | [
"def",
"com_google_fonts_check_metadata_copyright",
"(",
"family_metadata",
")",
":",
"copyright",
"=",
"None",
"fail",
"=",
"False",
"for",
"f",
"in",
"family_metadata",
".",
"fonts",
":",
"if",
"copyright",
"and",
"f",
".",
"copyright",
"!=",
"copyright",
":",... | METADATA.pb: Copyright notice is the same in all fonts? | [
"METADATA",
".",
"pb",
":",
"Copyright",
"notice",
"is",
"the",
"same",
"in",
"all",
"fonts?"
] | python | train | 35.076923 |
wavefrontHQ/python-client | wavefront_api_client/api/integration_api.py | https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/api/integration_api.py#L479-L500 | def get_integration(self, id, **kwargs): # noqa: E501
"""Gets a single Wavefront integration by its id, along with its status # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>... | [
"def",
"get_integration",
"(",
"self",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
".",
"get_integrat... | Gets a single Wavefront integration by its id, along with its status # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_integration(id, async_req=True)
>>> re... | [
"Gets",
"a",
"single",
"Wavefront",
"integration",
"by",
"its",
"id",
"along",
"with",
"its",
"status",
"#",
"noqa",
":",
"E501"
] | python | train | 42.181818 |
lsst-sqre/lsst-projectmeta-kit | lsstprojectmeta/tex/lsstdoc.py | https://github.com/lsst-sqre/lsst-projectmeta-kit/blob/ac8d4ff65bb93d8fdeb1b46ae6eb5d7414f1ae14/lsstprojectmeta/tex/lsstdoc.py#L317-L350 | def format_short_title(self, format='html5', deparagraph=True,
mathjax=False, smart=True, extra_args=None):
"""Get the document short title in the specified markup format.
Parameters
----------
format : `str`, optional
Output format (such as ``'htm... | [
"def",
"format_short_title",
"(",
"self",
",",
"format",
"=",
"'html5'",
",",
"deparagraph",
"=",
"True",
",",
"mathjax",
"=",
"False",
",",
"smart",
"=",
"True",
",",
"extra_args",
"=",
"None",
")",
":",
"if",
"self",
".",
"short_title",
"is",
"None",
... | Get the document short title in the specified markup format.
Parameters
----------
format : `str`, optional
Output format (such as ``'html5'`` or ``'plain'``).
deparagraph : `bool`, optional
Remove the paragraph tags from single paragraph content.
mathjax... | [
"Get",
"the",
"document",
"short",
"title",
"in",
"the",
"specified",
"markup",
"format",
"."
] | python | valid | 36.441176 |
lowandrew/OLCTools | accessoryFunctions/accessoryFunctions.py | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/accessoryFunctions/accessoryFunctions.py#L614-L626 | def isattr(self, key):
"""
Checks to see if an attribute exists. If it does, returns True, otherwise returns False
:param key: Dictionary key to be checked for presence in the datastore
:return: True/False depending on whether an attribute exists
"""
try:
if k... | [
"def",
"isattr",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"if",
"key",
"in",
"self",
".",
"datastore",
":",
"return",
"True",
"else",
":",
"return",
"False",
"except",
"AttributeError",
":",
"return",
"False"
] | Checks to see if an attribute exists. If it does, returns True, otherwise returns False
:param key: Dictionary key to be checked for presence in the datastore
:return: True/False depending on whether an attribute exists | [
"Checks",
"to",
"see",
"if",
"an",
"attribute",
"exists",
".",
"If",
"it",
"does",
"returns",
"True",
"otherwise",
"returns",
"False",
":",
"param",
"key",
":",
"Dictionary",
"key",
"to",
"be",
"checked",
"for",
"presence",
"in",
"the",
"datastore",
":",
... | python | train | 35.384615 |
dingusdk/PythonIhcSdk | ihcsdk/ihcclient.py | https://github.com/dingusdk/PythonIhcSdk/blob/7e2067e009fe7600b49f30bff1cf91dc72fc891e/ihcsdk/ihcclient.py#L260-L274 | def get_user_log(self, language='da'):
"""Get the controller state"""
payload = """<getUserLog1 xmlns="utcs" />
<getUserLog2 xmlns="utcs">0</getUserLog2>
<getUserLog3 xmlns="utcs">{language}</getUserLog3>
""".format(language=language)
... | [
"def",
"get_user_log",
"(",
"self",
",",
"language",
"=",
"'da'",
")",
":",
"payload",
"=",
"\"\"\"<getUserLog1 xmlns=\"utcs\" />\n <getUserLog2 xmlns=\"utcs\">0</getUserLog2>\n <getUserLog3 xmlns=\"utcs\">{language}</getUserLog3>\n ... | Get the controller state | [
"Get",
"the",
"controller",
"state"
] | python | train | 49.2 |
etcher-be/elib_miz | elib_miz/mission.py | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L674-L687 | def get_group_by_id(self, group_id) -> typing.Optional['Group']:
"""
Args:
group_id: group ID
Returns: Group
"""
VALID_POSITIVE_INT.validate(group_id, 'get_group_by_id')
for group in self.groups:
if group.group_id == group_id:
ret... | [
"def",
"get_group_by_id",
"(",
"self",
",",
"group_id",
")",
"->",
"typing",
".",
"Optional",
"[",
"'Group'",
"]",
":",
"VALID_POSITIVE_INT",
".",
"validate",
"(",
"group_id",
",",
"'get_group_by_id'",
")",
"for",
"group",
"in",
"self",
".",
"groups",
":",
... | Args:
group_id: group ID
Returns: Group | [
"Args",
":",
"group_id",
":",
"group",
"ID"
] | python | train | 24.071429 |
jrief/djangocms-cascade | cmsplugin_cascade/segmentation/mixins.py | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/segmentation/mixins.py#L88-L159 | def emulate_users(self, request):
"""
The list view
"""
def display_as_link(self, obj):
try:
identifier = getattr(user_model_admin, list_display_link)(obj)
except AttributeError:
identifier = admin.utils.lookup_field(list_display_li... | [
"def",
"emulate_users",
"(",
"self",
",",
"request",
")",
":",
"def",
"display_as_link",
"(",
"self",
",",
"obj",
")",
":",
"try",
":",
"identifier",
"=",
"getattr",
"(",
"user_model_admin",
",",
"list_display_link",
")",
"(",
"obj",
")",
"except",
"Attrib... | The list view | [
"The",
"list",
"view"
] | python | train | 50.152778 |
HazyResearch/fonduer | src/fonduer/features/featurizer.py | https://github.com/HazyResearch/fonduer/blob/4520f86a716f03dcca458a9f4bddac75b4e7068f/src/fonduer/features/featurizer.py#L181-L201 | def clear(self, train=False, split=0):
"""Delete Features of each class from the database.
:param train: Whether or not to clear the FeatureKeys
:type train: bool
:param split: Which split of candidates to clear features from.
:type split: int
"""
# Clear Feature... | [
"def",
"clear",
"(",
"self",
",",
"train",
"=",
"False",
",",
"split",
"=",
"0",
")",
":",
"# Clear Features for the candidates in the split passed in.",
"logger",
".",
"info",
"(",
"f\"Clearing Features (split {split})\"",
")",
"sub_query",
"=",
"(",
"self",
".",
... | Delete Features of each class from the database.
:param train: Whether or not to clear the FeatureKeys
:type train: bool
:param split: Which split of candidates to clear features from.
:type split: int | [
"Delete",
"Features",
"of",
"each",
"class",
"from",
"the",
"database",
"."
] | python | train | 42.142857 |
saltstack/salt | salt/client/api.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/api.py#L236-L293 | def create_token(self, creds):
'''
Create token with creds.
Token authorizes salt access if successful authentication
with the credentials in creds.
creds format is as follows:
{
'username': 'namestring',
'password': 'passwordstring',
... | [
"def",
"create_token",
"(",
"self",
",",
"creds",
")",
":",
"try",
":",
"tokenage",
"=",
"self",
".",
"resolver",
".",
"mk_token",
"(",
"creds",
")",
"except",
"Exception",
"as",
"ex",
":",
"raise",
"EauthAuthenticationError",
"(",
"\"Authentication failed wit... | Create token with creds.
Token authorizes salt access if successful authentication
with the credentials in creds.
creds format is as follows:
{
'username': 'namestring',
'password': 'passwordstring',
'eauth': 'eauthtypestring',
}
exam... | [
"Create",
"token",
"with",
"creds",
".",
"Token",
"authorizes",
"salt",
"access",
"if",
"successful",
"authentication",
"with",
"the",
"credentials",
"in",
"creds",
".",
"creds",
"format",
"is",
"as",
"follows",
":"
] | python | train | 31.672414 |
openstack/networking-cisco | networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L605-L613 | def store_net_db(self, tenant_id, net, net_dict, result):
"""Store service network in DB. """
network_dict = {'name': net_dict.get('name'),
'config_profile': net_dict.get('config_profile'),
'segmentation_id': net_dict.get('segmentation_id'),
... | [
"def",
"store_net_db",
"(",
"self",
",",
"tenant_id",
",",
"net",
",",
"net_dict",
",",
"result",
")",
":",
"network_dict",
"=",
"{",
"'name'",
":",
"net_dict",
".",
"get",
"(",
"'name'",
")",
",",
"'config_profile'",
":",
"net_dict",
".",
"get",
"(",
... | Store service network in DB. | [
"Store",
"service",
"network",
"in",
"DB",
"."
] | python | train | 59.777778 |
IBMStreams/pypi.streamsx | streamsx/topology/topology.py | https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L963-L1023 | def view(self, buffer_time = 10.0, sample_size = 10000, name=None, description=None, start=False):
"""
Defines a view on a stream.
A view is a continually updated sampled buffer of a streams's tuples.
Views allow visibility into a stream from external clients such
as Jupyter Not... | [
"def",
"view",
"(",
"self",
",",
"buffer_time",
"=",
"10.0",
",",
"sample_size",
"=",
"10000",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"start",
"=",
"False",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"''",
".",... | Defines a view on a stream.
A view is a continually updated sampled buffer of a streams's tuples.
Views allow visibility into a stream from external clients such
as Jupyter Notebooks, the Streams console,
`Microsoft Excel <https://www.ibm.com/support/knowledgecenter/SSCRJU_4.2.0/com.ibm... | [
"Defines",
"a",
"view",
"on",
"a",
"stream",
"."
] | python | train | 47.098361 |
gijzelaerr/python-snap7 | snap7/util.py | https://github.com/gijzelaerr/python-snap7/blob/a6db134c7a3a2ef187b9eca04669221d6fc634c3/snap7/util.py#L459-L476 | def write(self, client):
"""
Write current data to db in plc
"""
assert(isinstance(self._bytearray, DB))
assert(self.row_size >= 0)
db_nr = self._bytearray.db_number
offset = self.db_offset
data = self.get_bytearray()[offset:offset+self.row_size]
... | [
"def",
"write",
"(",
"self",
",",
"client",
")",
":",
"assert",
"(",
"isinstance",
"(",
"self",
".",
"_bytearray",
",",
"DB",
")",
")",
"assert",
"(",
"self",
".",
"row_size",
">=",
"0",
")",
"db_nr",
"=",
"self",
".",
"_bytearray",
".",
"db_number",... | Write current data to db in plc | [
"Write",
"current",
"data",
"to",
"db",
"in",
"plc"
] | python | train | 30.111111 |
remram44/rpaths | rpaths.py | https://github.com/remram44/rpaths/blob/e4ff55d985c4d643d9fd214539d45af39ae5a7cd/rpaths.py#L942-L956 | def open(self, mode='r', name=None, **kwargs):
"""Opens this file, or a file under this directory.
``path.open(mode, name)`` is a shortcut for ``(path/name).open(mode)``.
Note that this uses :func:`io.open()` which behaves differently from
:func:`open()` on Python 2; see the appropriat... | [
"def",
"open",
"(",
"self",
",",
"mode",
"=",
"'r'",
",",
"name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"is",
"not",
"None",
":",
"return",
"io",
".",
"open",
"(",
"(",
"self",
"/",
"name",
")",
".",
"path",
",",
"mode... | Opens this file, or a file under this directory.
``path.open(mode, name)`` is a shortcut for ``(path/name).open(mode)``.
Note that this uses :func:`io.open()` which behaves differently from
:func:`open()` on Python 2; see the appropriate documentation.
:param name: Path component to a... | [
"Opens",
"this",
"file",
"or",
"a",
"file",
"under",
"this",
"directory",
"."
] | python | train | 40.066667 |
rbarrois/restricted_pkg | restricted_pkg/base.py | https://github.com/rbarrois/restricted_pkg/blob/abbd3cb33ed85af02fbb531fd85dda9c1b070c85/restricted_pkg/base.py#L124-L135 | def fill(self, config, section):
"""Fill data from a given configuration section.
Args:
config (configparser): the configuration file
section (str): the section to use
"""
if config.has_section(section):
default_url = self.DEFAULT_REPOSITORIES.get(sel... | [
"def",
"fill",
"(",
"self",
",",
"config",
",",
"section",
")",
":",
"if",
"config",
".",
"has_section",
"(",
"section",
")",
":",
"default_url",
"=",
"self",
".",
"DEFAULT_REPOSITORIES",
".",
"get",
"(",
"self",
".",
"name",
",",
"''",
")",
"self",
... | Fill data from a given configuration section.
Args:
config (configparser): the configuration file
section (str): the section to use | [
"Fill",
"data",
"from",
"a",
"given",
"configuration",
"section",
"."
] | python | train | 46.416667 |
ozak/georasters | georasters/georasters.py | https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L917-L941 | def resize_old(self, block_size, order=0, mode='constant', cval=False):
'''
geo.resize(new_shape, order=0, mode='constant', cval=np.nan, preserve_range=True)
Returns resized georaster
'''
if not cval:
cval = np.nan
if (self.raster.dtype.name.find('float') != ... | [
"def",
"resize_old",
"(",
"self",
",",
"block_size",
",",
"order",
"=",
"0",
",",
"mode",
"=",
"'constant'",
",",
"cval",
"=",
"False",
")",
":",
"if",
"not",
"cval",
":",
"cval",
"=",
"np",
".",
"nan",
"if",
"(",
"self",
".",
"raster",
".",
"dty... | geo.resize(new_shape, order=0, mode='constant', cval=np.nan, preserve_range=True)
Returns resized georaster | [
"geo",
".",
"resize",
"(",
"new_shape",
"order",
"=",
"0",
"mode",
"=",
"constant",
"cval",
"=",
"np",
".",
"nan",
"preserve_range",
"=",
"True",
")"
] | python | train | 50.76 |
CalebBell/ht | ht/conv_two_phase.py | https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conv_two_phase.py#L501-L554 | def Martin_Sims(m, x, D, rhol, rhog, hl):
r'''Calculates the two-phase non-boiling heat transfer coefficient of a
liquid and gas flowing inside a tube of any inclination, as in [1]_ and
reviewed in [2]_.
.. math::
\frac{h_{TP}}{h_l} = 1 + 0.64\sqrt{\frac{V_{gs}}{V_{ls}}}
Para... | [
"def",
"Martin_Sims",
"(",
"m",
",",
"x",
",",
"D",
",",
"rhol",
",",
"rhog",
",",
"hl",
")",
":",
"Vgs",
"=",
"m",
"*",
"x",
"/",
"(",
"rhog",
"*",
"pi",
"/",
"4",
"*",
"D",
"**",
"2",
")",
"Vls",
"=",
"m",
"*",
"(",
"1",
"-",
"x",
"... | r'''Calculates the two-phase non-boiling heat transfer coefficient of a
liquid and gas flowing inside a tube of any inclination, as in [1]_ and
reviewed in [2]_.
.. math::
\frac{h_{TP}}{h_l} = 1 + 0.64\sqrt{\frac{V_{gs}}{V_{ls}}}
Parameters
----------
m : float
Ma... | [
"r",
"Calculates",
"the",
"two",
"-",
"phase",
"non",
"-",
"boiling",
"heat",
"transfer",
"coefficient",
"of",
"a",
"liquid",
"and",
"gas",
"flowing",
"inside",
"a",
"tube",
"of",
"any",
"inclination",
"as",
"in",
"[",
"1",
"]",
"_",
"and",
"reviewed",
... | python | train | 33.907407 |
census-instrumentation/opencensus-python | contrib/opencensus-ext-prometheus/opencensus/ext/prometheus/stats_exporter/__init__.py | https://github.com/census-instrumentation/opencensus-python/blob/992b223f7e34c5dcb65922b7d5c827e7a1351e7d/contrib/opencensus-ext-prometheus/opencensus/ext/prometheus/stats_exporter/__init__.py#L121-L132 | def register_view(self, view):
""" register_view will create the needed structure
in order to be able to sent all data to Prometheus
"""
v_name = get_view_name(self.options.namespace, view)
if v_name not in self.registered_views:
desc = {'name': v_name,
... | [
"def",
"register_view",
"(",
"self",
",",
"view",
")",
":",
"v_name",
"=",
"get_view_name",
"(",
"self",
".",
"options",
".",
"namespace",
",",
"view",
")",
"if",
"v_name",
"not",
"in",
"self",
".",
"registered_views",
":",
"desc",
"=",
"{",
"'name'",
... | register_view will create the needed structure
in order to be able to sent all data to Prometheus | [
"register_view",
"will",
"create",
"the",
"needed",
"structure",
"in",
"order",
"to",
"be",
"able",
"to",
"sent",
"all",
"data",
"to",
"Prometheus"
] | python | train | 42.083333 |
saltstack/salt | salt/modules/mongodb.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L299-L322 | def user_remove(name, user=None, password=None, host=None, port=None,
database='admin', authdb=None):
'''
Remove a MongoDB user
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_remove <name> <user> <password> <host> <port> <database>
'''
conn = _connect(user, pa... | [
"def",
"user_remove",
"(",
"name",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"database",
"=",
"'admin'",
",",
"authdb",
"=",
"None",
")",
":",
"conn",
"=",
"_connect",
"(",
"use... | Remove a MongoDB user
CLI Example:
.. code-block:: bash
salt '*' mongodb.user_remove <name> <user> <password> <host> <port> <database> | [
"Remove",
"a",
"MongoDB",
"user"
] | python | train | 29.083333 |
pandas-dev/pandas | pandas/core/arrays/categorical.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1967-L1998 | def _repr_categories_info(self):
"""
Returns a string representation of the footer.
"""
category_strs = self._repr_categories()
dtype = getattr(self.categories, 'dtype_str',
str(self.categories.dtype))
levheader = "Categories ({length}, {dtype}):... | [
"def",
"_repr_categories_info",
"(",
"self",
")",
":",
"category_strs",
"=",
"self",
".",
"_repr_categories",
"(",
")",
"dtype",
"=",
"getattr",
"(",
"self",
".",
"categories",
",",
"'dtype_str'",
",",
"str",
"(",
"self",
".",
"categories",
".",
"dtype",
"... | Returns a string representation of the footer. | [
"Returns",
"a",
"string",
"representation",
"of",
"the",
"footer",
"."
] | python | train | 40.5625 |
openvax/mhctools | mhctools/binding_prediction.py | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/binding_prediction.py#L109-L113 | def clone_with_updates(self, **kwargs):
"""Returns new BindingPrediction with updated fields"""
fields_dict = self.to_dict()
fields_dict.update(kwargs)
return BindingPrediction(**fields_dict) | [
"def",
"clone_with_updates",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"fields_dict",
"=",
"self",
".",
"to_dict",
"(",
")",
"fields_dict",
".",
"update",
"(",
"kwargs",
")",
"return",
"BindingPrediction",
"(",
"*",
"*",
"fields_dict",
")"
] | Returns new BindingPrediction with updated fields | [
"Returns",
"new",
"BindingPrediction",
"with",
"updated",
"fields"
] | python | valid | 43.8 |
pypa/pipenv | pipenv/patched/notpip/_internal/download.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/download.py#L770-L803 | def _copy_dist_from_dir(link_path, location):
"""Copy distribution files in `link_path` to `location`.
Invoked when user requests to install a local directory. E.g.:
pip install .
pip install ~/dev/git-repos/python-prompt-toolkit
"""
# Note: This is currently VERY SLOW if you have a ... | [
"def",
"_copy_dist_from_dir",
"(",
"link_path",
",",
"location",
")",
":",
"# Note: This is currently VERY SLOW if you have a lot of data in the",
"# directory, because it copies everything with `shutil.copytree`.",
"# What it should really do is build an sdist and install that.",
"# See https... | Copy distribution files in `link_path` to `location`.
Invoked when user requests to install a local directory. E.g.:
pip install .
pip install ~/dev/git-repos/python-prompt-toolkit | [
"Copy",
"distribution",
"files",
"in",
"link_path",
"to",
"location",
"."
] | python | train | 34.117647 |
dstufft/potpie | potpie/pseudo/__init__.py | https://github.com/dstufft/potpie/blob/1b12f25b77b8719418f88f49c45920c1eb8ee406/potpie/pseudo/__init__.py#L28-L50 | def _skip_char_around(self, string, char='\n'):
"""
Custom pseudo method for skipping a given char around a string.
The default char to be skipped is the new line (\n) one.
Example:
'\nHello\n' would call ``_base_compile`` with 'Hello' only.
"""
... | [
"def",
"_skip_char_around",
"(",
"self",
",",
"string",
",",
"char",
"=",
"'\\n'",
")",
":",
"starts",
",",
"ends",
"=",
"''",
",",
"''",
"n",
"=",
"len",
"(",
"char",
")",
"if",
"string",
".",
"startswith",
"(",
"char",
")",
":",
"starts",
"=",
... | Custom pseudo method for skipping a given char around a string.
The default char to be skipped is the new line (\n) one.
Example:
'\nHello\n' would call ``_base_compile`` with 'Hello' only. | [
"Custom",
"pseudo",
"method",
"for",
"skipping",
"a",
"given",
"char",
"around",
"a",
"string",
".",
"The",
"default",
"char",
"to",
"be",
"skipped",
"is",
"the",
"new",
"line",
"(",
"\\",
"n",
")",
"one",
".",
"Example",
":",
"\\",
"nHello",
"\\",
"... | python | train | 31.173913 |
Erotemic/utool | utool/util_graph.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L243-L278 | def nx_dag_node_rank(graph, nodes=None):
"""
Returns rank of nodes that define the "level" each node is on in a
topological sort. This is the same as the Graphviz dot rank.
Ignore:
simple_graph = ut.simplify_graph(exi_graph)
adj_dict = ut.nx_to_adj_dict(simple_graph)
import plot... | [
"def",
"nx_dag_node_rank",
"(",
"graph",
",",
"nodes",
"=",
"None",
")",
":",
"import",
"utool",
"as",
"ut",
"source",
"=",
"list",
"(",
"ut",
".",
"nx_source_nodes",
"(",
"graph",
")",
")",
"[",
"0",
"]",
"longest_paths",
"=",
"dict",
"(",
"[",
"(",... | Returns rank of nodes that define the "level" each node is on in a
topological sort. This is the same as the Graphviz dot rank.
Ignore:
simple_graph = ut.simplify_graph(exi_graph)
adj_dict = ut.nx_to_adj_dict(simple_graph)
import plottool as pt
pt.qt4ensure()
pt.show_nx(... | [
"Returns",
"rank",
"of",
"nodes",
"that",
"define",
"the",
"level",
"each",
"node",
"is",
"on",
"in",
"a",
"topological",
"sort",
".",
"This",
"is",
"the",
"same",
"as",
"the",
"Graphviz",
"dot",
"rank",
"."
] | python | train | 36.388889 |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L383-L440 | def simulated_binary_crossover(random, mom, dad, args):
"""Return the offspring of simulated binary crossover on the candidates.
This function performs simulated binary crossover (SBX), following the
implementation in NSGA-II
`(Deb et al., ICANNGA 1999) <http://vision.ucsd.edu/~sagarwal/icannga.p... | [
"def",
"simulated_binary_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"crossover_rate",
"=",
"args",
".",
"setdefault",
"(",
"'crossover_rate'",
",",
"1.0",
")",
"if",
"random",
".",
"random",
"(",
")",
"<",
"crossover_rate",
"... | Return the offspring of simulated binary crossover on the candidates.
This function performs simulated binary crossover (SBX), following the
implementation in NSGA-II
`(Deb et al., ICANNGA 1999) <http://vision.ucsd.edu/~sagarwal/icannga.pdf>`_.
.. Arguments:
random -- the random number g... | [
"Return",
"the",
"offspring",
"of",
"simulated",
"binary",
"crossover",
"on",
"the",
"candidates",
".",
"This",
"function",
"performs",
"simulated",
"binary",
"crossover",
"(",
"SBX",
")",
"following",
"the",
"implementation",
"in",
"NSGA",
"-",
"II",
"(",
"De... | python | train | 41.672414 |
py3270/py3270 | py3270/__init__.py | https://github.com/py3270/py3270/blob/c3e91b519f3a18b4be4799a00a96341957a8831f/py3270/__init__.py#L457-L467 | def string_found(self, ypos, xpos, string):
"""
Return True if `string` is found at screen co-ordinates
`ypos`/`xpos`, False otherwise.
Co-ordinates are 1 based, as listed in the status area of the
terminal.
"""
found = self.string_get(ypos, xpos,... | [
"def",
"string_found",
"(",
"self",
",",
"ypos",
",",
"xpos",
",",
"string",
")",
":",
"found",
"=",
"self",
".",
"string_get",
"(",
"ypos",
",",
"xpos",
",",
"len",
"(",
"string",
")",
")",
"log",
".",
"debug",
"(",
"'string_found() saw \"{0}\"'",
"."... | Return True if `string` is found at screen co-ordinates
`ypos`/`xpos`, False otherwise.
Co-ordinates are 1 based, as listed in the status area of the
terminal. | [
"Return",
"True",
"if",
"string",
"is",
"found",
"at",
"screen",
"co",
"-",
"ordinates",
"ypos",
"/",
"xpos",
"False",
"otherwise",
"."
] | python | valid | 37.636364 |
funilrys/PyFunceble | PyFunceble/generate.py | https://github.com/funilrys/PyFunceble/blob/cdf69cbde120199171f7158e1c33635753e6e2f5/PyFunceble/generate.py#L130-L151 | def _handle_non_existant_index(cls):
"""
Handle and check that some configuration index exists.
"""
try:
# We try to call the http code.
PyFunceble.INTERN["http_code"]
except KeyError:
# If it is not found.
# We initiate an empty ... | [
"def",
"_handle_non_existant_index",
"(",
"cls",
")",
":",
"try",
":",
"# We try to call the http code.",
"PyFunceble",
".",
"INTERN",
"[",
"\"http_code\"",
"]",
"except",
"KeyError",
":",
"# If it is not found.",
"# We initiate an empty http code.",
"PyFunceble",
".",
"I... | Handle and check that some configuration index exists. | [
"Handle",
"and",
"check",
"that",
"some",
"configuration",
"index",
"exists",
"."
] | python | test | 28.136364 |
batiste/django-page-cms | pages/templatetags/pages_tags.py | https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/templatetags/pages_tags.py#L553-L558 | def do_contactplaceholder(parser, token):
"""
Method that parse the contactplaceholder template tag.
"""
name, params = parse_placeholder(parser, token)
return ContactPlaceholderNode(name, **params) | [
"def",
"do_contactplaceholder",
"(",
"parser",
",",
"token",
")",
":",
"name",
",",
"params",
"=",
"parse_placeholder",
"(",
"parser",
",",
"token",
")",
"return",
"ContactPlaceholderNode",
"(",
"name",
",",
"*",
"*",
"params",
")"
] | Method that parse the contactplaceholder template tag. | [
"Method",
"that",
"parse",
"the",
"contactplaceholder",
"template",
"tag",
"."
] | python | train | 35.5 |
bitesofcode/projexui | projexui/widgets/xorbbrowserwidget/xorbbrowserwidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbbrowserwidget/xorbbrowserwidget.py#L687-L694 | def setHint( self, hint ):
"""
Sets the hint for this widget.
:param hint | <str>
"""
self._hint = hint
self.detailWidget().setHint(hint) | [
"def",
"setHint",
"(",
"self",
",",
"hint",
")",
":",
"self",
".",
"_hint",
"=",
"hint",
"self",
".",
"detailWidget",
"(",
")",
".",
"setHint",
"(",
"hint",
")"
] | Sets the hint for this widget.
:param hint | <str> | [
"Sets",
"the",
"hint",
"for",
"this",
"widget",
".",
":",
"param",
"hint",
"|",
"<str",
">"
] | python | train | 24.875 |
gwastro/pycbc | pycbc/inference/models/base.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/models/base.py#L222-L272 | def read_sampling_params_from_config(cp, section_group=None,
section='sampling_params'):
"""Reads sampling parameters from the given config file.
Parameters are read from the `[({section_group}_){section}]` section.
The options should list the variable args to transform... | [
"def",
"read_sampling_params_from_config",
"(",
"cp",
",",
"section_group",
"=",
"None",
",",
"section",
"=",
"'sampling_params'",
")",
":",
"if",
"section_group",
"is",
"not",
"None",
":",
"section_prefix",
"=",
"'{}_'",
".",
"format",
"(",
"section_group",
")"... | Reads sampling parameters from the given config file.
Parameters are read from the `[({section_group}_){section}]` section.
The options should list the variable args to transform; the parameters they
point to should list the parameters they are to be transformed to for
sampling. If a multiple parameter... | [
"Reads",
"sampling",
"parameters",
"from",
"the",
"given",
"config",
"file",
"."
] | python | train | 39.019608 |
heroku/sf-suds | suds/reader.py | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/reader.py#L48-L54 | def mangle(self, name, x):
"""
Mangle the name by hashing the I{name} and appending I{x}.
@return: the mangled name.
"""
h = abs(hash(name))
return '%s-%s' % (h, x) | [
"def",
"mangle",
"(",
"self",
",",
"name",
",",
"x",
")",
":",
"h",
"=",
"abs",
"(",
"hash",
"(",
"name",
")",
")",
"return",
"'%s-%s'",
"%",
"(",
"h",
",",
"x",
")"
] | Mangle the name by hashing the I{name} and appending I{x}.
@return: the mangled name. | [
"Mangle",
"the",
"name",
"by",
"hashing",
"the",
"I",
"{",
"name",
"}",
"and",
"appending",
"I",
"{",
"x",
"}",
"."
] | python | train | 29.428571 |
gwastro/pycbc | pycbc/filter/autocorrelation.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/filter/autocorrelation.py#L111-L173 | def calculate_acl(data, m=5, dtype=int):
r"""Calculates the autocorrelation length (ACL).
Given a normalized autocorrelation function :math:`\rho[i]` (by normalized,
we mean that :math:`\rho[0] = 1`), the ACL :math:`\tau` is:
.. math::
\tau = 1 + 2 \sum_{i=1}^{K} \rho[i].
The number of s... | [
"def",
"calculate_acl",
"(",
"data",
",",
"m",
"=",
"5",
",",
"dtype",
"=",
"int",
")",
":",
"# sanity check output data type",
"if",
"dtype",
"not",
"in",
"[",
"int",
",",
"float",
"]",
":",
"raise",
"ValueError",
"(",
"\"The dtype must be either int or float... | r"""Calculates the autocorrelation length (ACL).
Given a normalized autocorrelation function :math:`\rho[i]` (by normalized,
we mean that :math:`\rho[0] = 1`), the ACL :math:`\tau` is:
.. math::
\tau = 1 + 2 \sum_{i=1}^{K} \rho[i].
The number of samples used :math:`K` is found by using the f... | [
"r",
"Calculates",
"the",
"autocorrelation",
"length",
"(",
"ACL",
")",
"."
] | python | train | 27.952381 |
expert360/cfn-params | cfnparams/params.py | https://github.com/expert360/cfn-params/blob/f6d9d796b8ce346e9fd916e26ed08958e5356e31/cfnparams/params.py#L91-L111 | def new(cls, arg):
"""
Creates a new Parameter object from the given ParameterArgument.
"""
content = None
if arg.kind == 'file':
if os.path.exists(arg.value):
with open(arg.value, 'r') as f:
content = f.read()
else:
... | [
"def",
"new",
"(",
"cls",
",",
"arg",
")",
":",
"content",
"=",
"None",
"if",
"arg",
".",
"kind",
"==",
"'file'",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"arg",
".",
"value",
")",
":",
"with",
"open",
"(",
"arg",
".",
"value",
",",
... | Creates a new Parameter object from the given ParameterArgument. | [
"Creates",
"a",
"new",
"Parameter",
"object",
"from",
"the",
"given",
"ParameterArgument",
"."
] | python | train | 31.761905 |
Azure/azure-sdk-for-python | azure-servicebus/azure/servicebus/control_client/servicebusservice.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/servicebusservice.py#L1181-L1197 | def get_event_hub(self, hub_name):
'''
Retrieves an existing event hub.
hub_name:
Name of the event hub.
'''
_validate_not_none('hub_name', hub_name)
request = HTTPRequest()
request.method = 'GET'
request.host = self._get_host()
reques... | [
"def",
"get_event_hub",
"(",
"self",
",",
"hub_name",
")",
":",
"_validate_not_none",
"(",
"'hub_name'",
",",
"hub_name",
")",
"request",
"=",
"HTTPRequest",
"(",
")",
"request",
".",
"method",
"=",
"'GET'",
"request",
".",
"host",
"=",
"self",
".",
"_get_... | Retrieves an existing event hub.
hub_name:
Name of the event hub. | [
"Retrieves",
"an",
"existing",
"event",
"hub",
"."
] | python | test | 37.529412 |
RiotGames/cloud-inquisitor | backend/cloud_inquisitor/plugins/notifiers/email.py | https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/backend/cloud_inquisitor/plugins/notifiers/email.py#L204-L230 | def send_email(subsystem, sender, recipients, subject, html_body=None, text_body=None, message_uuid=None):
"""Send an email to a list of recipients using the system configured email method (SES or SMTP)
Args:
subsystem (str): Name of the subsystem where the email originated from
sender (str): F... | [
"def",
"send_email",
"(",
"subsystem",
",",
"sender",
",",
"recipients",
",",
"subject",
",",
"html_body",
"=",
"None",
",",
"text_body",
"=",
"None",
",",
"message_uuid",
"=",
"None",
")",
":",
"if",
"type",
"(",
"recipients",
")",
"==",
"str",
":",
"... | Send an email to a list of recipients using the system configured email method (SES or SMTP)
Args:
subsystem (str): Name of the subsystem where the email originated from
sender (str): From email address
recipients (`list` of `str`): List of recipient email addresses
subject (str): S... | [
"Send",
"an",
"email",
"to",
"a",
"list",
"of",
"recipients",
"using",
"the",
"system",
"configured",
"email",
"method",
"(",
"SES",
"or",
"SMTP",
")"
] | python | train | 36.851852 |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/project.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/project.py#L572-L579 | def push_current(self, project):
"""Temporary changes the current project to 'project'. Should
be followed by 'pop-current'."""
if __debug__:
from .targets import ProjectTarget
assert isinstance(project, ProjectTarget)
self.saved_current_project.append(self.curren... | [
"def",
"push_current",
"(",
"self",
",",
"project",
")",
":",
"if",
"__debug__",
":",
"from",
".",
"targets",
"import",
"ProjectTarget",
"assert",
"isinstance",
"(",
"project",
",",
"ProjectTarget",
")",
"self",
".",
"saved_current_project",
".",
"append",
"("... | Temporary changes the current project to 'project'. Should
be followed by 'pop-current'. | [
"Temporary",
"changes",
"the",
"current",
"project",
"to",
"project",
".",
"Should",
"be",
"followed",
"by",
"pop",
"-",
"current",
"."
] | python | train | 45.25 |
singularityhub/sregistry-cli | sregistry/main/gitlab/query.py | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/gitlab/query.py#L37-L77 | def search_all(self, collection, job_id=None):
'''a "show all" search that doesn't require a query
the user is shown URLs to
'''
results = [['job_id', 'browser']]
url = "%s/projects/%s/jobs" %(self.api_base,
quote_plus(collection.strip('/')))
response =... | [
"def",
"search_all",
"(",
"self",
",",
"collection",
",",
"job_id",
"=",
"None",
")",
":",
"results",
"=",
"[",
"[",
"'job_id'",
",",
"'browser'",
"]",
"]",
"url",
"=",
"\"%s/projects/%s/jobs\"",
"%",
"(",
"self",
".",
"api_base",
",",
"quote_plus",
"(",... | a "show all" search that doesn't require a query
the user is shown URLs to | [
"a",
"show",
"all",
"search",
"that",
"doesn",
"t",
"require",
"a",
"query",
"the",
"user",
"is",
"shown",
"URLs",
"to"
] | python | test | 37.121951 |
nnseva/django-access | access/managers.py | https://github.com/nnseva/django-access/blob/2e8b72830b1092652ca63125a8309189d70ad584/access/managers.py#L38-L45 | def register_plugin(cls, model, plugin):
'''
Reguster a plugin for the model.
The only one plugin can be registered. If you want to combine plugins, use CompoundPlugin.
'''
logger.info("Plugin registered for %s: %s", model, plugin)
cls.plugins[model] = plugin | [
"def",
"register_plugin",
"(",
"cls",
",",
"model",
",",
"plugin",
")",
":",
"logger",
".",
"info",
"(",
"\"Plugin registered for %s: %s\"",
",",
"model",
",",
"plugin",
")",
"cls",
".",
"plugins",
"[",
"model",
"]",
"=",
"plugin"
] | Reguster a plugin for the model.
The only one plugin can be registered. If you want to combine plugins, use CompoundPlugin. | [
"Reguster",
"a",
"plugin",
"for",
"the",
"model",
"."
] | python | train | 37.625 |
inveniosoftware/invenio-records-rest | invenio_records_rest/serializers/base.py | https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/serializers/base.py#L140-L154 | def preprocess_record(self, pid, record, links_factory=None, **kwargs):
"""Prepare a record and persistent identifier for serialization."""
links_factory = links_factory or (lambda x, record=None, **k: dict())
metadata = copy.deepcopy(record.replace_refs()) if self.replace_refs \
els... | [
"def",
"preprocess_record",
"(",
"self",
",",
"pid",
",",
"record",
",",
"links_factory",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"links_factory",
"=",
"links_factory",
"or",
"(",
"lambda",
"x",
",",
"record",
"=",
"None",
",",
"*",
"*",
"k",
... | Prepare a record and persistent identifier for serialization. | [
"Prepare",
"a",
"record",
"and",
"persistent",
"identifier",
"for",
"serialization",
"."
] | python | train | 49.666667 |
NarrativeScience/lsi | src/lsi/utils/hosts.py | https://github.com/NarrativeScience/lsi/blob/7d901b03fdb1a34ef795e5412bfe9685d948e32d/src/lsi/utils/hosts.py#L527-L545 | def filter_entries(entries, filters, exclude):
"""
Filters a list of host entries according to the given filters.
:param entries: A list of host entries.
:type entries: [:py:class:`HostEntry`]
:param filters: Regexes that must match a `HostEntry`.
:type filters: [``str``]
:param exclude: Re... | [
"def",
"filter_entries",
"(",
"entries",
",",
"filters",
",",
"exclude",
")",
":",
"filtered",
"=",
"[",
"entry",
"for",
"entry",
"in",
"entries",
"if",
"all",
"(",
"entry",
".",
"matches",
"(",
"f",
")",
"for",
"f",
"in",
"filters",
")",
"and",
"not... | Filters a list of host entries according to the given filters.
:param entries: A list of host entries.
:type entries: [:py:class:`HostEntry`]
:param filters: Regexes that must match a `HostEntry`.
:type filters: [``str``]
:param exclude: Regexes that must NOT match a `HostEntry`.
:type exclude:... | [
"Filters",
"a",
"list",
"of",
"host",
"entries",
"according",
"to",
"the",
"given",
"filters",
"."
] | python | test | 35 |
glitchassassin/lackey | lackey/RegionMatching.py | https://github.com/glitchassassin/lackey/blob/7adadfacd7f45d81186710be992f5668b15399fe/lackey/RegionMatching.py#L626-L684 | def exists(self, pattern, seconds=None):
""" Searches for an image pattern in the given region
Returns Match if pattern exists, None otherwise (does not throw exception)
Sikuli supports OCR search with a text parameter. This does not (yet).
"""
find_time = time.time()
r ... | [
"def",
"exists",
"(",
"self",
",",
"pattern",
",",
"seconds",
"=",
"None",
")",
":",
"find_time",
"=",
"time",
".",
"time",
"(",
")",
"r",
"=",
"self",
".",
"clipRegionToScreen",
"(",
")",
"if",
"r",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"... | Searches for an image pattern in the given region
Returns Match if pattern exists, None otherwise (does not throw exception)
Sikuli supports OCR search with a text parameter. This does not (yet). | [
"Searches",
"for",
"an",
"image",
"pattern",
"in",
"the",
"given",
"region"
] | python | train | 42.186441 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.