repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
mwouts/jupytext | jupytext/cell_reader.py | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L509-L557 | def find_region_end(self, lines):
"""Find the end of the region started with start and end markers"""
if self.metadata and 'cell_type' in self.metadata:
self.cell_type = self.metadata.pop('cell_type')
else:
self.cell_type = 'code'
parser = StringParser(self.langu... | [
"def",
"find_region_end",
"(",
"self",
",",
"lines",
")",
":",
"if",
"self",
".",
"metadata",
"and",
"'cell_type'",
"in",
"self",
".",
"metadata",
":",
"self",
".",
"cell_type",
"=",
"self",
".",
"metadata",
".",
"pop",
"(",
"'cell_type'",
")",
"else",
... | Find the end of the region started with start and end markers | [
"Find",
"the",
"end",
"of",
"the",
"region",
"started",
"with",
"start",
"and",
"end",
"markers"
] | python | train |
BlackEarth/bf | bf/css.py | https://github.com/BlackEarth/bf/blob/376041168874bbd6dee5ccfeece4a9e553223316/bf/css.py#L91-L99 | def all_selectors(Class, fn):
"""return a sorted list of selectors that occur in the stylesheet"""
selectors = []
cssparser = cssutils.CSSParser(validate=False)
css = cssparser.parseFile(fn)
for rule in [r for r in css.cssRules if type(r)==cssutils.css.CSSStyleRule]:
... | [
"def",
"all_selectors",
"(",
"Class",
",",
"fn",
")",
":",
"selectors",
"=",
"[",
"]",
"cssparser",
"=",
"cssutils",
".",
"CSSParser",
"(",
"validate",
"=",
"False",
")",
"css",
"=",
"cssparser",
".",
"parseFile",
"(",
"fn",
")",
"for",
"rule",
"in",
... | return a sorted list of selectors that occur in the stylesheet | [
"return",
"a",
"sorted",
"list",
"of",
"selectors",
"that",
"occur",
"in",
"the",
"stylesheet"
] | python | train |
sorgerlab/indra | indra/databases/cbio_client.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/cbio_client.py#L312-L347 | def get_ccle_mutations(gene_list, cell_lines, mutation_type=None):
"""Return a dict of mutations in given genes and cell lines from CCLE.
This is a specialized call to get_mutations tailored to CCLE cell lines.
Parameters
----------
gene_list : list[str]
A list of HGNC gene symbols to get ... | [
"def",
"get_ccle_mutations",
"(",
"gene_list",
",",
"cell_lines",
",",
"mutation_type",
"=",
"None",
")",
":",
"mutations",
"=",
"{",
"cl",
":",
"{",
"g",
":",
"[",
"]",
"for",
"g",
"in",
"gene_list",
"}",
"for",
"cl",
"in",
"cell_lines",
"}",
"for",
... | Return a dict of mutations in given genes and cell lines from CCLE.
This is a specialized call to get_mutations tailored to CCLE cell lines.
Parameters
----------
gene_list : list[str]
A list of HGNC gene symbols to get mutations in
cell_lines : list[str]
A list of CCLE cell line n... | [
"Return",
"a",
"dict",
"of",
"mutations",
"in",
"given",
"genes",
"and",
"cell",
"lines",
"from",
"CCLE",
"."
] | python | train |
LionelAuroux/pyrser | pyrser/hooks/set.py | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/hooks/set.py#L41-L52 | def set_node_as_int(self, dst, src):
"""
Set a node to a value captured from another node
example::
R = [
In : node #setcapture(_, node)
]
"""
dst.value = self.value(src)
return True | [
"def",
"set_node_as_int",
"(",
"self",
",",
"dst",
",",
"src",
")",
":",
"dst",
".",
"value",
"=",
"self",
".",
"value",
"(",
"src",
")",
"return",
"True"
] | Set a node to a value captured from another node
example::
R = [
In : node #setcapture(_, node)
] | [
"Set",
"a",
"node",
"to",
"a",
"value",
"captured",
"from",
"another",
"node"
] | python | test |
google/grr | grr/server/grr_response_server/databases/mem_artifacts.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_artifacts.py#L34-L41 | def ReadAllArtifacts(self):
"""Lists all artifacts that are stored in the database."""
artifacts = []
for artifact in itervalues(self.artifacts):
artifacts.append(artifact.Copy())
return artifacts | [
"def",
"ReadAllArtifacts",
"(",
"self",
")",
":",
"artifacts",
"=",
"[",
"]",
"for",
"artifact",
"in",
"itervalues",
"(",
"self",
".",
"artifacts",
")",
":",
"artifacts",
".",
"append",
"(",
"artifact",
".",
"Copy",
"(",
")",
")",
"return",
"artifacts"
] | Lists all artifacts that are stored in the database. | [
"Lists",
"all",
"artifacts",
"that",
"are",
"stored",
"in",
"the",
"database",
"."
] | python | train |
guma44/GEOparse | GEOparse/GEOTypes.py | https://github.com/guma44/GEOparse/blob/7ee8d5b8678d780382a6bf884afa69d2033f5ca0/GEOparse/GEOTypes.py#L773-L795 | def pivot_samples(self, values, index="ID_REF"):
"""Pivot samples by specified column.
Construct a table in which columns (names) are the samples, index
is a specified column eg. ID_REF and values in the columns are of one
specified type.
Args:
values (:obj:`str`): ... | [
"def",
"pivot_samples",
"(",
"self",
",",
"values",
",",
"index",
"=",
"\"ID_REF\"",
")",
":",
"data",
"=",
"[",
"]",
"for",
"gsm",
"in",
"self",
".",
"gsms",
".",
"values",
"(",
")",
":",
"tmp_data",
"=",
"gsm",
".",
"table",
".",
"copy",
"(",
"... | Pivot samples by specified column.
Construct a table in which columns (names) are the samples, index
is a specified column eg. ID_REF and values in the columns are of one
specified type.
Args:
values (:obj:`str`): Column name present in all GSMs.
index (:obj:`st... | [
"Pivot",
"samples",
"by",
"specified",
"column",
"."
] | python | train |
delfick/harpoon | harpoon/dockerpty/pty.py | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/dockerpty/pty.py#L202-L220 | def resize(self, size=None):
"""
Resize the container's PTY.
If `size` is not None, it must be a tuple of (height,width), otherwise
it will be determined by the size of the current TTY.
"""
if not self.israw():
return
size = size or tty.size(self.st... | [
"def",
"resize",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"israw",
"(",
")",
":",
"return",
"size",
"=",
"size",
"or",
"tty",
".",
"size",
"(",
"self",
".",
"stdout",
")",
"if",
"size",
"is",
"not",
"None",
":"... | Resize the container's PTY.
If `size` is not None, it must be a tuple of (height,width), otherwise
it will be determined by the size of the current TTY. | [
"Resize",
"the",
"container",
"s",
"PTY",
"."
] | python | train |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/registry.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/registry.py#L429-L454 | def _split_path(self, path):
"""
Splits a Registry path and returns the hive and key.
@type path: str
@param path: Registry path.
@rtype: tuple( int, str )
@return: Tuple containing the hive handle and the subkey path.
The hive handle is always one of the ... | [
"def",
"_split_path",
"(",
"self",
",",
"path",
")",
":",
"if",
"'\\\\'",
"in",
"path",
":",
"p",
"=",
"path",
".",
"find",
"(",
"'\\\\'",
")",
"hive",
"=",
"path",
"[",
":",
"p",
"]",
"path",
"=",
"path",
"[",
"p",
"+",
"1",
":",
"]",
"else"... | Splits a Registry path and returns the hive and key.
@type path: str
@param path: Registry path.
@rtype: tuple( int, str )
@return: Tuple containing the hive handle and the subkey path.
The hive handle is always one of the following integer constants:
- L{win... | [
"Splits",
"a",
"Registry",
"path",
"and",
"returns",
"the",
"hive",
"and",
"key",
"."
] | python | train |
PolicyStat/docx2html | docx2html/core.py | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L34-L46 | def replace_ext(file_path, new_ext):
"""
>>> replace_ext('one/two/three.four.doc', '.html')
'one/two/three.four.html'
>>> replace_ext('one/two/three.four.DOC', '.html')
'one/two/three.four.html'
>>> replace_ext('one/two/three.four.DOC', 'html')
'one/two/three.four.html'
"""
if not ne... | [
"def",
"replace_ext",
"(",
"file_path",
",",
"new_ext",
")",
":",
"if",
"not",
"new_ext",
".",
"startswith",
"(",
"os",
".",
"extsep",
")",
":",
"new_ext",
"=",
"os",
".",
"extsep",
"+",
"new_ext",
"index",
"=",
"file_path",
".",
"rfind",
"(",
"os",
... | >>> replace_ext('one/two/three.four.doc', '.html')
'one/two/three.four.html'
>>> replace_ext('one/two/three.four.DOC', '.html')
'one/two/three.four.html'
>>> replace_ext('one/two/three.four.DOC', 'html')
'one/two/three.four.html' | [
">>>",
"replace_ext",
"(",
"one",
"/",
"two",
"/",
"three",
".",
"four",
".",
"doc",
".",
"html",
")",
"one",
"/",
"two",
"/",
"three",
".",
"four",
".",
"html",
">>>",
"replace_ext",
"(",
"one",
"/",
"two",
"/",
"three",
".",
"four",
".",
"DOC",... | python | test |
Miserlou/Zappa | zappa/core.py | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2239-L2248 | def stack_outputs(self, name):
"""
Given a name, describes CloudFront stacks and returns dict of the stack Outputs
, else returns an empty dict.
"""
try:
stack = self.cf_client.describe_stacks(StackName=name)['Stacks'][0]
return {x['OutputKey']: x['OutputV... | [
"def",
"stack_outputs",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"stack",
"=",
"self",
".",
"cf_client",
".",
"describe_stacks",
"(",
"StackName",
"=",
"name",
")",
"[",
"'Stacks'",
"]",
"[",
"0",
"]",
"return",
"{",
"x",
"[",
"'OutputKey'",
"... | Given a name, describes CloudFront stacks and returns dict of the stack Outputs
, else returns an empty dict. | [
"Given",
"a",
"name",
"describes",
"CloudFront",
"stacks",
"and",
"returns",
"dict",
"of",
"the",
"stack",
"Outputs",
"else",
"returns",
"an",
"empty",
"dict",
"."
] | python | train |
saltstack/salt | salt/utils/cloud.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2425-L2448 | def is_public_ip(ip):
'''
Determines whether an IP address falls within one of the private IP ranges
'''
if ':' in ip:
# ipv6
if ip.startswith('fe80:'):
# ipv6 link local
return False
return True
addr = ip_to_int(ip)
if 167772160 < addr < 184549375... | [
"def",
"is_public_ip",
"(",
"ip",
")",
":",
"if",
"':'",
"in",
"ip",
":",
"# ipv6",
"if",
"ip",
".",
"startswith",
"(",
"'fe80:'",
")",
":",
"# ipv6 link local",
"return",
"False",
"return",
"True",
"addr",
"=",
"ip_to_int",
"(",
"ip",
")",
"if",
"1677... | Determines whether an IP address falls within one of the private IP ranges | [
"Determines",
"whether",
"an",
"IP",
"address",
"falls",
"within",
"one",
"of",
"the",
"private",
"IP",
"ranges"
] | python | train |
user-cont/conu | conu/backend/docker/container.py | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/container.py#L459-L506 | def execute(self, command, blocking=True, exec_create_kwargs=None, exec_start_kwargs=None):
"""
Execute a command in this container -- the container needs to be running.
If the command fails, a ConuException is thrown.
This is a blocking call by default and writes output of the command... | [
"def",
"execute",
"(",
"self",
",",
"command",
",",
"blocking",
"=",
"True",
",",
"exec_create_kwargs",
"=",
"None",
",",
"exec_start_kwargs",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"\"running command %s\"",
",",
"command",
")",
"exec_create_kwargs... | Execute a command in this container -- the container needs to be running.
If the command fails, a ConuException is thrown.
This is a blocking call by default and writes output of the command to logger
using the INFO level -- this behavior can be changed if you set
the argument `blockin... | [
"Execute",
"a",
"command",
"in",
"this",
"container",
"--",
"the",
"container",
"needs",
"to",
"be",
"running",
"."
] | python | train |
acorg/dark-matter | dark/filter.py | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/filter.py#L392-L443 | def parseFASTAEditingCommandLineOptions(args, reads):
"""
Examine parsed FASTA editing command-line options and return information
about kept sites and sequences.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to fil... | [
"def",
"parseFASTAEditingCommandLineOptions",
"(",
"args",
",",
"reads",
")",
":",
"removeGaps",
"=",
"args",
".",
"removeGaps",
"removeDescriptions",
"=",
"args",
".",
"removeDescriptions",
"truncateTitlesAfter",
"=",
"args",
".",
"truncateTitlesAfter",
"keepSites",
... | Examine parsed FASTA editing command-line options and return information
about kept sites and sequences.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to filter.
@return: The filtered C{Reads} instance. | [
"Examine",
"parsed",
"FASTA",
"editing",
"command",
"-",
"line",
"options",
"and",
"return",
"information",
"about",
"kept",
"sites",
"and",
"sequences",
"."
] | python | train |
kblin/ncbi-genome-download | ncbi_genome_download/core.py | https://github.com/kblin/ncbi-genome-download/blob/dc55382d351c29e1027be8fa3876701762c1d752/ncbi_genome_download/core.py#L582-L613 | def get_strain_label(entry, viral=False):
"""Try to extract a strain from an assemly summary entry.
First this checks 'infraspecific_name', then 'isolate', then
it tries to get it from 'organism_name'. If all fails, it
falls back to just returning the assembly accesion number.
"""
def get_strai... | [
"def",
"get_strain_label",
"(",
"entry",
",",
"viral",
"=",
"False",
")",
":",
"def",
"get_strain",
"(",
"entry",
")",
":",
"strain",
"=",
"entry",
"[",
"'infraspecific_name'",
"]",
"if",
"strain",
"!=",
"''",
":",
"strain",
"=",
"strain",
".",
"split",
... | Try to extract a strain from an assemly summary entry.
First this checks 'infraspecific_name', then 'isolate', then
it tries to get it from 'organism_name'. If all fails, it
falls back to just returning the assembly accesion number. | [
"Try",
"to",
"extract",
"a",
"strain",
"from",
"an",
"assemly",
"summary",
"entry",
"."
] | python | train |
apple/turicreate | src/unity/python/turicreate/data_structures/sframe.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/data_structures/sframe.py#L5590-L5655 | def dropna_split(self, columns=None, how='any'):
"""
Split rows with missing values from this SFrame. This function has the
same functionality as :py:func:`~turicreate.SFrame.dropna`, but returns a
tuple of two SFrames. The first item is the expected output from
:py:func:`~turic... | [
"def",
"dropna_split",
"(",
"self",
",",
"columns",
"=",
"None",
",",
"how",
"=",
"'any'",
")",
":",
"# If the user gives me an empty list (the indicator to use all columns)",
"# NA values being dropped would not be the expected behavior. This",
"# is a NOOP, so let's not bother the ... | Split rows with missing values from this SFrame. This function has the
same functionality as :py:func:`~turicreate.SFrame.dropna`, but returns a
tuple of two SFrames. The first item is the expected output from
:py:func:`~turicreate.SFrame.dropna`, and the second item contains all the
ro... | [
"Split",
"rows",
"with",
"missing",
"values",
"from",
"this",
"SFrame",
".",
"This",
"function",
"has",
"the",
"same",
"functionality",
"as",
":",
"py",
":",
"func",
":",
"~turicreate",
".",
"SFrame",
".",
"dropna",
"but",
"returns",
"a",
"tuple",
"of",
... | python | train |
ff0000/scarlet | scarlet/cms/list.py | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/list.py#L112-L124 | def get_filter_form(self, **kwargs):
"""
If there is a filter_form, initializes that
form with the contents of request.GET and
returns it.
"""
form = None
if self.filter_form:
form = self.filter_form(self.request.GET)
elif self.model and hasat... | [
"def",
"get_filter_form",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"form",
"=",
"None",
"if",
"self",
".",
"filter_form",
":",
"form",
"=",
"self",
".",
"filter_form",
"(",
"self",
".",
"request",
".",
"GET",
")",
"elif",
"self",
".",
"model",... | If there is a filter_form, initializes that
form with the contents of request.GET and
returns it. | [
"If",
"there",
"is",
"a",
"filter_form",
"initializes",
"that",
"form",
"with",
"the",
"contents",
"of",
"request",
".",
"GET",
"and",
"returns",
"it",
"."
] | python | train |
jwass/geojsonio.py | geojsonio/geojsonio.py | https://github.com/jwass/geojsonio.py/blob/8229a48238f128837e6dce49f18310df84968825/geojsonio/geojsonio.py#L18-L38 | def display(contents, domain=DEFAULT_DOMAIN, force_gist=False):
"""
Open a web browser pointing to geojson.io with the specified content.
If the content is large, an anonymous gist will be created on github and
the URL will instruct geojson.io to download the gist data and then
display. If the cont... | [
"def",
"display",
"(",
"contents",
",",
"domain",
"=",
"DEFAULT_DOMAIN",
",",
"force_gist",
"=",
"False",
")",
":",
"url",
"=",
"make_url",
"(",
"contents",
",",
"domain",
",",
"force_gist",
")",
"webbrowser",
".",
"open",
"(",
"url",
")",
"return",
"url... | Open a web browser pointing to geojson.io with the specified content.
If the content is large, an anonymous gist will be created on github and
the URL will instruct geojson.io to download the gist data and then
display. If the content is small, this step is not needed as the data can
be included in the... | [
"Open",
"a",
"web",
"browser",
"pointing",
"to",
"geojson",
".",
"io",
"with",
"the",
"specified",
"content",
"."
] | python | train |
google/grr | grr/core/executables/python_hacks/modify_network.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/executables/python_hacks/modify_network.py#L39-L57 | def DisableInterfaces(interface):
"""Tries to disable an interface. Only works on Vista and 7.
Args:
interface: Name of the interface to disable.
Returns:
res which is a tuple of (stdout, stderr, exit_status, time_taken).
"""
set_tested_versions = ['vista', '2008']
set_args = ['/c', 'netsh', 'set... | [
"def",
"DisableInterfaces",
"(",
"interface",
")",
":",
"set_tested_versions",
"=",
"[",
"'vista'",
",",
"'2008'",
"]",
"set_args",
"=",
"[",
"'/c'",
",",
"'netsh'",
",",
"'set'",
",",
"'interface'",
",",
"interface",
",",
"'DISABLED'",
"]",
"host_version",
... | Tries to disable an interface. Only works on Vista and 7.
Args:
interface: Name of the interface to disable.
Returns:
res which is a tuple of (stdout, stderr, exit_status, time_taken). | [
"Tries",
"to",
"disable",
"an",
"interface",
".",
"Only",
"works",
"on",
"Vista",
"and",
"7",
"."
] | python | train |
inveniosoftware/invenio-iiif | invenio_iiif/ext.py | https://github.com/inveniosoftware/invenio-iiif/blob/e4f2f93eaabdc8e2efea81c239ab76d481191959/invenio_iiif/ext.py#L46-L50 | def init_app(self, app):
"""Flask application initialization."""
super(InvenioIIIFAPI, self).init_app(app)
api = Api(app=app)
self.iiif_ext.init_restful(api, prefix=app.config['IIIF_API_PREFIX']) | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"super",
"(",
"InvenioIIIFAPI",
",",
"self",
")",
".",
"init_app",
"(",
"app",
")",
"api",
"=",
"Api",
"(",
"app",
"=",
"app",
")",
"self",
".",
"iiif_ext",
".",
"init_restful",
"(",
"api",
",",... | Flask application initialization. | [
"Flask",
"application",
"initialization",
"."
] | python | train |
biosustain/optlang | optlang/interface.py | https://github.com/biosustain/optlang/blob/13673ac26f6b3ba37a2ef392489722c52e3c5ff1/optlang/interface.py#L921-L936 | def to_json(self):
"""
Returns a json-compatible object from the objective that can be saved using the json module.
Example
--------
>>> import json
>>> with open("path_to_file.json", "w") as outfile:
>>> json.dump(obj.to_json(), outfile)
"""
... | [
"def",
"to_json",
"(",
"self",
")",
":",
"json_obj",
"=",
"{",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"expression\"",
":",
"expr_to_json",
"(",
"self",
".",
"expression",
")",
",",
"\"direction\"",
":",
"self",
".",
"direction",
"}",
"return",
"jso... | Returns a json-compatible object from the objective that can be saved using the json module.
Example
--------
>>> import json
>>> with open("path_to_file.json", "w") as outfile:
>>> json.dump(obj.to_json(), outfile) | [
"Returns",
"a",
"json",
"-",
"compatible",
"object",
"from",
"the",
"objective",
"that",
"can",
"be",
"saved",
"using",
"the",
"json",
"module",
"."
] | python | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/neural_network.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/neural_network.py#L1867-L1922 | def add_reorganize_data(self, name, input_name, output_name, mode = 'SPACE_TO_DEPTH', block_size = 2):
"""
Add a data reorganization layer of type "SPACE_TO_DEPTH" or "DEPTH_TO_SPACE".
Parameters
----------
name: str
The name of this layer.
input_name: str
... | [
"def",
"add_reorganize_data",
"(",
"self",
",",
"name",
",",
"input_name",
",",
"output_name",
",",
"mode",
"=",
"'SPACE_TO_DEPTH'",
",",
"block_size",
"=",
"2",
")",
":",
"spec",
"=",
"self",
".",
"spec",
"nn_spec",
"=",
"self",
".",
"nn_spec",
"# Add a n... | Add a data reorganization layer of type "SPACE_TO_DEPTH" or "DEPTH_TO_SPACE".
Parameters
----------
name: str
The name of this layer.
input_name: str
The input blob name of this layer.
output_name: str
The output blob name of this layer.
... | [
"Add",
"a",
"data",
"reorganization",
"layer",
"of",
"type",
"SPACE_TO_DEPTH",
"or",
"DEPTH_TO_SPACE",
"."
] | python | train |
CamDavidsonPilon/lifetimes | lifetimes/fitters/modified_beta_geo_fitter.py | https://github.com/CamDavidsonPilon/lifetimes/blob/f926308bc03c17c1d12fead729de43885cf13321/lifetimes/fitters/modified_beta_geo_fitter.py#L58-L113 | def fit(
self, frequency, recency, T, weights=None, initial_params=None, verbose=False, tol=1e-7, index=None, **kwargs
):
"""
Fit the data to the MBG/NBD model.
Parameters
----------
frequency: array_like
the frequency vector of customers' purchases
... | [
"def",
"fit",
"(",
"self",
",",
"frequency",
",",
"recency",
",",
"T",
",",
"weights",
"=",
"None",
",",
"initial_params",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"tol",
"=",
"1e-7",
",",
"index",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
... | Fit the data to the MBG/NBD model.
Parameters
----------
frequency: array_like
the frequency vector of customers' purchases
(denoted x in literature).
recency: array_like
the recency vector of customers' purchases
(denoted t_x in literatur... | [
"Fit",
"the",
"data",
"to",
"the",
"MBG",
"/",
"NBD",
"model",
"."
] | python | train |
inveniosoftware/invenio-pages | invenio_pages/admin.py | https://github.com/inveniosoftware/invenio-pages/blob/8d544d72fb4c22b7134c521f435add0abed42544/invenio_pages/admin.py#L72-L77 | def same_page_choosen(form, field):
"""Check that we are not trying to assign list page itself as a child."""
if form._obj is not None:
if field.data.id == form._obj.list_id:
raise ValidationError(
_('You cannot assign list page itself as a child.')) | [
"def",
"same_page_choosen",
"(",
"form",
",",
"field",
")",
":",
"if",
"form",
".",
"_obj",
"is",
"not",
"None",
":",
"if",
"field",
".",
"data",
".",
"id",
"==",
"form",
".",
"_obj",
".",
"list_id",
":",
"raise",
"ValidationError",
"(",
"_",
"(",
... | Check that we are not trying to assign list page itself as a child. | [
"Check",
"that",
"we",
"are",
"not",
"trying",
"to",
"assign",
"list",
"page",
"itself",
"as",
"a",
"child",
"."
] | python | train |
BD2KOnFHIR/fhirtordf | fhirtordf/fhir/signature.py | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/fhir/signature.py#L82-L88 | def signature(name: str) -> Optional[Tuple]:
"""
Return the file or URL signature for name
:param name:
:return:
"""
return url_signature(name) if is_url(name) else file_signature(name) if is_file(name) else None | [
"def",
"signature",
"(",
"name",
":",
"str",
")",
"->",
"Optional",
"[",
"Tuple",
"]",
":",
"return",
"url_signature",
"(",
"name",
")",
"if",
"is_url",
"(",
"name",
")",
"else",
"file_signature",
"(",
"name",
")",
"if",
"is_file",
"(",
"name",
")",
... | Return the file or URL signature for name
:param name:
:return: | [
"Return",
"the",
"file",
"or",
"URL",
"signature",
"for",
"name",
":",
"param",
"name",
":",
":",
"return",
":"
] | python | train |
projectatomic/atomic-reactor | atomic_reactor/api.py | https://github.com/projectatomic/atomic-reactor/blob/fd31c01b964097210bf169960d051e5f04019a80/atomic_reactor/api.py#L124-L145 | def build_image_here(source, image,
parent_registry=None, target_registries=None, parent_registry_insecure=False,
target_registries_insecure=False, dont_pull_base_image=False, **kwargs):
"""
build image from provided dockerfile (specified by `source`) in current environ... | [
"def",
"build_image_here",
"(",
"source",
",",
"image",
",",
"parent_registry",
"=",
"None",
",",
"target_registries",
"=",
"None",
",",
"parent_registry_insecure",
"=",
"False",
",",
"target_registries_insecure",
"=",
"False",
",",
"dont_pull_base_image",
"=",
"Fal... | build image from provided dockerfile (specified by `source`) in current environment
:param source: dict, where/how to get source code to put in image
:param image: str, tag for built image ([registry/]image_name[:tag])
:param parent_registry: str, registry to pull base image from
:param target_registri... | [
"build",
"image",
"from",
"provided",
"dockerfile",
"(",
"specified",
"by",
"source",
")",
"in",
"current",
"environment"
] | python | train |
eandersson/amqpstorm | amqpstorm/queue.py | https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/queue.py#L18-L55 | def declare(self, queue='', passive=False, durable=False,
exclusive=False, auto_delete=False, arguments=None):
"""Declare a Queue.
:param str queue: Queue name
:param bool passive: Do not create
:param bool durable: Durable queue
:param bool exclusive: Request ex... | [
"def",
"declare",
"(",
"self",
",",
"queue",
"=",
"''",
",",
"passive",
"=",
"False",
",",
"durable",
"=",
"False",
",",
"exclusive",
"=",
"False",
",",
"auto_delete",
"=",
"False",
",",
"arguments",
"=",
"None",
")",
":",
"if",
"not",
"compatibility",... | Declare a Queue.
:param str queue: Queue name
:param bool passive: Do not create
:param bool durable: Durable queue
:param bool exclusive: Request exclusive access
:param bool auto_delete: Automatically delete when not in use
:param dict arguments: Queue key/value argume... | [
"Declare",
"a",
"Queue",
"."
] | python | train |
spyder-ide/spyder | spyder/plugins/help/plugin.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L328-L330 | def set_rich_text_font(self, font):
"""Set rich text mode font"""
self.rich_text.set_font(font, fixed_font=self.get_plugin_font()) | [
"def",
"set_rich_text_font",
"(",
"self",
",",
"font",
")",
":",
"self",
".",
"rich_text",
".",
"set_font",
"(",
"font",
",",
"fixed_font",
"=",
"self",
".",
"get_plugin_font",
"(",
")",
")"
] | Set rich text mode font | [
"Set",
"rich",
"text",
"mode",
"font"
] | python | train |
globocom/GloboNetworkAPI-client-python | networkapiclient/Network.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Network.py#L417-L479 | def add_network_ipv6_hosts(
self,
id_vlan,
id_tipo_rede,
num_hosts,
id_ambiente_vip=None):
"""
Add new networkipv6
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:param id_tipo_rede: Identifier of ... | [
"def",
"add_network_ipv6_hosts",
"(",
"self",
",",
"id_vlan",
",",
"id_tipo_rede",
",",
"num_hosts",
",",
"id_ambiente_vip",
"=",
"None",
")",
":",
"vlan_map",
"=",
"dict",
"(",
")",
"vlan_map",
"[",
"'id_vlan'",
"]",
"=",
"id_vlan",
"vlan_map",
"[",
"'id_ti... | Add new networkipv6
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:param id_tipo_rede: Identifier of the NetworkType. Integer value and greater than zero.
:param num_hosts: Number of hosts expected. Integer value and greater than zero.
:param id_ambiente_v... | [
"Add",
"new",
"networkipv6"
] | python | train |
mrcagney/make_gtfs | make_gtfs/protofeed.py | https://github.com/mrcagney/make_gtfs/blob/37b6f88e03bac708c2e85d6f4b6d48a0c92e4a59/make_gtfs/protofeed.py#L73-L86 | def copy(self):
"""
Return a copy of this ProtoFeed, that is, a feed with all the
same attributes.
"""
other = ProtoFeed()
for key in cs.PROTOFEED_ATTRS:
value = getattr(self, key)
if isinstance(value, pd.DataFrame):
# Pandas copy D... | [
"def",
"copy",
"(",
"self",
")",
":",
"other",
"=",
"ProtoFeed",
"(",
")",
"for",
"key",
"in",
"cs",
".",
"PROTOFEED_ATTRS",
":",
"value",
"=",
"getattr",
"(",
"self",
",",
"key",
")",
"if",
"isinstance",
"(",
"value",
",",
"pd",
".",
"DataFrame",
... | Return a copy of this ProtoFeed, that is, a feed with all the
same attributes. | [
"Return",
"a",
"copy",
"of",
"this",
"ProtoFeed",
"that",
"is",
"a",
"feed",
"with",
"all",
"the",
"same",
"attributes",
"."
] | python | train |
hozn/coilmq | coilmq/engine.py | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/engine.py#L87-L94 | def unbind(self):
"""
Unbinds this connection from queue and topic managers (freeing up resources)
and resets state.
"""
self.connected = False
self.queue_manager.disconnect(self.connection)
self.topic_manager.disconnect(self.connection) | [
"def",
"unbind",
"(",
"self",
")",
":",
"self",
".",
"connected",
"=",
"False",
"self",
".",
"queue_manager",
".",
"disconnect",
"(",
"self",
".",
"connection",
")",
"self",
".",
"topic_manager",
".",
"disconnect",
"(",
"self",
".",
"connection",
")"
] | Unbinds this connection from queue and topic managers (freeing up resources)
and resets state. | [
"Unbinds",
"this",
"connection",
"from",
"queue",
"and",
"topic",
"managers",
"(",
"freeing",
"up",
"resources",
")",
"and",
"resets",
"state",
"."
] | python | train |
hyperledger/indy-plenum | plenum/server/node.py | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L2569-L2610 | def processPropagate(self, msg: Propagate, frm):
"""
Process one propagateRequest sent to this node asynchronously
- If this propagateRequest hasn't been seen by this node, then broadcast
it to all nodes after verifying the the signature.
- Add the client to blacklist if its sig... | [
"def",
"processPropagate",
"(",
"self",
",",
"msg",
":",
"Propagate",
",",
"frm",
")",
":",
"logger",
".",
"debug",
"(",
"\"{} received propagated request: {}\"",
".",
"format",
"(",
"self",
".",
"name",
",",
"msg",
")",
")",
"request",
"=",
"TxnUtilConfig",... | Process one propagateRequest sent to this node asynchronously
- If this propagateRequest hasn't been seen by this node, then broadcast
it to all nodes after verifying the the signature.
- Add the client to blacklist if its signature is invalid
:param msg: the propagateRequest
:... | [
"Process",
"one",
"propagateRequest",
"sent",
"to",
"this",
"node",
"asynchronously"
] | python | train |
martinpitt/python-dbusmock | dbusmock/templates/bluez4.py | https://github.com/martinpitt/python-dbusmock/blob/26f65f78bc0ed347233f699a8d6ee0e6880e7eb0/dbusmock/templates/bluez4.py#L274-L283 | def ListDevices(self):
'''List all known devices
'''
devices = []
for obj in mockobject.objects.keys():
if obj.startswith('/org/bluez/') and 'dev_' in obj:
devices.append(dbus.ObjectPath(obj, variant_level=1))
return dbus.Array(devices, variant_level=1) | [
"def",
"ListDevices",
"(",
"self",
")",
":",
"devices",
"=",
"[",
"]",
"for",
"obj",
"in",
"mockobject",
".",
"objects",
".",
"keys",
"(",
")",
":",
"if",
"obj",
".",
"startswith",
"(",
"'/org/bluez/'",
")",
"and",
"'dev_'",
"in",
"obj",
":",
"device... | List all known devices | [
"List",
"all",
"known",
"devices"
] | python | train |
matthewdeanmartin/jiggle_version | jiggle_version/module_finder.py | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/module_finder.py#L238-L271 | def find_single_file_project(self): # type: () -> List[str]
"""
Take first non-setup.py python file. What a mess.
:return:
"""
# TODO: use package_dirs
packaged_dirs = ""
try:
# Right now only returns 1st.
packaged_dirs = self.extract_pack... | [
"def",
"find_single_file_project",
"(",
"self",
")",
":",
"# type: () -> List[str]",
"# TODO: use package_dirs",
"packaged_dirs",
"=",
"\"\"",
"try",
":",
"# Right now only returns 1st.",
"packaged_dirs",
"=",
"self",
".",
"extract_package_dir",
"(",
")",
"except",
":",
... | Take first non-setup.py python file. What a mess.
:return: | [
"Take",
"first",
"non",
"-",
"setup",
".",
"py",
"python",
"file",
".",
"What",
"a",
"mess",
".",
":",
"return",
":"
] | python | train |
charnley/rmsd | rmsd/calculate_rmsd.py | https://github.com/charnley/rmsd/blob/cd8af499fb63529a1b5b1f880fdb2dab2731544a/rmsd/calculate_rmsd.py#L198-L207 | def makeW(r1, r2, r3, r4=0):
"""
matrix involved in quaternion rotation
"""
W = np.asarray([
[r4, r3, -r2, r1],
[-r3, r4, r1, r2],
[r2, -r1, r4, r3],
[-r1, -r2, -r3, r4]])
return W | [
"def",
"makeW",
"(",
"r1",
",",
"r2",
",",
"r3",
",",
"r4",
"=",
"0",
")",
":",
"W",
"=",
"np",
".",
"asarray",
"(",
"[",
"[",
"r4",
",",
"r3",
",",
"-",
"r2",
",",
"r1",
"]",
",",
"[",
"-",
"r3",
",",
"r4",
",",
"r1",
",",
"r2",
"]",... | matrix involved in quaternion rotation | [
"matrix",
"involved",
"in",
"quaternion",
"rotation"
] | python | train |
mromanello/hucitlib | knowledge_base/surfext/__init__.py | https://github.com/mromanello/hucitlib/blob/6587d1b04eb7e5b48ad7359be845e5d3b444d6fa/knowledge_base/surfext/__init__.py#L225-L343 | def to_json(self):
"""
Serialises a HucitAuthor to a JSON formatted string.
Example:
>> homer = kb.get_resource_by_urn("urn:cts:greekLit:tlg0012")
>> homer.to_json()
{
"name_abbreviations": [
"Hom."
],
"urn": "urn:cts:greekLit:t... | [
"def",
"to_json",
"(",
"self",
")",
":",
"names",
"=",
"self",
".",
"get_names",
"(",
")",
"return",
"json",
".",
"dumps",
"(",
"{",
"\"uri\"",
":",
"self",
".",
"subject",
",",
"\"urn\"",
":",
"str",
"(",
"self",
".",
"get_urn",
"(",
")",
")",
"... | Serialises a HucitAuthor to a JSON formatted string.
Example:
>> homer = kb.get_resource_by_urn("urn:cts:greekLit:tlg0012")
>> homer.to_json()
{
"name_abbreviations": [
"Hom."
],
"urn": "urn:cts:greekLit:tlg0012",
"works": [
... | [
"Serialises",
"a",
"HucitAuthor",
"to",
"a",
"JSON",
"formatted",
"string",
"."
] | python | train |
gwastro/pycbc | pycbc/tmpltbank/em_progenitors.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/tmpltbank/em_progenitors.py#L388-L411 | def xi_eq(x, kappa, chi_eff, q):
"""
The roots of this equation determine the orbital radius
at the onset of NS tidal disruption in a nonprecessing
NS-BH binary [(7) in Foucart PRD 86, 124007 (2012)]
Parameters
-----------
x: float
orbital separation in units of the NS radius
ka... | [
"def",
"xi_eq",
"(",
"x",
",",
"kappa",
",",
"chi_eff",
",",
"q",
")",
":",
"return",
"x",
"**",
"3",
"*",
"(",
"x",
"**",
"2",
"-",
"3",
"*",
"kappa",
"*",
"x",
"+",
"2",
"*",
"chi_eff",
"*",
"kappa",
"*",
"math",
".",
"sqrt",
"(",
"kappa"... | The roots of this equation determine the orbital radius
at the onset of NS tidal disruption in a nonprecessing
NS-BH binary [(7) in Foucart PRD 86, 124007 (2012)]
Parameters
-----------
x: float
orbital separation in units of the NS radius
kappa: float
the BH mass divided by the... | [
"The",
"roots",
"of",
"this",
"equation",
"determine",
"the",
"orbital",
"radius",
"at",
"the",
"onset",
"of",
"NS",
"tidal",
"disruption",
"in",
"a",
"nonprecessing",
"NS",
"-",
"BH",
"binary",
"[",
"(",
"7",
")",
"in",
"Foucart",
"PRD",
"86",
"124007",... | python | train |
globality-corp/microcosm-flask | microcosm_flask/conventions/crud.py | https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/conventions/crud.py#L74-L105 | def configure_count(self, ns, definition):
"""
Register a count endpoint.
The definition's func should be a count function, which must:
- accept kwargs for the query string
- return a count is the total number of items available
The definition's request_schema will be u... | [
"def",
"configure_count",
"(",
"self",
",",
"ns",
",",
"definition",
")",
":",
"@",
"self",
".",
"add_route",
"(",
"ns",
".",
"collection_path",
",",
"Operation",
".",
"Count",
",",
"ns",
")",
"@",
"qs",
"(",
"definition",
".",
"request_schema",
")",
"... | Register a count endpoint.
The definition's func should be a count function, which must:
- accept kwargs for the query string
- return a count is the total number of items available
The definition's request_schema will be used to process query string arguments.
:param ns: the ... | [
"Register",
"a",
"count",
"endpoint",
"."
] | python | train |
senseobservationsystems/commonsense-python-lib | senseapi.py | https://github.com/senseobservationsystems/commonsense-python-lib/blob/aac59a1751ef79eb830b3ca1fab6ef2c83931f87/senseapi.py#L1779-L1789 | def DomainTokensCreate(self, domain_id, amount):
"""
This method creates tokens that can be used by users who want to join the domain.
Tokens are automatically deleted after usage.
Only domain managers can create tokens.
"""
if self.__SenseApiCall__('/... | [
"def",
"DomainTokensCreate",
"(",
"self",
",",
"domain_id",
",",
"amount",
")",
":",
"if",
"self",
".",
"__SenseApiCall__",
"(",
"'/domains/{0}/tokens.json'",
".",
"format",
"(",
"domain_id",
")",
",",
"'POST'",
",",
"parameters",
"=",
"{",
"\"amount\"",
":",
... | This method creates tokens that can be used by users who want to join the domain.
Tokens are automatically deleted after usage.
Only domain managers can create tokens. | [
"This",
"method",
"creates",
"tokens",
"that",
"can",
"be",
"used",
"by",
"users",
"who",
"want",
"to",
"join",
"the",
"domain",
".",
"Tokens",
"are",
"automatically",
"deleted",
"after",
"usage",
".",
"Only",
"domain",
"managers",
"can",
"create",
"tokens",... | python | train |
jim-easterbrook/pywws | src/pywws/conversions.py | https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/conversions.py#L190-L200 | def dew_point(temp, hum):
"""Compute dew point, using formula from
http://en.wikipedia.org/wiki/Dew_point.
"""
if temp is None or hum is None:
return None
a = 17.27
b = 237.7
gamma = ((a * temp) / (b + temp)) + math.log(float(hum) / 100.0)
return (b * gamma) / (a - gamma) | [
"def",
"dew_point",
"(",
"temp",
",",
"hum",
")",
":",
"if",
"temp",
"is",
"None",
"or",
"hum",
"is",
"None",
":",
"return",
"None",
"a",
"=",
"17.27",
"b",
"=",
"237.7",
"gamma",
"=",
"(",
"(",
"a",
"*",
"temp",
")",
"/",
"(",
"b",
"+",
"tem... | Compute dew point, using formula from
http://en.wikipedia.org/wiki/Dew_point. | [
"Compute",
"dew",
"point",
"using",
"formula",
"from",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Dew_point",
"."
] | python | train |
allenai/allennlp | allennlp/semparse/contexts/quarel_utils.py | https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/contexts/quarel_utils.py#L126-L182 | def get_explanation(logical_form: str,
world_extractions: JsonDict,
answer_index: int,
world: QuarelWorld) -> List[JsonDict]:
"""
Create explanation (as a list of header/content entries) for an answer
"""
output = []
nl_world = {}
if wo... | [
"def",
"get_explanation",
"(",
"logical_form",
":",
"str",
",",
"world_extractions",
":",
"JsonDict",
",",
"answer_index",
":",
"int",
",",
"world",
":",
"QuarelWorld",
")",
"->",
"List",
"[",
"JsonDict",
"]",
":",
"output",
"=",
"[",
"]",
"nl_world",
"=",... | Create explanation (as a list of header/content entries) for an answer | [
"Create",
"explanation",
"(",
"as",
"a",
"list",
"of",
"header",
"/",
"content",
"entries",
")",
"for",
"an",
"answer"
] | python | train |
JoseAntFer/pyny3d | pyny3d/geoms.py | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L961-L991 | def contiguous(polygons):
"""
Static method. Check whether a set of convex polygons are all
contiguous. Two polygons are considered contiguous if they
share, at least, one side (two vertices).
This is not a complete verification, it is a very simplified
one. For a g... | [
"def",
"contiguous",
"(",
"polygons",
")",
":",
"from",
"pyny3d",
".",
"utils",
"import",
"sort_numpy",
"n",
"=",
"len",
"(",
"polygons",
")",
"points",
"=",
"sort_numpy",
"(",
"np",
".",
"concatenate",
"(",
"[",
"polygon",
".",
"points",
"for",
"polygon... | Static method. Check whether a set of convex polygons are all
contiguous. Two polygons are considered contiguous if they
share, at least, one side (two vertices).
This is not a complete verification, it is a very simplified
one. For a given set of polygons this method will verify tha... | [
"Static",
"method",
".",
"Check",
"whether",
"a",
"set",
"of",
"convex",
"polygons",
"are",
"all",
"contiguous",
".",
"Two",
"polygons",
"are",
"considered",
"contiguous",
"if",
"they",
"share",
"at",
"least",
"one",
"side",
"(",
"two",
"vertices",
")",
".... | python | train |
GearPlug/paymentsos-python | paymentsos/tokens.py | https://github.com/GearPlug/paymentsos-python/blob/2f32ba83ae890c96799b71d49fc6740bc1081f89/paymentsos/tokens.py#L6-L38 | def create_token(self, *, holder_name, card_number, credit_card_cvv, expiration_date, token_type='credit_card',
identity_document=None, billing_address=None, additional_details=None):
"""
When creating a Token, remember to use the public-key header instead of the private-key header,... | [
"def",
"create_token",
"(",
"self",
",",
"*",
",",
"holder_name",
",",
"card_number",
",",
"credit_card_cvv",
",",
"expiration_date",
",",
"token_type",
"=",
"'credit_card'",
",",
"identity_document",
"=",
"None",
",",
"billing_address",
"=",
"None",
",",
"addit... | When creating a Token, remember to use the public-key header instead of the private-key header,
and do not include the app-id header.
Args:
holder_name: Name of the credit card holder.
card_number: Credit card number.
credit_card_cvv: The CVV number on the card (3 or... | [
"When",
"creating",
"a",
"Token",
"remember",
"to",
"use",
"the",
"public",
"-",
"key",
"header",
"instead",
"of",
"the",
"private",
"-",
"key",
"header",
"and",
"do",
"not",
"include",
"the",
"app",
"-",
"id",
"header",
"."
] | python | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/midl.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/midl.py#L73-L79 | def generate(env):
"""Add Builders and construction variables for midl to an Environment."""
env['MIDL'] = 'MIDL.EXE'
env['MIDLFLAGS'] = SCons.Util.CLVar('/nologo')
env['MIDLCOM'] = '$MIDL $MIDLFLAGS /tlb ${TARGETS[0]} /h ${TARGETS[1]} /iid ${TARGETS[2]} /proxy ${TARGETS[3]} /dlldata... | [
"def",
"generate",
"(",
"env",
")",
":",
"env",
"[",
"'MIDL'",
"]",
"=",
"'MIDL.EXE'",
"env",
"[",
"'MIDLFLAGS'",
"]",
"=",
"SCons",
".",
"Util",
".",
"CLVar",
"(",
"'/nologo'",
")",
"env",
"[",
"'MIDLCOM'",
"]",
"=",
"'$MIDL $MIDLFLAGS /tlb ${TARGETS[0]} ... | Add Builders and construction variables for midl to an Environment. | [
"Add",
"Builders",
"and",
"construction",
"variables",
"for",
"midl",
"to",
"an",
"Environment",
"."
] | python | train |
blue-yonder/tsfresh | tsfresh/feature_extraction/feature_calculators.py | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L772-L783 | def last_location_of_minimum(x):
"""
Returns the last location of the minimal value of x.
The position is calculated relatively to the length of x.
:param x: the time series to calculate the feature of
:type x: numpy.ndarray
:return: the value of this feature
:return type: float
"""
... | [
"def",
"last_location_of_minimum",
"(",
"x",
")",
":",
"x",
"=",
"np",
".",
"asarray",
"(",
"x",
")",
"return",
"1.0",
"-",
"np",
".",
"argmin",
"(",
"x",
"[",
":",
":",
"-",
"1",
"]",
")",
"/",
"len",
"(",
"x",
")",
"if",
"len",
"(",
"x",
... | Returns the last location of the minimal value of x.
The position is calculated relatively to the length of x.
:param x: the time series to calculate the feature of
:type x: numpy.ndarray
:return: the value of this feature
:return type: float | [
"Returns",
"the",
"last",
"location",
"of",
"the",
"minimal",
"value",
"of",
"x",
".",
"The",
"position",
"is",
"calculated",
"relatively",
"to",
"the",
"length",
"of",
"x",
"."
] | python | train |
saxix/sample-data-utils | sample_data_utils/people.py | https://github.com/saxix/sample-data-utils/blob/769f1b46e60def2675a14bd5872047af6d1ea398/sample_data_utils/people.py#L32-L54 | def title(languages=None, genders=None):
"""
returns a random title
.. code-block:: python
>>> d.title()
u'Mrs.'
>>> d.title(['es'])
u'El Sr.'
>>> d.title(None, [GENDER_FEMALE])
u'Mrs.'
:param languages: list of allowed languages. ['en'] if None
:pa... | [
"def",
"title",
"(",
"languages",
"=",
"None",
",",
"genders",
"=",
"None",
")",
":",
"languages",
"=",
"languages",
"or",
"[",
"'en'",
"]",
"genders",
"=",
"genders",
"or",
"(",
"GENDER_FEMALE",
",",
"GENDER_MALE",
")",
"choices",
"=",
"_get_titles",
"(... | returns a random title
.. code-block:: python
>>> d.title()
u'Mrs.'
>>> d.title(['es'])
u'El Sr.'
>>> d.title(None, [GENDER_FEMALE])
u'Mrs.'
:param languages: list of allowed languages. ['en'] if None
:param genders: list of allowed genders. (GENDER_FEMALE,... | [
"returns",
"a",
"random",
"title"
] | python | test |
swharden/PyOriginTools | PyOriginTools/workbook.py | https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L191-L194 | def nRows(self):
"""returns maximum number of rows based on the longest colData"""
if self.nCols: return max([len(x) for x in self.colData])
else: return 0 | [
"def",
"nRows",
"(",
"self",
")",
":",
"if",
"self",
".",
"nCols",
":",
"return",
"max",
"(",
"[",
"len",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"colData",
"]",
")",
"else",
":",
"return",
"0"
] | returns maximum number of rows based on the longest colData | [
"returns",
"maximum",
"number",
"of",
"rows",
"based",
"on",
"the",
"longest",
"colData"
] | python | train |
f213/rumetr-client | rumetr/roometr.py | https://github.com/f213/rumetr-client/blob/5180152bcb2eed8246b88035db7c0bb1fe603166/rumetr/roometr.py#L191-L210 | def check_appt(self, complex: str, house: str, appt: str) -> bool:
"""
Check if given appartment exists in the rumetr database
"""
self.check_house(complex, house)
if '%s__%s__%s' % (complex, house, appt) in self._checked_appts:
return True
try:
s... | [
"def",
"check_appt",
"(",
"self",
",",
"complex",
":",
"str",
",",
"house",
":",
"str",
",",
"appt",
":",
"str",
")",
"->",
"bool",
":",
"self",
".",
"check_house",
"(",
"complex",
",",
"house",
")",
"if",
"'%s__%s__%s'",
"%",
"(",
"complex",
",",
... | Check if given appartment exists in the rumetr database | [
"Check",
"if",
"given",
"appartment",
"exists",
"in",
"the",
"rumetr",
"database"
] | python | train |
rmorshea/spectate | spectate/core.py | https://github.com/rmorshea/spectate/blob/79bd84dd8d00889015ce1d1e190db865a02cdb93/spectate/core.py#L311-L341 | def watch(value, spectator_type=Spectator):
"""Register a :class:`Specatator` to a :class:`Watchable` and return it.
In order to register callbacks to an eventful object, you need to create
a Spectator that will watch it for you. A :class:`Specatator` is a relatively simple
object that has methods for ... | [
"def",
"watch",
"(",
"value",
",",
"spectator_type",
"=",
"Spectator",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Watchable",
")",
":",
"wtype",
"=",
"type",
"(",
"value",
")",
"else",
":",
"raise",
"TypeError",
"(",
"\"Expected a Watchable, not %r.\"... | Register a :class:`Specatator` to a :class:`Watchable` and return it.
In order to register callbacks to an eventful object, you need to create
a Spectator that will watch it for you. A :class:`Specatator` is a relatively simple
object that has methods for adding, deleting, and triggering callbacks. To
... | [
"Register",
"a",
":",
"class",
":",
"Specatator",
"to",
"a",
":",
"class",
":",
"Watchable",
"and",
"return",
"it",
"."
] | python | train |
pdkit/pdkit | pdkit/finger_tapping_processor.py | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/finger_tapping_processor.py#L118-L131 | def incoordination_score(self, data_frame):
"""
This method calculates the variance of the time interval in msec between taps
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return is: incoordination score
:rtype is: float
... | [
"def",
"incoordination_score",
"(",
"self",
",",
"data_frame",
")",
":",
"diff",
"=",
"data_frame",
".",
"td",
"[",
"1",
":",
"-",
"1",
"]",
".",
"values",
"-",
"data_frame",
".",
"td",
"[",
"0",
":",
"-",
"2",
"]",
".",
"values",
"inc_s",
"=",
"... | This method calculates the variance of the time interval in msec between taps
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return is: incoordination score
:rtype is: float | [
"This",
"method",
"calculates",
"the",
"variance",
"of",
"the",
"time",
"interval",
"in",
"msec",
"between",
"taps"
] | python | train |
mitsei/dlkit | dlkit/records/assessment/basic/drag_and_drop_records.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/basic/drag_and_drop_records.py#L952-L967 | def clear_target_names(self, target_id):
"""stub"""
if self.get_targets_metadata().is_read_only():
raise NoAccess()
updated_targets = []
for current_target in self.my_osid_object_form._my_map['targets']:
if current_target['id'] != target_id:
update... | [
"def",
"clear_target_names",
"(",
"self",
",",
"target_id",
")",
":",
"if",
"self",
".",
"get_targets_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
":",
"raise",
"NoAccess",
"(",
")",
"updated_targets",
"=",
"[",
"]",
"for",
"current_target",
"in",
"... | stub | [
"stub"
] | python | train |
openstack/proliantutils | proliantutils/ilo/firmware_controller.py | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/ilo/firmware_controller.py#L193-L248 | def _get_socket(self, sslversion=ssl.PROTOCOL_TLSv1):
"""Sets up an https connection and do an HTTP/raw socket request
:param sslversion: version of ssl session
:raises: IloConnectionError, for connection failures
:returns: ssl wrapped socket object
"""
err = None
... | [
"def",
"_get_socket",
"(",
"self",
",",
"sslversion",
"=",
"ssl",
".",
"PROTOCOL_TLSv1",
")",
":",
"err",
"=",
"None",
"sock",
"=",
"None",
"try",
":",
"for",
"res",
"in",
"socket",
".",
"getaddrinfo",
"(",
"self",
".",
"hostname",
",",
"self",
".",
... | Sets up an https connection and do an HTTP/raw socket request
:param sslversion: version of ssl session
:raises: IloConnectionError, for connection failures
:returns: ssl wrapped socket object | [
"Sets",
"up",
"an",
"https",
"connection",
"and",
"do",
"an",
"HTTP",
"/",
"raw",
"socket",
"request"
] | python | train |
eclipse/unide.python | src/unide/measurement.py | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/measurement.py#L214-L222 | def samples(self):
"""Yield samples as dictionaries, keyed by dimensions."""
names = self.series.dimensions
for n, offset in enumerate(self.series.offsets):
dt = datetime.timedelta(microseconds=offset * 1000)
d = {"ts": self.ts + dt}
for name in names:
... | [
"def",
"samples",
"(",
"self",
")",
":",
"names",
"=",
"self",
".",
"series",
".",
"dimensions",
"for",
"n",
",",
"offset",
"in",
"enumerate",
"(",
"self",
".",
"series",
".",
"offsets",
")",
":",
"dt",
"=",
"datetime",
".",
"timedelta",
"(",
"micros... | Yield samples as dictionaries, keyed by dimensions. | [
"Yield",
"samples",
"as",
"dictionaries",
"keyed",
"by",
"dimensions",
"."
] | python | train |
sdispater/pendulum | pendulum/__init__.py | https://github.com/sdispater/pendulum/blob/94d28b0d3cb524ae02361bd1ed7ea03e2e655e4e/pendulum/__init__.py#L137-L145 | def local(
year, month, day, hour=0, minute=0, second=0, microsecond=0
): # type: (int, int, int, int, int, int, int) -> DateTime
"""
Return a DateTime in the local timezone.
"""
return datetime(
year, month, day, hour, minute, second, microsecond, tz=local_timezone()
) | [
"def",
"local",
"(",
"year",
",",
"month",
",",
"day",
",",
"hour",
"=",
"0",
",",
"minute",
"=",
"0",
",",
"second",
"=",
"0",
",",
"microsecond",
"=",
"0",
")",
":",
"# type: (int, int, int, int, int, int, int) -> DateTime",
"return",
"datetime",
"(",
"y... | Return a DateTime in the local timezone. | [
"Return",
"a",
"DateTime",
"in",
"the",
"local",
"timezone",
"."
] | python | train |
tkarabela/pysubs2 | pysubs2/time.py | https://github.com/tkarabela/pysubs2/blob/6439eb5159e6aa6b47e0f8e1d950e8bdd7c5341f/pysubs2/time.py#L68-L86 | def frames_to_ms(frames, fps):
"""
Convert frame-based duration to milliseconds.
Arguments:
frames: Number of frames (should be int).
fps: Framerate (must be a positive number, eg. 23.976).
Returns:
Number of milliseconds (rounded to int).
Raises:
V... | [
"def",
"frames_to_ms",
"(",
"frames",
",",
"fps",
")",
":",
"if",
"fps",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"Framerate must be positive number (%f).\"",
"%",
"fps",
")",
"return",
"int",
"(",
"round",
"(",
"frames",
"*",
"(",
"1000",
"/",
"fps",... | Convert frame-based duration to milliseconds.
Arguments:
frames: Number of frames (should be int).
fps: Framerate (must be a positive number, eg. 23.976).
Returns:
Number of milliseconds (rounded to int).
Raises:
ValueError: fps was negative or zero. | [
"Convert",
"frame",
"-",
"based",
"duration",
"to",
"milliseconds",
".",
"Arguments",
":",
"frames",
":",
"Number",
"of",
"frames",
"(",
"should",
"be",
"int",
")",
".",
"fps",
":",
"Framerate",
"(",
"must",
"be",
"a",
"positive",
"number",
"eg",
".",
... | python | train |
RIPE-NCC/ripe.atlas.sagan | ripe/atlas/sagan/base.py | https://github.com/RIPE-NCC/ripe.atlas.sagan/blob/f0e57221cf0ba3504baddd3ea460fc955bc41cc6/ripe/atlas/sagan/base.py#L264-L281 | def calculate_median(given_list):
"""
Returns the median of values in the given list.
"""
median = None
if not given_list:
return median
given_list = sorted(given_list)
list_length = len(given_list)
if list_length % 2:
median = g... | [
"def",
"calculate_median",
"(",
"given_list",
")",
":",
"median",
"=",
"None",
"if",
"not",
"given_list",
":",
"return",
"median",
"given_list",
"=",
"sorted",
"(",
"given_list",
")",
"list_length",
"=",
"len",
"(",
"given_list",
")",
"if",
"list_length",
"%... | Returns the median of values in the given list. | [
"Returns",
"the",
"median",
"of",
"values",
"in",
"the",
"given",
"list",
"."
] | python | train |
COUR4G3/flask-gssapi | flask_gssapi.py | https://github.com/COUR4G3/flask-gssapi/blob/d3842e14cdf9bf6818d7a154845e951a8e9c058d/flask_gssapi.py#L44-L62 | def authenticate(self):
"""Attempts to authenticate the user if a token was provided."""
if request.headers.get('Authorization', '').startswith('Negotiate '):
in_token = base64.b64decode(request.headers['Authorization'][10:])
try:
creds = current_app.extensions['... | [
"def",
"authenticate",
"(",
"self",
")",
":",
"if",
"request",
".",
"headers",
".",
"get",
"(",
"'Authorization'",
",",
"''",
")",
".",
"startswith",
"(",
"'Negotiate '",
")",
":",
"in_token",
"=",
"base64",
".",
"b64decode",
"(",
"request",
".",
"header... | Attempts to authenticate the user if a token was provided. | [
"Attempts",
"to",
"authenticate",
"the",
"user",
"if",
"a",
"token",
"was",
"provided",
"."
] | python | train |
kstaniek/condoor | condoor/protocols/ssh.py | https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/protocols/ssh.py#L32-L52 | def get_command(self, version=2):
"""Return the SSH protocol specific command to connect."""
try:
options = _C['options']
options_str = " -o ".join(options)
if options_str:
options_str = "-o " + options_str + " "
except KeyError:
op... | [
"def",
"get_command",
"(",
"self",
",",
"version",
"=",
"2",
")",
":",
"try",
":",
"options",
"=",
"_C",
"[",
"'options'",
"]",
"options_str",
"=",
"\" -o \"",
".",
"join",
"(",
"options",
")",
"if",
"options_str",
":",
"options_str",
"=",
"\"-o \"",
"... | Return the SSH protocol specific command to connect. | [
"Return",
"the",
"SSH",
"protocol",
"specific",
"command",
"to",
"connect",
"."
] | python | train |
qubell/contrib-python-qubell-client | qubell/api/private/instance.py | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/instance.py#L508-L522 | def get_most_recent_update_time(self):
"""
Indicated most recent update of the instance, assumption based on:
- if currentWorkflow exists, its startedAt time is most recent update.
- else max of workflowHistory startedAt is most recent update.
"""
def parse_time(t):
... | [
"def",
"get_most_recent_update_time",
"(",
"self",
")",
":",
"def",
"parse_time",
"(",
"t",
")",
":",
"if",
"t",
":",
"return",
"time",
".",
"gmtime",
"(",
"t",
"/",
"1000",
")",
"return",
"None",
"try",
":",
"max_wf_started_at",
"=",
"max",
"(",
"[",
... | Indicated most recent update of the instance, assumption based on:
- if currentWorkflow exists, its startedAt time is most recent update.
- else max of workflowHistory startedAt is most recent update. | [
"Indicated",
"most",
"recent",
"update",
"of",
"the",
"instance",
"assumption",
"based",
"on",
":",
"-",
"if",
"currentWorkflow",
"exists",
"its",
"startedAt",
"time",
"is",
"most",
"recent",
"update",
".",
"-",
"else",
"max",
"of",
"workflowHistory",
"started... | python | train |
willemarcel/osmcha | osmcha/changeset.py | https://github.com/willemarcel/osmcha/blob/9a22ed11834ed20c6b91e7b5685f66880ea09350/osmcha/changeset.py#L110-L118 | def get_metadata(changeset):
"""Get the metadata of a changeset using the OSM API and return it as a XML
ElementTree.
Args:
changeset: the id of the changeset.
"""
url = 'https://www.openstreetmap.org/api/0.6/changeset/{}'.format(changeset)
return ET.fromstring(requests.get(url).content... | [
"def",
"get_metadata",
"(",
"changeset",
")",
":",
"url",
"=",
"'https://www.openstreetmap.org/api/0.6/changeset/{}'",
".",
"format",
"(",
"changeset",
")",
"return",
"ET",
".",
"fromstring",
"(",
"requests",
".",
"get",
"(",
"url",
")",
".",
"content",
")",
"... | Get the metadata of a changeset using the OSM API and return it as a XML
ElementTree.
Args:
changeset: the id of the changeset. | [
"Get",
"the",
"metadata",
"of",
"a",
"changeset",
"using",
"the",
"OSM",
"API",
"and",
"return",
"it",
"as",
"a",
"XML",
"ElementTree",
"."
] | python | valid |
theislab/scanpy | scanpy/plotting/_tools/__init__.py | https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/plotting/_tools/__init__.py#L590-L638 | def sim(adata, tmax_realization=None, as_heatmap=False, shuffle=False,
show=None, save=None):
"""Plot results of simulation.
Parameters
----------
as_heatmap : bool (default: False)
Plot the timeseries as heatmap.
tmax_realization : int or None (default: False)
Number of obs... | [
"def",
"sim",
"(",
"adata",
",",
"tmax_realization",
"=",
"None",
",",
"as_heatmap",
"=",
"False",
",",
"shuffle",
"=",
"False",
",",
"show",
"=",
"None",
",",
"save",
"=",
"None",
")",
":",
"from",
".",
".",
".",
"import",
"utils",
"as",
"sc_utils",... | Plot results of simulation.
Parameters
----------
as_heatmap : bool (default: False)
Plot the timeseries as heatmap.
tmax_realization : int or None (default: False)
Number of observations in one realization of the time series. The data matrix
adata.X consists in concatenated rea... | [
"Plot",
"results",
"of",
"simulation",
"."
] | python | train |
Microsoft/botbuilder-python | libraries/botframework-connector/azure_bdist_wheel.py | https://github.com/Microsoft/botbuilder-python/blob/274663dd91c811bae6ac4488915ba5880771b0a7/libraries/botframework-connector/azure_bdist_wheel.py#L321-L353 | def setupcfg_requirements(self):
"""Generate requirements from setup.cfg as
('Requires-Dist', 'requirement; qualifier') tuples. From a metadata
section in setup.cfg:
[metadata]
provides-extra = extra1
extra2
requires-dist = requirement; qualifier
... | [
"def",
"setupcfg_requirements",
"(",
"self",
")",
":",
"metadata",
"=",
"self",
".",
"distribution",
".",
"get_option_dict",
"(",
"'metadata'",
")",
"# our .ini parser folds - to _ in key names:",
"for",
"key",
",",
"title",
"in",
"(",
"(",
"'provides_extra'",
",",
... | Generate requirements from setup.cfg as
('Requires-Dist', 'requirement; qualifier') tuples. From a metadata
section in setup.cfg:
[metadata]
provides-extra = extra1
extra2
requires-dist = requirement; qualifier
another; qualifier2
unqualified
... | [
"Generate",
"requirements",
"from",
"setup",
".",
"cfg",
"as",
"(",
"Requires",
"-",
"Dist",
"requirement",
";",
"qualifier",
")",
"tuples",
".",
"From",
"a",
"metadata",
"section",
"in",
"setup",
".",
"cfg",
":"
] | python | test |
spotify/pyschema | pyschema/source_generation.py | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/source_generation.py#L193-L224 | def _class_source(schema, indent):
"""Generate Python source code for one specific class
Doesn't include or take into account any dependencies between record types
"""
def_pattern = (
"class {class_name}(pyschema.Record):\n"
"{indent}# WARNING: This class was generated by pyschema.to_p... | [
"def",
"_class_source",
"(",
"schema",
",",
"indent",
")",
":",
"def_pattern",
"=",
"(",
"\"class {class_name}(pyschema.Record):\\n\"",
"\"{indent}# WARNING: This class was generated by pyschema.to_python_source\\n\"",
"\"{indent}# there is a risk that any modification made to this class w... | Generate Python source code for one specific class
Doesn't include or take into account any dependencies between record types | [
"Generate",
"Python",
"source",
"code",
"for",
"one",
"specific",
"class"
] | python | test |
saltstack/salt | salt/modules/sysmod.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sysmod.py#L582-L632 | def list_state_functions(*args, **kwargs): # pylint: disable=unused-argument
'''
List the functions for all state modules. Optionally, specify a state
module or modules from which to list.
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' sys.list_state_functions... | [
"def",
"list_state_functions",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=unused-argument",
"# NOTE: **kwargs is used here to prevent a traceback when garbage",
"# arguments are tacked on to the end.",
"st_",
"=",
"salt",
".",
"state",
".",
... | List the functions for all state modules. Optionally, specify a state
module or modules from which to list.
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' sys.list_state_functions
salt '*' sys.list_state_functions file
salt '*' sys.list_state_functions ... | [
"List",
"the",
"functions",
"for",
"all",
"state",
"modules",
".",
"Optionally",
"specify",
"a",
"state",
"module",
"or",
"modules",
"from",
"which",
"to",
"list",
"."
] | python | train |
jazzband/django-mongonaut | mongonaut/forms/forms.py | https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/forms.py#L101-L121 | def create_list_dict(self, document, list_field, doc_key):
"""
Genereates a dictionary representation of the list field. Document
should be the document the list_field comes from.
DO NOT CALL DIRECTLY
"""
list_dict = {"_document": document}
if isinstance(list_fi... | [
"def",
"create_list_dict",
"(",
"self",
",",
"document",
",",
"list_field",
",",
"doc_key",
")",
":",
"list_dict",
"=",
"{",
"\"_document\"",
":",
"document",
"}",
"if",
"isinstance",
"(",
"list_field",
".",
"field",
",",
"EmbeddedDocumentField",
")",
":",
"... | Genereates a dictionary representation of the list field. Document
should be the document the list_field comes from.
DO NOT CALL DIRECTLY | [
"Genereates",
"a",
"dictionary",
"representation",
"of",
"the",
"list",
"field",
".",
"Document",
"should",
"be",
"the",
"document",
"the",
"list_field",
"comes",
"from",
"."
] | python | valid |
vxgmichel/aioconsole | aioconsole/events.py | https://github.com/vxgmichel/aioconsole/blob/8223435723d616fd4db398431d6a6182a6015e3f/aioconsole/events.py#L71-L79 | def set_interactive_policy(*, locals=None, banner=None, serve=None,
prompt_control=None):
"""Use an interactive event loop by default."""
policy = InteractiveEventLoopPolicy(
locals=locals,
banner=banner,
serve=serve,
prompt_control=prompt_control)
... | [
"def",
"set_interactive_policy",
"(",
"*",
",",
"locals",
"=",
"None",
",",
"banner",
"=",
"None",
",",
"serve",
"=",
"None",
",",
"prompt_control",
"=",
"None",
")",
":",
"policy",
"=",
"InteractiveEventLoopPolicy",
"(",
"locals",
"=",
"locals",
",",
"ban... | Use an interactive event loop by default. | [
"Use",
"an",
"interactive",
"event",
"loop",
"by",
"default",
"."
] | python | train |
VorskiImagineering/C3PO | c3po/mod/communicator.py | https://github.com/VorskiImagineering/C3PO/blob/e3e35835e5ac24158848afed4f905ca44ac3ae00/c3po/mod/communicator.py#L241-L256 | def upload(self):
"""
Upload all po files to GDocs ignoring conflicts.
This method looks for all msgids in po_files and sends them
as ods to GDocs Spreadsheet.
"""
local_ods_path = os.path.join(self.temp_path, LOCAL_ODS)
try:
po_to_ods(self.languages, ... | [
"def",
"upload",
"(",
"self",
")",
":",
"local_ods_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"temp_path",
",",
"LOCAL_ODS",
")",
"try",
":",
"po_to_ods",
"(",
"self",
".",
"languages",
",",
"self",
".",
"locale_root",
",",
"self",
... | Upload all po files to GDocs ignoring conflicts.
This method looks for all msgids in po_files and sends them
as ods to GDocs Spreadsheet. | [
"Upload",
"all",
"po",
"files",
"to",
"GDocs",
"ignoring",
"conflicts",
".",
"This",
"method",
"looks",
"for",
"all",
"msgids",
"in",
"po_files",
"and",
"sends",
"them",
"as",
"ods",
"to",
"GDocs",
"Spreadsheet",
"."
] | python | test |
numenta/nupic | src/nupic/encoders/delta.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/delta.py#L102-L116 | def topDownCompute(self, encoded):
"""[ScalarEncoder class method override]"""
#Decode to delta scalar
if self._prevAbsolute==None or self._prevDelta==None:
return [EncoderResult(value=0, scalar=0,
encoding=numpy.zeros(self.n))]
ret = self._adaptiveScalarEnc.topDownCo... | [
"def",
"topDownCompute",
"(",
"self",
",",
"encoded",
")",
":",
"#Decode to delta scalar",
"if",
"self",
".",
"_prevAbsolute",
"==",
"None",
"or",
"self",
".",
"_prevDelta",
"==",
"None",
":",
"return",
"[",
"EncoderResult",
"(",
"value",
"=",
"0",
",",
"s... | [ScalarEncoder class method override] | [
"[",
"ScalarEncoder",
"class",
"method",
"override",
"]"
] | python | valid |
GGiecold/DBSCAN_multiplex | DBSCAN_multiplex.py | https://github.com/GGiecold/DBSCAN_multiplex/blob/075b1eec86d0e75166a9378d7d9a8974fc0a5e2e/DBSCAN_multiplex.py#L194-L442 | def load(hdf5_file_name, data, minPts, eps = None, quantile = 50, subsamples_matrix = None, samples_weights = None,
metric = 'minkowski', p = 2, verbose = True):
"""Determines the radius 'eps' for DBSCAN clustering of 'data' in an adaptive, data-dependent way.
Parameters
----------
hdf5_file_name : fi... | [
"def",
"load",
"(",
"hdf5_file_name",
",",
"data",
",",
"minPts",
",",
"eps",
"=",
"None",
",",
"quantile",
"=",
"50",
",",
"subsamples_matrix",
"=",
"None",
",",
"samples_weights",
"=",
"None",
",",
"metric",
"=",
"'minkowski'",
",",
"p",
"=",
"2",
",... | Determines the radius 'eps' for DBSCAN clustering of 'data' in an adaptive, data-dependent way.
Parameters
----------
hdf5_file_name : file object or string
The handle or name of an HDF5 data structure where any array needed for DBSCAN
and too large to fit into memory is to be stored.
... | [
"Determines",
"the",
"radius",
"eps",
"for",
"DBSCAN",
"clustering",
"of",
"data",
"in",
"an",
"adaptive",
"data",
"-",
"dependent",
"way",
"."
] | python | train |
nion-software/nionswift | nion/swift/Facade.py | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/Facade.py#L2761-L2768 | def document_windows(self) -> typing.List[DocumentWindow]:
"""Return the document windows.
.. versionadded:: 1.0
Scriptable: Yes
"""
return [DocumentWindow(document_controller) for document_controller in self.__application.document_controllers] | [
"def",
"document_windows",
"(",
"self",
")",
"->",
"typing",
".",
"List",
"[",
"DocumentWindow",
"]",
":",
"return",
"[",
"DocumentWindow",
"(",
"document_controller",
")",
"for",
"document_controller",
"in",
"self",
".",
"__application",
".",
"document_controller... | Return the document windows.
.. versionadded:: 1.0
Scriptable: Yes | [
"Return",
"the",
"document",
"windows",
"."
] | python | train |
TelAPI/telapi-python | telapi/rest/__init__.py | https://github.com/TelAPI/telapi-python/blob/a13dcb12f7ae5ca9f681b96f2802fff6ec2aff32/telapi/rest/__init__.py#L178-L197 | def fetch(self, resource_data=None):
"""Populates this class with remote data"""
if not self._populated:
params = {
"Page" : self.page,
"PageSize" : self.page_size,
}
params.update(self._filters)
if not resource_data... | [
"def",
"fetch",
"(",
"self",
",",
"resource_data",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_populated",
":",
"params",
"=",
"{",
"\"Page\"",
":",
"self",
".",
"page",
",",
"\"PageSize\"",
":",
"self",
".",
"page_size",
",",
"}",
"params",
"... | Populates this class with remote data | [
"Populates",
"this",
"class",
"with",
"remote",
"data"
] | python | train |
Lagg/steamodd | steam/items.py | https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L839-L850 | def account_info(self):
""" Certain attributes have a user's account information
associated with it such as a gifted or crafted item.
A dict with two keys: 'persona' and 'id64'.
None if the attribute has no account information attached to it. """
account_info = self._attribute.g... | [
"def",
"account_info",
"(",
"self",
")",
":",
"account_info",
"=",
"self",
".",
"_attribute",
".",
"get",
"(",
"\"account_info\"",
")",
"if",
"account_info",
":",
"return",
"{",
"\"persona\"",
":",
"account_info",
".",
"get",
"(",
"\"personaname\"",
",",
"\"... | Certain attributes have a user's account information
associated with it such as a gifted or crafted item.
A dict with two keys: 'persona' and 'id64'.
None if the attribute has no account information attached to it. | [
"Certain",
"attributes",
"have",
"a",
"user",
"s",
"account",
"information",
"associated",
"with",
"it",
"such",
"as",
"a",
"gifted",
"or",
"crafted",
"item",
"."
] | python | train |
a-tal/nagaram | nagaram/cmdline.py | https://github.com/a-tal/nagaram/blob/2edcb0ef8cb569ebd1c398be826472b4831d6110/nagaram/cmdline.py#L14-L45 | def pretty_print(input_word, anagrams, by_length=False):
"""Prints the anagram results sorted by score to stdout.
Args:
input_word: the base word we searched on
anagrams: generator of (word, score) from anagrams_in_word
by_length: a boolean to declare printing by length instead of score... | [
"def",
"pretty_print",
"(",
"input_word",
",",
"anagrams",
",",
"by_length",
"=",
"False",
")",
":",
"scores",
"=",
"{",
"}",
"if",
"by_length",
":",
"noun",
"=",
"\"tiles\"",
"for",
"word",
",",
"score",
"in",
"anagrams",
":",
"try",
":",
"scores",
"[... | Prints the anagram results sorted by score to stdout.
Args:
input_word: the base word we searched on
anagrams: generator of (word, score) from anagrams_in_word
by_length: a boolean to declare printing by length instead of score | [
"Prints",
"the",
"anagram",
"results",
"sorted",
"by",
"score",
"to",
"stdout",
"."
] | python | test |
samuelcolvin/pydantic | pydantic/schema.py | https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L408-L474 | def field_type_schema(
field: Field,
*,
by_alias: bool,
model_name_map: Dict[Type['main.BaseModel'], str],
schema_overrides: bool = False,
ref_prefix: Optional[str] = None,
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
"""
Used by ``field_schema()``, you probably should be using that funct... | [
"def",
"field_type_schema",
"(",
"field",
":",
"Field",
",",
"*",
",",
"by_alias",
":",
"bool",
",",
"model_name_map",
":",
"Dict",
"[",
"Type",
"[",
"'main.BaseModel'",
"]",
",",
"str",
"]",
",",
"schema_overrides",
":",
"bool",
"=",
"False",
",",
"ref_... | Used by ``field_schema()``, you probably should be using that function.
Take a single ``field`` and generate the schema for its type only, not including additional
information as title, etc. Also return additional schema definitions, from sub-models. | [
"Used",
"by",
"field_schema",
"()",
"you",
"probably",
"should",
"be",
"using",
"that",
"function",
"."
] | python | train |
pgmpy/pgmpy | pgmpy/independencies/Independencies.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/independencies/Independencies.py#L135-L239 | def closure(self):
"""
Returns a new `Independencies()`-object that additionally contains those `IndependenceAssertions`
that are implied by the the current independencies (using with the `semi-graphoid axioms
<https://en.wikipedia.org/w/index.php?title=Conditional_independence&oldid=708... | [
"def",
"closure",
"(",
"self",
")",
":",
"def",
"single_var",
"(",
"var",
")",
":",
"\"Checks if var represents a single variable\"",
"if",
"not",
"hasattr",
"(",
"var",
",",
"'__iter__'",
")",
":",
"return",
"True",
"else",
":",
"return",
"len",
"(",
"var",... | Returns a new `Independencies()`-object that additionally contains those `IndependenceAssertions`
that are implied by the the current independencies (using with the `semi-graphoid axioms
<https://en.wikipedia.org/w/index.php?title=Conditional_independence&oldid=708760689#Rules_of_conditional_independenc... | [
"Returns",
"a",
"new",
"Independencies",
"()",
"-",
"object",
"that",
"additionally",
"contains",
"those",
"IndependenceAssertions",
"that",
"are",
"implied",
"by",
"the",
"the",
"current",
"independencies",
"(",
"using",
"with",
"the",
"semi",
"-",
"graphoid",
... | python | train |
fhamborg/news-please | newsplease/crawler/spiders/rss_crawler.py | https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/crawler/spiders/rss_crawler.py#L42-L49 | def parse(self, response):
"""
Extracts the Rss Feed and initiates crawling it.
:param obj response: The scrapy response
"""
yield scrapy.Request(self.helper.url_extractor.get_rss_url(response),
callback=self.rss_parse) | [
"def",
"parse",
"(",
"self",
",",
"response",
")",
":",
"yield",
"scrapy",
".",
"Request",
"(",
"self",
".",
"helper",
".",
"url_extractor",
".",
"get_rss_url",
"(",
"response",
")",
",",
"callback",
"=",
"self",
".",
"rss_parse",
")"
] | Extracts the Rss Feed and initiates crawling it.
:param obj response: The scrapy response | [
"Extracts",
"the",
"Rss",
"Feed",
"and",
"initiates",
"crawling",
"it",
"."
] | python | train |
rwl/pylon | pyreto/continuous/experiment.py | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/continuous/experiment.py#L205-L246 | def _oneInteraction(self):
""" Coordinates one interaction between each agent and its environment.
"""
self.stepid += 1
logger.info("Entering simulation period %d." % self.stepid)
# Apply branches outages.
if self.branchOutages is not None:
self.doOutages()
... | [
"def",
"_oneInteraction",
"(",
"self",
")",
":",
"self",
".",
"stepid",
"+=",
"1",
"logger",
".",
"info",
"(",
"\"Entering simulation period %d.\"",
"%",
"self",
".",
"stepid",
")",
"# Apply branches outages.",
"if",
"self",
".",
"branchOutages",
"is",
"not",
... | Coordinates one interaction between each agent and its environment. | [
"Coordinates",
"one",
"interaction",
"between",
"each",
"agent",
"and",
"its",
"environment",
"."
] | python | train |
javipalanca/spade | spade/behaviour.py | https://github.com/javipalanca/spade/blob/59942bd1a1edae4c807d06cabb178d5630cbf61b/spade/behaviour.py#L469-L482 | def add_state(self, name: str, state: State, initial: bool = False):
""" Adds a new state to the FSM.
Args:
name (str): the name of the state, which is used as its identifier.
state (spade.behaviour.State): The state class
initial (bool, optional): wether the state is the ... | [
"def",
"add_state",
"(",
"self",
",",
"name",
":",
"str",
",",
"state",
":",
"State",
",",
"initial",
":",
"bool",
"=",
"False",
")",
":",
"if",
"not",
"issubclass",
"(",
"state",
".",
"__class__",
",",
"State",
")",
":",
"raise",
"AttributeError",
"... | Adds a new state to the FSM.
Args:
name (str): the name of the state, which is used as its identifier.
state (spade.behaviour.State): The state class
initial (bool, optional): wether the state is the initial state or not. (Only one initial state is allowed) (Default value = False) | [
"Adds",
"a",
"new",
"state",
"to",
"the",
"FSM",
"."
] | python | train |
lucastheis/django-publications | publications/templatetags/publication_extras.py | https://github.com/lucastheis/django-publications/blob/5a75cf88cf794937711b6850ff2acb07fe005f08/publications/templatetags/publication_extras.py#L67-L88 | def get_publication_list(context, list, template='publications/publications.html'):
"""
Get a publication list.
"""
list = List.objects.filter(list__iexact=list)
if not list:
return ''
list = list[0]
publications = list.publication_set.all()
publications = publications.order_by('-year', '-month', '-id')
... | [
"def",
"get_publication_list",
"(",
"context",
",",
"list",
",",
"template",
"=",
"'publications/publications.html'",
")",
":",
"list",
"=",
"List",
".",
"objects",
".",
"filter",
"(",
"list__iexact",
"=",
"list",
")",
"if",
"not",
"list",
":",
"return",
"''... | Get a publication list. | [
"Get",
"a",
"publication",
"list",
"."
] | python | valid |
treycucco/bidon | bidon/util/transform.py | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L73-L86 | def get_flattened(dct, names, path_joiner="_"):
"""Flatten a child dicts, whose resulting keys are joined by path_joiner.
E.G. { "valuation": { "currency": "USD", "amount": "100" } } ->
{ "valuation_currency": "USD", "valuation_amount": "100" }
"""
new_dct = dict()
for key, val in dct.items():
if ... | [
"def",
"get_flattened",
"(",
"dct",
",",
"names",
",",
"path_joiner",
"=",
"\"_\"",
")",
":",
"new_dct",
"=",
"dict",
"(",
")",
"for",
"key",
",",
"val",
"in",
"dct",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"names",
":",
"child",
"=",
"{"... | Flatten a child dicts, whose resulting keys are joined by path_joiner.
E.G. { "valuation": { "currency": "USD", "amount": "100" } } ->
{ "valuation_currency": "USD", "valuation_amount": "100" } | [
"Flatten",
"a",
"child",
"dicts",
"whose",
"resulting",
"keys",
"are",
"joined",
"by",
"path_joiner",
"."
] | python | train |
josiahcarlson/rom | rom/util.py | https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L489-L499 | def flush(self, full=False, all=False, force=False):
'''
Call ``.save()`` on all modified entities in the session. Use when you
want to flush changes to Redis, but don't want to lose your local
session cache.
See the ``.commit()`` method for arguments and their meanings.
... | [
"def",
"flush",
"(",
"self",
",",
"full",
"=",
"False",
",",
"all",
"=",
"False",
",",
"force",
"=",
"False",
")",
":",
"self",
".",
"_init",
"(",
")",
"return",
"self",
".",
"save",
"(",
"*",
"self",
".",
"known",
".",
"values",
"(",
")",
",",... | Call ``.save()`` on all modified entities in the session. Use when you
want to flush changes to Redis, but don't want to lose your local
session cache.
See the ``.commit()`` method for arguments and their meanings. | [
"Call",
".",
"save",
"()",
"on",
"all",
"modified",
"entities",
"in",
"the",
"session",
".",
"Use",
"when",
"you",
"want",
"to",
"flush",
"changes",
"to",
"Redis",
"but",
"don",
"t",
"want",
"to",
"lose",
"your",
"local",
"session",
"cache",
"."
] | python | test |
modin-project/modin | modin/engines/base/frame/partition_manager.py | https://github.com/modin-project/modin/blob/5b77d242596560c646b8405340c9ce64acb183cb/modin/engines/base/frame/partition_manager.py#L200-L216 | def map_across_blocks(self, map_func):
"""Applies `map_func` to every partition.
Args:
map_func: The function to apply.
Returns:
A new BaseFrameManager object, the type of object that called this.
"""
preprocessed_map_func = self.preprocess_func(map_func... | [
"def",
"map_across_blocks",
"(",
"self",
",",
"map_func",
")",
":",
"preprocessed_map_func",
"=",
"self",
".",
"preprocess_func",
"(",
"map_func",
")",
"new_partitions",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"part",
".",
"apply",
"(",
"preprocessed_map_func"... | Applies `map_func` to every partition.
Args:
map_func: The function to apply.
Returns:
A new BaseFrameManager object, the type of object that called this. | [
"Applies",
"map_func",
"to",
"every",
"partition",
"."
] | python | train |
django-leonardo/django-leonardo | leonardo/utils/settings.py | https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L69-L80 | def _is_leonardo_module(whatever):
'''check if is leonardo module'''
# check if is python module
if hasattr(whatever, 'default') \
or hasattr(whatever, 'leonardo_module_conf'):
return True
# check if is python object
for key in dir(whatever):
if 'LEONARDO' in key:
... | [
"def",
"_is_leonardo_module",
"(",
"whatever",
")",
":",
"# check if is python module",
"if",
"hasattr",
"(",
"whatever",
",",
"'default'",
")",
"or",
"hasattr",
"(",
"whatever",
",",
"'leonardo_module_conf'",
")",
":",
"return",
"True",
"# check if is python object",... | check if is leonardo module | [
"check",
"if",
"is",
"leonardo",
"module"
] | python | train |
SpriteLink/NIPAP | nipap-www/nipapwww/controllers/xhr.py | https://github.com/SpriteLink/NIPAP/blob/f96069f11ab952d80b13cab06e0528f2d24b3de9/nipap-www/nipapwww/controllers/xhr.py#L749-L786 | def get_current_vrfs(self):
""" Return VRF filter list from session variable
Before returning list, make a search for all VRFs currently in the
list to verify that they still exist.
"""
# Verify that all currently selected VRFs still exists
cur_vrfs = session.ge... | [
"def",
"get_current_vrfs",
"(",
"self",
")",
":",
"# Verify that all currently selected VRFs still exists",
"cur_vrfs",
"=",
"session",
".",
"get",
"(",
"'current_vrfs'",
",",
"{",
"}",
")",
".",
"items",
"(",
")",
"if",
"len",
"(",
"cur_vrfs",
")",
">",
"0",
... | Return VRF filter list from session variable
Before returning list, make a search for all VRFs currently in the
list to verify that they still exist. | [
"Return",
"VRF",
"filter",
"list",
"from",
"session",
"variable"
] | python | train |
aisthesis/pynance | pynance/opt/core.py | https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/core.py#L69-L96 | def info(self):
"""
Show expiration dates, equity price, quote time.
Returns
-------
self : :class:`~pynance.opt.core.Options`
Returns a reference to the calling object to allow
chaining.
expiries : :class:`pandas.tseries.index.DatetimeIndex`
... | [
"def",
"info",
"(",
"self",
")",
":",
"print",
"(",
"\"Expirations:\"",
")",
"_i",
"=",
"0",
"for",
"_datetime",
"in",
"self",
".",
"data",
".",
"index",
".",
"levels",
"[",
"1",
"]",
".",
"to_pydatetime",
"(",
")",
":",
"print",
"(",
"\"{:2d} {}\"",... | Show expiration dates, equity price, quote time.
Returns
-------
self : :class:`~pynance.opt.core.Options`
Returns a reference to the calling object to allow
chaining.
expiries : :class:`pandas.tseries.index.DatetimeIndex`
Examples
--------
... | [
"Show",
"expiration",
"dates",
"equity",
"price",
"quote",
"time",
"."
] | python | train |
dropbox/stone | stone/ir/api.py | https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/ir/api.py#L323-L337 | def get_namespaces_imported_by_route_io(self):
# type: () -> typing.List[ApiNamespace]
"""
Returns a list of Namespace objects. A namespace is a member of this
list if it is imported by the current namespace and has a data type
from it referenced as an argument, result, or error ... | [
"def",
"get_namespaces_imported_by_route_io",
"(",
"self",
")",
":",
"# type: () -> typing.List[ApiNamespace]",
"namespace_data_types",
"=",
"sorted",
"(",
"self",
".",
"get_route_io_data_types",
"(",
")",
",",
"key",
"=",
"lambda",
"dt",
":",
"dt",
".",
"name",
")"... | Returns a list of Namespace objects. A namespace is a member of this
list if it is imported by the current namespace and has a data type
from it referenced as an argument, result, or error of a route.
Namespaces are in ASCII order by name. | [
"Returns",
"a",
"list",
"of",
"Namespace",
"objects",
".",
"A",
"namespace",
"is",
"a",
"member",
"of",
"this",
"list",
"if",
"it",
"is",
"imported",
"by",
"the",
"current",
"namespace",
"and",
"has",
"a",
"data",
"type",
"from",
"it",
"referenced",
"as"... | python | train |
openearth/bmi-python | bmi/wrapper.py | https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L701-L711 | def set_current_time(self, current_time):
"""
sets current time of simulation
"""
current_time = c_double(current_time)
try:
self.library.set_current_time.argtypes = [POINTER(c_double)]
self.library.set_current_time.restype = None
self.library.... | [
"def",
"set_current_time",
"(",
"self",
",",
"current_time",
")",
":",
"current_time",
"=",
"c_double",
"(",
"current_time",
")",
"try",
":",
"self",
".",
"library",
".",
"set_current_time",
".",
"argtypes",
"=",
"[",
"POINTER",
"(",
"c_double",
")",
"]",
... | sets current time of simulation | [
"sets",
"current",
"time",
"of",
"simulation"
] | python | train |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L481-L497 | def get_resource_attribute(resource_attr_id, **kwargs):
"""
Get a specific resource attribte, by ID
If type_id is Gspecified, only
return the resource attributes within the type.
"""
resource_attr_qry = db.DBSession.query(ResourceAttr).filter(
ResourceAttr.id == resource_att... | [
"def",
"get_resource_attribute",
"(",
"resource_attr_id",
",",
"*",
"*",
"kwargs",
")",
":",
"resource_attr_qry",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAttr",
")",
".",
"filter",
"(",
"ResourceAttr",
".",
"id",
"==",
"resource_attr_id",
",",... | Get a specific resource attribte, by ID
If type_id is Gspecified, only
return the resource attributes within the type. | [
"Get",
"a",
"specific",
"resource",
"attribte",
"by",
"ID",
"If",
"type_id",
"is",
"Gspecified",
"only",
"return",
"the",
"resource",
"attributes",
"within",
"the",
"type",
"."
] | python | train |
tanghaibao/jcvi | jcvi/variation/str.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/variation/str.py#L350-L405 | def treds(args):
"""
%prog treds hli.tred.tsv
Compile allele_frequency for TREDs results. Write data.tsv, meta.tsv and
mask.tsv in one go.
"""
p = OptionParser(treds.__doc__)
p.add_option("--csv", default=False, action="store_true",
help="Also write `meta.csv`")
opts, a... | [
"def",
"treds",
"(",
"args",
")",
":",
"p",
"=",
"OptionParser",
"(",
"treds",
".",
"__doc__",
")",
"p",
".",
"add_option",
"(",
"\"--csv\"",
",",
"default",
"=",
"False",
",",
"action",
"=",
"\"store_true\"",
",",
"help",
"=",
"\"Also write `meta.csv`\"",... | %prog treds hli.tred.tsv
Compile allele_frequency for TREDs results. Write data.tsv, meta.tsv and
mask.tsv in one go. | [
"%prog",
"treds",
"hli",
".",
"tred",
".",
"tsv"
] | python | train |
AkihikoITOH/capybara | capybara/virtualenv/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.py | https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.py#L197-L254 | def cache_response(self, request, response, body=None):
"""
Algorithm for caching requests.
This assumes a requests Response object.
"""
# From httplib2: Don't cache 206's since we aren't going to
# handle byte range requests
if response.status not... | [
"def",
"cache_response",
"(",
"self",
",",
"request",
",",
"response",
",",
"body",
"=",
"None",
")",
":",
"# From httplib2: Don't cache 206's since we aren't going to",
"# handle byte range requests",
"if",
"response",
".",
"status",
"not",
"in",
"[",
"2... | Algorithm for caching requests.
This assumes a requests Response object. | [
"Algorithm",
"for",
"caching",
"requests",
"."
] | python | test |
CiscoTestAutomation/yang | ncdiff/src/yang/ncdiff/model.py | https://github.com/CiscoTestAutomation/yang/blob/c70ec5ac5a91f276c4060009203770ece92e76b4/ncdiff/src/yang/ncdiff/model.py#L480-L520 | def download_all(self, check_before_download=True):
'''download_all
High-level api: Convert cxml tree to an internal schema tree. This
method is recursive.
Parameters
----------
check_before_download : `bool`
True if checking capabilities.txt file is requir... | [
"def",
"download_all",
"(",
"self",
",",
"check_before_download",
"=",
"True",
")",
":",
"# check the content of self.yang_capabilities",
"if",
"check_before_download",
":",
"if",
"not",
"self",
".",
"need_download",
":",
"logger",
".",
"info",
"(",
"'Skip downloading... | download_all
High-level api: Convert cxml tree to an internal schema tree. This
method is recursive.
Parameters
----------
check_before_download : `bool`
True if checking capabilities.txt file is required.
Returns
-------
None
... | [
"download_all"
] | python | train |
bspaans/python-mingus | mingus/midi/sequencer.py | https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/sequencer.py#L129-L145 | def play_Note(self, note, channel=1, velocity=100):
"""Play a Note object on a channel with a velocity[0-127].
You can either specify the velocity and channel here as arguments or
you can set the Note.velocity and Note.channel attributes, which
will take presedence over the function arg... | [
"def",
"play_Note",
"(",
"self",
",",
"note",
",",
"channel",
"=",
"1",
",",
"velocity",
"=",
"100",
")",
":",
"if",
"hasattr",
"(",
"note",
",",
"'velocity'",
")",
":",
"velocity",
"=",
"note",
".",
"velocity",
"if",
"hasattr",
"(",
"note",
",",
"... | Play a Note object on a channel with a velocity[0-127].
You can either specify the velocity and channel here as arguments or
you can set the Note.velocity and Note.channel attributes, which
will take presedence over the function arguments. | [
"Play",
"a",
"Note",
"object",
"on",
"a",
"channel",
"with",
"a",
"velocity",
"[",
"0",
"-",
"127",
"]",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/cwl/workflow.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/workflow.py#L72-L100 | def _merge_wf_inputs(new, out, wf_outputs, to_ignore, parallel, nested_inputs):
"""Merge inputs for a sub-workflow, adding any not present inputs in out.
Skips inputs that are internally generated or generated and ignored, keeping
only as inputs those that we do not generate internally.
"""
interna... | [
"def",
"_merge_wf_inputs",
"(",
"new",
",",
"out",
",",
"wf_outputs",
",",
"to_ignore",
",",
"parallel",
",",
"nested_inputs",
")",
":",
"internal_generated_ids",
"=",
"[",
"]",
"for",
"vignore",
"in",
"to_ignore",
":",
"vignore_id",
"=",
"_get_string_vid",
"(... | Merge inputs for a sub-workflow, adding any not present inputs in out.
Skips inputs that are internally generated or generated and ignored, keeping
only as inputs those that we do not generate internally. | [
"Merge",
"inputs",
"for",
"a",
"sub",
"-",
"workflow",
"adding",
"any",
"not",
"present",
"inputs",
"in",
"out",
"."
] | python | train |
BernardFW/bernard | src/bernard/engine/triggers.py | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/triggers.py#L119-L131 | async def get_value(self):
"""
Get the value from the API. Make sure to use a lock in order not to
fetch the value twice at the same time.
"""
cc = self.request.custom_content
async with self.lock:
if self.content_key not in cc:
cc[self.conte... | [
"async",
"def",
"get_value",
"(",
"self",
")",
":",
"cc",
"=",
"self",
".",
"request",
".",
"custom_content",
"async",
"with",
"self",
".",
"lock",
":",
"if",
"self",
".",
"content_key",
"not",
"in",
"cc",
":",
"cc",
"[",
"self",
".",
"content_key",
... | Get the value from the API. Make sure to use a lock in order not to
fetch the value twice at the same time. | [
"Get",
"the",
"value",
"from",
"the",
"API",
".",
"Make",
"sure",
"to",
"use",
"a",
"lock",
"in",
"order",
"not",
"to",
"fetch",
"the",
"value",
"twice",
"at",
"the",
"same",
"time",
"."
] | python | train |
kennethreitz/legit | legit/cli.py | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L262-L278 | def do_install(ctx, verbose, fake):
"""Installs legit git aliases."""
click.echo('The following git aliases will be installed:\n')
aliases = cli.list_commands(ctx)
output_aliases(aliases)
if click.confirm('\n{}Install aliases above?'.format('FAKE ' if fake else ''), default=fake):
for alias... | [
"def",
"do_install",
"(",
"ctx",
",",
"verbose",
",",
"fake",
")",
":",
"click",
".",
"echo",
"(",
"'The following git aliases will be installed:\\n'",
")",
"aliases",
"=",
"cli",
".",
"list_commands",
"(",
"ctx",
")",
"output_aliases",
"(",
"aliases",
")",
"i... | Installs legit git aliases. | [
"Installs",
"legit",
"git",
"aliases",
"."
] | python | train |
jf-parent/brome | brome/core/proxy_driver.py | https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/core/proxy_driver.py#L857-L886 | def embed(self, title=''):
"""Start an IPython embed
Calling embed won't do anything in a multithread context
The stack_depth will be found automatically
"""
if self.embed_disabled:
self.warning_log("Embed is disabled when runned from the grid runner because of the ... | [
"def",
"embed",
"(",
"self",
",",
"title",
"=",
"''",
")",
":",
"if",
"self",
".",
"embed_disabled",
":",
"self",
".",
"warning_log",
"(",
"\"Embed is disabled when runned from the grid runner because of the multithreading\"",
")",
"# noqa",
"return",
"False",
"from",... | Start an IPython embed
Calling embed won't do anything in a multithread context
The stack_depth will be found automatically | [
"Start",
"an",
"IPython",
"embed"
] | python | train |
saltstack/salt | salt/utils/gitfs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L965-L974 | def env_is_exposed(self, tgt_env):
'''
Check if an environment is exposed by comparing it against a whitelist
and blacklist.
'''
return salt.utils.stringutils.check_whitelist_blacklist(
tgt_env,
whitelist=self.saltenv_whitelist,
blacklist=self.... | [
"def",
"env_is_exposed",
"(",
"self",
",",
"tgt_env",
")",
":",
"return",
"salt",
".",
"utils",
".",
"stringutils",
".",
"check_whitelist_blacklist",
"(",
"tgt_env",
",",
"whitelist",
"=",
"self",
".",
"saltenv_whitelist",
",",
"blacklist",
"=",
"self",
".",
... | Check if an environment is exposed by comparing it against a whitelist
and blacklist. | [
"Check",
"if",
"an",
"environment",
"is",
"exposed",
"by",
"comparing",
"it",
"against",
"a",
"whitelist",
"and",
"blacklist",
"."
] | python | train |
kblin/ncbi-genome-download | ncbi_genome_download/__main__.py | https://github.com/kblin/ncbi-genome-download/blob/dc55382d351c29e1027be8fa3876701762c1d752/ncbi_genome_download/__main__.py#L8-L32 | def main():
"""Build and parse command line."""
parser = argument_parser(version=__version__)
args = parser.parse_args()
if args.debug:
log_level = logging.DEBUG
elif args.verbose:
log_level = logging.INFO
else:
log_level = logging.WARNING
logging.basicConfig(format... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argument_parser",
"(",
"version",
"=",
"__version__",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"if",
"args",
".",
"debug",
":",
"log_level",
"=",
"logging",
".",
"DEBUG",
"elif",
"args",
"."... | Build and parse command line. | [
"Build",
"and",
"parse",
"command",
"line",
"."
] | python | train |
mikedh/trimesh | trimesh/path/arc.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/path/arc.py#L159-L205 | def to_threepoint(center, radius, angles=None):
"""
For 2D arcs, given a center and radius convert them to three
points on the arc.
Parameters
-----------
center : (2,) float
Center point on the plane
radius : float
Radius of arc
angles : (2,) float
Angles in radians f... | [
"def",
"to_threepoint",
"(",
"center",
",",
"radius",
",",
"angles",
"=",
"None",
")",
":",
"# if no angles provided assume we want a half circle",
"if",
"angles",
"is",
"None",
":",
"angles",
"=",
"[",
"0.0",
",",
"np",
".",
"pi",
"]",
"# force angles to float6... | For 2D arcs, given a center and radius convert them to three
points on the arc.
Parameters
-----------
center : (2,) float
Center point on the plane
radius : float
Radius of arc
angles : (2,) float
Angles in radians for start and end angle
if not specified, will default ... | [
"For",
"2D",
"arcs",
"given",
"a",
"center",
"and",
"radius",
"convert",
"them",
"to",
"three",
"points",
"on",
"the",
"arc",
"."
] | python | train |
readbeyond/aeneas | aeneas/executejob.py | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executejob.py#L122-L185 | def load_job_from_container(self, container_path, config_string=None):
"""
Load the job from the given :class:`aeneas.container.Container` object.
If ``config_string`` is ``None``,
the container must contain a configuration file;
otherwise use the provided config string
... | [
"def",
"load_job_from_container",
"(",
"self",
",",
"container_path",
",",
"config_string",
"=",
"None",
")",
":",
"self",
".",
"log",
"(",
"u\"Loading job from container...\"",
")",
"# create working directory where the input container",
"# will be decompressed",
"self",
"... | Load the job from the given :class:`aeneas.container.Container` object.
If ``config_string`` is ``None``,
the container must contain a configuration file;
otherwise use the provided config string
(i.e., the wizard case).
:param string container_path: the path to the input conta... | [
"Load",
"the",
"job",
"from",
"the",
"given",
":",
"class",
":",
"aeneas",
".",
"container",
".",
"Container",
"object",
"."
] | python | train |
Kortemme-Lab/klab | klab/bio/clustalo.py | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/clustalo.py#L569-L597 | def _determine_representative_chains(self):
''' Quotient the chains to get equivalence classes of chains. These will be used for the actual mapping.'''
# todo: This logic should be moved into the FASTA class or a more general module (maybe a fast exists which uses a C/C++ library?) but at present it is ... | [
"def",
"_determine_representative_chains",
"(",
"self",
")",
":",
"# todo: This logic should be moved into the FASTA class or a more general module (maybe a fast exists which uses a C/C++ library?) but at present it is easier to write here since we do not need to worry about other PDB IDs.",
"equivale... | Quotient the chains to get equivalence classes of chains. These will be used for the actual mapping. | [
"Quotient",
"the",
"chains",
"to",
"get",
"equivalence",
"classes",
"of",
"chains",
".",
"These",
"will",
"be",
"used",
"for",
"the",
"actual",
"mapping",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.