partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | S | Generate a MongoDB sort order list using the Django ORM style. | marrow/mongo/param/sort.py | def S(Document, *fields):
"""Generate a MongoDB sort order list using the Django ORM style."""
result = []
for field in fields:
if isinstance(field, tuple): # Unpack existing tuple.
field, direction = field
result.append((field, direction))
continue
direction = ASCENDING
if not field.starts... | def S(Document, *fields):
"""Generate a MongoDB sort order list using the Django ORM style."""
result = []
for field in fields:
if isinstance(field, tuple): # Unpack existing tuple.
field, direction = field
result.append((field, direction))
continue
direction = ASCENDING
if not field.starts... | [
"Generate",
"a",
"MongoDB",
"sort",
"order",
"list",
"using",
"the",
"Django",
"ORM",
"style",
"."
] | marrow/mongo | python | https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/param/sort.py#L12-L38 | [
"def",
"S",
"(",
"Document",
",",
"*",
"fields",
")",
":",
"result",
"=",
"[",
"]",
"for",
"field",
"in",
"fields",
":",
"if",
"isinstance",
"(",
"field",
",",
"tuple",
")",
":",
"# Unpack existing tuple.",
"field",
",",
"direction",
"=",
"field",
"res... | 2066dc73e281b8a46cb5fc965267d6b8e1b18467 |
train | Get.run | Reads data from CNPJ list and write results to output directory. | receita/tools/get.py | def run(self):
"""Reads data from CNPJ list and write results to output directory."""
self._assure_output_dir(self.output)
companies = self.read()
print '%s CNPJs found' % len(companies)
pbar = ProgressBar(
widgets=[Counter(), ' ', Percentage(), ' ', Bar(), ' ', Time... | def run(self):
"""Reads data from CNPJ list and write results to output directory."""
self._assure_output_dir(self.output)
companies = self.read()
print '%s CNPJs found' % len(companies)
pbar = ProgressBar(
widgets=[Counter(), ' ', Percentage(), ' ', Bar(), ' ', Time... | [
"Reads",
"data",
"from",
"CNPJ",
"list",
"and",
"write",
"results",
"to",
"output",
"directory",
"."
] | vkruoso/receita-tools | python | https://github.com/vkruoso/receita-tools/blob/fd62a252c76541c9feac6470b9048b31348ffe86/receita/tools/get.py#L25-L48 | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"_assure_output_dir",
"(",
"self",
".",
"output",
")",
"companies",
"=",
"self",
".",
"read",
"(",
")",
"print",
"'%s CNPJs found'",
"%",
"len",
"(",
"companies",
")",
"pbar",
"=",
"ProgressBar",
"(",
"... | fd62a252c76541c9feac6470b9048b31348ffe86 |
train | Get.read | Reads data from the CSV file. | receita/tools/get.py | def read(self):
"""Reads data from the CSV file."""
companies = []
with open(self.file) as f:
reader = unicodecsv.reader(f)
for line in reader:
if len(line) >= 1:
cnpj = self.format(line[0])
if self.valid(cnpj):
... | def read(self):
"""Reads data from the CSV file."""
companies = []
with open(self.file) as f:
reader = unicodecsv.reader(f)
for line in reader:
if len(line) >= 1:
cnpj = self.format(line[0])
if self.valid(cnpj):
... | [
"Reads",
"data",
"from",
"the",
"CSV",
"file",
"."
] | vkruoso/receita-tools | python | https://github.com/vkruoso/receita-tools/blob/fd62a252c76541c9feac6470b9048b31348ffe86/receita/tools/get.py#L50-L60 | [
"def",
"read",
"(",
"self",
")",
":",
"companies",
"=",
"[",
"]",
"with",
"open",
"(",
"self",
".",
"file",
")",
"as",
"f",
":",
"reader",
"=",
"unicodecsv",
".",
"reader",
"(",
"f",
")",
"for",
"line",
"in",
"reader",
":",
"if",
"len",
"(",
"l... | fd62a252c76541c9feac6470b9048b31348ffe86 |
train | Get.write | Writes json data to the output directory. | receita/tools/get.py | def write(self, data):
"""Writes json data to the output directory."""
cnpj, data = data
path = os.path.join(self.output, '%s.json' % cnpj)
with open(path, 'w') as f:
json.dump(data, f, encoding='utf-8') | def write(self, data):
"""Writes json data to the output directory."""
cnpj, data = data
path = os.path.join(self.output, '%s.json' % cnpj)
with open(path, 'w') as f:
json.dump(data, f, encoding='utf-8') | [
"Writes",
"json",
"data",
"to",
"the",
"output",
"directory",
"."
] | vkruoso/receita-tools | python | https://github.com/vkruoso/receita-tools/blob/fd62a252c76541c9feac6470b9048b31348ffe86/receita/tools/get.py#L62-L68 | [
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"cnpj",
",",
"data",
"=",
"data",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"output",
",",
"'%s.json'",
"%",
"cnpj",
")",
"with",
"open",
"(",
"path",
",",
"'w'",
")",
"as... | fd62a252c76541c9feac6470b9048b31348ffe86 |
train | Get.valid | Check if a CNPJ is valid.
We should avoid sending invalid CNPJ to the web service as we know
it is going to be a waste of bandwidth. Assumes CNPJ is a string. | receita/tools/get.py | def valid(self, cnpj):
"""Check if a CNPJ is valid.
We should avoid sending invalid CNPJ to the web service as we know
it is going to be a waste of bandwidth. Assumes CNPJ is a string.
"""
if len(cnpj) != 14:
return False
tam = 12
nums = cnpj[:tam]
... | def valid(self, cnpj):
"""Check if a CNPJ is valid.
We should avoid sending invalid CNPJ to the web service as we know
it is going to be a waste of bandwidth. Assumes CNPJ is a string.
"""
if len(cnpj) != 14:
return False
tam = 12
nums = cnpj[:tam]
... | [
"Check",
"if",
"a",
"CNPJ",
"is",
"valid",
"."
] | vkruoso/receita-tools | python | https://github.com/vkruoso/receita-tools/blob/fd62a252c76541c9feac6470b9048b31348ffe86/receita/tools/get.py#L88-L125 | [
"def",
"valid",
"(",
"self",
",",
"cnpj",
")",
":",
"if",
"len",
"(",
"cnpj",
")",
"!=",
"14",
":",
"return",
"False",
"tam",
"=",
"12",
"nums",
"=",
"cnpj",
"[",
":",
"tam",
"]",
"digs",
"=",
"cnpj",
"[",
"tam",
":",
"]",
"tot",
"=",
"0",
... | fd62a252c76541c9feac6470b9048b31348ffe86 |
train | write_taxon_info | Writes out data from `taxon` to the `output` stream to demonstrate
the attributes of a taxon object.
(currently some lines are commented out until the web-services call returns more info. See:
https://github.com/OpenTreeOfLife/taxomachine/issues/85
).
If `include_anc` is True, then ancestor info... | tutorials/ot-taxon-info.py | def write_taxon_info(taxon, include_anc, output):
"""Writes out data from `taxon` to the `output` stream to demonstrate
the attributes of a taxon object.
(currently some lines are commented out until the web-services call returns more info. See:
https://github.com/OpenTreeOfLife/taxomachine/issues/8... | def write_taxon_info(taxon, include_anc, output):
"""Writes out data from `taxon` to the `output` stream to demonstrate
the attributes of a taxon object.
(currently some lines are commented out until the web-services call returns more info. See:
https://github.com/OpenTreeOfLife/taxomachine/issues/8... | [
"Writes",
"out",
"data",
"from",
"taxon",
"to",
"the",
"output",
"stream",
"to",
"demonstrate",
"the",
"attributes",
"of",
"a",
"taxon",
"object",
".",
"(",
"currently",
"some",
"lines",
"are",
"commented",
"out",
"until",
"the",
"web",
"-",
"services",
"c... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-taxon-info.py#L18-L42 | [
"def",
"write_taxon_info",
"(",
"taxon",
",",
"include_anc",
",",
"output",
")",
":",
"output",
".",
"write",
"(",
"u'Taxon info for OTT ID (ot:ottId) = {}\\n'",
".",
"format",
"(",
"taxon",
".",
"ott_id",
")",
")",
"output",
".",
"write",
"(",
"u' name (ot:o... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | main | This function sets up a command-line option parser and then calls match_and_print
to do all of the real work. | tutorials/ot-taxon-info.py | def main(argv):
"""This function sets up a command-line option parser and then calls match_and_print
to do all of the real work.
"""
import argparse
import codecs
# have to be ready to deal with utf-8 names
out = codecs.getwriter('utf-8')(sys.stdout)
description = 'Uses Open Tree of Lif... | def main(argv):
"""This function sets up a command-line option parser and then calls match_and_print
to do all of the real work.
"""
import argparse
import codecs
# have to be ready to deal with utf-8 names
out = codecs.getwriter('utf-8')(sys.stdout)
description = 'Uses Open Tree of Lif... | [
"This",
"function",
"sets",
"up",
"a",
"command",
"-",
"line",
"option",
"parser",
"and",
"then",
"calls",
"match_and_print",
"to",
"do",
"all",
"of",
"the",
"real",
"work",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-taxon-info.py#L45-L65 | [
"def",
"main",
"(",
"argv",
")",
":",
"import",
"argparse",
"import",
"codecs",
"# have to be ready to deal with utf-8 names",
"out",
"=",
"codecs",
".",
"getwriter",
"(",
"'utf-8'",
")",
"(",
"sys",
".",
"stdout",
")",
"description",
"=",
"'Uses Open Tree of Life... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | get_default_config_filename | Returns the configuration filepath.
If PEYOTL_CONFIG_FILE is in the env that is the preferred choice; otherwise ~/.peyotl/config is preferred.
If the preferred file does not exist, then the packaged peyotl/default.conf from the installation of peyotl is
used.
A RuntimeError is raised if that fails. | peyotl/utility/get_config.py | def get_default_config_filename():
"""Returns the configuration filepath.
If PEYOTL_CONFIG_FILE is in the env that is the preferred choice; otherwise ~/.peyotl/config is preferred.
If the preferred file does not exist, then the packaged peyotl/default.conf from the installation of peyotl is
used.
A... | def get_default_config_filename():
"""Returns the configuration filepath.
If PEYOTL_CONFIG_FILE is in the env that is the preferred choice; otherwise ~/.peyotl/config is preferred.
If the preferred file does not exist, then the packaged peyotl/default.conf from the installation of peyotl is
used.
A... | [
"Returns",
"the",
"configuration",
"filepath",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/get_config.py#L73-L104 | [
"def",
"get_default_config_filename",
"(",
")",
":",
"global",
"_CONFIG_FN",
"if",
"_CONFIG_FN",
"is",
"not",
"None",
":",
"return",
"_CONFIG_FN",
"with",
"_CONFIG_FN_LOCK",
":",
"if",
"_CONFIG_FN",
"is",
"not",
"None",
":",
"return",
"_CONFIG_FN",
"if",
"'PEYOT... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | get_raw_default_config_and_read_file_list | Returns a ConfigParser object and a list of filenames that were parsed to initialize it | peyotl/utility/get_config.py | def get_raw_default_config_and_read_file_list():
"""Returns a ConfigParser object and a list of filenames that were parsed to initialize it"""
global _CONFIG, _READ_DEFAULT_FILES
if _CONFIG is not None:
return _CONFIG, _READ_DEFAULT_FILES
with _CONFIG_LOCK:
if _CONFIG is not None:
... | def get_raw_default_config_and_read_file_list():
"""Returns a ConfigParser object and a list of filenames that were parsed to initialize it"""
global _CONFIG, _READ_DEFAULT_FILES
if _CONFIG is not None:
return _CONFIG, _READ_DEFAULT_FILES
with _CONFIG_LOCK:
if _CONFIG is not None:
... | [
"Returns",
"a",
"ConfigParser",
"object",
"and",
"a",
"list",
"of",
"filenames",
"that",
"were",
"parsed",
"to",
"initialize",
"it"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/get_config.py#L107-L124 | [
"def",
"get_raw_default_config_and_read_file_list",
"(",
")",
":",
"global",
"_CONFIG",
",",
"_READ_DEFAULT_FILES",
"if",
"_CONFIG",
"is",
"not",
"None",
":",
"return",
"_CONFIG",
",",
"_READ_DEFAULT_FILES",
"with",
"_CONFIG_LOCK",
":",
"if",
"_CONFIG",
"is",
"not",... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _raw_config_setting | Read (section, param) from `config_obj`. If not found, return `default`
If the setting is not found and `default` is None, then an warn-level message is logged.
`config_filename` can be None, filepath or list of filepaths - it is only used for logging.
If warn_on_none_level is None (or lower than the logg... | peyotl/utility/get_config.py | def _raw_config_setting(config_obj, section, param, default=None, config_filename='', warn_on_none_level=logging.WARN):
"""Read (section, param) from `config_obj`. If not found, return `default`
If the setting is not found and `default` is None, then an warn-level message is logged.
`config_filename` can b... | def _raw_config_setting(config_obj, section, param, default=None, config_filename='', warn_on_none_level=logging.WARN):
"""Read (section, param) from `config_obj`. If not found, return `default`
If the setting is not found and `default` is None, then an warn-level message is logged.
`config_filename` can b... | [
"Read",
"(",
"section",
"param",
")",
"from",
"config_obj",
".",
"If",
"not",
"found",
"return",
"default"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/get_config.py#L149-L164 | [
"def",
"_raw_config_setting",
"(",
"config_obj",
",",
"section",
",",
"param",
",",
"default",
"=",
"None",
",",
"config_filename",
"=",
"''",
",",
"warn_on_none_level",
"=",
"logging",
".",
"WARN",
")",
":",
"# noinspection PyBroadException",
"try",
":",
"retur... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _create_overrides_from_config | Creates a two-level dictionary of d[section][option] from a config parser object. | peyotl/utility/get_config.py | def _create_overrides_from_config(config):
"""Creates a two-level dictionary of d[section][option] from a config parser object."""
d = {}
for s in config.sections():
d[s] = {}
for opt in config.options(s):
d[s][opt] = config.get(s, opt)
return d | def _create_overrides_from_config(config):
"""Creates a two-level dictionary of d[section][option] from a config parser object."""
d = {}
for s in config.sections():
d[s] = {}
for opt in config.options(s):
d[s][opt] = config.get(s, opt)
return d | [
"Creates",
"a",
"two",
"-",
"level",
"dictionary",
"of",
"d",
"[",
"section",
"]",
"[",
"option",
"]",
"from",
"a",
"config",
"parser",
"object",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/get_config.py#L298-L305 | [
"def",
"_create_overrides_from_config",
"(",
"config",
")",
":",
"d",
"=",
"{",
"}",
"for",
"s",
"in",
"config",
".",
"sections",
"(",
")",
":",
"d",
"[",
"s",
"]",
"=",
"{",
"}",
"for",
"opt",
"in",
"config",
".",
"options",
"(",
"s",
")",
":",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | get_config_object | Thread-safe accessor for the immutable default ConfigWrapper object | peyotl/utility/get_config.py | def get_config_object():
"""Thread-safe accessor for the immutable default ConfigWrapper object"""
global _DEFAULT_CONFIG_WRAPPER
if _DEFAULT_CONFIG_WRAPPER is not None:
return _DEFAULT_CONFIG_WRAPPER
with _DEFAULT_CONFIG_WRAPPER_LOCK:
if _DEFAULT_CONFIG_WRAPPER is not None:
... | def get_config_object():
"""Thread-safe accessor for the immutable default ConfigWrapper object"""
global _DEFAULT_CONFIG_WRAPPER
if _DEFAULT_CONFIG_WRAPPER is not None:
return _DEFAULT_CONFIG_WRAPPER
with _DEFAULT_CONFIG_WRAPPER_LOCK:
if _DEFAULT_CONFIG_WRAPPER is not None:
... | [
"Thread",
"-",
"safe",
"accessor",
"for",
"the",
"immutable",
"default",
"ConfigWrapper",
"object"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/get_config.py#L315-L324 | [
"def",
"get_config_object",
"(",
")",
":",
"global",
"_DEFAULT_CONFIG_WRAPPER",
"if",
"_DEFAULT_CONFIG_WRAPPER",
"is",
"not",
"None",
":",
"return",
"_DEFAULT_CONFIG_WRAPPER",
"with",
"_DEFAULT_CONFIG_WRAPPER_LOCK",
":",
"if",
"_DEFAULT_CONFIG_WRAPPER",
"is",
"not",
"None... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | ConfigWrapper.get_from_config_setting_cascade | return the first non-None setting from a series where each
element in `sec_param_list` is a section, param pair suitable for
a get_config_setting call.
Note that non-None values for overrides for this ConfigWrapper instance will cause
this call to only evaluate the first element in ... | peyotl/utility/get_config.py | def get_from_config_setting_cascade(self, sec_param_list, default=None, warn_on_none_level=logging.WARN):
"""return the first non-None setting from a series where each
element in `sec_param_list` is a section, param pair suitable for
a get_config_setting call.
Note that non-None values ... | def get_from_config_setting_cascade(self, sec_param_list, default=None, warn_on_none_level=logging.WARN):
"""return the first non-None setting from a series where each
element in `sec_param_list` is a section, param pair suitable for
a get_config_setting call.
Note that non-None values ... | [
"return",
"the",
"first",
"non",
"-",
"None",
"setting",
"from",
"a",
"series",
"where",
"each",
"element",
"in",
"sec_param_list",
"is",
"a",
"section",
"param",
"pair",
"suitable",
"for",
"a",
"get_config_setting",
"call",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/get_config.py#L213-L228 | [
"def",
"get_from_config_setting_cascade",
"(",
"self",
",",
"sec_param_list",
",",
"default",
"=",
"None",
",",
"warn_on_none_level",
"=",
"logging",
".",
"WARN",
")",
":",
"for",
"section",
",",
"param",
"in",
"sec_param_list",
":",
"r",
"=",
"self",
".",
"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | validate_amendment | Takes an `obj` that is an amendment object.
`retain_deprecated` if False, then `obj` may be modified to replace
deprecated constructs with new syntax. If it is True, the `obj` will
not be modified.
Returns the pair:
errors, adaptor
`errors` is a simple list of error messages
`ada... | peyotl/amendments/validation/__init__.py | def validate_amendment(obj, retain_deprecated=True, **kwargs):
"""Takes an `obj` that is an amendment object.
`retain_deprecated` if False, then `obj` may be modified to replace
deprecated constructs with new syntax. If it is True, the `obj` will
not be modified.
Returns the pair:
er... | def validate_amendment(obj, retain_deprecated=True, **kwargs):
"""Takes an `obj` that is an amendment object.
`retain_deprecated` if False, then `obj` may be modified to replace
deprecated constructs with new syntax. If it is True, the `obj` will
not be modified.
Returns the pair:
er... | [
"Takes",
"an",
"obj",
"that",
"is",
"an",
"amendment",
"object",
".",
"retain_deprecated",
"if",
"False",
"then",
"obj",
"may",
"be",
"modified",
"to",
"replace",
"deprecated",
"constructs",
"with",
"new",
"syntax",
".",
"If",
"it",
"is",
"True",
"the",
"o... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/validation/__init__.py#L7-L22 | [
"def",
"validate_amendment",
"(",
"obj",
",",
"retain_deprecated",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# Gather and report errors in a simple list",
"errors",
"=",
"[",
"]",
"n",
"=",
"create_validation_adaptor",
"(",
"obj",
",",
"errors",
",",
"*",... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | create_anc_lineage_from_id2par | Returns a list from [ott_id, ott_id's par, ..., root ott_id] | peyotl/phylo/tree.py | def create_anc_lineage_from_id2par(id2par_id, ott_id):
"""Returns a list from [ott_id, ott_id's par, ..., root ott_id]"""
curr = ott_id
n = id2par_id.get(curr)
if n is None:
raise KeyError('The OTT ID {} was not found'.format(ott_id))
lineage = [curr]
while n is not None:
lineage... | def create_anc_lineage_from_id2par(id2par_id, ott_id):
"""Returns a list from [ott_id, ott_id's par, ..., root ott_id]"""
curr = ott_id
n = id2par_id.get(curr)
if n is None:
raise KeyError('The OTT ID {} was not found'.format(ott_id))
lineage = [curr]
while n is not None:
lineage... | [
"Returns",
"a",
"list",
"from",
"[",
"ott_id",
"ott_id",
"s",
"par",
"...",
"root",
"ott_id",
"]"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylo/tree.py#L348-L358 | [
"def",
"create_anc_lineage_from_id2par",
"(",
"id2par_id",
",",
"ott_id",
")",
":",
"curr",
"=",
"ott_id",
"n",
"=",
"id2par_id",
".",
"get",
"(",
"curr",
")",
"if",
"n",
"is",
"None",
":",
"raise",
"KeyError",
"(",
"'The OTT ID {} was not found'",
".",
"for... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | parse_id2par_dict | Expecting a dict of id2parent ID or a pickled object (passed in as file object `stream` or `filepath`) | peyotl/phylo/tree.py | def parse_id2par_dict(id2par=None,
id_list=None,
id2par_stream=None,
id2par_filepath=None,
id_list_stream=None,
id_list_filepath=None,
_class=TreeWithPathsInEdges):
"""Expecting a dict... | def parse_id2par_dict(id2par=None,
id_list=None,
id2par_stream=None,
id2par_filepath=None,
id_list_stream=None,
id_list_filepath=None,
_class=TreeWithPathsInEdges):
"""Expecting a dict... | [
"Expecting",
"a",
"dict",
"of",
"id2parent",
"ID",
"or",
"a",
"pickled",
"object",
"(",
"passed",
"in",
"as",
"file",
"object",
"stream",
"or",
"filepath",
")"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylo/tree.py#L539-L568 | [
"def",
"parse_id2par_dict",
"(",
"id2par",
"=",
"None",
",",
"id_list",
"=",
"None",
",",
"id2par_stream",
"=",
"None",
",",
"id2par_filepath",
"=",
"None",
",",
"id_list_stream",
"=",
"None",
",",
"id_list_filepath",
"=",
"None",
",",
"_class",
"=",
"TreeWi... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | Node.before_after_apply | Applies the functions to each node in a subtree using an traversal in which
encountered twice: once right before its descendants, and once right
after its last descendant | peyotl/phylo/tree.py | def before_after_apply(self, before_fn, after_fn, leaf_fn=None):
"""Applies the functions to each node in a subtree using an traversal in which
encountered twice: once right before its descendants, and once right
after its last descendant
"""
stack = [self]
while stack:
... | def before_after_apply(self, before_fn, after_fn, leaf_fn=None):
"""Applies the functions to each node in a subtree using an traversal in which
encountered twice: once right before its descendants, and once right
after its last descendant
"""
stack = [self]
while stack:
... | [
"Applies",
"the",
"functions",
"to",
"each",
"node",
"in",
"a",
"subtree",
"using",
"an",
"traversal",
"in",
"which",
"encountered",
"twice",
":",
"once",
"right",
"before",
"its",
"descendants",
"and",
"once",
"right",
"after",
"its",
"last",
"descendant"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylo/tree.py#L66-L85 | [
"def",
"before_after_apply",
"(",
"self",
",",
"before_fn",
",",
"after_fn",
",",
"leaf_fn",
"=",
"None",
")",
":",
"stack",
"=",
"[",
"self",
"]",
"while",
"stack",
":",
"node",
"=",
"stack",
".",
"pop",
"(",
")",
"if",
"node",
".",
"is_leaf",
":",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | Node.preorder_iter | From DendroPy
Preorder traversal of self and its child_nodes. Returns self
and all descendants such that a node is returned before its
child_nodes (and their child_nodes). Filtered by filter_fn: node is
only returned if no filter_fn is given or if filter_fn returns
True. | peyotl/phylo/tree.py | def preorder_iter(self, filter_fn=None):
""" From DendroPy
Preorder traversal of self and its child_nodes. Returns self
and all descendants such that a node is returned before its
child_nodes (and their child_nodes). Filtered by filter_fn: node is
only returned if no filter_fn i... | def preorder_iter(self, filter_fn=None):
""" From DendroPy
Preorder traversal of self and its child_nodes. Returns self
and all descendants such that a node is returned before its
child_nodes (and their child_nodes). Filtered by filter_fn: node is
only returned if no filter_fn i... | [
"From",
"DendroPy",
"Preorder",
"traversal",
"of",
"self",
"and",
"its",
"child_nodes",
".",
"Returns",
"self",
"and",
"all",
"descendants",
"such",
"that",
"a",
"node",
"is",
"returned",
"before",
"its",
"child_nodes",
"(",
"and",
"their",
"child_nodes",
")",... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylo/tree.py#L87-L100 | [
"def",
"preorder_iter",
"(",
"self",
",",
"filter_fn",
"=",
"None",
")",
":",
"stack",
"=",
"[",
"self",
"]",
"while",
"stack",
":",
"node",
"=",
"stack",
".",
"pop",
"(",
")",
"if",
"filter_fn",
"is",
"None",
"or",
"filter_fn",
"(",
"node",
")",
"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | Node.postorder_iter | From DendroPy
Postorder traversal of the self and its child_nodes. Returns self
and all descendants such that a node's child_nodes (and their
child_nodes) are visited before node. Filtered by filter_fn:
node is only returned if no filter_fn is given or if filter_fn
returns True... | peyotl/phylo/tree.py | def postorder_iter(self, filter_fn=None):
"""From DendroPy
Postorder traversal of the self and its child_nodes. Returns self
and all descendants such that a node's child_nodes (and their
child_nodes) are visited before node. Filtered by filter_fn:
node is only returned if no fi... | def postorder_iter(self, filter_fn=None):
"""From DendroPy
Postorder traversal of the self and its child_nodes. Returns self
and all descendants such that a node's child_nodes (and their
child_nodes) are visited before node. Filtered by filter_fn:
node is only returned if no fi... | [
"From",
"DendroPy",
"Postorder",
"traversal",
"of",
"the",
"self",
"and",
"its",
"child_nodes",
".",
"Returns",
"self",
"and",
"all",
"descendants",
"such",
"that",
"a",
"node",
"s",
"child_nodes",
"(",
"and",
"their",
"child_nodes",
")",
"are",
"visited",
"... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylo/tree.py#L102-L119 | [
"def",
"postorder_iter",
"(",
"self",
",",
"filter_fn",
"=",
"None",
")",
":",
"stack",
"=",
"[",
"(",
"self",
",",
"False",
")",
"]",
"while",
"stack",
":",
"node",
",",
"state",
"=",
"stack",
".",
"pop",
"(",
")",
"if",
"state",
":",
"if",
"fil... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TreeWithPathsInEdges.add_bits4subtree_ids | Adds a long integer bits4subtree_ids to each node (Fails cryptically if that field is already present!)
relevant_ids can be a dict of _id to bit representation.
If it is not supplied, a dict will be created by registering the leaf._id into a dict (and returning the dict)
the bits4subtree_ids wil... | peyotl/phylo/tree.py | def add_bits4subtree_ids(self, relevant_ids):
"""Adds a long integer bits4subtree_ids to each node (Fails cryptically if that field is already present!)
relevant_ids can be a dict of _id to bit representation.
If it is not supplied, a dict will be created by registering the leaf._id into a dict ... | def add_bits4subtree_ids(self, relevant_ids):
"""Adds a long integer bits4subtree_ids to each node (Fails cryptically if that field is already present!)
relevant_ids can be a dict of _id to bit representation.
If it is not supplied, a dict will be created by registering the leaf._id into a dict ... | [
"Adds",
"a",
"long",
"integer",
"bits4subtree_ids",
"to",
"each",
"node",
"(",
"Fails",
"cryptically",
"if",
"that",
"field",
"is",
"already",
"present!",
")",
"relevant_ids",
"can",
"be",
"a",
"dict",
"of",
"_id",
"to",
"bit",
"representation",
".",
"If",
... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylo/tree.py#L302-L345 | [
"def",
"add_bits4subtree_ids",
"(",
"self",
",",
"relevant_ids",
")",
":",
"if",
"relevant_ids",
":",
"checking",
"=",
"True",
"else",
":",
"checking",
"=",
"False",
"relevant_ids",
"=",
"{",
"}",
"bit",
"=",
"1",
"self",
".",
"bits2internal_node",
"=",
"{... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | do_parse | Parse the jsg in infilename and save the results in outfilename
:param infilename: file containing jsg
:param outfilename: target python file
:param verbose: verbose output flag
:return: true if success | pyjsg/parser_impl/generate_python.py | def do_parse(infilename: str, outfilename: str, verbose: bool) -> bool:
"""
Parse the jsg in infilename and save the results in outfilename
:param infilename: file containing jsg
:param outfilename: target python file
:param verbose: verbose output flag
:return: true if success
"""
pytho... | def do_parse(infilename: str, outfilename: str, verbose: bool) -> bool:
"""
Parse the jsg in infilename and save the results in outfilename
:param infilename: file containing jsg
:param outfilename: target python file
:param verbose: verbose output flag
:return: true if success
"""
pytho... | [
"Parse",
"the",
"jsg",
"in",
"infilename",
"and",
"save",
"the",
"results",
"in",
"outfilename",
":",
"param",
"infilename",
":",
"file",
"containing",
"jsg",
":",
"param",
"outfilename",
":",
"target",
"python",
"file",
":",
"param",
"verbose",
":",
"verbos... | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/generate_python.py#L38-L53 | [
"def",
"do_parse",
"(",
"infilename",
":",
"str",
",",
"outfilename",
":",
"str",
",",
"verbose",
":",
"bool",
")",
"->",
"bool",
":",
"python",
"=",
"parse",
"(",
"FileStream",
"(",
"infilename",
",",
"encoding",
"=",
"\"utf-8\"",
")",
",",
"infilename"... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | parse | Parse the text in infile and save the results in outfile
:param input_: string or stream to parse
:param source: source name for python file header
:return: python text if successful | pyjsg/parser_impl/generate_python.py | def parse(input_: Union[str, FileStream], source: str) -> Optional[str]:
"""Parse the text in infile and save the results in outfile
:param input_: string or stream to parse
:param source: source name for python file header
:return: python text if successful
"""
# Step 1: Tokenize the input st... | def parse(input_: Union[str, FileStream], source: str) -> Optional[str]:
"""Parse the text in infile and save the results in outfile
:param input_: string or stream to parse
:param source: source name for python file header
:return: python text if successful
"""
# Step 1: Tokenize the input st... | [
"Parse",
"the",
"text",
"in",
"infile",
"and",
"save",
"the",
"results",
"in",
"outfile"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/generate_python.py#L56-L91 | [
"def",
"parse",
"(",
"input_",
":",
"Union",
"[",
"str",
",",
"FileStream",
"]",
",",
"source",
":",
"str",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"# Step 1: Tokenize the input stream",
"error_listener",
"=",
"ParseErrorListener",
"(",
")",
"if",
"not"... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | genargs | Create a command line parser
:return: parser | pyjsg/parser_impl/generate_python.py | def genargs() -> ArgumentParser:
"""
Create a command line parser
:return: parser
"""
parser = ArgumentParser()
parser.add_argument("infile", help="Input JSG specification")
parser.add_argument("-o", "--outfile", help="Output python file (Default: {infile}.py)")
parser.add_argument("-e",... | def genargs() -> ArgumentParser:
"""
Create a command line parser
:return: parser
"""
parser = ArgumentParser()
parser.add_argument("infile", help="Input JSG specification")
parser.add_argument("-o", "--outfile", help="Output python file (Default: {infile}.py)")
parser.add_argument("-e",... | [
"Create",
"a",
"command",
"line",
"parser",
":",
"return",
":",
"parser"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/generate_python.py#L94-L104 | [
"def",
"genargs",
"(",
")",
"->",
"ArgumentParser",
":",
"parser",
"=",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"infile\"",
",",
"help",
"=",
"\"Input JSG specification\"",
")",
"parser",
".",
"add_argument",
"(",
"\"-o\"",
",",
"\"--... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | evaluate | Load fname as a module. Will raise an exception if there is an error
:param module_name: resulting name of module
:param fname: name to load | pyjsg/parser_impl/generate_python.py | def evaluate(module_name: str, fname: str, verbose: bool):
"""
Load fname as a module. Will raise an exception if there is an error
:param module_name: resulting name of module
:param fname: name to load
"""
if verbose:
print("Testing {}".format(fname))
spec = importlib.util.spec_f... | def evaluate(module_name: str, fname: str, verbose: bool):
"""
Load fname as a module. Will raise an exception if there is an error
:param module_name: resulting name of module
:param fname: name to load
"""
if verbose:
print("Testing {}".format(fname))
spec = importlib.util.spec_f... | [
"Load",
"fname",
"as",
"a",
"module",
".",
"Will",
"raise",
"an",
"exception",
"if",
"there",
"is",
"an",
"error",
":",
"param",
"module_name",
":",
"resulting",
"name",
"of",
"module",
":",
"param",
"fname",
":",
"name",
"to",
"load"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/generate_python.py#L107-L117 | [
"def",
"evaluate",
"(",
"module_name",
":",
"str",
",",
"fname",
":",
"str",
",",
"verbose",
":",
"bool",
")",
":",
"if",
"verbose",
":",
"print",
"(",
"\"Testing {}\"",
".",
"format",
"(",
"fname",
")",
")",
"spec",
"=",
"importlib",
".",
"util",
".... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | Client.fetch | Executes a request by AsyncHTTPClient,
asynchronously returning an `tornado.HTTPResponse`.
The ``raise_error=False`` argument currently suppresses
*all* errors, encapsulating them in `HTTPResponse` objects
following the tornado http-client standard | tornadoalf/client.py | def fetch(self, request, callback=None, raise_error=True, **kwargs):
"""Executes a request by AsyncHTTPClient,
asynchronously returning an `tornado.HTTPResponse`.
The ``raise_error=False`` argument currently suppresses
*all* errors, encapsulating them in `HTTPResponse` objects
... | def fetch(self, request, callback=None, raise_error=True, **kwargs):
"""Executes a request by AsyncHTTPClient,
asynchronously returning an `tornado.HTTPResponse`.
The ``raise_error=False`` argument currently suppresses
*all* errors, encapsulating them in `HTTPResponse` objects
... | [
"Executes",
"a",
"request",
"by",
"AsyncHTTPClient",
"asynchronously",
"returning",
"an",
"tornado",
".",
"HTTPResponse",
"."
] | globocom/tornado-alf | python | https://github.com/globocom/tornado-alf/blob/3c3ec58c33f2d4ddfbed4ac18ca89d6beedf9c87/tornadoalf/client.py#L29-L66 | [
"def",
"fetch",
"(",
"self",
",",
"request",
",",
"callback",
"=",
"None",
",",
"raise_error",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# accepts request as string then convert it to HTTPRequest",
"if",
"isinstance",
"(",
"request",
",",
"str",
")",
":... | 3c3ec58c33f2d4ddfbed4ac18ca89d6beedf9c87 |
train | search_target_obj | Query for a specific target:
http://asterank.com/api/skymorph/search?<params>
target Target object (lookup in MPC). | bowshock/skymorph.py | def search_target_obj(target):
'''
Query for a specific target:
http://asterank.com/api/skymorph/search?<params>
target Target object (lookup in MPC).
'''
base_url = "http://asterank.com/api/skymorph/search?"
if not isinstance(target, str):
raise ValueError("The target arg you prov... | def search_target_obj(target):
'''
Query for a specific target:
http://asterank.com/api/skymorph/search?<params>
target Target object (lookup in MPC).
'''
base_url = "http://asterank.com/api/skymorph/search?"
if not isinstance(target, str):
raise ValueError("The target arg you prov... | [
"Query",
"for",
"a",
"specific",
"target",
":"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/skymorph.py#L9-L23 | [
"def",
"search_target_obj",
"(",
"target",
")",
":",
"base_url",
"=",
"\"http://asterank.com/api/skymorph/search?\"",
"if",
"not",
"isinstance",
"(",
"target",
",",
"str",
")",
":",
"raise",
"ValueError",
"(",
"\"The target arg you provided is not the type of str\"",
")",... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | search_orbit | Query based on orbital elements:
http://asterank.com/api/skymorph/search_orbit?<params>
epoch Epoch ([M]JD or ISO)
ecc eccentricity
per Perihelion distance (AU)
per_date Perihelion date ([M]JD or ISO)
om Longitude of ascending node (deg)
w Argument of perihelion (deg)
i Inclination (deg... | bowshock/skymorph.py | def search_orbit(**kwargs):
'''
Query based on orbital elements:
http://asterank.com/api/skymorph/search_orbit?<params>
epoch Epoch ([M]JD or ISO)
ecc eccentricity
per Perihelion distance (AU)
per_date Perihelion date ([M]JD or ISO)
om Longitude of ascending node (deg)
w Argument of... | def search_orbit(**kwargs):
'''
Query based on orbital elements:
http://asterank.com/api/skymorph/search_orbit?<params>
epoch Epoch ([M]JD or ISO)
ecc eccentricity
per Perihelion distance (AU)
per_date Perihelion date ([M]JD or ISO)
om Longitude of ascending node (deg)
w Argument of... | [
"Query",
"based",
"on",
"orbital",
"elements",
":"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/skymorph.py#L26-L50 | [
"def",
"search_orbit",
"(",
"*",
"*",
"kwargs",
")",
":",
"base_url",
"=",
"\"http://asterank.com/api/skymorph/search_orbit?\"",
"for",
"key",
"in",
"kwargs",
":",
"base_url",
"+=",
"str",
"(",
"key",
")",
"+",
"\"=\"",
"+",
"kwargs",
"[",
"key",
"]",
"+",
... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | search_position | Query based on position and time (+/- 1 day):
http://asterank.com/api/skymorph/search_position?<params>
ra Right ascension (HMS)
Dec Declination (DMS)
time Date and time (UTC)
per_date Perihelion date ([M]JD or ISO)
om Longitude of ascending node (deg)
w Argument of perihelion (deg)
i I... | bowshock/skymorph.py | def search_position(**kwargs):
'''
Query based on position and time (+/- 1 day):
http://asterank.com/api/skymorph/search_position?<params>
ra Right ascension (HMS)
Dec Declination (DMS)
time Date and time (UTC)
per_date Perihelion date ([M]JD or ISO)
om Longitude of ascending node (deg)... | def search_position(**kwargs):
'''
Query based on position and time (+/- 1 day):
http://asterank.com/api/skymorph/search_position?<params>
ra Right ascension (HMS)
Dec Declination (DMS)
time Date and time (UTC)
per_date Perihelion date ([M]JD or ISO)
om Longitude of ascending node (deg)... | [
"Query",
"based",
"on",
"position",
"and",
"time",
"(",
"+",
"/",
"-",
"1",
"day",
")",
":"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/skymorph.py#L53-L77 | [
"def",
"search_position",
"(",
"*",
"*",
"kwargs",
")",
":",
"base_url",
"=",
"\"http://asterank.com/api/skymorph/search_position?\"",
"for",
"key",
"in",
"kwargs",
":",
"base_url",
"+=",
"str",
"(",
"key",
")",
"+",
"\"=\"",
"+",
"kwargs",
"[",
"key",
"]",
... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | collection_to_included_trees | Takes a collection object (or a filepath to collection object), returns
each element of the `decisions` list that has the decision set to included. | peyotl/collections_store/__init__.py | def collection_to_included_trees(collection):
"""Takes a collection object (or a filepath to collection object), returns
each element of the `decisions` list that has the decision set to included.
"""
if is_str_type(collection):
collection = read_as_json(collection)
inc = []
for d in col... | def collection_to_included_trees(collection):
"""Takes a collection object (or a filepath to collection object), returns
each element of the `decisions` list that has the decision set to included.
"""
if is_str_type(collection):
collection = read_as_json(collection)
inc = []
for d in col... | [
"Takes",
"a",
"collection",
"object",
"(",
"or",
"a",
"filepath",
"to",
"collection",
"object",
")",
"returns",
"each",
"element",
"of",
"the",
"decisions",
"list",
"that",
"has",
"the",
"decision",
"set",
"to",
"included",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/__init__.py#L33-L43 | [
"def",
"collection_to_included_trees",
"(",
"collection",
")",
":",
"if",
"is_str_type",
"(",
"collection",
")",
":",
"collection",
"=",
"read_as_json",
"(",
"collection",
")",
"inc",
"=",
"[",
"]",
"for",
"d",
"in",
"collection",
".",
"get",
"(",
"'decision... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | tree_is_in_collection | Takes a collection object (or a filepath to collection object), returns
True if it includes a decision to include the specified tree | peyotl/collections_store/__init__.py | def tree_is_in_collection(collection, study_id=None, tree_id=None):
"""Takes a collection object (or a filepath to collection object), returns
True if it includes a decision to include the specified tree
"""
included = collection_to_included_trees(collection)
study_id = study_id.strip()
tree_id ... | def tree_is_in_collection(collection, study_id=None, tree_id=None):
"""Takes a collection object (or a filepath to collection object), returns
True if it includes a decision to include the specified tree
"""
included = collection_to_included_trees(collection)
study_id = study_id.strip()
tree_id ... | [
"Takes",
"a",
"collection",
"object",
"(",
"or",
"a",
"filepath",
"to",
"collection",
"object",
")",
"returns",
"True",
"if",
"it",
"includes",
"a",
"decision",
"to",
"include",
"the",
"specified",
"tree"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/__init__.py#L45-L55 | [
"def",
"tree_is_in_collection",
"(",
"collection",
",",
"study_id",
"=",
"None",
",",
"tree_id",
"=",
"None",
")",
":",
"included",
"=",
"collection_to_included_trees",
"(",
"collection",
")",
"study_id",
"=",
"study_id",
".",
"strip",
"(",
")",
"tree_id",
"="... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | validate_config | Call jsonschema validation to raise JSONValidation on non-compliance or silently pass.
:param key: validation schema key of interest
:param config: configuration dict to validate | von_agent/validate_config.py | def validate_config(key: str, config: dict) -> None:
"""
Call jsonschema validation to raise JSONValidation on non-compliance or silently pass.
:param key: validation schema key of interest
:param config: configuration dict to validate
"""
try:
jsonschema.validate(config, CONFIG_JSON_S... | def validate_config(key: str, config: dict) -> None:
"""
Call jsonschema validation to raise JSONValidation on non-compliance or silently pass.
:param key: validation schema key of interest
:param config: configuration dict to validate
"""
try:
jsonschema.validate(config, CONFIG_JSON_S... | [
"Call",
"jsonschema",
"validation",
"to",
"raise",
"JSONValidation",
"on",
"non",
"-",
"compliance",
"or",
"silently",
"pass",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/validate_config.py#L86-L99 | [
"def",
"validate_config",
"(",
"key",
":",
"str",
",",
"config",
":",
"dict",
")",
"->",
"None",
":",
"try",
":",
"jsonschema",
".",
"validate",
"(",
"config",
",",
"CONFIG_JSON_SCHEMA",
"[",
"key",
"]",
")",
"except",
"jsonschema",
".",
"ValidationError",... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | __make_id | Generate an identifier for a callable signal receiver.
This is used when disconnecting receivers, where we need to correctly
establish equivalence between the input receiver and the receivers assigned
to a signal.
Args:
receiver: A callable object.
Returns:
An identifier for the r... | mixbox/signals.py | def __make_id(receiver):
"""Generate an identifier for a callable signal receiver.
This is used when disconnecting receivers, where we need to correctly
establish equivalence between the input receiver and the receivers assigned
to a signal.
Args:
receiver: A callable object.
Returns:... | def __make_id(receiver):
"""Generate an identifier for a callable signal receiver.
This is used when disconnecting receivers, where we need to correctly
establish equivalence between the input receiver and the receivers assigned
to a signal.
Args:
receiver: A callable object.
Returns:... | [
"Generate",
"an",
"identifier",
"for",
"a",
"callable",
"signal",
"receiver",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/signals.py#L41-L56 | [
"def",
"__make_id",
"(",
"receiver",
")",
":",
"if",
"__is_bound_method",
"(",
"receiver",
")",
":",
"return",
"(",
"id",
"(",
"receiver",
".",
"__func__",
")",
",",
"id",
"(",
"receiver",
".",
"__self__",
")",
")",
"return",
"id",
"(",
"receiver",
")"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | __purge | Remove all dead signal receivers from the global receivers collection.
Note:
It is assumed that the caller holds the __lock. | mixbox/signals.py | def __purge():
"""Remove all dead signal receivers from the global receivers collection.
Note:
It is assumed that the caller holds the __lock.
"""
global __receivers
newreceivers = collections.defaultdict(list)
for signal, receivers in six.iteritems(__receivers):
alive = [x for... | def __purge():
"""Remove all dead signal receivers from the global receivers collection.
Note:
It is assumed that the caller holds the __lock.
"""
global __receivers
newreceivers = collections.defaultdict(list)
for signal, receivers in six.iteritems(__receivers):
alive = [x for... | [
"Remove",
"all",
"dead",
"signal",
"receivers",
"from",
"the",
"global",
"receivers",
"collection",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/signals.py#L59-L72 | [
"def",
"__purge",
"(",
")",
":",
"global",
"__receivers",
"newreceivers",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"signal",
",",
"receivers",
"in",
"six",
".",
"iteritems",
"(",
"__receivers",
")",
":",
"alive",
"=",
"[",
"x",
"f... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | __live_receivers | Return all signal handlers that are currently still alive for the
input `signal`.
Args:
signal: A signal name.
Returns:
A list of callable receivers for the input signal. | mixbox/signals.py | def __live_receivers(signal):
"""Return all signal handlers that are currently still alive for the
input `signal`.
Args:
signal: A signal name.
Returns:
A list of callable receivers for the input signal.
"""
with __lock:
__purge()
receivers = [funcref() for func... | def __live_receivers(signal):
"""Return all signal handlers that are currently still alive for the
input `signal`.
Args:
signal: A signal name.
Returns:
A list of callable receivers for the input signal.
"""
with __lock:
__purge()
receivers = [funcref() for func... | [
"Return",
"all",
"signal",
"handlers",
"that",
"are",
"currently",
"still",
"alive",
"for",
"the",
"input",
"signal",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/signals.py#L75-L89 | [
"def",
"__live_receivers",
"(",
"signal",
")",
":",
"with",
"__lock",
":",
"__purge",
"(",
")",
"receivers",
"=",
"[",
"funcref",
"(",
")",
"for",
"funcref",
"in",
"__receivers",
"[",
"signal",
"]",
"]",
"return",
"receivers"
] | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | __is_bound_method | Return ``True`` if the `method` is a bound method (attached to an class
instance.
Args:
method: A method or function type object. | mixbox/signals.py | def __is_bound_method(method):
"""Return ``True`` if the `method` is a bound method (attached to an class
instance.
Args:
method: A method or function type object.
"""
if not(hasattr(method, "__func__") and hasattr(method, "__self__")):
return False
# Bound methods have a __sel... | def __is_bound_method(method):
"""Return ``True`` if the `method` is a bound method (attached to an class
instance.
Args:
method: A method or function type object.
"""
if not(hasattr(method, "__func__") and hasattr(method, "__self__")):
return False
# Bound methods have a __sel... | [
"Return",
"True",
"if",
"the",
"method",
"is",
"a",
"bound",
"method",
"(",
"attached",
"to",
"an",
"class",
"instance",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/signals.py#L92-L103 | [
"def",
"__is_bound_method",
"(",
"method",
")",
":",
"if",
"not",
"(",
"hasattr",
"(",
"method",
",",
"\"__func__\"",
")",
"and",
"hasattr",
"(",
"method",
",",
"\"__self__\"",
")",
")",
":",
"return",
"False",
"# Bound methods have a __self__ attribute pointing t... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | connect | Register `receiver` method/function as a receiver for the `signal`.
When the signal is emitted, this receiver will be invoked along with
all other associated signals.
Args:
signal: A signal identifier (e.g., a signal name)
receiver: A callable object to connect to the signal. | mixbox/signals.py | def connect(signal, receiver):
"""Register `receiver` method/function as a receiver for the `signal`.
When the signal is emitted, this receiver will be invoked along with
all other associated signals.
Args:
signal: A signal identifier (e.g., a signal name)
receiver: A callable object t... | def connect(signal, receiver):
"""Register `receiver` method/function as a receiver for the `signal`.
When the signal is emitted, this receiver will be invoked along with
all other associated signals.
Args:
signal: A signal identifier (e.g., a signal name)
receiver: A callable object t... | [
"Register",
"receiver",
"method",
"/",
"function",
"as",
"a",
"receiver",
"for",
"the",
"signal",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/signals.py#L127-L146 | [
"def",
"connect",
"(",
"signal",
",",
"receiver",
")",
":",
"__check_receiver",
"(",
"receiver",
")",
"if",
"__is_bound_method",
"(",
"receiver",
")",
":",
"ref",
"=",
"WeakMethod",
"else",
":",
"ref",
"=",
"weakref",
".",
"ref",
"with",
"__lock",
":",
"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | disconnect | Disconnect the receiver `func` from the signal, identified by
`signal_id`.
Args:
signal: The signal identifier.
receiver: The callable receiver to disconnect.
Returns:
True if the receiver was successfully disconnected. False otherwise. | mixbox/signals.py | def disconnect(signal, receiver):
"""Disconnect the receiver `func` from the signal, identified by
`signal_id`.
Args:
signal: The signal identifier.
receiver: The callable receiver to disconnect.
Returns:
True if the receiver was successfully disconnected. False otherwise.
... | def disconnect(signal, receiver):
"""Disconnect the receiver `func` from the signal, identified by
`signal_id`.
Args:
signal: The signal identifier.
receiver: The callable receiver to disconnect.
Returns:
True if the receiver was successfully disconnected. False otherwise.
... | [
"Disconnect",
"the",
"receiver",
"func",
"from",
"the",
"signal",
"identified",
"by",
"signal_id",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/signals.py#L149-L175 | [
"def",
"disconnect",
"(",
"signal",
",",
"receiver",
")",
":",
"inputkey",
"=",
"__make_id",
"(",
"receiver",
")",
"with",
"__lock",
":",
"__purge",
"(",
")",
"receivers",
"=",
"__receivers",
".",
"get",
"(",
"signal",
")",
"for",
"idx",
"in",
"six",
"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | emit | Emit a signal by serially calling each registered signal receiver for
the `signal`.
Note:
The receiver must accept the *args and/or **kwargs that have been
passed to it. There expected parameters are not dictated by
mixbox.
Args:
signal: A signal identifier or name.... | mixbox/signals.py | def emit(signal, *args, **kwargs):
"""Emit a signal by serially calling each registered signal receiver for
the `signal`.
Note:
The receiver must accept the *args and/or **kwargs that have been
passed to it. There expected parameters are not dictated by
mixbox.
Args:
... | def emit(signal, *args, **kwargs):
"""Emit a signal by serially calling each registered signal receiver for
the `signal`.
Note:
The receiver must accept the *args and/or **kwargs that have been
passed to it. There expected parameters are not dictated by
mixbox.
Args:
... | [
"Emit",
"a",
"signal",
"by",
"serially",
"calling",
"each",
"registered",
"signal",
"receiver",
"for",
"the",
"signal",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/signals.py#L194-L214 | [
"def",
"emit",
"(",
"signal",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"signal",
"not",
"in",
"__receivers",
":",
"return",
"receivers",
"=",
"__live_receivers",
"(",
"signal",
")",
"for",
"func",
"in",
"receivers",
":",
"func",
"(",
... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | arrayuniqify | Very fast uniqify routine for numpy arrays.
**Parameters**
**X** : numpy array
Determine the unique elements of this numpy array.
**retainorder** : Boolean, optional
Whether or not to return indices corresponding to unique
v... | tabular/fast.py | def arrayuniqify(X, retainorder=False):
"""
Very fast uniqify routine for numpy arrays.
**Parameters**
**X** : numpy array
Determine the unique elements of this numpy array.
**retainorder** : Boolean, optional
Whether or not to return in... | def arrayuniqify(X, retainorder=False):
"""
Very fast uniqify routine for numpy arrays.
**Parameters**
**X** : numpy array
Determine the unique elements of this numpy array.
**retainorder** : Boolean, optional
Whether or not to return in... | [
"Very",
"fast",
"uniqify",
"routine",
"for",
"numpy",
"arrays",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/fast.py#L19-L75 | [
"def",
"arrayuniqify",
"(",
"X",
",",
"retainorder",
"=",
"False",
")",
":",
"s",
"=",
"X",
".",
"argsort",
"(",
")",
"X",
"=",
"X",
"[",
"s",
"]",
"D",
"=",
"np",
".",
"append",
"(",
"[",
"True",
"]",
",",
"X",
"[",
"1",
":",
"]",
"!=",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | recarrayuniqify | Very fast uniqify routine for numpy record arrays (or ndarrays with
structured dtype).
Record array version of func:`tabular.fast.arrayuniqify`.
**Parameters**
**X** : numpy recarray
Determine the unique elements of this numpy recarray.
**retainorder** : B... | tabular/fast.py | def recarrayuniqify(X, retainorder=False):
"""
Very fast uniqify routine for numpy record arrays (or ndarrays with
structured dtype).
Record array version of func:`tabular.fast.arrayuniqify`.
**Parameters**
**X** : numpy recarray
Determine the unique elements of... | def recarrayuniqify(X, retainorder=False):
"""
Very fast uniqify routine for numpy record arrays (or ndarrays with
structured dtype).
Record array version of func:`tabular.fast.arrayuniqify`.
**Parameters**
**X** : numpy recarray
Determine the unique elements of... | [
"Very",
"fast",
"uniqify",
"routine",
"for",
"numpy",
"record",
"arrays",
"(",
"or",
"ndarrays",
"with",
"structured",
"dtype",
")",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/fast.py#L78-L139 | [
"def",
"recarrayuniqify",
"(",
"X",
",",
"retainorder",
"=",
"False",
")",
":",
"N",
"=",
"X",
".",
"dtype",
".",
"names",
"s",
"=",
"X",
".",
"argsort",
"(",
"order",
"=",
"N",
")",
"s",
"=",
"s",
".",
"view",
"(",
"np",
".",
"ndarray",
")",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | equalspairs | Indices of elements in a sorted numpy array equal to those in another.
Given numpy array `X` and sorted numpy array `Y`, determine the indices in
Y equal to indices in X.
Returns `[A,B]` where `A` and `B` are numpy arrays of indices in `X` such
that::
Y[A[i]:B[i]] = Y[Y == X[i]]`
`... | tabular/fast.py | def equalspairs(X, Y):
"""
Indices of elements in a sorted numpy array equal to those in another.
Given numpy array `X` and sorted numpy array `Y`, determine the indices in
Y equal to indices in X.
Returns `[A,B]` where `A` and `B` are numpy arrays of indices in `X` such
that::
... | def equalspairs(X, Y):
"""
Indices of elements in a sorted numpy array equal to those in another.
Given numpy array `X` and sorted numpy array `Y`, determine the indices in
Y equal to indices in X.
Returns `[A,B]` where `A` and `B` are numpy arrays of indices in `X` such
that::
... | [
"Indices",
"of",
"elements",
"in",
"a",
"sorted",
"numpy",
"array",
"equal",
"to",
"those",
"in",
"another",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/fast.py#L142-L191 | [
"def",
"equalspairs",
"(",
"X",
",",
"Y",
")",
":",
"T",
"=",
"Y",
".",
"copy",
"(",
")",
"R",
"=",
"(",
"T",
"[",
"1",
":",
"]",
"!=",
"T",
"[",
":",
"-",
"1",
"]",
")",
".",
"nonzero",
"(",
")",
"[",
"0",
"]",
"R",
"=",
"np",
".",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | recarrayequalspairs | Indices of elements in a sorted numpy recarray (or ndarray with
structured dtype) equal to those in another.
Record array version of func:`tabular.fast.equalspairs`, but slightly
different because the concept of being sorted is less well-defined for a
record array.
Given numpy recarray `X` and ... | tabular/fast.py | def recarrayequalspairs(X,Y,weak=True):
"""
Indices of elements in a sorted numpy recarray (or ndarray with
structured dtype) equal to those in another.
Record array version of func:`tabular.fast.equalspairs`, but slightly
different because the concept of being sorted is less well-defined for a
... | def recarrayequalspairs(X,Y,weak=True):
"""
Indices of elements in a sorted numpy recarray (or ndarray with
structured dtype) equal to those in another.
Record array version of func:`tabular.fast.equalspairs`, but slightly
different because the concept of being sorted is less well-defined for a
... | [
"Indices",
"of",
"elements",
"in",
"a",
"sorted",
"numpy",
"recarray",
"(",
"or",
"ndarray",
"with",
"structured",
"dtype",
")",
"equal",
"to",
"those",
"in",
"another",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/fast.py#L194-L257 | [
"def",
"recarrayequalspairs",
"(",
"X",
",",
"Y",
",",
"weak",
"=",
"True",
")",
":",
"if",
"(",
"weak",
"and",
"set",
"(",
"X",
".",
"dtype",
".",
"names",
")",
"!=",
"set",
"(",
"Y",
".",
"dtype",
".",
"names",
")",
")",
"or",
"(",
"not",
"... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | isin | Indices of elements in a numpy array that appear in another.
Fast routine for determining indices of elements in numpy array `X` that
appear in numpy array `Y`, returning a boolean array `Z` such that::
Z[i] = X[i] in Y
**Parameters**
**X** : numpy array
Nu... | tabular/fast.py | def isin(X,Y):
"""
Indices of elements in a numpy array that appear in another.
Fast routine for determining indices of elements in numpy array `X` that
appear in numpy array `Y`, returning a boolean array `Z` such that::
Z[i] = X[i] in Y
**Parameters**
**X** : numpy ar... | def isin(X,Y):
"""
Indices of elements in a numpy array that appear in another.
Fast routine for determining indices of elements in numpy array `X` that
appear in numpy array `Y`, returning a boolean array `Z` such that::
Z[i] = X[i] in Y
**Parameters**
**X** : numpy ar... | [
"Indices",
"of",
"elements",
"in",
"a",
"numpy",
"array",
"that",
"appear",
"in",
"another",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/fast.py#L260-L304 | [
"def",
"isin",
"(",
"X",
",",
"Y",
")",
":",
"if",
"len",
"(",
"Y",
")",
">",
"0",
":",
"T",
"=",
"Y",
".",
"copy",
"(",
")",
"T",
".",
"sort",
"(",
")",
"D",
"=",
"T",
".",
"searchsorted",
"(",
"X",
")",
"T",
"=",
"np",
".",
"append",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | recarrayisin | Indices of elements in a numpy record array (or ndarray with structured
dtype) that appear in another.
Fast routine for determining indices of elements in numpy record array `X`
that appear in numpy record array `Y`, returning a boolean array `Z` such
that::
Z[i] = X[i] in Y
Record... | tabular/fast.py | def recarrayisin(X,Y,weak=True):
"""
Indices of elements in a numpy record array (or ndarray with structured
dtype) that appear in another.
Fast routine for determining indices of elements in numpy record array `X`
that appear in numpy record array `Y`, returning a boolean array `Z` such
tha... | def recarrayisin(X,Y,weak=True):
"""
Indices of elements in a numpy record array (or ndarray with structured
dtype) that appear in another.
Fast routine for determining indices of elements in numpy record array `X`
that appear in numpy record array `Y`, returning a boolean array `Z` such
tha... | [
"Indices",
"of",
"elements",
"in",
"a",
"numpy",
"record",
"array",
"(",
"or",
"ndarray",
"with",
"structured",
"dtype",
")",
"that",
"appear",
"in",
"another",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/fast.py#L308-L354 | [
"def",
"recarrayisin",
"(",
"X",
",",
"Y",
",",
"weak",
"=",
"True",
")",
":",
"if",
"(",
"weak",
"and",
"set",
"(",
"X",
".",
"dtype",
".",
"names",
")",
"!=",
"set",
"(",
"Y",
".",
"dtype",
".",
"names",
")",
")",
"or",
"(",
"not",
"weak",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | arraydifference | Elements of a numpy array that do not appear in another.
Fast routine for determining which elements in numpy array `X`
do not appear in numpy array `Y`.
**Parameters**
**X** : numpy array
Numpy array to comapare to numpy array `Y`.
Return subset of `... | tabular/fast.py | def arraydifference(X,Y):
"""
Elements of a numpy array that do not appear in another.
Fast routine for determining which elements in numpy array `X`
do not appear in numpy array `Y`.
**Parameters**
**X** : numpy array
Numpy array to comapare to numpy array `Y`.
... | def arraydifference(X,Y):
"""
Elements of a numpy array that do not appear in another.
Fast routine for determining which elements in numpy array `X`
do not appear in numpy array `Y`.
**Parameters**
**X** : numpy array
Numpy array to comapare to numpy array `Y`.
... | [
"Elements",
"of",
"a",
"numpy",
"array",
"that",
"do",
"not",
"appear",
"in",
"another",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/fast.py#L357-L391 | [
"def",
"arraydifference",
"(",
"X",
",",
"Y",
")",
":",
"if",
"len",
"(",
"Y",
")",
">",
"0",
":",
"Z",
"=",
"isin",
"(",
"X",
",",
"Y",
")",
"return",
"X",
"[",
"np",
".",
"invert",
"(",
"Z",
")",
"]",
"else",
":",
"return",
"X"
] | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | recarraydifference | Records of a numpy recarray (or ndarray with structured dtype)
that do not appear in another.
Fast routine for determining which records in numpy array `X`
do not appear in numpy recarray `Y`.
Record array version of func:`tabular.fast.arraydifference`.
**Parameters**
**X** : numpy ... | tabular/fast.py | def recarraydifference(X,Y):
"""
Records of a numpy recarray (or ndarray with structured dtype)
that do not appear in another.
Fast routine for determining which records in numpy array `X`
do not appear in numpy recarray `Y`.
Record array version of func:`tabular.fast.arraydifference`.
**... | def recarraydifference(X,Y):
"""
Records of a numpy recarray (or ndarray with structured dtype)
that do not appear in another.
Fast routine for determining which records in numpy array `X`
do not appear in numpy recarray `Y`.
Record array version of func:`tabular.fast.arraydifference`.
**... | [
"Records",
"of",
"a",
"numpy",
"recarray",
"(",
"or",
"ndarray",
"with",
"structured",
"dtype",
")",
"that",
"do",
"not",
"appear",
"in",
"another",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/fast.py#L394-L431 | [
"def",
"recarraydifference",
"(",
"X",
",",
"Y",
")",
":",
"if",
"len",
"(",
"Y",
")",
">",
"0",
":",
"Z",
"=",
"recarrayisin",
"(",
"X",
",",
"Y",
")",
"return",
"X",
"[",
"np",
".",
"invert",
"(",
"Z",
")",
"]",
"else",
":",
"return",
"X"
] | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | arraymax | Fast "vectorized" max function for element-wise comparison of two numpy arrays.
For two numpy arrays `X` and `Y` of equal length,
return numpy array `Z` such that::
Z[i] = max(X[i],Y[i])
**Parameters**
**X** : numpy array
Numpy array; `len(X) = len(Y)`.
... | tabular/fast.py | def arraymax(X,Y):
"""
Fast "vectorized" max function for element-wise comparison of two numpy arrays.
For two numpy arrays `X` and `Y` of equal length,
return numpy array `Z` such that::
Z[i] = max(X[i],Y[i])
**Parameters**
**X** : numpy array
Numpy... | def arraymax(X,Y):
"""
Fast "vectorized" max function for element-wise comparison of two numpy arrays.
For two numpy arrays `X` and `Y` of equal length,
return numpy array `Z` such that::
Z[i] = max(X[i],Y[i])
**Parameters**
**X** : numpy array
Numpy... | [
"Fast",
"vectorized",
"max",
"function",
"for",
"element",
"-",
"wise",
"comparison",
"of",
"two",
"numpy",
"arrays",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/fast.py#L434-L469 | [
"def",
"arraymax",
"(",
"X",
",",
"Y",
")",
":",
"Z",
"=",
"np",
".",
"zeros",
"(",
"(",
"len",
"(",
"X",
")",
",",
")",
",",
"int",
")",
"A",
"=",
"X",
"<=",
"Y",
"B",
"=",
"Y",
"<",
"X",
"Z",
"[",
"A",
"]",
"=",
"Y",
"[",
"A",
"]"... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | Wallet._seed2did | Derive DID, as per indy-sdk, from seed.
:return: DID | von_agent/wallet.py | async def _seed2did(self) -> str:
"""
Derive DID, as per indy-sdk, from seed.
:return: DID
"""
rv = None
dids_with_meta = json.loads(await did.list_my_dids_with_meta(self.handle)) # list
if dids_with_meta:
for did_with_meta in dids_with_meta: # di... | async def _seed2did(self) -> str:
"""
Derive DID, as per indy-sdk, from seed.
:return: DID
"""
rv = None
dids_with_meta = json.loads(await did.list_my_dids_with_meta(self.handle)) # list
if dids_with_meta:
for did_with_meta in dids_with_meta: # di... | [
"Derive",
"DID",
"as",
"per",
"indy",
"-",
"sdk",
"from",
"seed",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/wallet.py#L181-L211 | [
"async",
"def",
"_seed2did",
"(",
"self",
")",
"->",
"str",
":",
"rv",
"=",
"None",
"dids_with_meta",
"=",
"json",
".",
"loads",
"(",
"await",
"did",
".",
"list_my_dids_with_meta",
"(",
"self",
".",
"handle",
")",
")",
"# list",
"if",
"dids_with_meta",
"... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | Wallet.create | Create wallet as configured and store DID, or else re-use any existing configuration.
Operation sequence create/store-DID/close does not auto-remove the wallet on close,
even if so configured.
:return: current object | von_agent/wallet.py | async def create(self) -> 'Wallet':
"""
Create wallet as configured and store DID, or else re-use any existing configuration.
Operation sequence create/store-DID/close does not auto-remove the wallet on close,
even if so configured.
:return: current object
"""
L... | async def create(self) -> 'Wallet':
"""
Create wallet as configured and store DID, or else re-use any existing configuration.
Operation sequence create/store-DID/close does not auto-remove the wallet on close,
even if so configured.
:return: current object
"""
L... | [
"Create",
"wallet",
"as",
"configured",
"and",
"store",
"DID",
"or",
"else",
"re",
"-",
"use",
"any",
"existing",
"configuration",
".",
"Operation",
"sequence",
"create",
"/",
"store",
"-",
"DID",
"/",
"close",
"does",
"not",
"auto",
"-",
"remove",
"the",
... | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/wallet.py#L213-L272 | [
"async",
"def",
"create",
"(",
"self",
")",
"->",
"'Wallet'",
":",
"LOGGER",
".",
"debug",
"(",
"'Wallet.create >>>'",
")",
"try",
":",
"await",
"wallet",
".",
"create_wallet",
"(",
"config",
"=",
"json",
".",
"dumps",
"(",
"self",
".",
"cfg",
")",
","... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | Wallet.open | Explicit entry. Open wallet as configured, for later closure via close().
For use when keeping wallet open across multiple calls.
:return: current object | von_agent/wallet.py | async def open(self) -> 'Wallet':
"""
Explicit entry. Open wallet as configured, for later closure via close().
For use when keeping wallet open across multiple calls.
:return: current object
"""
LOGGER.debug('Wallet.open >>>')
if not self.created:
... | async def open(self) -> 'Wallet':
"""
Explicit entry. Open wallet as configured, for later closure via close().
For use when keeping wallet open across multiple calls.
:return: current object
"""
LOGGER.debug('Wallet.open >>>')
if not self.created:
... | [
"Explicit",
"entry",
".",
"Open",
"wallet",
"as",
"configured",
"for",
"later",
"closure",
"via",
"close",
"()",
".",
"For",
"use",
"when",
"keeping",
"wallet",
"open",
"across",
"multiple",
"calls",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/wallet.py#L291-L315 | [
"async",
"def",
"open",
"(",
"self",
")",
"->",
"'Wallet'",
":",
"LOGGER",
".",
"debug",
"(",
"'Wallet.open >>>'",
")",
"if",
"not",
"self",
".",
"created",
":",
"LOGGER",
".",
"debug",
"(",
"'Wallet.open: <!< absent wallet %s'",
",",
"self",
".",
"name",
... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | Wallet.remove | Remove serialized wallet if it exists. | von_agent/wallet.py | async def remove(self) -> None:
"""
Remove serialized wallet if it exists.
"""
LOGGER.debug('Wallet.remove >>>')
try:
LOGGER.info('Removing wallet: %s', self.name)
await wallet.delete_wallet(json.dumps(self.cfg), json.dumps(self.access_creds))
ex... | async def remove(self) -> None:
"""
Remove serialized wallet if it exists.
"""
LOGGER.debug('Wallet.remove >>>')
try:
LOGGER.info('Removing wallet: %s', self.name)
await wallet.delete_wallet(json.dumps(self.cfg), json.dumps(self.access_creds))
ex... | [
"Remove",
"serialized",
"wallet",
"if",
"it",
"exists",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/wallet.py#L353-L366 | [
"async",
"def",
"remove",
"(",
"self",
")",
"->",
"None",
":",
"LOGGER",
".",
"debug",
"(",
"'Wallet.remove >>>'",
")",
"try",
":",
"LOGGER",
".",
"info",
"(",
"'Removing wallet: %s'",
",",
"self",
".",
"name",
")",
"await",
"wallet",
".",
"delete_wallet",... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | _PhylesystemAPIWrapper.push_failure_state | Returns a tuple: the boolean for whether or not pushes succeed, and the
entire object returned by a call to push_failure on the phylesystem-api.
This should only be called with wrappers around remote services (RuntimeError
will be raised if you call this with a local wrapper. | peyotl/api/phylesystem_api.py | def push_failure_state(self):
"""Returns a tuple: the boolean for whether or not pushes succeed, and the
entire object returned by a call to push_failure on the phylesystem-api.
This should only be called with wrappers around remote services (RuntimeError
will be raised if you call this ... | def push_failure_state(self):
"""Returns a tuple: the boolean for whether or not pushes succeed, and the
entire object returned by a call to push_failure on the phylesystem-api.
This should only be called with wrappers around remote services (RuntimeError
will be raised if you call this ... | [
"Returns",
"a",
"tuple",
":",
"the",
"boolean",
"for",
"whether",
"or",
"not",
"pushes",
"succeed",
"and",
"the",
"entire",
"object",
"returned",
"by",
"a",
"call",
"to",
"push_failure",
"on",
"the",
"phylesystem",
"-",
"api",
".",
"This",
"should",
"only"... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/api/phylesystem_api.py#L97-L106 | [
"def",
"push_failure_state",
"(",
"self",
")",
":",
"if",
"self",
".",
"_src_code",
"==",
"_GET_LOCAL",
":",
"raise",
"RuntimeError",
"(",
"'push_failure_state only pertains to work with remote phyleysystem instances'",
")",
"r",
"=",
"self",
".",
"_remote_push_failure",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _PhylesystemAPIWrapper.get | Syntactic sugar around to make it easier to get fine-grained access
to the parts of a file without composing a PhyloSchema object.
Possible invocations include:
w.get('pg_10')
w.get('pg_10', 'trees')
w.get('pg_10', 'trees', format='nexus')
w.get('pg_10', t... | peyotl/api/phylesystem_api.py | def get(self, study_id, content=None, schema=None, **kwargs):
"""Syntactic sugar around to make it easier to get fine-grained access
to the parts of a file without composing a PhyloSchema object.
Possible invocations include:
w.get('pg_10')
w.get('pg_10', 'trees')
... | def get(self, study_id, content=None, schema=None, **kwargs):
"""Syntactic sugar around to make it easier to get fine-grained access
to the parts of a file without composing a PhyloSchema object.
Possible invocations include:
w.get('pg_10')
w.get('pg_10', 'trees')
... | [
"Syntactic",
"sugar",
"around",
"to",
"make",
"it",
"easier",
"to",
"get",
"fine",
"-",
"grained",
"access",
"to",
"the",
"parts",
"of",
"a",
"file",
"without",
"composing",
"a",
"PhyloSchema",
"object",
".",
"Possible",
"invocations",
"include",
":",
"w",
... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/api/phylesystem_api.py#L108-L133 | [
"def",
"get",
"(",
"self",
",",
"study_id",
",",
"content",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"study_id",
",",
"TreeRef",
")",
":",
"return",
"self",
".",
"get",
"(",
"study_id",
"=... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | loadSV | Load a delimited text file to a numpy record array.
Basically, this function calls loadSVcols and combines columns returned by
that function into a numpy ndarray with stuctured dtype. Also uses and
returns metadata including column names, formats, coloring, &c. if these
items are determined during ... | tabular/io.py | def loadSV(fname, shape=None, titles=None, aligned=False, byteorder=None,
renamer=None, **kwargs):
"""
Load a delimited text file to a numpy record array.
Basically, this function calls loadSVcols and combines columns returned by
that function into a numpy ndarray with stuctured dtype. A... | def loadSV(fname, shape=None, titles=None, aligned=False, byteorder=None,
renamer=None, **kwargs):
"""
Load a delimited text file to a numpy record array.
Basically, this function calls loadSVcols and combines columns returned by
that function into a numpy ndarray with stuctured dtype. A... | [
"Load",
"a",
"delimited",
"text",
"file",
"to",
"a",
"numpy",
"record",
"array",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L39-L152 | [
"def",
"loadSV",
"(",
"fname",
",",
"shape",
"=",
"None",
",",
"titles",
"=",
"None",
",",
"aligned",
"=",
"False",
",",
"byteorder",
"=",
"None",
",",
"renamer",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"[",
"columns",
",",
"metadata",
"]",... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | loadSVcols | Load a separated value text file to a list of column arrays.
Basically, this function calls loadSVrecs, and transposes the string-valued
row data returned by that function into a Python list of numpy arrays
corresponding to columns, each a uniform Python type (int, float, str).
Also uses and return... | tabular/io.py | def loadSVcols(fname, usecols=None, excludecols=None, valuefixer=None,
colfixer=None, missingvalues=None, fillingvalues=None,
typeinferer=None, **kwargs):
"""
Load a separated value text file to a list of column arrays.
Basically, this function calls loadSVrecs, and transpose... | def loadSVcols(fname, usecols=None, excludecols=None, valuefixer=None,
colfixer=None, missingvalues=None, fillingvalues=None,
typeinferer=None, **kwargs):
"""
Load a separated value text file to a list of column arrays.
Basically, this function calls loadSVrecs, and transpose... | [
"Load",
"a",
"separated",
"value",
"text",
"file",
"to",
"a",
"list",
"of",
"column",
"arrays",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L155-L348 | [
"def",
"loadSVcols",
"(",
"fname",
",",
"usecols",
"=",
"None",
",",
"excludecols",
"=",
"None",
",",
"valuefixer",
"=",
"None",
",",
"colfixer",
"=",
"None",
",",
"missingvalues",
"=",
"None",
",",
"fillingvalues",
"=",
"None",
",",
"typeinferer",
"=",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | loadSVrecs | Load a separated value text file to a list of lists of strings of records.
Takes a tabular text file with a specified delimeter and end-of-line
character, and return data as a list of lists of strings corresponding to
records (rows). Also uses and returns metadata (including column names,
formats, ... | tabular/io.py | def loadSVrecs(fname, uselines=None, skiprows=0, linefixer=None,
delimiter_regex=None, verbosity=DEFAULT_VERBOSITY, **metadata):
"""
Load a separated value text file to a list of lists of strings of records.
Takes a tabular text file with a specified delimeter and end-of-line
character... | def loadSVrecs(fname, uselines=None, skiprows=0, linefixer=None,
delimiter_regex=None, verbosity=DEFAULT_VERBOSITY, **metadata):
"""
Load a separated value text file to a list of lists of strings of records.
Takes a tabular text file with a specified delimeter and end-of-line
character... | [
"Load",
"a",
"separated",
"value",
"text",
"file",
"to",
"a",
"list",
"of",
"lists",
"of",
"strings",
"of",
"records",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L401-L572 | [
"def",
"loadSVrecs",
"(",
"fname",
",",
"uselines",
"=",
"None",
",",
"skiprows",
"=",
"0",
",",
"linefixer",
"=",
"None",
",",
"delimiter_regex",
"=",
"None",
",",
"verbosity",
"=",
"DEFAULT_VERBOSITY",
",",
"*",
"*",
"metadata",
")",
":",
"if",
"delimi... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | saveSV | Save a tabarray to a separated-variable (CSV) file.
**Parameters**
**fname** : string
Path to a separated variable (CSV) text file.
**X** : tabarray
The actual data in a :class:`tabular.tab.tabarray`.
**comments** : string, optional
The character... | tabular/io.py | def saveSV(fname, X, comments=None, metadata=None, printmetadict=None,
dialect=None, delimiter=None, doublequote=True,
lineterminator='\n', escapechar = None,
quoting=csv.QUOTE_MINIMAL, quotechar='"',
skipinitialspace=False, stringifier=None... | def saveSV(fname, X, comments=None, metadata=None, printmetadict=None,
dialect=None, delimiter=None, doublequote=True,
lineterminator='\n', escapechar = None,
quoting=csv.QUOTE_MINIMAL, quotechar='"',
skipinitialspace=False, stringifier=None... | [
"Save",
"a",
"tabarray",
"to",
"a",
"separated",
"-",
"variable",
"(",
"CSV",
")",
"file",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L705-L894 | [
"def",
"saveSV",
"(",
"fname",
",",
"X",
",",
"comments",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"printmetadict",
"=",
"None",
",",
"dialect",
"=",
"None",
",",
"delimiter",
"=",
"None",
",",
"doublequote",
"=",
"True",
",",
"lineterminator",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | inferdialect | Attempts to convert infer dialect from csv file lines.
Essentially a small extension of the "sniff" function from Python CSV
module. csv.Sniffer().sniff attempts to infer the delimiter from a
putative delimited text file by analyzing character frequencies. This
function adds additional analy... | tabular/io.py | def inferdialect(fname=None, datalines=None, delimiter_regex=None,
verbosity=DEFAULT_VERBOSITY):
"""
Attempts to convert infer dialect from csv file lines.
Essentially a small extension of the "sniff" function from Python CSV
module. csv.Sniffer().sniff attempts to infer the d... | def inferdialect(fname=None, datalines=None, delimiter_regex=None,
verbosity=DEFAULT_VERBOSITY):
"""
Attempts to convert infer dialect from csv file lines.
Essentially a small extension of the "sniff" function from Python CSV
module. csv.Sniffer().sniff attempts to infer the d... | [
"Attempts",
"to",
"convert",
"infer",
"dialect",
"from",
"csv",
"file",
"lines",
".",
"Essentially",
"a",
"small",
"extension",
"of",
"the",
"sniff",
"function",
"from",
"Python",
"CSV",
"module",
".",
"csv",
".",
"Sniffer",
"()",
".",
"sniff",
"attempts",
... | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L985-L1088 | [
"def",
"inferdialect",
"(",
"fname",
"=",
"None",
",",
"datalines",
"=",
"None",
",",
"delimiter_regex",
"=",
"None",
",",
"verbosity",
"=",
"DEFAULT_VERBOSITY",
")",
":",
"if",
"datalines",
"is",
"None",
":",
"if",
"is_string_like",
"(",
"fname",
")",
":"... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | readstoredmetadata | Read metadata from a delimited text file. | tabular/io.py | def readstoredmetadata(fname, skiprows=0, linenumber=None, comments='#',
metametadata=None, verbosity=DEFAULT_VERBOSITY):
"""
Read metadata from a delimited text file.
"""
if is_string_like(fname):
fh = file(fname, 'rU')
elif hasattr(fname, 'readline'):
f... | def readstoredmetadata(fname, skiprows=0, linenumber=None, comments='#',
metametadata=None, verbosity=DEFAULT_VERBOSITY):
"""
Read metadata from a delimited text file.
"""
if is_string_like(fname):
fh = file(fname, 'rU')
elif hasattr(fname, 'readline'):
f... | [
"Read",
"metadata",
"from",
"a",
"delimited",
"text",
"file",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1092-L1174 | [
"def",
"readstoredmetadata",
"(",
"fname",
",",
"skiprows",
"=",
"0",
",",
"linenumber",
"=",
"None",
",",
"comments",
"=",
"'#'",
",",
"metametadata",
"=",
"None",
",",
"verbosity",
"=",
"DEFAULT_VERBOSITY",
")",
":",
"if",
"is_string_like",
"(",
"fname",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | processmetadata | Process Metadata from stored (or "packed") state to functional state.
Metadata can come be read from a file "packed" in various ways,
e.g. with a string representation of a dialect or coloring dictionary.
This function "unpacks" the stored metadata into useable Python
objects. It consists of a list... | tabular/io.py | def processmetadata(metadata, items=None, comments=None, delimiter_regex=None,
ncols=None, verbosity=DEFAULT_VERBOSITY):
"""
Process Metadata from stored (or "packed") state to functional state.
Metadata can come be read from a file "packed" in various ways,
e.g. with a string repr... | def processmetadata(metadata, items=None, comments=None, delimiter_regex=None,
ncols=None, verbosity=DEFAULT_VERBOSITY):
"""
Process Metadata from stored (or "packed") state to functional state.
Metadata can come be read from a file "packed" in various ways,
e.g. with a string repr... | [
"Process",
"Metadata",
"from",
"stored",
"(",
"or",
"packed",
")",
"state",
"to",
"functional",
"state",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1177-L1354 | [
"def",
"processmetadata",
"(",
"metadata",
",",
"items",
"=",
"None",
",",
"comments",
"=",
"None",
",",
"delimiter_regex",
"=",
"None",
",",
"ncols",
"=",
"None",
",",
"verbosity",
"=",
"DEFAULT_VERBOSITY",
")",
":",
"items",
"=",
"items",
".",
"split",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | inferheader | Infers header from a CSV or other tab-delimited file.
This is essentially small extension of the csv.Sniffer.has_header algorithm.
provided in the Python csv module. First, it checks to see whether a
metametadata dictionary is present, specifiying the lines numbers of
metadata lines in the head... | tabular/io.py | def inferheader(lines, comments=None, metadata=None,
verbosity=DEFAULT_VERBOSITY):
"""
Infers header from a CSV or other tab-delimited file.
This is essentially small extension of the csv.Sniffer.has_header algorithm.
provided in the Python csv module. First, it checks to see whet... | def inferheader(lines, comments=None, metadata=None,
verbosity=DEFAULT_VERBOSITY):
"""
Infers header from a CSV or other tab-delimited file.
This is essentially small extension of the csv.Sniffer.has_header algorithm.
provided in the Python csv module. First, it checks to see whet... | [
"Infers",
"header",
"from",
"a",
"CSV",
"or",
"other",
"tab",
"-",
"delimited",
"file",
".",
"This",
"is",
"essentially",
"small",
"extension",
"of",
"the",
"csv",
".",
"Sniffer",
".",
"has_header",
"algorithm",
".",
"provided",
"in",
"the",
"Python",
"csv... | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1364-L1436 | [
"def",
"inferheader",
"(",
"lines",
",",
"comments",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"verbosity",
"=",
"DEFAULT_VERBOSITY",
")",
":",
"if",
"(",
"(",
"comments",
"is",
"None",
")",
"and",
"metadata",
"and",
"(",
"'comments'",
"in",
"metad... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | IsMetaMetaDict | Checks whether a given AST (abstract syntax tree) object represents a
metametadata dictionary. | tabular/io.py | def IsMetaMetaDict(AST):
"""
Checks whether a given AST (abstract syntax tree) object represents a
metametadata dictionary.
"""
isintpair = lambda x : (isinstance(x,Tuple) and (len(x.asList()) == 2) and
isctype(x.asList()[0], int) and
... | def IsMetaMetaDict(AST):
"""
Checks whether a given AST (abstract syntax tree) object represents a
metametadata dictionary.
"""
isintpair = lambda x : (isinstance(x,Tuple) and (len(x.asList()) == 2) and
isctype(x.asList()[0], int) and
... | [
"Checks",
"whether",
"a",
"given",
"AST",
"(",
"abstract",
"syntax",
"tree",
")",
"object",
"represents",
"a",
"metametadata",
"dictionary",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1447-L1468 | [
"def",
"IsMetaMetaDict",
"(",
"AST",
")",
":",
"isintpair",
"=",
"lambda",
"x",
":",
"(",
"isinstance",
"(",
"x",
",",
"Tuple",
")",
"and",
"(",
"len",
"(",
"x",
".",
"asList",
"(",
")",
")",
"==",
"2",
")",
"and",
"isctype",
"(",
"x",
".",
"as... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | dialectfromstring | Attempts to convert a string representation of a CSV
dialect (as would be read from a file header, for instance)
into an actual csv.Dialect object. | tabular/io.py | def dialectfromstring(s):
"""
Attempts to convert a string representation of a CSV
dialect (as would be read from a file header, for instance)
into an actual csv.Dialect object.
"""
try:
AST = compiler.parse(s)
except SyntaxError:
return
else:
try:
... | def dialectfromstring(s):
"""
Attempts to convert a string representation of a CSV
dialect (as would be read from a file header, for instance)
into an actual csv.Dialect object.
"""
try:
AST = compiler.parse(s)
except SyntaxError:
return
else:
try:
... | [
"Attempts",
"to",
"convert",
"a",
"string",
"representation",
"of",
"a",
"CSV",
"dialect",
"(",
"as",
"would",
"be",
"read",
"from",
"a",
"file",
"header",
"for",
"instance",
")",
"into",
"an",
"actual",
"csv",
".",
"Dialect",
"object",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1470-L1500 | [
"def",
"dialectfromstring",
"(",
"s",
")",
":",
"try",
":",
"AST",
"=",
"compiler",
".",
"parse",
"(",
"s",
")",
"except",
"SyntaxError",
":",
"return",
"else",
":",
"try",
":",
"if",
"(",
"len",
"(",
"AST",
".",
"getChildren",
"(",
")",
")",
">",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | coloringfromstring | Attempts to convert a string representation of a coloring dictionary (as
would be read from a file header, for instance) into an actual coloring
dictionary. | tabular/io.py | def coloringfromstring(s):
"""
Attempts to convert a string representation of a coloring dictionary (as
would be read from a file header, for instance) into an actual coloring
dictionary.
"""
try:
AST = compiler.parse(s)
except SyntaxError:
return
else:
try... | def coloringfromstring(s):
"""
Attempts to convert a string representation of a coloring dictionary (as
would be read from a file header, for instance) into an actual coloring
dictionary.
"""
try:
AST = compiler.parse(s)
except SyntaxError:
return
else:
try... | [
"Attempts",
"to",
"convert",
"a",
"string",
"representation",
"of",
"a",
"coloring",
"dictionary",
"(",
"as",
"would",
"be",
"read",
"from",
"a",
"file",
"header",
"for",
"instance",
")",
"into",
"an",
"actual",
"coloring",
"dictionary",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1503-L1529 | [
"def",
"coloringfromstring",
"(",
"s",
")",
":",
"try",
":",
"AST",
"=",
"compiler",
".",
"parse",
"(",
"s",
")",
"except",
"SyntaxError",
":",
"return",
"else",
":",
"try",
":",
"if",
"len",
"(",
"AST",
".",
"getChildren",
"(",
")",
")",
">",
"1",... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | loadbinary | Load a numpy binary file or archive created by tabular.io.savebinary.
Load a numpy binary file (``.npy``) or archive (``.npz``) created by
:func:`tabular.io.savebinary`.
The data and associated data type (e.g. `dtype`, including if given, column
names) are loaded and reconstituted.
If `fnam... | tabular/io.py | def loadbinary(fname):
"""
Load a numpy binary file or archive created by tabular.io.savebinary.
Load a numpy binary file (``.npy``) or archive (``.npz``) created by
:func:`tabular.io.savebinary`.
The data and associated data type (e.g. `dtype`, including if given, column
names) are load... | def loadbinary(fname):
"""
Load a numpy binary file or archive created by tabular.io.savebinary.
Load a numpy binary file (``.npy``) or archive (``.npz``) created by
:func:`tabular.io.savebinary`.
The data and associated data type (e.g. `dtype`, including if given, column
names) are load... | [
"Load",
"a",
"numpy",
"binary",
"file",
"or",
"archive",
"created",
"by",
"tabular",
".",
"io",
".",
"savebinary",
".",
"Load",
"a",
"numpy",
"binary",
"file",
"(",
".",
"npy",
")",
"or",
"archive",
"(",
".",
"npz",
")",
"created",
"by",
":",
"func",... | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1618-L1692 | [
"def",
"loadbinary",
"(",
"fname",
")",
":",
"X",
"=",
"np",
".",
"load",
"(",
"fname",
")",
"if",
"isinstance",
"(",
"X",
",",
"np",
".",
"lib",
".",
"npyio",
".",
"NpzFile",
")",
":",
"if",
"'coloring'",
"in",
"X",
".",
"files",
":",
"coloring"... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | savebinary | Save a tabarray to a numpy binary file or archive.
Save a tabarray to a numpy binary file (``.npy``) or archive
(``.npz``) that can be loaded by :func:`tabular.io.savebinary`.
The ``.npz`` file is a zipped archive created using
:func:`numpy.savez` and containing one or more ``.npy`` files,
whi... | tabular/io.py | def savebinary(fname, X, savecoloring=True):
"""
Save a tabarray to a numpy binary file or archive.
Save a tabarray to a numpy binary file (``.npy``) or archive
(``.npz``) that can be loaded by :func:`tabular.io.savebinary`.
The ``.npz`` file is a zipped archive created using
:func:`numpy.... | def savebinary(fname, X, savecoloring=True):
"""
Save a tabarray to a numpy binary file or archive.
Save a tabarray to a numpy binary file (``.npy``) or archive
(``.npz``) that can be loaded by :func:`tabular.io.savebinary`.
The ``.npz`` file is a zipped archive created using
:func:`numpy.... | [
"Save",
"a",
"tabarray",
"to",
"a",
"numpy",
"binary",
"file",
"or",
"archive",
".",
"Save",
"a",
"tabarray",
"to",
"a",
"numpy",
"binary",
"file",
"(",
".",
"npy",
")",
"or",
"archive",
"(",
".",
"npz",
")",
"that",
"can",
"be",
"loaded",
"by",
":... | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1694-L1744 | [
"def",
"savebinary",
"(",
"fname",
",",
"X",
",",
"savecoloring",
"=",
"True",
")",
":",
"if",
"fname",
"[",
"-",
"4",
":",
"]",
"==",
"'.npy'",
":",
"np",
".",
"save",
"(",
"fname",
",",
"X",
")",
"else",
":",
"if",
"savecoloring",
"is",
"True",... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | parsetypes | Parse the types from a structured numpy dtype object.
Return list of string representations of types from a structured numpy
dtype object, e.g. ['int', 'float', 'str'].
Used by :func:`tabular.io.saveSV` to write out type information in the
header.
**Parameters**
**dtype** : numpy dtyp... | tabular/io.py | def parsetypes(dtype):
"""
Parse the types from a structured numpy dtype object.
Return list of string representations of types from a structured numpy
dtype object, e.g. ['int', 'float', 'str'].
Used by :func:`tabular.io.saveSV` to write out type information in the
header.
**Parameters... | def parsetypes(dtype):
"""
Parse the types from a structured numpy dtype object.
Return list of string representations of types from a structured numpy
dtype object, e.g. ['int', 'float', 'str'].
Used by :func:`tabular.io.saveSV` to write out type information in the
header.
**Parameters... | [
"Parse",
"the",
"types",
"from",
"a",
"structured",
"numpy",
"dtype",
"object",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1808-L1835 | [
"def",
"parsetypes",
"(",
"dtype",
")",
":",
"return",
"[",
"dtype",
"[",
"i",
"]",
".",
"name",
".",
"strip",
"(",
"'1234567890'",
")",
".",
"rstrip",
"(",
"'ing'",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"dtype",
")",
")",
"]"
] | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | thresholdcoloring | Threshold a coloring dictionary for a given list of column names.
Threshold `coloring` based on `names`, a list of strings in::
coloring.values()
**Parameters**
**coloring** : dictionary
Hierarchical structure on the columns given in the header of the
file; an attr... | tabular/io.py | def thresholdcoloring(coloring, names):
"""
Threshold a coloring dictionary for a given list of column names.
Threshold `coloring` based on `names`, a list of strings in::
coloring.values()
**Parameters**
**coloring** : dictionary
Hierarchical structure on the columns g... | def thresholdcoloring(coloring, names):
"""
Threshold a coloring dictionary for a given list of column names.
Threshold `coloring` based on `names`, a list of strings in::
coloring.values()
**Parameters**
**coloring** : dictionary
Hierarchical structure on the columns g... | [
"Threshold",
"a",
"coloring",
"dictionary",
"for",
"a",
"given",
"list",
"of",
"column",
"names",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1838-L1873 | [
"def",
"thresholdcoloring",
"(",
"coloring",
",",
"names",
")",
":",
"for",
"key",
"in",
"coloring",
".",
"keys",
"(",
")",
":",
"if",
"len",
"(",
"[",
"k",
"for",
"k",
"in",
"coloring",
"[",
"key",
"]",
"if",
"k",
"in",
"names",
"]",
")",
"==",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | delete | Unified "strong" version of delete (remove) for files and directories.
Unified "strong" version of delete that uses `os.remove` for a file and
`shutil.rmtree` for a directory tree.
**Parameters**
**to_delete** : string
Path to a file or directory.
**See Also:**
`os <h... | tabular/io.py | def delete(to_delete):
"""
Unified "strong" version of delete (remove) for files and directories.
Unified "strong" version of delete that uses `os.remove` for a file and
`shutil.rmtree` for a directory tree.
**Parameters**
**to_delete** : string
Path to a file or directory.... | def delete(to_delete):
"""
Unified "strong" version of delete (remove) for files and directories.
Unified "strong" version of delete that uses `os.remove` for a file and
`shutil.rmtree` for a directory tree.
**Parameters**
**to_delete** : string
Path to a file or directory.... | [
"Unified",
"strong",
"version",
"of",
"delete",
"(",
"remove",
")",
"for",
"files",
"and",
"directories",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1900-L1922 | [
"def",
"delete",
"(",
"to_delete",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"to_delete",
")",
":",
"os",
".",
"remove",
"(",
"to_delete",
")",
"elif",
"os",
".",
"path",
".",
"isdir",
"(",
"to_delete",
")",
":",
"shutil",
".",
"rmtree... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | makedir | "Strong" directory maker.
"Strong" version of `os.mkdir`. If `dir_name` already exists, this deletes
it first.
**Parameters**
**dir_name** : string
Path to a file directory that may or may not already exist.
**See Also:**
:func:`tabular.io.delete`,
`os <http... | tabular/io.py | def makedir(dir_name):
"""
"Strong" directory maker.
"Strong" version of `os.mkdir`. If `dir_name` already exists, this deletes
it first.
**Parameters**
**dir_name** : string
Path to a file directory that may or may not already exist.
**See Also:**
:func:`ta... | def makedir(dir_name):
"""
"Strong" directory maker.
"Strong" version of `os.mkdir`. If `dir_name` already exists, this deletes
it first.
**Parameters**
**dir_name** : string
Path to a file directory that may or may not already exist.
**See Also:**
:func:`ta... | [
"Strong",
"directory",
"maker",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/io.py#L1924-L1945 | [
"def",
"makedir",
"(",
"dir_name",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"dir_name",
")",
":",
"delete",
"(",
"dir_name",
")",
"os",
".",
"mkdir",
"(",
"dir_name",
")"
] | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | apod | HTTP REQUEST
GET https://api.nasa.gov/planetary/apod
QUERY PARAMETERS
Parameter Type Default Description
date YYYY-MM-DD today The date of the APOD image to retrieve
concept_tags bool False Return an ordered dictionary of concepts from the APOD explanation
api_key string DEMO_KEY api.nasa.gov... | bowshock/apod.py | def apod(date=None, concept_tags=None):
'''
HTTP REQUEST
GET https://api.nasa.gov/planetary/apod
QUERY PARAMETERS
Parameter Type Default Description
date YYYY-MM-DD today The date of the APOD image to retrieve
concept_tags bool False Return an ordered dictionary of concepts from the APOD ... | def apod(date=None, concept_tags=None):
'''
HTTP REQUEST
GET https://api.nasa.gov/planetary/apod
QUERY PARAMETERS
Parameter Type Default Description
date YYYY-MM-DD today The date of the APOD image to retrieve
concept_tags bool False Return an ordered dictionary of concepts from the APOD ... | [
"HTTP",
"REQUEST"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/apod.py#L9-L38 | [
"def",
"apod",
"(",
"date",
"=",
"None",
",",
"concept_tags",
"=",
"None",
")",
":",
"base_url",
"=",
"\"https://api.nasa.gov/planetary/apod?\"",
"if",
"date",
":",
"try",
":",
"vali_date",
"(",
"date",
")",
"base_url",
"+=",
"\"date=\"",
"+",
"date",
"+",
... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | pass_community | Decorator to pass community. | invenio_communities/views/ui.py | def pass_community(f):
"""Decorator to pass community."""
@wraps(f)
def inner(community_id, *args, **kwargs):
c = Community.get(community_id)
if c is None:
abort(404)
return f(c, *args, **kwargs)
return inner | def pass_community(f):
"""Decorator to pass community."""
@wraps(f)
def inner(community_id, *args, **kwargs):
c = Community.get(community_id)
if c is None:
abort(404)
return f(c, *args, **kwargs)
return inner | [
"Decorator",
"to",
"pass",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/views/ui.py#L56-L64 | [
"def",
"pass_community",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"inner",
"(",
"community_id",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"c",
"=",
"Community",
".",
"get",
"(",
"community_id",
")",
"if",
"c",
"is",
"Non... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | permission_required | Decorator to require permission. | invenio_communities/views/ui.py | def permission_required(action):
"""Decorator to require permission."""
def decorator(f):
@wraps(f)
def inner(community, *args, **kwargs):
permission = current_permission_factory(community, action=action)
if not permission.can():
abort(403)
ret... | def permission_required(action):
"""Decorator to require permission."""
def decorator(f):
@wraps(f)
def inner(community, *args, **kwargs):
permission = current_permission_factory(community, action=action)
if not permission.can():
abort(403)
ret... | [
"Decorator",
"to",
"require",
"permission",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/views/ui.py#L67-L77 | [
"def",
"permission_required",
"(",
"action",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"inner",
"(",
"community",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"permission",
"=",
"current_permission_fa... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | format_item | Render a template to a string with the provided item in context. | invenio_communities/views/ui.py | def format_item(item, template, name='item'):
"""Render a template to a string with the provided item in context."""
ctx = {name: item}
return render_template_to_string(template, **ctx) | def format_item(item, template, name='item'):
"""Render a template to a string with the provided item in context."""
ctx = {name: item}
return render_template_to_string(template, **ctx) | [
"Render",
"a",
"template",
"to",
"a",
"string",
"with",
"the",
"provided",
"item",
"in",
"context",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/views/ui.py#L81-L84 | [
"def",
"format_item",
"(",
"item",
",",
"template",
",",
"name",
"=",
"'item'",
")",
":",
"ctx",
"=",
"{",
"name",
":",
"item",
"}",
"return",
"render_template_to_string",
"(",
"template",
",",
"*",
"*",
"ctx",
")"
] | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | index | Index page with uploader and list of existing depositions. | invenio_communities/views/ui.py | def index():
"""Index page with uploader and list of existing depositions."""
ctx = mycommunities_ctx()
p = request.args.get('p', type=str)
so = request.args.get('so', type=str)
page = request.args.get('page', type=int, default=1)
so = so or current_app.config.get('COMMUNITIES_DEFAULT_SORTING_... | def index():
"""Index page with uploader and list of existing depositions."""
ctx = mycommunities_ctx()
p = request.args.get('p', type=str)
so = request.args.get('so', type=str)
page = request.args.get('page', type=int, default=1)
so = so or current_app.config.get('COMMUNITIES_DEFAULT_SORTING_... | [
"Index",
"page",
"with",
"uploader",
"and",
"list",
"of",
"existing",
"depositions",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/views/ui.py#L96-L126 | [
"def",
"index",
"(",
")",
":",
"ctx",
"=",
"mycommunities_ctx",
"(",
")",
"p",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'p'",
",",
"type",
"=",
"str",
")",
"so",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'so'",
",",
"type",
"=",
"str... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | generic_item | Index page with uploader and list of existing depositions. | invenio_communities/views/ui.py | def generic_item(community, template, **extra_ctx):
"""Index page with uploader and list of existing depositions."""
# Check existence of community
ctx = mycommunities_ctx()
ctx.update({
'is_owner': community.id_user == current_user.get_id(),
'community': community,
'detail': Tru... | def generic_item(community, template, **extra_ctx):
"""Index page with uploader and list of existing depositions."""
# Check existence of community
ctx = mycommunities_ctx()
ctx.update({
'is_owner': community.id_user == current_user.get_id(),
'community': community,
'detail': Tru... | [
"Index",
"page",
"with",
"uploader",
"and",
"list",
"of",
"existing",
"depositions",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/views/ui.py#L155-L166 | [
"def",
"generic_item",
"(",
"community",
",",
"template",
",",
"*",
"*",
"extra_ctx",
")",
":",
"# Check existence of community",
"ctx",
"=",
"mycommunities_ctx",
"(",
")",
"ctx",
".",
"update",
"(",
"{",
"'is_owner'",
":",
"community",
".",
"id_user",
"==",
... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | new | Create a new community. | invenio_communities/views/ui.py | def new():
"""Create a new community."""
form = CommunityForm(formdata=request.values)
ctx = mycommunities_ctx()
ctx.update({
'form': form,
'is_new': True,
'community': None,
})
if form.validate_on_submit():
data = copy.deepcopy(form.data)
community_id ... | def new():
"""Create a new community."""
form = CommunityForm(formdata=request.values)
ctx = mycommunities_ctx()
ctx.update({
'form': form,
'is_new': True,
'community': None,
})
if form.validate_on_submit():
data = copy.deepcopy(form.data)
community_id ... | [
"Create",
"a",
"new",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/views/ui.py#L171-L209 | [
"def",
"new",
"(",
")",
":",
"form",
"=",
"CommunityForm",
"(",
"formdata",
"=",
"request",
".",
"values",
")",
"ctx",
"=",
"mycommunities_ctx",
"(",
")",
"ctx",
".",
"update",
"(",
"{",
"'form'",
":",
"form",
",",
"'is_new'",
":",
"True",
",",
"'com... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | edit | Create or edit a community. | invenio_communities/views/ui.py | def edit(community):
"""Create or edit a community."""
form = EditCommunityForm(formdata=request.values, obj=community)
deleteform = DeleteCommunityForm()
ctx = mycommunities_ctx()
ctx.update({
'form': form,
'is_new': False,
'community': community,
'deleteform': delet... | def edit(community):
"""Create or edit a community."""
form = EditCommunityForm(formdata=request.values, obj=community)
deleteform = DeleteCommunityForm()
ctx = mycommunities_ctx()
ctx.update({
'form': form,
'is_new': False,
'community': community,
'deleteform': delet... | [
"Create",
"or",
"edit",
"a",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/views/ui.py#L216-L247 | [
"def",
"edit",
"(",
"community",
")",
":",
"form",
"=",
"EditCommunityForm",
"(",
"formdata",
"=",
"request",
".",
"values",
",",
"obj",
"=",
"community",
")",
"deleteform",
"=",
"DeleteCommunityForm",
"(",
")",
"ctx",
"=",
"mycommunities_ctx",
"(",
")",
"... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | delete | Delete a community. | invenio_communities/views/ui.py | def delete(community):
"""Delete a community."""
deleteform = DeleteCommunityForm(formdata=request.values)
ctx = mycommunities_ctx()
ctx.update({
'deleteform': deleteform,
'is_new': False,
'community': community,
})
if deleteform.validate_on_submit():
community.d... | def delete(community):
"""Delete a community."""
deleteform = DeleteCommunityForm(formdata=request.values)
ctx = mycommunities_ctx()
ctx.update({
'deleteform': deleteform,
'is_new': False,
'community': community,
})
if deleteform.validate_on_submit():
community.d... | [
"Delete",
"a",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/views/ui.py#L254-L271 | [
"def",
"delete",
"(",
"community",
")",
":",
"deleteform",
"=",
"DeleteCommunityForm",
"(",
"formdata",
"=",
"request",
".",
"values",
")",
"ctx",
"=",
"mycommunities_ctx",
"(",
")",
"ctx",
".",
"update",
"(",
"{",
"'deleteform'",
":",
"deleteform",
",",
"... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | curate | Index page with uploader and list of existing depositions.
:param community_id: ID of the community to curate. | invenio_communities/views/ui.py | def curate(community):
"""Index page with uploader and list of existing depositions.
:param community_id: ID of the community to curate.
"""
if request.method == 'POST':
action = request.json.get('action')
recid = request.json.get('recid')
# 'recid' is mandatory
if not ... | def curate(community):
"""Index page with uploader and list of existing depositions.
:param community_id: ID of the community to curate.
"""
if request.method == 'POST':
action = request.json.get('action')
recid = request.json.get('recid')
# 'recid' is mandatory
if not ... | [
"Index",
"page",
"with",
"uploader",
"and",
"list",
"of",
"existing",
"depositions",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/views/ui.py#L278-L315 | [
"def",
"curate",
"(",
"community",
")",
":",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"action",
"=",
"request",
".",
"json",
".",
"get",
"(",
"'action'",
")",
"recid",
"=",
"request",
".",
"json",
".",
"get",
"(",
"'recid'",
")",
"# 'reci... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | evaluate_tree_rooting | Returns None if the taxanomy contributes no information to the rooting decision
(e.g. all of the tips are within one genus in the taxonomy)
TODO: need to coordinate with Jim Allman and see if we can
do this in a non- O(nm) manner (where n and m are the # of non-trivial edges in the phylo and taxo tree)... | peyotl/evaluate_tree.py | def evaluate_tree_rooting(nexson, ott, tree_proxy):
"""
Returns None if the taxanomy contributes no information to the rooting decision
(e.g. all of the tips are within one genus in the taxonomy)
TODO: need to coordinate with Jim Allman and see if we can
do this in a non- O(nm) manner (where n ... | def evaluate_tree_rooting(nexson, ott, tree_proxy):
"""
Returns None if the taxanomy contributes no information to the rooting decision
(e.g. all of the tips are within one genus in the taxonomy)
TODO: need to coordinate with Jim Allman and see if we can
do this in a non- O(nm) manner (where n ... | [
"Returns",
"None",
"if",
"the",
"taxanomy",
"contributes",
"no",
"information",
"to",
"the",
"rooting",
"decision",
"(",
"e",
".",
"g",
".",
"all",
"of",
"the",
"tips",
"are",
"within",
"one",
"genus",
"in",
"the",
"taxonomy",
")"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/evaluate_tree.py#L9-L194 | [
"def",
"evaluate_tree_rooting",
"(",
"nexson",
",",
"ott",
",",
"tree_proxy",
")",
":",
"pruned_phylo",
",",
"taxo_tree",
"=",
"create_pruned_and_taxonomy_for_tip_ott_ids",
"(",
"tree_proxy",
",",
"ott",
")",
"if",
"taxo_tree",
"is",
"None",
":",
"# this can happen ... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | ot_find_tree | Uses a peyotl wrapper around an Open Tree web service to get a list of trees including values `value` for a given property to be searched on `porperty`.
The oti_wrapper can be None (in which case the default wrapper from peyotl.sugar will be used.
All other arguments correspond to the arguments of the web-serv... | tutorials/ot-oti-find-tree.py | def ot_find_tree(arg_dict, exact=True, verbose=False, oti_wrapper=None):
"""Uses a peyotl wrapper around an Open Tree web service to get a list of trees including values `value` for a given property to be searched on `porperty`.
The oti_wrapper can be None (in which case the default wrapper from peyotl.sugar w... | def ot_find_tree(arg_dict, exact=True, verbose=False, oti_wrapper=None):
"""Uses a peyotl wrapper around an Open Tree web service to get a list of trees including values `value` for a given property to be searched on `porperty`.
The oti_wrapper can be None (in which case the default wrapper from peyotl.sugar w... | [
"Uses",
"a",
"peyotl",
"wrapper",
"around",
"an",
"Open",
"Tree",
"web",
"service",
"to",
"get",
"a",
"list",
"of",
"trees",
"including",
"values",
"value",
"for",
"a",
"given",
"property",
"to",
"be",
"searched",
"on",
"porperty",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-oti-find-tree.py#L12-L24 | [
"def",
"ot_find_tree",
"(",
"arg_dict",
",",
"exact",
"=",
"True",
",",
"verbose",
"=",
"False",
",",
"oti_wrapper",
"=",
"None",
")",
":",
"if",
"oti_wrapper",
"is",
"None",
":",
"from",
"peyotl",
".",
"sugar",
"import",
"oti",
"oti_wrapper",
"=",
"oti"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | print_matching_trees | The `TreeRef` instance returned by the oti.find_trees(... wrap_response=True)
can be used as an argument to the phylesystem_api.get call.
If you pass in a string (instead of a TreeRef), the string will be interpreted as a study ID | tutorials/ot-oti-find-tree.py | def print_matching_trees(arg_dict, tree_format, exact, verbose):
"""The `TreeRef` instance returned by the oti.find_trees(... wrap_response=True)
can be used as an argument to the phylesystem_api.get call.
If you pass in a string (instead of a TreeRef), the string will be interpreted as a study ID
"""
... | def print_matching_trees(arg_dict, tree_format, exact, verbose):
"""The `TreeRef` instance returned by the oti.find_trees(... wrap_response=True)
can be used as an argument to the phylesystem_api.get call.
If you pass in a string (instead of a TreeRef), the string will be interpreted as a study ID
"""
... | [
"The",
"TreeRef",
"instance",
"returned",
"by",
"the",
"oti",
".",
"find_trees",
"(",
"...",
"wrap_response",
"=",
"True",
")",
"can",
"be",
"used",
"as",
"an",
"argument",
"to",
"the",
"phylesystem_api",
".",
"get",
"call",
".",
"If",
"you",
"pass",
"in... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-oti-find-tree.py#L27-L36 | [
"def",
"print_matching_trees",
"(",
"arg_dict",
",",
"tree_format",
",",
"exact",
",",
"verbose",
")",
":",
"from",
"peyotl",
".",
"sugar",
"import",
"phylesystem_api",
"tree_list",
"=",
"ot_find_tree",
"(",
"arg_dict",
",",
"exact",
"=",
"exact",
",",
"verbos... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | proc_forward | Resolve etype to an actual type if it is a forward reference | pyjsg/jsglib/typing_patch_36.py | def proc_forward(etype, namespace: Dict[str, Any]):
""" Resolve etype to an actual type if it is a forward reference """
return etype._eval_type(namespace, namespace) if type(etype) is _ForwardRef else etype | def proc_forward(etype, namespace: Dict[str, Any]):
""" Resolve etype to an actual type if it is a forward reference """
return etype._eval_type(namespace, namespace) if type(etype) is _ForwardRef else etype | [
"Resolve",
"etype",
"to",
"an",
"actual",
"type",
"if",
"it",
"is",
"a",
"forward",
"reference"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/typing_patch_36.py#L14-L16 | [
"def",
"proc_forward",
"(",
"etype",
",",
"namespace",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"return",
"etype",
".",
"_eval_type",
"(",
"namespace",
",",
"namespace",
")",
"if",
"type",
"(",
"etype",
")",
"is",
"_ForwardRef",
"else",
"ety... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | is_iterable | Determine whether etype is a List or other iterable | pyjsg/jsglib/typing_patch_36.py | def is_iterable(etype) -> bool:
""" Determine whether etype is a List or other iterable """
return type(etype) is GenericMeta and issubclass(etype.__extra__, Iterable) | def is_iterable(etype) -> bool:
""" Determine whether etype is a List or other iterable """
return type(etype) is GenericMeta and issubclass(etype.__extra__, Iterable) | [
"Determine",
"whether",
"etype",
"is",
"a",
"List",
"or",
"other",
"iterable"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/typing_patch_36.py#L29-L31 | [
"def",
"is_iterable",
"(",
"etype",
")",
"->",
"bool",
":",
"return",
"type",
"(",
"etype",
")",
"is",
"GenericMeta",
"and",
"issubclass",
"(",
"etype",
".",
"__extra__",
",",
"Iterable",
")"
] | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | union_conforms | Determine whether element conforms to at least one of the types in etype
:param element: element to test
:param etype: type to test against
:param namespace: Namespace to use for resolving forward references
:param conforms: conformance test function
:return: True if element conforms to at least on... | pyjsg/jsglib/typing_patch_36.py | def union_conforms(element: Union, etype, namespace: Dict[str, Any], conforms: Callable) -> bool:
""" Determine whether element conforms to at least one of the types in etype
:param element: element to test
:param etype: type to test against
:param namespace: Namespace to use for resolving forward refe... | def union_conforms(element: Union, etype, namespace: Dict[str, Any], conforms: Callable) -> bool:
""" Determine whether element conforms to at least one of the types in etype
:param element: element to test
:param etype: type to test against
:param namespace: Namespace to use for resolving forward refe... | [
"Determine",
"whether",
"element",
"conforms",
"to",
"at",
"least",
"one",
"of",
"the",
"types",
"in",
"etype"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/typing_patch_36.py#L34-L44 | [
"def",
"union_conforms",
"(",
"element",
":",
"Union",
",",
"etype",
",",
"namespace",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"conforms",
":",
"Callable",
")",
"->",
"bool",
":",
"union_vals",
"=",
"etype",
".",
"__union_params__",
"if",
"sys",
... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | main | This function sets up a command-line option parser and then calls fetch_and_write_mrca
to do all of the real work. | tutorials/ot-tree-of-life-mrca.py | def main(argv):
"""This function sets up a command-line option parser and then calls fetch_and_write_mrca
to do all of the real work.
"""
import argparse
description = 'Uses Open Tree of Life web services to the MRCA for a set of OTT IDs.'
parser = argparse.ArgumentParser(prog='ot-tree-of-life-m... | def main(argv):
"""This function sets up a command-line option parser and then calls fetch_and_write_mrca
to do all of the real work.
"""
import argparse
description = 'Uses Open Tree of Life web services to the MRCA for a set of OTT IDs.'
parser = argparse.ArgumentParser(prog='ot-tree-of-life-m... | [
"This",
"function",
"sets",
"up",
"a",
"command",
"-",
"line",
"option",
"parser",
"and",
"then",
"calls",
"fetch_and_write_mrca",
"to",
"do",
"all",
"of",
"the",
"real",
"work",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-tree-of-life-mrca.py#L63-L82 | [
"def",
"main",
"(",
"argv",
")",
":",
"import",
"argparse",
"description",
"=",
"'Uses Open Tree of Life web services to the MRCA for a set of OTT IDs.'",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"'ot-tree-of-life-mrca'",
",",
"description",
"="... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | Origin.send_schema | Send schema to ledger, then retrieve it as written to the ledger and return it.
If schema already exists on ledger, log error and return schema.
:param schema_data_json: schema data json with name, version, attribute names; e.g.,
::
{
'name': 'my-schema',
... | von_agent/agent/origin.py | async def send_schema(self, schema_data_json: str) -> str:
"""
Send schema to ledger, then retrieve it as written to the ledger and return it.
If schema already exists on ledger, log error and return schema.
:param schema_data_json: schema data json with name, version, attribute names; ... | async def send_schema(self, schema_data_json: str) -> str:
"""
Send schema to ledger, then retrieve it as written to the ledger and return it.
If schema already exists on ledger, log error and return schema.
:param schema_data_json: schema data json with name, version, attribute names; ... | [
"Send",
"schema",
"to",
"ledger",
"then",
"retrieve",
"it",
"as",
"written",
"to",
"the",
"ledger",
"and",
"return",
"it",
".",
"If",
"schema",
"already",
"exists",
"on",
"ledger",
"log",
"error",
"and",
"return",
"schema",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/origin.py#L36-L82 | [
"async",
"def",
"send_schema",
"(",
"self",
",",
"schema_data_json",
":",
"str",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'Origin.send_schema >>> schema_data_json: %s'",
",",
"schema_data_json",
")",
"schema_data",
"=",
"json",
".",
"loads",
"(",
"sc... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | TypeAwareDocStore._locked_refresh_doc_ids | Assumes that the caller has the _index_lock ! | peyotl/git_storage/type_aware_doc_store.py | def _locked_refresh_doc_ids(self):
"""Assumes that the caller has the _index_lock !
"""
d = {}
for s in self._shards:
for k in s.doc_index.keys():
if k in d:
raise KeyError('doc "{i}" found in multiple repos'.format(i=k))
d[... | def _locked_refresh_doc_ids(self):
"""Assumes that the caller has the _index_lock !
"""
d = {}
for s in self._shards:
for k in s.doc_index.keys():
if k in d:
raise KeyError('doc "{i}" found in multiple repos'.format(i=k))
d[... | [
"Assumes",
"that",
"the",
"caller",
"has",
"the",
"_index_lock",
"!"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/git_storage/type_aware_doc_store.py#L157-L166 | [
"def",
"_locked_refresh_doc_ids",
"(",
"self",
")",
":",
"d",
"=",
"{",
"}",
"for",
"s",
"in",
"self",
".",
"_shards",
":",
"for",
"k",
"in",
"s",
".",
"doc_index",
".",
"keys",
"(",
")",
":",
"if",
"k",
"in",
"d",
":",
"raise",
"KeyError",
"(",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TypeAwareDocStore.push_doc_to_remote | This will push the master branch to the remote named `remote_name`
using the mirroring strategy to cut down on locking of the working repo.
`doc_id` is used to determine which shard should be pushed.
if `doc_id` is None, all shards are pushed. | peyotl/git_storage/type_aware_doc_store.py | def push_doc_to_remote(self, remote_name, doc_id=None):
"""This will push the master branch to the remote named `remote_name`
using the mirroring strategy to cut down on locking of the working repo.
`doc_id` is used to determine which shard should be pushed.
if `doc_id` is None, all sha... | def push_doc_to_remote(self, remote_name, doc_id=None):
"""This will push the master branch to the remote named `remote_name`
using the mirroring strategy to cut down on locking of the working repo.
`doc_id` is used to determine which shard should be pushed.
if `doc_id` is None, all sha... | [
"This",
"will",
"push",
"the",
"master",
"branch",
"to",
"the",
"remote",
"named",
"remote_name",
"using",
"the",
"mirroring",
"strategy",
"to",
"cut",
"down",
"on",
"locking",
"of",
"the",
"working",
"repo",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/git_storage/type_aware_doc_store.py#L214-L229 | [
"def",
"push_doc_to_remote",
"(",
"self",
",",
"remote_name",
",",
"doc_id",
"=",
"None",
")",
":",
"if",
"doc_id",
"is",
"None",
":",
"ret",
"=",
"True",
"# @TODO should spawn a thread of each shard...",
"for",
"shard",
"in",
"self",
".",
"_shards",
":",
"if"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TypeAwareDocStore.annotate_and_write | This is the heart of the api's __finish_write_verb
It was moved to phylesystem to make it easier to coordinate it
with the caching decisions. We have been debating whether
to cache @id and @dateCreated attributes for the annotations
or cache the whole annotation. Since these ... | peyotl/git_storage/type_aware_doc_store.py | def annotate_and_write(self, # pylint: disable=R0201
git_data,
nexson,
doc_id,
auth_info,
adaptor,
annotation,
parent_sha,
... | def annotate_and_write(self, # pylint: disable=R0201
git_data,
nexson,
doc_id,
auth_info,
adaptor,
annotation,
parent_sha,
... | [
"This",
"is",
"the",
"heart",
"of",
"the",
"api",
"s",
"__finish_write_verb",
"It",
"was",
"moved",
"to",
"phylesystem",
"to",
"make",
"it",
"easier",
"to",
"coordinate",
"it",
"with",
"the",
"caching",
"decisions",
".",
"We",
"have",
"been",
"debating",
"... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/git_storage/type_aware_doc_store.py#L251-L280 | [
"def",
"annotate_and_write",
"(",
"self",
",",
"# pylint: disable=R0201",
"git_data",
",",
"nexson",
",",
"doc_id",
",",
"auth_info",
",",
"adaptor",
",",
"annotation",
",",
"parent_sha",
",",
"commit_msg",
"=",
"''",
",",
"master_file_blob_included",
"=",
"None",... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TypeAwareDocStore.iter_doc_objs | Generator that iterates over all detected documents (eg, nexson studies)
and returns the doc object (deserialized from JSON) for each doc.
Order is by shard, but arbitrary within shards.
@TEMP not locked to prevent doc creation/deletion | peyotl/git_storage/type_aware_doc_store.py | def iter_doc_objs(self, **kwargs):
"""Generator that iterates over all detected documents (eg, nexson studies)
and returns the doc object (deserialized from JSON) for each doc.
Order is by shard, but arbitrary within shards.
@TEMP not locked to prevent doc creation/deletion
"""
... | def iter_doc_objs(self, **kwargs):
"""Generator that iterates over all detected documents (eg, nexson studies)
and returns the doc object (deserialized from JSON) for each doc.
Order is by shard, but arbitrary within shards.
@TEMP not locked to prevent doc creation/deletion
"""
... | [
"Generator",
"that",
"iterates",
"over",
"all",
"detected",
"documents",
"(",
"eg",
"nexson",
"studies",
")",
"and",
"returns",
"the",
"doc",
"object",
"(",
"deserialized",
"from",
"JSON",
")",
"for",
"each",
"doc",
".",
"Order",
"is",
"by",
"shard",
"but"... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/git_storage/type_aware_doc_store.py#L313-L321 | [
"def",
"iter_doc_objs",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"shard",
"in",
"self",
".",
"_shards",
":",
"for",
"doc_id",
",",
"blob",
"in",
"shard",
".",
"iter_doc_objs",
"(",
"*",
"*",
"kwargs",
")",
":",
"yield",
"doc_id",
",",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TypeAwareDocStore.iter_doc_filepaths | Generator that iterates over all detected documents.
and returns the filesystem path to each doc.
Order is by shard, but arbitrary within shards.
@TEMP not locked to prevent doc creation/deletion | peyotl/git_storage/type_aware_doc_store.py | def iter_doc_filepaths(self, **kwargs):
"""Generator that iterates over all detected documents.
and returns the filesystem path to each doc.
Order is by shard, but arbitrary within shards.
@TEMP not locked to prevent doc creation/deletion
"""
for shard in self._shards:
... | def iter_doc_filepaths(self, **kwargs):
"""Generator that iterates over all detected documents.
and returns the filesystem path to each doc.
Order is by shard, but arbitrary within shards.
@TEMP not locked to prevent doc creation/deletion
"""
for shard in self._shards:
... | [
"Generator",
"that",
"iterates",
"over",
"all",
"detected",
"documents",
".",
"and",
"returns",
"the",
"filesystem",
"path",
"to",
"each",
"doc",
".",
"Order",
"is",
"by",
"shard",
"but",
"arbitrary",
"within",
"shards",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/git_storage/type_aware_doc_store.py#L323-L331 | [
"def",
"iter_doc_filepaths",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"shard",
"in",
"self",
".",
"_shards",
":",
"for",
"doc_id",
",",
"blob",
"in",
"shard",
".",
"iter_doc_filepaths",
"(",
"*",
"*",
"kwargs",
")",
":",
"yield",
"doc_id"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | CommunityForm.data | Form data. | invenio_communities/forms.py | def data(self):
"""Form data."""
d = super(CommunityForm, self).data
d.pop('csrf_token', None)
return d | def data(self):
"""Form data."""
d = super(CommunityForm, self).data
d.pop('csrf_token', None)
return d | [
"Form",
"data",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/forms.py#L54-L58 | [
"def",
"data",
"(",
"self",
")",
":",
"d",
"=",
"super",
"(",
"CommunityForm",
",",
"self",
")",
".",
"data",
"d",
".",
"pop",
"(",
"'csrf_token'",
",",
"None",
")",
"return",
"d"
] | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | CommunityForm.validate_identifier | Validate field identifier. | invenio_communities/forms.py | def validate_identifier(self, field):
"""Validate field identifier."""
if field.data:
field.data = field.data.lower()
if Community.get(field.data, with_deleted=True):
raise validators.ValidationError(
_('The identifier already exists. '
... | def validate_identifier(self, field):
"""Validate field identifier."""
if field.data:
field.data = field.data.lower()
if Community.get(field.data, with_deleted=True):
raise validators.ValidationError(
_('The identifier already exists. '
... | [
"Validate",
"field",
"identifier",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/forms.py#L154-L161 | [
"def",
"validate_identifier",
"(",
"self",
",",
"field",
")",
":",
"if",
"field",
".",
"data",
":",
"field",
".",
"data",
"=",
"field",
".",
"data",
".",
"lower",
"(",
")",
"if",
"Community",
".",
"get",
"(",
"field",
".",
"data",
",",
"with_deleted"... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | open_for_group_write | Open with mode=mode and permissions '-rw-rw-r--' group writable is
the default on some systems/accounts, but it is important that it be present on our deployment machine | peyotl/utility/input_output.py | def open_for_group_write(fp, mode, encoding='utf-8'):
"""Open with mode=mode and permissions '-rw-rw-r--' group writable is
the default on some systems/accounts, but it is important that it be present on our deployment machine
"""
d = os.path.split(fp)[0]
if not os.path.exists(d):
os.makedir... | def open_for_group_write(fp, mode, encoding='utf-8'):
"""Open with mode=mode and permissions '-rw-rw-r--' group writable is
the default on some systems/accounts, but it is important that it be present on our deployment machine
"""
d = os.path.split(fp)[0]
if not os.path.exists(d):
os.makedir... | [
"Open",
"with",
"mode",
"=",
"mode",
"and",
"permissions",
"-",
"rw",
"-",
"rw",
"-",
"r",
"--",
"group",
"writable",
"is",
"the",
"default",
"on",
"some",
"systems",
"/",
"accounts",
"but",
"it",
"is",
"important",
"that",
"it",
"be",
"present",
"on",... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/input_output.py#L12-L22 | [
"def",
"open_for_group_write",
"(",
"fp",
",",
"mode",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"d",
"=",
"os",
".",
"path",
".",
"split",
"(",
"fp",
")",
"[",
"0",
"]",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"d",
")",
":",
"os",... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | read_filepath | Returns the text content of `filepath` | peyotl/utility/input_output.py | def read_filepath(filepath, encoding='utf-8'):
"""Returns the text content of `filepath`"""
with codecs.open(filepath, 'r', encoding=encoding) as fo:
return fo.read() | def read_filepath(filepath, encoding='utf-8'):
"""Returns the text content of `filepath`"""
with codecs.open(filepath, 'r', encoding=encoding) as fo:
return fo.read() | [
"Returns",
"the",
"text",
"content",
"of",
"filepath"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/input_output.py#L25-L28 | [
"def",
"read_filepath",
"(",
"filepath",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"filepath",
",",
"'r'",
",",
"encoding",
"=",
"encoding",
")",
"as",
"fo",
":",
"return",
"fo",
".",
"read",
"(",
")"
] | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | write_to_filepath | Writes `content` to the `filepath` Creates parent directory
if needed, and uses the specified file `mode` and data `encoding`.
If `group_writeable` is True, the output file will have permissions to be
writable by the group (on POSIX systems) | peyotl/utility/input_output.py | def write_to_filepath(content, filepath, encoding='utf-8', mode='w', group_writeable=False):
"""Writes `content` to the `filepath` Creates parent directory
if needed, and uses the specified file `mode` and data `encoding`.
If `group_writeable` is True, the output file will have permissions to be
wri... | def write_to_filepath(content, filepath, encoding='utf-8', mode='w', group_writeable=False):
"""Writes `content` to the `filepath` Creates parent directory
if needed, and uses the specified file `mode` and data `encoding`.
If `group_writeable` is True, the output file will have permissions to be
wri... | [
"Writes",
"content",
"to",
"the",
"filepath",
"Creates",
"parent",
"directory",
"if",
"needed",
"and",
"uses",
"the",
"specified",
"file",
"mode",
"and",
"data",
"encoding",
".",
"If",
"group_writeable",
"is",
"True",
"the",
"output",
"file",
"will",
"have",
... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/input_output.py#L31-L45 | [
"def",
"write_to_filepath",
"(",
"content",
",",
"filepath",
",",
"encoding",
"=",
"'utf-8'",
",",
"mode",
"=",
"'w'",
",",
"group_writeable",
"=",
"False",
")",
":",
"par_dir",
"=",
"os",
".",
"path",
".",
"split",
"(",
"filepath",
")",
"[",
"0",
"]",... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | download | Returns the text fetched via http GET from URL, read as `encoding` | peyotl/utility/input_output.py | def download(url, encoding='utf-8'):
"""Returns the text fetched via http GET from URL, read as `encoding`"""
import requests
response = requests.get(url)
response.encoding = encoding
return response.text | def download(url, encoding='utf-8'):
"""Returns the text fetched via http GET from URL, read as `encoding`"""
import requests
response = requests.get(url)
response.encoding = encoding
return response.text | [
"Returns",
"the",
"text",
"fetched",
"via",
"http",
"GET",
"from",
"URL",
"read",
"as",
"encoding"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/input_output.py#L53-L58 | [
"def",
"download",
"(",
"url",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"import",
"requests",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"response",
".",
"encoding",
"=",
"encoding",
"return",
"response",
".",
"text"
] | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | write_as_json | Writes `blob` as JSON to the filepath `dest` or the filestream `dest` (if it isn't a string)
uses utf-8 encoding if the filepath is given (does not change the encoding if dest is already open). | peyotl/utility/input_output.py | def write_as_json(blob, dest, indent=0, sort_keys=True):
"""Writes `blob` as JSON to the filepath `dest` or the filestream `dest` (if it isn't a string)
uses utf-8 encoding if the filepath is given (does not change the encoding if dest is already open).
"""
opened_out = False
if is_str_type(dest):
... | def write_as_json(blob, dest, indent=0, sort_keys=True):
"""Writes `blob` as JSON to the filepath `dest` or the filestream `dest` (if it isn't a string)
uses utf-8 encoding if the filepath is given (does not change the encoding if dest is already open).
"""
opened_out = False
if is_str_type(dest):
... | [
"Writes",
"blob",
"as",
"JSON",
"to",
"the",
"filepath",
"dest",
"or",
"the",
"filestream",
"dest",
"(",
"if",
"it",
"isn",
"t",
"a",
"string",
")",
"uses",
"utf",
"-",
"8",
"encoding",
"if",
"the",
"filepath",
"is",
"given",
"(",
"does",
"not",
"cha... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/input_output.py#L61-L77 | [
"def",
"write_as_json",
"(",
"blob",
",",
"dest",
",",
"indent",
"=",
"0",
",",
"sort_keys",
"=",
"True",
")",
":",
"opened_out",
"=",
"False",
"if",
"is_str_type",
"(",
"dest",
")",
":",
"out",
"=",
"codecs",
".",
"open",
"(",
"dest",
",",
"mode",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.