repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
guaix-ucm/numina | numina/instrument/simulation/factory.py | RunCounter.runstring | def runstring(self):
"""Return the run number and the file name."""
cfile = self.template % self.last
self.last += 1
return cfile | python | def runstring(self):
"""Return the run number and the file name."""
cfile = self.template % self.last
self.last += 1
return cfile | [
"def",
"runstring",
"(",
"self",
")",
":",
"cfile",
"=",
"self",
".",
"template",
"%",
"self",
".",
"last",
"self",
".",
"last",
"+=",
"1",
"return",
"cfile"
] | Return the run number and the file name. | [
"Return",
"the",
"run",
"number",
"and",
"the",
"file",
"name",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/instrument/simulation/factory.py#L21-L25 | train |
guaix-ucm/numina | numina/dal/dictdal.py | BaseDictDAL.obsres_from_oblock_id | def obsres_from_oblock_id(self, obsid, configuration=None):
""""
Override instrument configuration if configuration is not None
"""
este = self.ob_table[obsid]
obsres = obsres_from_dict(este)
_logger.debug("obsres_from_oblock_id id='%s', mode='%s' START", obsid, obsres.mo... | python | def obsres_from_oblock_id(self, obsid, configuration=None):
""""
Override instrument configuration if configuration is not None
"""
este = self.ob_table[obsid]
obsres = obsres_from_dict(este)
_logger.debug("obsres_from_oblock_id id='%s', mode='%s' START", obsid, obsres.mo... | [
"def",
"obsres_from_oblock_id",
"(",
"self",
",",
"obsid",
",",
"configuration",
"=",
"None",
")",
":",
"este",
"=",
"self",
".",
"ob_table",
"[",
"obsid",
"]",
"obsres",
"=",
"obsres_from_dict",
"(",
"este",
")",
"_logger",
".",
"debug",
"(",
"\"obsres_fr... | Override instrument configuration if configuration is not None | [
"Override",
"instrument",
"configuration",
"if",
"configuration",
"is",
"not",
"None"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/dal/dictdal.py#L141-L179 | train |
guaix-ucm/numina | numina/core/tagexpr.py | map_tree | def map_tree(visitor, tree):
"""Apply function to nodes"""
newn = [map_tree(visitor, node) for node in tree.nodes]
return visitor(tree, newn) | python | def map_tree(visitor, tree):
"""Apply function to nodes"""
newn = [map_tree(visitor, node) for node in tree.nodes]
return visitor(tree, newn) | [
"def",
"map_tree",
"(",
"visitor",
",",
"tree",
")",
":",
"newn",
"=",
"[",
"map_tree",
"(",
"visitor",
",",
"node",
")",
"for",
"node",
"in",
"tree",
".",
"nodes",
"]",
"return",
"visitor",
"(",
"tree",
",",
"newn",
")"
] | Apply function to nodes | [
"Apply",
"function",
"to",
"nodes"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/tagexpr.py#L44-L47 | train |
guaix-ucm/numina | numina/core/tagexpr.py | filter_tree | def filter_tree(condition, tree):
"""Return parts of the tree that fulfill condition"""
if condition(tree):
for node in tree.nodes:
# this works in python > 3.3
# yield from filter_tree(condition, node)
for n in filter_tree(condition, node):
yield n
... | python | def filter_tree(condition, tree):
"""Return parts of the tree that fulfill condition"""
if condition(tree):
for node in tree.nodes:
# this works in python > 3.3
# yield from filter_tree(condition, node)
for n in filter_tree(condition, node):
yield n
... | [
"def",
"filter_tree",
"(",
"condition",
",",
"tree",
")",
":",
"if",
"condition",
"(",
"tree",
")",
":",
"for",
"node",
"in",
"tree",
".",
"nodes",
":",
"for",
"n",
"in",
"filter_tree",
"(",
"condition",
",",
"node",
")",
":",
"yield",
"n",
"yield",
... | Return parts of the tree that fulfill condition | [
"Return",
"parts",
"of",
"the",
"tree",
"that",
"fulfill",
"condition"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/tagexpr.py#L50-L58 | train |
guaix-ucm/numina | numina/core/tagexpr.py | Expression.fill_placeholders | def fill_placeholders(self, tags):
"""Substitute Placeholder nodes by its value in tags"""
def change_p_node_tags(node, children):
if isinstance(node, Placeholder):
value = ConstExpr(tags[node.name])
return value
else:
return node.c... | python | def fill_placeholders(self, tags):
"""Substitute Placeholder nodes by its value in tags"""
def change_p_node_tags(node, children):
if isinstance(node, Placeholder):
value = ConstExpr(tags[node.name])
return value
else:
return node.c... | [
"def",
"fill_placeholders",
"(",
"self",
",",
"tags",
")",
":",
"def",
"change_p_node_tags",
"(",
"node",
",",
"children",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"Placeholder",
")",
":",
"value",
"=",
"ConstExpr",
"(",
"tags",
"[",
"node",
".",
... | Substitute Placeholder nodes by its value in tags | [
"Substitute",
"Placeholder",
"nodes",
"by",
"its",
"value",
"in",
"tags"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/tagexpr.py#L137-L146 | train |
SUNCAT-Center/CatHub | cathub/ase_tools/gas_phase_references.py | molecules2symbols | def molecules2symbols(molecules, add_hydrogen=True):
"""Take a list of molecules and return just a list of atomic
symbols, possibly adding hydrogen
"""
symbols = sorted(
list(set(
ase.symbols.string2symbols(''.join(
map(
lambda _x:
... | python | def molecules2symbols(molecules, add_hydrogen=True):
"""Take a list of molecules and return just a list of atomic
symbols, possibly adding hydrogen
"""
symbols = sorted(
list(set(
ase.symbols.string2symbols(''.join(
map(
lambda _x:
... | [
"def",
"molecules2symbols",
"(",
"molecules",
",",
"add_hydrogen",
"=",
"True",
")",
":",
"symbols",
"=",
"sorted",
"(",
"list",
"(",
"set",
"(",
"ase",
".",
"symbols",
".",
"string2symbols",
"(",
"''",
".",
"join",
"(",
"map",
"(",
"lambda",
"_x",
":"... | Take a list of molecules and return just a list of atomic
symbols, possibly adding hydrogen | [
"Take",
"a",
"list",
"of",
"molecules",
"and",
"return",
"just",
"a",
"list",
"of",
"atomic",
"symbols",
"possibly",
"adding",
"hydrogen"
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/ase_tools/gas_phase_references.py#L8-L25 | train |
SUNCAT-Center/CatHub | cathub/ase_tools/gas_phase_references.py | construct_reference_system | def construct_reference_system(
symbols,
candidates=None,
options=None,
):
"""Take a list of symbols and construct gas phase
references system, when possible avoiding O2.
Candidates can be rearranged, where earlier candidates
get higher preference than later candidates
assume symbols so... | python | def construct_reference_system(
symbols,
candidates=None,
options=None,
):
"""Take a list of symbols and construct gas phase
references system, when possible avoiding O2.
Candidates can be rearranged, where earlier candidates
get higher preference than later candidates
assume symbols so... | [
"def",
"construct_reference_system",
"(",
"symbols",
",",
"candidates",
"=",
"None",
",",
"options",
"=",
"None",
",",
")",
":",
"if",
"hasattr",
"(",
"options",
",",
"'no_hydrogen'",
")",
"and",
"options",
".",
"no_hydrogen",
":",
"add_hydrogen",
"=",
"Fals... | Take a list of symbols and construct gas phase
references system, when possible avoiding O2.
Candidates can be rearranged, where earlier candidates
get higher preference than later candidates
assume symbols sorted by atomic number | [
"Take",
"a",
"list",
"of",
"symbols",
"and",
"construct",
"gas",
"phase",
"references",
"system",
"when",
"possible",
"avoiding",
"O2",
".",
"Candidates",
"can",
"be",
"rearranged",
"where",
"earlier",
"candidates",
"get",
"higher",
"preference",
"than",
"later"... | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/ase_tools/gas_phase_references.py#L28-L106 | train |
SUNCAT-Center/CatHub | cathub/ase_tools/gas_phase_references.py | get_stoichiometry_factors | def get_stoichiometry_factors(adsorbates, references):
"""Take a list of adsorabtes and a corresponding reference
system and return a list of dictionaries encoding the
stoichiometry factors converting between adsorbates and
reference molecules.
"""
stoichiometry = get_atomic_stoichiometry(refere... | python | def get_stoichiometry_factors(adsorbates, references):
"""Take a list of adsorabtes and a corresponding reference
system and return a list of dictionaries encoding the
stoichiometry factors converting between adsorbates and
reference molecules.
"""
stoichiometry = get_atomic_stoichiometry(refere... | [
"def",
"get_stoichiometry_factors",
"(",
"adsorbates",
",",
"references",
")",
":",
"stoichiometry",
"=",
"get_atomic_stoichiometry",
"(",
"references",
")",
"stoichiometry_factors",
"=",
"{",
"}",
"for",
"adsorbate",
"in",
"adsorbates",
":",
"for",
"symbol",
"in",
... | Take a list of adsorabtes and a corresponding reference
system and return a list of dictionaries encoding the
stoichiometry factors converting between adsorbates and
reference molecules. | [
"Take",
"a",
"list",
"of",
"adsorabtes",
"and",
"a",
"corresponding",
"reference",
"system",
"and",
"return",
"a",
"list",
"of",
"dictionaries",
"encoding",
"the",
"stoichiometry",
"factors",
"converting",
"between",
"adsorbates",
"and",
"reference",
"molecules",
... | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/ase_tools/gas_phase_references.py#L132-L161 | train |
druids/django-chamber | chamber/importers/__init__.py | AbstractCSVImporter.get_fields_dict | def get_fields_dict(self, row):
"""
Returns a dict of field name and cleaned value pairs to initialize the model.
Beware, it aligns the lists of fields and row values with Nones to allow for adding fields not found in the CSV.
Whitespace around the value of the cell is stripped.
... | python | def get_fields_dict(self, row):
"""
Returns a dict of field name and cleaned value pairs to initialize the model.
Beware, it aligns the lists of fields and row values with Nones to allow for adding fields not found in the CSV.
Whitespace around the value of the cell is stripped.
... | [
"def",
"get_fields_dict",
"(",
"self",
",",
"row",
")",
":",
"return",
"{",
"k",
":",
"getattr",
"(",
"self",
",",
"'clean_{}'",
".",
"format",
"(",
"k",
")",
",",
"lambda",
"x",
":",
"x",
")",
"(",
"v",
".",
"strip",
"(",
")",
"if",
"isinstance"... | Returns a dict of field name and cleaned value pairs to initialize the model.
Beware, it aligns the lists of fields and row values with Nones to allow for adding fields not found in the CSV.
Whitespace around the value of the cell is stripped. | [
"Returns",
"a",
"dict",
"of",
"field",
"name",
"and",
"cleaned",
"value",
"pairs",
"to",
"initialize",
"the",
"model",
".",
"Beware",
"it",
"aligns",
"the",
"lists",
"of",
"fields",
"and",
"row",
"values",
"with",
"Nones",
"to",
"allow",
"for",
"adding",
... | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/importers/__init__.py#L90-L98 | train |
guaix-ucm/numina | numina/store/gtc/load.py | process_node | def process_node(node):
"""Process a node in result.json structure"""
value = node['value']
mname = node['name']
typeid = node['typeid']
if typeid == 52: # StructDataValue
obj = {}
for el in value['elements']:
key, val = process_node(el)
obj[key] = val
... | python | def process_node(node):
"""Process a node in result.json structure"""
value = node['value']
mname = node['name']
typeid = node['typeid']
if typeid == 52: # StructDataValue
obj = {}
for el in value['elements']:
key, val = process_node(el)
obj[key] = val
... | [
"def",
"process_node",
"(",
"node",
")",
":",
"value",
"=",
"node",
"[",
"'value'",
"]",
"mname",
"=",
"node",
"[",
"'name'",
"]",
"typeid",
"=",
"node",
"[",
"'typeid'",
"]",
"if",
"typeid",
"==",
"52",
":",
"obj",
"=",
"{",
"}",
"for",
"el",
"i... | Process a node in result.json structure | [
"Process",
"a",
"node",
"in",
"result",
".",
"json",
"structure"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/store/gtc/load.py#L20-L59 | train |
guaix-ucm/numina | numina/store/gtc/load.py | build_result | def build_result(data):
"""Create a dictionary with the contents of result.json"""
more = {}
for key, value in data.items():
if key != 'elements':
newnode = value
else:
newnode = {}
for el in value:
nkey, nvalue = process_node(el)
... | python | def build_result(data):
"""Create a dictionary with the contents of result.json"""
more = {}
for key, value in data.items():
if key != 'elements':
newnode = value
else:
newnode = {}
for el in value:
nkey, nvalue = process_node(el)
... | [
"def",
"build_result",
"(",
"data",
")",
":",
"more",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"if",
"key",
"!=",
"'elements'",
":",
"newnode",
"=",
"value",
"else",
":",
"newnode",
"=",
"{",
"}",
"for... | Create a dictionary with the contents of result.json | [
"Create",
"a",
"dictionary",
"with",
"the",
"contents",
"of",
"result",
".",
"json"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/store/gtc/load.py#L62-L76 | train |
guaix-ucm/numina | numina/core/recipeinout.py | RecipeInOut._finalize | def _finalize(self, all_msg_errors=None):
"""Access all the instance descriptors
This wil trigger an exception if a required
parameter is not set
"""
if all_msg_errors is None:
all_msg_errors = []
for key in self.stored():
try:
ge... | python | def _finalize(self, all_msg_errors=None):
"""Access all the instance descriptors
This wil trigger an exception if a required
parameter is not set
"""
if all_msg_errors is None:
all_msg_errors = []
for key in self.stored():
try:
ge... | [
"def",
"_finalize",
"(",
"self",
",",
"all_msg_errors",
"=",
"None",
")",
":",
"if",
"all_msg_errors",
"is",
"None",
":",
"all_msg_errors",
"=",
"[",
"]",
"for",
"key",
"in",
"self",
".",
"stored",
"(",
")",
":",
"try",
":",
"getattr",
"(",
"self",
"... | Access all the instance descriptors
This wil trigger an exception if a required
parameter is not set | [
"Access",
"all",
"the",
"instance",
"descriptors"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/recipeinout.py#L44-L61 | train |
guaix-ucm/numina | numina/core/recipeinout.py | RecipeInOut.validate | def validate(self):
"""Validate myself."""
for key, req in self.stored().items():
val = getattr(self, key)
req.validate(val)
# Run checks defined in __checkers__
self._run_checks() | python | def validate(self):
"""Validate myself."""
for key, req in self.stored().items():
val = getattr(self, key)
req.validate(val)
# Run checks defined in __checkers__
self._run_checks() | [
"def",
"validate",
"(",
"self",
")",
":",
"for",
"key",
",",
"req",
"in",
"self",
".",
"stored",
"(",
")",
".",
"items",
"(",
")",
":",
"val",
"=",
"getattr",
"(",
"self",
",",
"key",
")",
"req",
".",
"validate",
"(",
"val",
")",
"self",
".",
... | Validate myself. | [
"Validate",
"myself",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/recipeinout.py#L70-L78 | train |
guaix-ucm/numina | numina/core/validator.py | validate | def validate(method):
"""Decorate run method, inputs and outputs are validated"""
@wraps(method)
def mod_run(self, rinput):
self.validate_input(rinput)
#
result = method(self, rinput)
#
self.validate_result(result)
return result
return mod_run | python | def validate(method):
"""Decorate run method, inputs and outputs are validated"""
@wraps(method)
def mod_run(self, rinput):
self.validate_input(rinput)
#
result = method(self, rinput)
#
self.validate_result(result)
return result
return mod_run | [
"def",
"validate",
"(",
"method",
")",
":",
"@",
"wraps",
"(",
"method",
")",
"def",
"mod_run",
"(",
"self",
",",
"rinput",
")",
":",
"self",
".",
"validate_input",
"(",
"rinput",
")",
"result",
"=",
"method",
"(",
"self",
",",
"rinput",
")",
"self",... | Decorate run method, inputs and outputs are validated | [
"Decorate",
"run",
"method",
"inputs",
"and",
"outputs",
"are",
"validated"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/validator.py#L19-L31 | train |
guaix-ucm/numina | numina/core/validator.py | as_list | def as_list(callable):
"""Convert a scalar validator in a list validator"""
@wraps(callable)
def wrapper(value_iter):
return [callable(value) for value in value_iter]
return wrapper | python | def as_list(callable):
"""Convert a scalar validator in a list validator"""
@wraps(callable)
def wrapper(value_iter):
return [callable(value) for value in value_iter]
return wrapper | [
"def",
"as_list",
"(",
"callable",
")",
":",
"@",
"wraps",
"(",
"callable",
")",
"def",
"wrapper",
"(",
"value_iter",
")",
":",
"return",
"[",
"callable",
"(",
"value",
")",
"for",
"value",
"in",
"value_iter",
"]",
"return",
"wrapper"
] | Convert a scalar validator in a list validator | [
"Convert",
"a",
"scalar",
"validator",
"in",
"a",
"list",
"validator"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/validator.py#L41-L47 | train |
guaix-ucm/numina | numina/core/validator.py | range_validator | def range_validator(minval=None, maxval=None):
"""Generates a function that validates that a number is within range
Parameters
==========
minval: numeric, optional:
Values strictly lesser than `minval` are rejected
maxval: numeric, optional:
Values strictly greater than `maxval` are... | python | def range_validator(minval=None, maxval=None):
"""Generates a function that validates that a number is within range
Parameters
==========
minval: numeric, optional:
Values strictly lesser than `minval` are rejected
maxval: numeric, optional:
Values strictly greater than `maxval` are... | [
"def",
"range_validator",
"(",
"minval",
"=",
"None",
",",
"maxval",
"=",
"None",
")",
":",
"def",
"checker_func",
"(",
"value",
")",
":",
"if",
"minval",
"is",
"not",
"None",
"and",
"value",
"<",
"minval",
":",
"msg",
"=",
"\"must be >= {}\"",
".",
"f... | Generates a function that validates that a number is within range
Parameters
==========
minval: numeric, optional:
Values strictly lesser than `minval` are rejected
maxval: numeric, optional:
Values strictly greater than `maxval` are rejected
Returns
=======
A function that... | [
"Generates",
"a",
"function",
"that",
"validates",
"that",
"a",
"number",
"is",
"within",
"range"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/validator.py#L50-L75 | train |
pylp/pylp | pylp/cli/run.py | run | def run(path, tasks):
"""Run a pylpfile."""
# Test if the pylpfile exists
readable_path = make_readable_path(path)
if not os.path.isfile(path):
logger.log(logger.red("Can't read pylpfile "), logger.magenta(readable_path))
sys.exit(-1)
else:
logger.log("Using pylpfile ", logger.magenta(readable_path))
# R... | python | def run(path, tasks):
"""Run a pylpfile."""
# Test if the pylpfile exists
readable_path = make_readable_path(path)
if not os.path.isfile(path):
logger.log(logger.red("Can't read pylpfile "), logger.magenta(readable_path))
sys.exit(-1)
else:
logger.log("Using pylpfile ", logger.magenta(readable_path))
# R... | [
"def",
"run",
"(",
"path",
",",
"tasks",
")",
":",
"readable_path",
"=",
"make_readable_path",
"(",
"path",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"logger",
".",
"log",
"(",
"logger",
".",
"red",
"(",
"\"Can't read... | Run a pylpfile. | [
"Run",
"a",
"pylpfile",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/run.py#L18-L45 | train |
pylp/pylp | pylp/cli/run.py | wait_and_quit | async def wait_and_quit(loop):
"""Wait until all task are executed."""
from pylp.lib.tasks import running
if running:
await asyncio.wait(map(lambda runner: runner.future, running)) | python | async def wait_and_quit(loop):
"""Wait until all task are executed."""
from pylp.lib.tasks import running
if running:
await asyncio.wait(map(lambda runner: runner.future, running)) | [
"async",
"def",
"wait_and_quit",
"(",
"loop",
")",
":",
"from",
"pylp",
".",
"lib",
".",
"tasks",
"import",
"running",
"if",
"running",
":",
"await",
"asyncio",
".",
"wait",
"(",
"map",
"(",
"lambda",
"runner",
":",
"runner",
".",
"future",
",",
"runni... | Wait until all task are executed. | [
"Wait",
"until",
"all",
"task",
"are",
"executed",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/run.py#L49-L53 | train |
inspirehep/inspire-schemas | inspire_schemas/readers/literature.py | LiteratureReader.is_published | def is_published(self):
"""Return True if a record is published.
We say that a record is published if it is citeable, which means that
it has enough information in a ``publication_info``, or if we know its
DOI and a ``journal_title``, which means it is in press.
Returns:
... | python | def is_published(self):
"""Return True if a record is published.
We say that a record is published if it is citeable, which means that
it has enough information in a ``publication_info``, or if we know its
DOI and a ``journal_title``, which means it is in press.
Returns:
... | [
"def",
"is_published",
"(",
"self",
")",
":",
"citeable",
"=",
"'publication_info'",
"in",
"self",
".",
"record",
"and",
"is_citeable",
"(",
"self",
".",
"record",
"[",
"'publication_info'",
"]",
")",
"submitted",
"=",
"'dois'",
"in",
"self",
".",
"record",
... | Return True if a record is published.
We say that a record is published if it is citeable, which means that
it has enough information in a ``publication_info``, or if we know its
DOI and a ``journal_title``, which means it is in press.
Returns:
bool: whether the record is p... | [
"Return",
"True",
"if",
"a",
"record",
"is",
"published",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/readers/literature.py#L351-L382 | train |
inspirehep/inspire-schemas | inspire_schemas/readers/literature.py | LiteratureReader.get_page_artid_for_publication_info | def get_page_artid_for_publication_info(publication_info, separator):
"""Return the page range or the article id of a publication_info entry.
Args:
publication_info(dict): a publication_info field entry of a record
separator(basestring): optional page range symbol, defaults to a... | python | def get_page_artid_for_publication_info(publication_info, separator):
"""Return the page range or the article id of a publication_info entry.
Args:
publication_info(dict): a publication_info field entry of a record
separator(basestring): optional page range symbol, defaults to a... | [
"def",
"get_page_artid_for_publication_info",
"(",
"publication_info",
",",
"separator",
")",
":",
"if",
"'artid'",
"in",
"publication_info",
":",
"return",
"publication_info",
"[",
"'artid'",
"]",
"elif",
"'page_start'",
"in",
"publication_info",
"and",
"'page_end'",
... | Return the page range or the article id of a publication_info entry.
Args:
publication_info(dict): a publication_info field entry of a record
separator(basestring): optional page range symbol, defaults to a single dash
Returns:
string: the page range or the article ... | [
"Return",
"the",
"page",
"range",
"or",
"the",
"article",
"id",
"of",
"a",
"publication_info",
"entry",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/readers/literature.py#L449-L475 | train |
inspirehep/inspire-schemas | inspire_schemas/readers/literature.py | LiteratureReader.get_page_artid | def get_page_artid(self, separator='-'):
"""Return the page range or the article id of a record.
Args:
separator(basestring): optional page range symbol, defaults to a single dash
Returns:
string: the page range or the article id of the record.
Examples:
... | python | def get_page_artid(self, separator='-'):
"""Return the page range or the article id of a record.
Args:
separator(basestring): optional page range symbol, defaults to a single dash
Returns:
string: the page range or the article id of the record.
Examples:
... | [
"def",
"get_page_artid",
"(",
"self",
",",
"separator",
"=",
"'-'",
")",
":",
"publication_info",
"=",
"get_value",
"(",
"self",
".",
"record",
",",
"'publication_info[0]'",
",",
"default",
"=",
"{",
"}",
")",
"return",
"LiteratureReader",
".",
"get_page_artid... | Return the page range or the article id of a record.
Args:
separator(basestring): optional page range symbol, defaults to a single dash
Returns:
string: the page range or the article id of the record.
Examples:
>>> record = {
... 'publicatio... | [
"Return",
"the",
"page",
"range",
"or",
"the",
"article",
"id",
"of",
"a",
"record",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/readers/literature.py#L477-L504 | train |
xflr6/bitsets | bitsets/transform.py | chunkreverse | def chunkreverse(integers, dtype='L'):
"""Yield integers of dtype bit-length reverting their bit-order.
>>> list(chunkreverse([0b10000000, 0b11000000, 0b00000001], 'B'))
[1, 3, 128]
>>> list(chunkreverse([0x8000, 0xC000, 0x0001], 'H'))
[1, 3, 32768]
"""
if dtype in ('B', 8):
return... | python | def chunkreverse(integers, dtype='L'):
"""Yield integers of dtype bit-length reverting their bit-order.
>>> list(chunkreverse([0b10000000, 0b11000000, 0b00000001], 'B'))
[1, 3, 128]
>>> list(chunkreverse([0x8000, 0xC000, 0x0001], 'H'))
[1, 3, 32768]
"""
if dtype in ('B', 8):
return... | [
"def",
"chunkreverse",
"(",
"integers",
",",
"dtype",
"=",
"'L'",
")",
":",
"if",
"dtype",
"in",
"(",
"'B'",
",",
"8",
")",
":",
"return",
"map",
"(",
"RBYTES",
".",
"__getitem__",
",",
"integers",
")",
"fmt",
"=",
"'{0:0%db}'",
"%",
"NBITS",
"[",
... | Yield integers of dtype bit-length reverting their bit-order.
>>> list(chunkreverse([0b10000000, 0b11000000, 0b00000001], 'B'))
[1, 3, 128]
>>> list(chunkreverse([0x8000, 0xC000, 0x0001], 'H'))
[1, 3, 32768] | [
"Yield",
"integers",
"of",
"dtype",
"bit",
"-",
"length",
"reverting",
"their",
"bit",
"-",
"order",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/transform.py#L26-L40 | train |
xflr6/bitsets | bitsets/transform.py | pack | def pack(chunks, r=32):
"""Return integer concatenating integer chunks of r > 0 bit-length.
>>> pack([0, 1, 0, 1, 0, 1], 1)
42
>>> pack([0, 1], 8)
256
>>> pack([0, 1], 0)
Traceback (most recent call last):
...
ValueError: pack needs r > 0
"""
if r < 1:
raise Va... | python | def pack(chunks, r=32):
"""Return integer concatenating integer chunks of r > 0 bit-length.
>>> pack([0, 1, 0, 1, 0, 1], 1)
42
>>> pack([0, 1], 8)
256
>>> pack([0, 1], 0)
Traceback (most recent call last):
...
ValueError: pack needs r > 0
"""
if r < 1:
raise Va... | [
"def",
"pack",
"(",
"chunks",
",",
"r",
"=",
"32",
")",
":",
"if",
"r",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"'pack needs r > 0'",
")",
"n",
"=",
"shift",
"=",
"0",
"for",
"c",
"in",
"chunks",
":",
"n",
"+=",
"c",
"<<",
"shift",
"shift",
... | Return integer concatenating integer chunks of r > 0 bit-length.
>>> pack([0, 1, 0, 1, 0, 1], 1)
42
>>> pack([0, 1], 8)
256
>>> pack([0, 1], 0)
Traceback (most recent call last):
...
ValueError: pack needs r > 0 | [
"Return",
"integer",
"concatenating",
"integer",
"chunks",
"of",
"r",
">",
"0",
"bit",
"-",
"length",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/transform.py#L43-L66 | train |
xflr6/bitsets | bitsets/transform.py | unpack | def unpack(n, r=32):
"""Yield r > 0 bit-length integers splitting n into chunks.
>>> list(unpack(42, 1))
[0, 1, 0, 1, 0, 1]
>>> list(unpack(256, 8))
[0, 1]
>>> list(unpack(2, 0))
Traceback (most recent call last):
...
ValueError: unpack needs r > 0
"""
if r < 1:
... | python | def unpack(n, r=32):
"""Yield r > 0 bit-length integers splitting n into chunks.
>>> list(unpack(42, 1))
[0, 1, 0, 1, 0, 1]
>>> list(unpack(256, 8))
[0, 1]
>>> list(unpack(2, 0))
Traceback (most recent call last):
...
ValueError: unpack needs r > 0
"""
if r < 1:
... | [
"def",
"unpack",
"(",
"n",
",",
"r",
"=",
"32",
")",
":",
"if",
"r",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"'unpack needs r > 0'",
")",
"mask",
"=",
"(",
"1",
"<<",
"r",
")",
"-",
"1",
"while",
"n",
":",
"yield",
"n",
"&",
"mask",
"n",
"... | Yield r > 0 bit-length integers splitting n into chunks.
>>> list(unpack(42, 1))
[0, 1, 0, 1, 0, 1]
>>> list(unpack(256, 8))
[0, 1]
>>> list(unpack(2, 0))
Traceback (most recent call last):
...
ValueError: unpack needs r > 0 | [
"Yield",
"r",
">",
"0",
"bit",
"-",
"length",
"integers",
"splitting",
"n",
"into",
"chunks",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/transform.py#L69-L90 | train |
xflr6/bitsets | bitsets/transform.py | packbools | def packbools(bools, dtype='L'):
"""Yield integers concatenating bools in chunks of dtype bit-length.
>>> list(packbools([False, True, False, True, False, True], 'B'))
[42]
"""
r = NBITS[dtype]
atoms = ATOMS[dtype]
for chunk in zip_longest(*[iter(bools)] * r, fillvalue=False):
yiel... | python | def packbools(bools, dtype='L'):
"""Yield integers concatenating bools in chunks of dtype bit-length.
>>> list(packbools([False, True, False, True, False, True], 'B'))
[42]
"""
r = NBITS[dtype]
atoms = ATOMS[dtype]
for chunk in zip_longest(*[iter(bools)] * r, fillvalue=False):
yiel... | [
"def",
"packbools",
"(",
"bools",
",",
"dtype",
"=",
"'L'",
")",
":",
"r",
"=",
"NBITS",
"[",
"dtype",
"]",
"atoms",
"=",
"ATOMS",
"[",
"dtype",
"]",
"for",
"chunk",
"in",
"zip_longest",
"(",
"*",
"[",
"iter",
"(",
"bools",
")",
"]",
"*",
"r",
... | Yield integers concatenating bools in chunks of dtype bit-length.
>>> list(packbools([False, True, False, True, False, True], 'B'))
[42] | [
"Yield",
"integers",
"concatenating",
"bools",
"in",
"chunks",
"of",
"dtype",
"bit",
"-",
"length",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/transform.py#L93-L103 | train |
xflr6/bitsets | bitsets/transform.py | unpackbools | def unpackbools(integers, dtype='L'):
"""Yield booleans unpacking integers of dtype bit-length.
>>> list(unpackbools([42], 'B'))
[False, True, False, True, False, True, False, False]
"""
atoms = ATOMS[dtype]
for chunk in integers:
for a in atoms:
yield not not chunk & a | python | def unpackbools(integers, dtype='L'):
"""Yield booleans unpacking integers of dtype bit-length.
>>> list(unpackbools([42], 'B'))
[False, True, False, True, False, True, False, False]
"""
atoms = ATOMS[dtype]
for chunk in integers:
for a in atoms:
yield not not chunk & a | [
"def",
"unpackbools",
"(",
"integers",
",",
"dtype",
"=",
"'L'",
")",
":",
"atoms",
"=",
"ATOMS",
"[",
"dtype",
"]",
"for",
"chunk",
"in",
"integers",
":",
"for",
"a",
"in",
"atoms",
":",
"yield",
"not",
"not",
"chunk",
"&",
"a"
] | Yield booleans unpacking integers of dtype bit-length.
>>> list(unpackbools([42], 'B'))
[False, True, False, True, False, True, False, False] | [
"Yield",
"booleans",
"unpacking",
"integers",
"of",
"dtype",
"bit",
"-",
"length",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/transform.py#L106-L116 | train |
guaix-ucm/numina | numina/array/wavecalib/arccalibration.py | select_data_for_fit | def select_data_for_fit(list_of_wvfeatures):
"""Select information from valid arc lines to facilitate posterior fits.
Parameters
----------
list_of_wvfeatures : list (of WavecalFeature instances)
A list of size equal to the number of identified lines, which
elements are instances of the... | python | def select_data_for_fit(list_of_wvfeatures):
"""Select information from valid arc lines to facilitate posterior fits.
Parameters
----------
list_of_wvfeatures : list (of WavecalFeature instances)
A list of size equal to the number of identified lines, which
elements are instances of the... | [
"def",
"select_data_for_fit",
"(",
"list_of_wvfeatures",
")",
":",
"nlines_arc",
"=",
"len",
"(",
"list_of_wvfeatures",
")",
"nfit",
"=",
"0",
"ifit",
"=",
"[",
"]",
"xfit",
"=",
"np",
".",
"array",
"(",
"[",
"]",
")",
"yfit",
"=",
"np",
".",
"array",
... | Select information from valid arc lines to facilitate posterior fits.
Parameters
----------
list_of_wvfeatures : list (of WavecalFeature instances)
A list of size equal to the number of identified lines, which
elements are instances of the class WavecalFeature, containing
all the re... | [
"Select",
"information",
"from",
"valid",
"arc",
"lines",
"to",
"facilitate",
"posterior",
"fits",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/arccalibration.py#L39-L82 | train |
guaix-ucm/numina | numina/array/wavecalib/arccalibration.py | gen_triplets_master | def gen_triplets_master(wv_master, geometry=None, debugplot=0):
"""Compute information associated to triplets in master table.
Determine all the possible triplets that can be generated from the
array `wv_master`. In addition, the relative position of the
central line of each triplet is also computed.
... | python | def gen_triplets_master(wv_master, geometry=None, debugplot=0):
"""Compute information associated to triplets in master table.
Determine all the possible triplets that can be generated from the
array `wv_master`. In addition, the relative position of the
central line of each triplet is also computed.
... | [
"def",
"gen_triplets_master",
"(",
"wv_master",
",",
"geometry",
"=",
"None",
",",
"debugplot",
"=",
"0",
")",
":",
"nlines_master",
"=",
"wv_master",
".",
"size",
"wv_previous",
"=",
"wv_master",
"[",
"0",
"]",
"for",
"i",
"in",
"range",
"(",
"1",
",",
... | Compute information associated to triplets in master table.
Determine all the possible triplets that can be generated from the
array `wv_master`. In addition, the relative position of the
central line of each triplet is also computed.
Parameters
----------
wv_master : 1d numpy array, float
... | [
"Compute",
"information",
"associated",
"to",
"triplets",
"in",
"master",
"table",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/arccalibration.py#L324-L425 | train |
guaix-ucm/numina | numina/array/wavecalib/arccalibration.py | arccalibration | def arccalibration(wv_master,
xpos_arc,
naxis1_arc,
crpix1,
wv_ini_search,
wv_end_search,
wvmin_useful,
wvmax_useful,
error_xpos_arc,
times_sigma_r,
... | python | def arccalibration(wv_master,
xpos_arc,
naxis1_arc,
crpix1,
wv_ini_search,
wv_end_search,
wvmin_useful,
wvmax_useful,
error_xpos_arc,
times_sigma_r,
... | [
"def",
"arccalibration",
"(",
"wv_master",
",",
"xpos_arc",
",",
"naxis1_arc",
",",
"crpix1",
",",
"wv_ini_search",
",",
"wv_end_search",
",",
"wvmin_useful",
",",
"wvmax_useful",
",",
"error_xpos_arc",
",",
"times_sigma_r",
",",
"frac_triplets_for_sum",
",",
"times... | Performs arc line identification for arc calibration.
This function is a wrapper of two functions, which are responsible
of computing all the relevant information concerning the triplets
generated from the master table and the actual identification
procedure of the arc lines, respectively.
The sep... | [
"Performs",
"arc",
"line",
"identification",
"for",
"arc",
"calibration",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/arccalibration.py#L428-L543 | train |
guaix-ucm/numina | numina/array/wavecalib/arccalibration.py | match_wv_arrays | def match_wv_arrays(wv_master, wv_expected_all_peaks, delta_wv_max):
"""Match two lists with wavelengths.
Assign individual wavelengths from wv_master to each expected
wavelength when the latter is within the maximum allowed range.
Parameters
----------
wv_master : numpy array
Array co... | python | def match_wv_arrays(wv_master, wv_expected_all_peaks, delta_wv_max):
"""Match two lists with wavelengths.
Assign individual wavelengths from wv_master to each expected
wavelength when the latter is within the maximum allowed range.
Parameters
----------
wv_master : numpy array
Array co... | [
"def",
"match_wv_arrays",
"(",
"wv_master",
",",
"wv_expected_all_peaks",
",",
"delta_wv_max",
")",
":",
"wv_verified_all_peaks",
"=",
"np",
".",
"zeros_like",
"(",
"wv_expected_all_peaks",
")",
"wv_unused",
"=",
"np",
".",
"ones_like",
"(",
"wv_expected_all_peaks",
... | Match two lists with wavelengths.
Assign individual wavelengths from wv_master to each expected
wavelength when the latter is within the maximum allowed range.
Parameters
----------
wv_master : numpy array
Array containing the master wavelengths.
wv_expected_all_peaks : numpy array
... | [
"Match",
"two",
"lists",
"with",
"wavelengths",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/arccalibration.py#L1519-L1600 | train |
guaix-ucm/numina | numina/array/display/matplotlib_qt.py | set_window_geometry | def set_window_geometry(geometry):
"""Set window geometry.
Parameters
==========
geometry : tuple (4 integers) or None
x, y, dx, dy values employed to set the Qt backend geometry.
"""
if geometry is not None:
x_geom, y_geom, dx_geom, dy_geom = geometry
mngr = plt.get_c... | python | def set_window_geometry(geometry):
"""Set window geometry.
Parameters
==========
geometry : tuple (4 integers) or None
x, y, dx, dy values employed to set the Qt backend geometry.
"""
if geometry is not None:
x_geom, y_geom, dx_geom, dy_geom = geometry
mngr = plt.get_c... | [
"def",
"set_window_geometry",
"(",
"geometry",
")",
":",
"if",
"geometry",
"is",
"not",
"None",
":",
"x_geom",
",",
"y_geom",
",",
"dx_geom",
",",
"dy_geom",
"=",
"geometry",
"mngr",
"=",
"plt",
".",
"get_current_fig_manager",
"(",
")",
"if",
"'window'",
"... | Set window geometry.
Parameters
==========
geometry : tuple (4 integers) or None
x, y, dx, dy values employed to set the Qt backend geometry. | [
"Set",
"window",
"geometry",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/matplotlib_qt.py#L8-L27 | train |
arkottke/pysra | pysra/tools.py | parse_fixed_width | def parse_fixed_width(types, lines):
"""Parse a fixed width line."""
values = []
line = []
for width, parser in types:
if not line:
line = lines.pop(0).replace('\n', '')
values.append(parser(line[:width]))
line = line[width:]
return values | python | def parse_fixed_width(types, lines):
"""Parse a fixed width line."""
values = []
line = []
for width, parser in types:
if not line:
line = lines.pop(0).replace('\n', '')
values.append(parser(line[:width]))
line = line[width:]
return values | [
"def",
"parse_fixed_width",
"(",
"types",
",",
"lines",
")",
":",
"values",
"=",
"[",
"]",
"line",
"=",
"[",
"]",
"for",
"width",
",",
"parser",
"in",
"types",
":",
"if",
"not",
"line",
":",
"line",
"=",
"lines",
".",
"pop",
"(",
"0",
")",
".",
... | Parse a fixed width line. | [
"Parse",
"a",
"fixed",
"width",
"line",
"."
] | c72fd389d6c15203c0c00728ac00f101bae6369d | https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/tools.py#L48-L59 | train |
arkottke/pysra | pysra/tools.py | _parse_curves | def _parse_curves(block, **kwargs):
"""Parse nonlinear curves block."""
count = int(block.pop(0))
curves = []
for i in range(count):
for param in ['mod_reduc', 'damping']:
length, name = parse_fixed_width([(5, int), (65, to_str)], block)
curves.append(
si... | python | def _parse_curves(block, **kwargs):
"""Parse nonlinear curves block."""
count = int(block.pop(0))
curves = []
for i in range(count):
for param in ['mod_reduc', 'damping']:
length, name = parse_fixed_width([(5, int), (65, to_str)], block)
curves.append(
si... | [
"def",
"_parse_curves",
"(",
"block",
",",
"**",
"kwargs",
")",
":",
"count",
"=",
"int",
"(",
"block",
".",
"pop",
"(",
"0",
")",
")",
"curves",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"count",
")",
":",
"for",
"param",
"in",
"[",
"'mod... | Parse nonlinear curves block. | [
"Parse",
"nonlinear",
"curves",
"block",
"."
] | c72fd389d6c15203c0c00728ac00f101bae6369d | https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/tools.py#L62-L80 | train |
arkottke/pysra | pysra/tools.py | _parse_soil_profile | def _parse_soil_profile(block, units, curves, **kwargs):
"""Parse soil profile block."""
wt_layer, length, _, name = parse_fixed_width(
3 * [(5, int)] + [(55, to_str)], block)
layers = []
soil_types = []
for i in range(length):
index, soil_idx, thickness, shear_mod, damping, unit_wt... | python | def _parse_soil_profile(block, units, curves, **kwargs):
"""Parse soil profile block."""
wt_layer, length, _, name = parse_fixed_width(
3 * [(5, int)] + [(55, to_str)], block)
layers = []
soil_types = []
for i in range(length):
index, soil_idx, thickness, shear_mod, damping, unit_wt... | [
"def",
"_parse_soil_profile",
"(",
"block",
",",
"units",
",",
"curves",
",",
"**",
"kwargs",
")",
":",
"wt_layer",
",",
"length",
",",
"_",
",",
"name",
"=",
"parse_fixed_width",
"(",
"3",
"*",
"[",
"(",
"5",
",",
"int",
")",
"]",
"+",
"[",
"(",
... | Parse soil profile block. | [
"Parse",
"soil",
"profile",
"block",
"."
] | c72fd389d6c15203c0c00728ac00f101bae6369d | https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/tools.py#L83-L123 | train |
arkottke/pysra | pysra/tools.py | _parse_motion | def _parse_motion(block, **kwargs):
"""Parse motin specification block."""
_, fa_length, time_step, name, fmt = parse_fixed_width(
[(5, int), (5, int), (10, float), (30, to_str), (30, to_str)], block)
scale, pga, _, header_lines, _ = parse_fixed_width(
3 * [(10, to_float)] + 2 * [(5, int)],... | python | def _parse_motion(block, **kwargs):
"""Parse motin specification block."""
_, fa_length, time_step, name, fmt = parse_fixed_width(
[(5, int), (5, int), (10, float), (30, to_str), (30, to_str)], block)
scale, pga, _, header_lines, _ = parse_fixed_width(
3 * [(10, to_float)] + 2 * [(5, int)],... | [
"def",
"_parse_motion",
"(",
"block",
",",
"**",
"kwargs",
")",
":",
"_",
",",
"fa_length",
",",
"time_step",
",",
"name",
",",
"fmt",
"=",
"parse_fixed_width",
"(",
"[",
"(",
"5",
",",
"int",
")",
",",
"(",
"5",
",",
"int",
")",
",",
"(",
"10",
... | Parse motin specification block. | [
"Parse",
"motin",
"specification",
"block",
"."
] | c72fd389d6c15203c0c00728ac00f101bae6369d | https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/tools.py#L126-L154 | train |
arkottke/pysra | pysra/tools.py | _parse_input_loc | def _parse_input_loc(block, profile, **kwargs):
"""Parse input location block."""
layer, wave_field = parse_fixed_width(2 * [(5, int)], block)
return profile.location(
motion.WaveField[wave_field],
index=(layer - 1), ) | python | def _parse_input_loc(block, profile, **kwargs):
"""Parse input location block."""
layer, wave_field = parse_fixed_width(2 * [(5, int)], block)
return profile.location(
motion.WaveField[wave_field],
index=(layer - 1), ) | [
"def",
"_parse_input_loc",
"(",
"block",
",",
"profile",
",",
"**",
"kwargs",
")",
":",
"layer",
",",
"wave_field",
"=",
"parse_fixed_width",
"(",
"2",
"*",
"[",
"(",
"5",
",",
"int",
")",
"]",
",",
"block",
")",
"return",
"profile",
".",
"location",
... | Parse input location block. | [
"Parse",
"input",
"location",
"block",
"."
] | c72fd389d6c15203c0c00728ac00f101bae6369d | https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/tools.py#L157-L163 | train |
arkottke/pysra | pysra/tools.py | _parse_run_control | def _parse_run_control(block):
"""Parse run control block."""
_, max_iterations, strain_ratio, _, _ = parse_fixed_width(
2 * [(5, int)] + [(10, float)] + 2 * [(5, int)], block)
return propagation.EquivalentLinearCalculation(
strain_ratio, max_iterations, tolerance=10.) | python | def _parse_run_control(block):
"""Parse run control block."""
_, max_iterations, strain_ratio, _, _ = parse_fixed_width(
2 * [(5, int)] + [(10, float)] + 2 * [(5, int)], block)
return propagation.EquivalentLinearCalculation(
strain_ratio, max_iterations, tolerance=10.) | [
"def",
"_parse_run_control",
"(",
"block",
")",
":",
"_",
",",
"max_iterations",
",",
"strain_ratio",
",",
"_",
",",
"_",
"=",
"parse_fixed_width",
"(",
"2",
"*",
"[",
"(",
"5",
",",
"int",
")",
"]",
"+",
"[",
"(",
"10",
",",
"float",
")",
"]",
"... | Parse run control block. | [
"Parse",
"run",
"control",
"block",
"."
] | c72fd389d6c15203c0c00728ac00f101bae6369d | https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/tools.py#L166-L172 | train |
guaix-ucm/numina | numina/array/blocks.py | blockgen1d | def blockgen1d(block, size):
"""Compute 1d block intervals to be used by combine.
blockgen1d computes the slices by recursively halving the initial
interval (0, size) by 2 until its size is lesser or equal than block
:param block: an integer maximum block size
:param size: original size of the int... | python | def blockgen1d(block, size):
"""Compute 1d block intervals to be used by combine.
blockgen1d computes the slices by recursively halving the initial
interval (0, size) by 2 until its size is lesser or equal than block
:param block: an integer maximum block size
:param size: original size of the int... | [
"def",
"blockgen1d",
"(",
"block",
",",
"size",
")",
":",
"def",
"numblock",
"(",
"blk",
",",
"x",
")",
":",
"a",
",",
"b",
"=",
"x",
"if",
"b",
"-",
"a",
"<=",
"blk",
":",
"return",
"[",
"x",
"]",
"else",
":",
"result",
"=",
"[",
"]",
"d",... | Compute 1d block intervals to be used by combine.
blockgen1d computes the slices by recursively halving the initial
interval (0, size) by 2 until its size is lesser or equal than block
:param block: an integer maximum block size
:param size: original size of the interval, it corresponds to a 0:size sl... | [
"Compute",
"1d",
"block",
"intervals",
"to",
"be",
"used",
"by",
"combine",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/blocks.py#L23-L53 | train |
guaix-ucm/numina | numina/array/blocks.py | blockgen | def blockgen(blocks, shape):
"""Generate a list of slice tuples to be used by combine.
The tuples represent regions in an N-dimensional image.
:param blocks: a tuple of block sizes
:param shape: the shape of the n-dimensional array
:return: an iterator to the list of tuples of slices
Example:... | python | def blockgen(blocks, shape):
"""Generate a list of slice tuples to be used by combine.
The tuples represent regions in an N-dimensional image.
:param blocks: a tuple of block sizes
:param shape: the shape of the n-dimensional array
:return: an iterator to the list of tuples of slices
Example:... | [
"def",
"blockgen",
"(",
"blocks",
",",
"shape",
")",
":",
"iterables",
"=",
"[",
"blockgen1d",
"(",
"l",
",",
"s",
")",
"for",
"(",
"l",
",",
"s",
")",
"in",
"zip",
"(",
"blocks",
",",
"shape",
")",
"]",
"return",
"product",
"(",
"*",
"iterables"... | Generate a list of slice tuples to be used by combine.
The tuples represent regions in an N-dimensional image.
:param blocks: a tuple of block sizes
:param shape: the shape of the n-dimensional array
:return: an iterator to the list of tuples of slices
Example:
>>> blocks = (500, 512)
... | [
"Generate",
"a",
"list",
"of",
"slice",
"tuples",
"to",
"be",
"used",
"by",
"combine",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/blocks.py#L56-L82 | train |
guaix-ucm/numina | numina/array/blocks.py | blk_coverage_1d | def blk_coverage_1d(blk, size):
"""Return the part of a 1d array covered by a block.
:param blk: size of the 1d block
:param size: size of the 1d a image
:return: a tuple of size covered and remaining size
Example:
>>> blk_coverage_1d(7, 100)
(98, 2)
"""
rem = size % blk
... | python | def blk_coverage_1d(blk, size):
"""Return the part of a 1d array covered by a block.
:param blk: size of the 1d block
:param size: size of the 1d a image
:return: a tuple of size covered and remaining size
Example:
>>> blk_coverage_1d(7, 100)
(98, 2)
"""
rem = size % blk
... | [
"def",
"blk_coverage_1d",
"(",
"blk",
",",
"size",
")",
":",
"rem",
"=",
"size",
"%",
"blk",
"maxpix",
"=",
"size",
"-",
"rem",
"return",
"maxpix",
",",
"rem"
] | Return the part of a 1d array covered by a block.
:param blk: size of the 1d block
:param size: size of the 1d a image
:return: a tuple of size covered and remaining size
Example:
>>> blk_coverage_1d(7, 100)
(98, 2) | [
"Return",
"the",
"part",
"of",
"a",
"1d",
"array",
"covered",
"by",
"a",
"block",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/blocks.py#L85-L100 | train |
guaix-ucm/numina | numina/array/blocks.py | max_blk_coverage | def max_blk_coverage(blk, shape):
"""Return the maximum shape of an array covered by a block.
:param blk: the N-dimensional shape of the block
:param shape: the N-dimensional shape of the array
:return: the shape of the covered region
Example:
>>> max_blk_coverage(blk=(7, 6), shape=(100, ... | python | def max_blk_coverage(blk, shape):
"""Return the maximum shape of an array covered by a block.
:param blk: the N-dimensional shape of the block
:param shape: the N-dimensional shape of the array
:return: the shape of the covered region
Example:
>>> max_blk_coverage(blk=(7, 6), shape=(100, ... | [
"def",
"max_blk_coverage",
"(",
"blk",
",",
"shape",
")",
":",
"return",
"tuple",
"(",
"blk_coverage_1d",
"(",
"b",
",",
"s",
")",
"[",
"0",
"]",
"for",
"b",
",",
"s",
"in",
"zip",
"(",
"blk",
",",
"shape",
")",
")"
] | Return the maximum shape of an array covered by a block.
:param blk: the N-dimensional shape of the block
:param shape: the N-dimensional shape of the array
:return: the shape of the covered region
Example:
>>> max_blk_coverage(blk=(7, 6), shape=(100, 43))
(98, 42) | [
"Return",
"the",
"maximum",
"shape",
"of",
"an",
"array",
"covered",
"by",
"a",
"block",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/blocks.py#L103-L117 | train |
guaix-ucm/numina | numina/array/blocks.py | blk_nd_short | def blk_nd_short(blk, shape):
"""Iterate trough the blocks that strictly cover an array.
Iterate trough the blocks that recover the part of the array
given by max_blk_coverage.
:param blk: the N-dimensional shape of the block
:param shape: the N-dimensional shape of the array
:return: a genera... | python | def blk_nd_short(blk, shape):
"""Iterate trough the blocks that strictly cover an array.
Iterate trough the blocks that recover the part of the array
given by max_blk_coverage.
:param blk: the N-dimensional shape of the block
:param shape: the N-dimensional shape of the array
:return: a genera... | [
"def",
"blk_nd_short",
"(",
"blk",
",",
"shape",
")",
":",
"internals",
"=",
"(",
"blk_1d_short",
"(",
"b",
",",
"s",
")",
"for",
"b",
",",
"s",
"in",
"zip",
"(",
"blk",
",",
"shape",
")",
")",
"return",
"product",
"(",
"*",
"internals",
")"
] | Iterate trough the blocks that strictly cover an array.
Iterate trough the blocks that recover the part of the array
given by max_blk_coverage.
:param blk: the N-dimensional shape of the block
:param shape: the N-dimensional shape of the array
:return: a generator that yields the blocks
Examp... | [
"Iterate",
"trough",
"the",
"blocks",
"that",
"strictly",
"cover",
"an",
"array",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/blocks.py#L137-L169 | train |
guaix-ucm/numina | numina/array/blocks.py | blk_nd | def blk_nd(blk, shape):
"""Iterate through the blocks that cover an array.
This function first iterates trough the blocks that recover
the part of the array given by max_blk_coverage
and then iterates with smaller blocks for the rest
of the array.
:param blk: the N-dimensional shape of the blo... | python | def blk_nd(blk, shape):
"""Iterate through the blocks that cover an array.
This function first iterates trough the blocks that recover
the part of the array given by max_blk_coverage
and then iterates with smaller blocks for the rest
of the array.
:param blk: the N-dimensional shape of the blo... | [
"def",
"blk_nd",
"(",
"blk",
",",
"shape",
")",
":",
"internals",
"=",
"(",
"blk_1d",
"(",
"b",
",",
"s",
")",
"for",
"b",
",",
"s",
"in",
"zip",
"(",
"blk",
",",
"shape",
")",
")",
"return",
"product",
"(",
"*",
"internals",
")"
] | Iterate through the blocks that cover an array.
This function first iterates trough the blocks that recover
the part of the array given by max_blk_coverage
and then iterates with smaller blocks for the rest
of the array.
:param blk: the N-dimensional shape of the block
:param shape: the N-dime... | [
"Iterate",
"through",
"the",
"blocks",
"that",
"cover",
"an",
"array",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/blocks.py#L192-L226 | train |
guaix-ucm/numina | numina/array/blocks.py | block_view | def block_view(arr, block=(3, 3)):
"""Provide a 2D block view to 2D array.
No error checking made. Therefore meaningful (as implemented) only for
blocks strictly compatible with the shape of A.
"""
# simple shape and strides computations may seem at first strange
# unless one is able to recog... | python | def block_view(arr, block=(3, 3)):
"""Provide a 2D block view to 2D array.
No error checking made. Therefore meaningful (as implemented) only for
blocks strictly compatible with the shape of A.
"""
# simple shape and strides computations may seem at first strange
# unless one is able to recog... | [
"def",
"block_view",
"(",
"arr",
",",
"block",
"=",
"(",
"3",
",",
"3",
")",
")",
":",
"shape",
"=",
"(",
"arr",
".",
"shape",
"[",
"0",
"]",
"//",
"block",
"[",
"0",
"]",
",",
"arr",
".",
"shape",
"[",
"1",
"]",
"//",
"block",
"[",
"1",
... | Provide a 2D block view to 2D array.
No error checking made. Therefore meaningful (as implemented) only for
blocks strictly compatible with the shape of A. | [
"Provide",
"a",
"2D",
"block",
"view",
"to",
"2D",
"array",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/blocks.py#L229-L241 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | is_citeable | def is_citeable(publication_info):
"""Check some fields in order to define if the article is citeable.
:param publication_info: publication_info field
already populated
:type publication_info: list
"""
def _item_has_pub_info(item):
return all(
key in item for key in (
... | python | def is_citeable(publication_info):
"""Check some fields in order to define if the article is citeable.
:param publication_info: publication_info field
already populated
:type publication_info: list
"""
def _item_has_pub_info(item):
return all(
key in item for key in (
... | [
"def",
"is_citeable",
"(",
"publication_info",
")",
":",
"def",
"_item_has_pub_info",
"(",
"item",
")",
":",
"return",
"all",
"(",
"key",
"in",
"item",
"for",
"key",
"in",
"(",
"'journal_title'",
",",
"'journal_volume'",
")",
")",
"def",
"_item_has_page_or_art... | Check some fields in order to define if the article is citeable.
:param publication_info: publication_info field
already populated
:type publication_info: list | [
"Check",
"some",
"fields",
"in",
"order",
"to",
"define",
"if",
"the",
"article",
"is",
"citeable",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L46-L75 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_abstract | def add_abstract(self, abstract, source=None):
"""Add abstract.
:param abstract: abstract for the current document.
:type abstract: string
:param source: source for the given abstract.
:type source: string
"""
self._append_to('abstracts', self._sourced_dict(
... | python | def add_abstract(self, abstract, source=None):
"""Add abstract.
:param abstract: abstract for the current document.
:type abstract: string
:param source: source for the given abstract.
:type source: string
"""
self._append_to('abstracts', self._sourced_dict(
... | [
"def",
"add_abstract",
"(",
"self",
",",
"abstract",
",",
"source",
"=",
"None",
")",
":",
"self",
".",
"_append_to",
"(",
"'abstracts'",
",",
"self",
".",
"_sourced_dict",
"(",
"source",
",",
"value",
"=",
"abstract",
".",
"strip",
"(",
")",
",",
")",... | Add abstract.
:param abstract: abstract for the current document.
:type abstract: string
:param source: source for the given abstract.
:type source: string | [
"Add",
"abstract",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L150-L162 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_arxiv_eprint | def add_arxiv_eprint(self, arxiv_id, arxiv_categories):
"""Add arxiv eprint.
:param arxiv_id: arxiv id for the current document.
:type arxiv_id: string
:param arxiv_categories: arXiv categories for the current document.
:type arxiv_categories: list
"""
self._app... | python | def add_arxiv_eprint(self, arxiv_id, arxiv_categories):
"""Add arxiv eprint.
:param arxiv_id: arxiv id for the current document.
:type arxiv_id: string
:param arxiv_categories: arXiv categories for the current document.
:type arxiv_categories: list
"""
self._app... | [
"def",
"add_arxiv_eprint",
"(",
"self",
",",
"arxiv_id",
",",
"arxiv_categories",
")",
":",
"self",
".",
"_append_to",
"(",
"'arxiv_eprints'",
",",
"{",
"'value'",
":",
"arxiv_id",
",",
"'categories'",
":",
"arxiv_categories",
",",
"}",
")",
"self",
".",
"se... | Add arxiv eprint.
:param arxiv_id: arxiv id for the current document.
:type arxiv_id: string
:param arxiv_categories: arXiv categories for the current document.
:type arxiv_categories: list | [
"Add",
"arxiv",
"eprint",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L165-L178 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_doi | def add_doi(self, doi, source=None, material=None):
"""Add doi.
:param doi: doi for the current document.
:type doi: string
:param source: source for the doi.
:type source: string
:param material: material for the doi.
:type material: string
"""
... | python | def add_doi(self, doi, source=None, material=None):
"""Add doi.
:param doi: doi for the current document.
:type doi: string
:param source: source for the doi.
:type source: string
:param material: material for the doi.
:type material: string
"""
... | [
"def",
"add_doi",
"(",
"self",
",",
"doi",
",",
"source",
"=",
"None",
",",
"material",
"=",
"None",
")",
":",
"if",
"doi",
"is",
"None",
":",
"return",
"try",
":",
"doi",
"=",
"idutils",
".",
"normalize_doi",
"(",
"doi",
")",
"except",
"AttributeErr... | Add doi.
:param doi: doi for the current document.
:type doi: string
:param source: source for the doi.
:type source: string
:param material: material for the doi.
:type material: string | [
"Add",
"doi",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L181-L211 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.make_author | def make_author(self, full_name,
affiliations=(),
roles=(),
raw_affiliations=(),
source=None,
ids=(),
emails=(),
alternative_names=()):
"""Make a subrecord representing an ... | python | def make_author(self, full_name,
affiliations=(),
roles=(),
raw_affiliations=(),
source=None,
ids=(),
emails=(),
alternative_names=()):
"""Make a subrecord representing an ... | [
"def",
"make_author",
"(",
"self",
",",
"full_name",
",",
"affiliations",
"=",
"(",
")",
",",
"roles",
"=",
"(",
")",
",",
"raw_affiliations",
"=",
"(",
")",
",",
"source",
"=",
"None",
",",
"ids",
"=",
"(",
")",
",",
"emails",
"=",
"(",
")",
","... | Make a subrecord representing an author.
Args:
full_name(str): full name of the author. If not yet in standard
Inspire form, it will be normalized.
affiliations(List[str]): Inspire normalized affiliations of the
author.
roles(List[str]): Inspi... | [
"Make",
"a",
"subrecord",
"representing",
"an",
"author",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L224-L273 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_book | def add_book(self, publisher=None, place=None, date=None):
"""
Make a dictionary that is representing a book.
:param publisher: publisher name
:type publisher: string
:param place: place of publication
:type place: string
:param date: A (partial) date in any f... | python | def add_book(self, publisher=None, place=None, date=None):
"""
Make a dictionary that is representing a book.
:param publisher: publisher name
:type publisher: string
:param place: place of publication
:type place: string
:param date: A (partial) date in any f... | [
"def",
"add_book",
"(",
"self",
",",
"publisher",
"=",
"None",
",",
"place",
"=",
"None",
",",
"date",
"=",
"None",
")",
":",
"imprint",
"=",
"{",
"}",
"if",
"date",
"is",
"not",
"None",
":",
"imprint",
"[",
"'date'",
"]",
"=",
"normalize_date",
"(... | Make a dictionary that is representing a book.
:param publisher: publisher name
:type publisher: string
:param place: place of publication
:type place: string
:param date: A (partial) date in any format.
The date should contain at least a year
:type date: ... | [
"Make",
"a",
"dictionary",
"that",
"is",
"representing",
"a",
"book",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L276-L302 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_inspire_categories | def add_inspire_categories(self, subject_terms, source=None):
"""Add inspire categories.
:param subject_terms: user categories for the current document.
:type subject_terms: list
:param source: source for the given categories.
:type source: string
"""
for catego... | python | def add_inspire_categories(self, subject_terms, source=None):
"""Add inspire categories.
:param subject_terms: user categories for the current document.
:type subject_terms: list
:param source: source for the given categories.
:type source: string
"""
for catego... | [
"def",
"add_inspire_categories",
"(",
"self",
",",
"subject_terms",
",",
"source",
"=",
"None",
")",
":",
"for",
"category",
"in",
"subject_terms",
":",
"category_dict",
"=",
"self",
".",
"_sourced_dict",
"(",
"source",
",",
"term",
"=",
"category",
",",
")"... | Add inspire categories.
:param subject_terms: user categories for the current document.
:type subject_terms: list
:param source: source for the given categories.
:type source: string | [
"Add",
"inspire",
"categories",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L344-L358 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_keyword | def add_keyword(self, keyword, schema=None, source=None):
"""Add a keyword.
Args:
keyword(str): keyword to add.
schema(str): schema to which the keyword belongs.
source(str): source for the keyword.
"""
keyword_dict = self._sourced_dict(source, value=... | python | def add_keyword(self, keyword, schema=None, source=None):
"""Add a keyword.
Args:
keyword(str): keyword to add.
schema(str): schema to which the keyword belongs.
source(str): source for the keyword.
"""
keyword_dict = self._sourced_dict(source, value=... | [
"def",
"add_keyword",
"(",
"self",
",",
"keyword",
",",
"schema",
"=",
"None",
",",
"source",
"=",
"None",
")",
":",
"keyword_dict",
"=",
"self",
".",
"_sourced_dict",
"(",
"source",
",",
"value",
"=",
"keyword",
")",
"if",
"schema",
"is",
"not",
"None... | Add a keyword.
Args:
keyword(str): keyword to add.
schema(str): schema to which the keyword belongs.
source(str): source for the keyword. | [
"Add",
"a",
"keyword",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L361-L374 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_private_note | def add_private_note(self, private_notes, source=None):
"""Add private notes.
:param private_notes: hidden notes for the current document
:type private_notes: string
:param source: source for the given private notes
:type source: string
"""
self._append_to('_pri... | python | def add_private_note(self, private_notes, source=None):
"""Add private notes.
:param private_notes: hidden notes for the current document
:type private_notes: string
:param source: source for the given private notes
:type source: string
"""
self._append_to('_pri... | [
"def",
"add_private_note",
"(",
"self",
",",
"private_notes",
",",
"source",
"=",
"None",
")",
":",
"self",
".",
"_append_to",
"(",
"'_private_notes'",
",",
"self",
".",
"_sourced_dict",
"(",
"source",
",",
"value",
"=",
"private_notes",
",",
")",
")"
] | Add private notes.
:param private_notes: hidden notes for the current document
:type private_notes: string
:param source: source for the given private notes
:type source: string | [
"Add",
"private",
"notes",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L377-L389 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_publication_info | def add_publication_info(
self,
year=None,
cnum=None,
artid=None,
page_end=None,
page_start=None,
journal_issue=None,
journal_title=None,
journal_volume=None,
pubinfo_freetext=None,
material=None,
parent_record=None,
... | python | def add_publication_info(
self,
year=None,
cnum=None,
artid=None,
page_end=None,
page_start=None,
journal_issue=None,
journal_title=None,
journal_volume=None,
pubinfo_freetext=None,
material=None,
parent_record=None,
... | [
"def",
"add_publication_info",
"(",
"self",
",",
"year",
"=",
"None",
",",
"cnum",
"=",
"None",
",",
"artid",
"=",
"None",
",",
"page_end",
"=",
"None",
",",
"page_start",
"=",
"None",
",",
"journal_issue",
"=",
"None",
",",
"journal_title",
"=",
"None",... | Add publication info.
:param year: year of publication
:type year: integer
:param cnum: inspire conference number
:type cnum: string
:param artid: article id
:type artid: string
:param page_end: final page for the article
:type page_end: string
... | [
"Add",
"publication",
"info",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L392-L480 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_thesis | def add_thesis(
self,
defense_date=None,
degree_type=None,
institution=None,
date=None
):
"""Add thesis info.
:param defense_date: defense date for the current thesis
:type defense_date: string. A formatted date is required (yyyy-mm-dd)
:para... | python | def add_thesis(
self,
defense_date=None,
degree_type=None,
institution=None,
date=None
):
"""Add thesis info.
:param defense_date: defense date for the current thesis
:type defense_date: string. A formatted date is required (yyyy-mm-dd)
:para... | [
"def",
"add_thesis",
"(",
"self",
",",
"defense_date",
"=",
"None",
",",
"degree_type",
"=",
"None",
",",
"institution",
"=",
"None",
",",
"date",
"=",
"None",
")",
":",
"self",
".",
"record",
".",
"setdefault",
"(",
"'thesis_info'",
",",
"{",
"}",
")"... | Add thesis info.
:param defense_date: defense date for the current thesis
:type defense_date: string. A formatted date is required (yyyy-mm-dd)
:param degree_type: degree type for the current thesis
:type degree_type: string
:param institution: author's affiliation for the cur... | [
"Add",
"thesis",
"info",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L503-L537 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_license | def add_license(
self,
url=None,
license=None,
material=None,
imposing=None
):
"""Add license.
:param url: url for the description of the license
:type url: string
:param license: license type
:type license: string
:param mat... | python | def add_license(
self,
url=None,
license=None,
material=None,
imposing=None
):
"""Add license.
:param url: url for the description of the license
:type url: string
:param license: license type
:type license: string
:param mat... | [
"def",
"add_license",
"(",
"self",
",",
"url",
"=",
"None",
",",
"license",
"=",
"None",
",",
"material",
"=",
"None",
",",
"imposing",
"=",
"None",
")",
":",
"hep_license",
"=",
"{",
"}",
"try",
":",
"license_from_url",
"=",
"get_license_from_url",
"(",... | Add license.
:param url: url for the description of the license
:type url: string
:param license: license type
:type license: string
:param material: material type
:type material: string
:param imposing: imposing type
:type imposing: string | [
"Add",
"license",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L559-L593 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_public_note | def add_public_note(self, public_note, source=None):
"""Add public note.
:param public_note: public note for the current article.
:type public_note: string
:param source: source for the given notes.
:type source: string
"""
self._append_to('public_notes', self._... | python | def add_public_note(self, public_note, source=None):
"""Add public note.
:param public_note: public note for the current article.
:type public_note: string
:param source: source for the given notes.
:type source: string
"""
self._append_to('public_notes', self._... | [
"def",
"add_public_note",
"(",
"self",
",",
"public_note",
",",
"source",
"=",
"None",
")",
":",
"self",
".",
"_append_to",
"(",
"'public_notes'",
",",
"self",
".",
"_sourced_dict",
"(",
"source",
",",
"value",
"=",
"public_note",
",",
")",
")"
] | Add public note.
:param public_note: public note for the current article.
:type public_note: string
:param source: source for the given notes.
:type source: string | [
"Add",
"public",
"note",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L596-L608 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_title | def add_title(self, title, subtitle=None, source=None):
"""Add title.
:param title: title for the current document
:type title: string
:param subtitle: subtitle for the current document
:type subtitle: string
:param source: source for the given title
:type sour... | python | def add_title(self, title, subtitle=None, source=None):
"""Add title.
:param title: title for the current document
:type title: string
:param subtitle: subtitle for the current document
:type subtitle: string
:param source: source for the given title
:type sour... | [
"def",
"add_title",
"(",
"self",
",",
"title",
",",
"subtitle",
"=",
"None",
",",
"source",
"=",
"None",
")",
":",
"title_entry",
"=",
"self",
".",
"_sourced_dict",
"(",
"source",
",",
"title",
"=",
"title",
",",
")",
"if",
"subtitle",
"is",
"not",
"... | Add title.
:param title: title for the current document
:type title: string
:param subtitle: subtitle for the current document
:type subtitle: string
:param source: source for the given title
:type source: string | [
"Add",
"title",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L611-L630 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_title_translation | def add_title_translation(self, title, language, source=None):
"""Add title translation.
:param title: translated title
:type title: string
:param language: language for the original title
:type language: string (2 characters ISO639-1)
:param source: source for the giv... | python | def add_title_translation(self, title, language, source=None):
"""Add title translation.
:param title: translated title
:type title: string
:param language: language for the original title
:type language: string (2 characters ISO639-1)
:param source: source for the giv... | [
"def",
"add_title_translation",
"(",
"self",
",",
"title",
",",
"language",
",",
"source",
"=",
"None",
")",
":",
"title_translation",
"=",
"self",
".",
"_sourced_dict",
"(",
"source",
",",
"title",
"=",
"title",
",",
"language",
"=",
"language",
",",
")",... | Add title translation.
:param title: translated title
:type title: string
:param language: language for the original title
:type language: string (2 characters ISO639-1)
:param source: source for the given title
:type source: string | [
"Add",
"title",
"translation",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L633-L651 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_report_number | def add_report_number(self, report_number, source=None):
"""Add report numbers.
:param report_number: report number for the current document
:type report_number: string
:param source: source for the given report number
:type source: string
"""
self._append_to('r... | python | def add_report_number(self, report_number, source=None):
"""Add report numbers.
:param report_number: report number for the current document
:type report_number: string
:param source: source for the given report number
:type source: string
"""
self._append_to('r... | [
"def",
"add_report_number",
"(",
"self",
",",
"report_number",
",",
"source",
"=",
"None",
")",
":",
"self",
".",
"_append_to",
"(",
"'report_numbers'",
",",
"self",
".",
"_sourced_dict",
"(",
"source",
",",
"value",
"=",
"report_number",
",",
")",
")"
] | Add report numbers.
:param report_number: report number for the current document
:type report_number: string
:param source: source for the given report number
:type source: string | [
"Add",
"report",
"numbers",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L665-L677 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_collaboration | def add_collaboration(self, collaboration):
"""Add collaboration.
:param collaboration: collaboration for the current document
:type collaboration: string
"""
collaborations = normalize_collaboration(collaboration)
for collaboration in collaborations:
self._a... | python | def add_collaboration(self, collaboration):
"""Add collaboration.
:param collaboration: collaboration for the current document
:type collaboration: string
"""
collaborations = normalize_collaboration(collaboration)
for collaboration in collaborations:
self._a... | [
"def",
"add_collaboration",
"(",
"self",
",",
"collaboration",
")",
":",
"collaborations",
"=",
"normalize_collaboration",
"(",
"collaboration",
")",
"for",
"collaboration",
"in",
"collaborations",
":",
"self",
".",
"_append_to",
"(",
"'collaborations'",
",",
"{",
... | Add collaboration.
:param collaboration: collaboration for the current document
:type collaboration: string | [
"Add",
"collaboration",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L680-L690 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_copyright | def add_copyright(
self,
material=None,
holder=None,
statement=None,
url=None,
year=None
):
"""Add Copyright.
:type material: string
:type holder: string
:type statement: string
:type url: string
:type year: int
... | python | def add_copyright(
self,
material=None,
holder=None,
statement=None,
url=None,
year=None
):
"""Add Copyright.
:type material: string
:type holder: string
:type statement: string
:type url: string
:type year: int
... | [
"def",
"add_copyright",
"(",
"self",
",",
"material",
"=",
"None",
",",
"holder",
"=",
"None",
",",
"statement",
"=",
"None",
",",
"url",
"=",
"None",
",",
"year",
"=",
"None",
")",
":",
"copyright",
"=",
"{",
"}",
"for",
"key",
"in",
"(",
"'holder... | Add Copyright.
:type material: string
:type holder: string
:type statement: string
:type url: string
:type year: int | [
"Add",
"Copyright",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L754-L785 | train |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | LiteratureBuilder.add_figure | def add_figure(self, key, url, **kwargs):
"""Add a figure.
Args:
key (string): document key
url (string): document url
Keyword Args:
caption (string): simple description
label (string):
material (string):
original_url (stri... | python | def add_figure(self, key, url, **kwargs):
"""Add a figure.
Args:
key (string): document key
url (string): document url
Keyword Args:
caption (string): simple description
label (string):
material (string):
original_url (stri... | [
"def",
"add_figure",
"(",
"self",
",",
"key",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"figure",
"=",
"self",
".",
"_check_metadata_for_file",
"(",
"key",
"=",
"key",
",",
"url",
"=",
"url",
",",
"**",
"kwargs",
")",
"for",
"dict_key",
"in",
"(",
... | Add a figure.
Args:
key (string): document key
url (string): document url
Keyword Args:
caption (string): simple description
label (string):
material (string):
original_url (string): original url
filename (string): curr... | [
"Add",
"a",
"figure",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L863-L899 | train |
guaix-ucm/numina | numina/array/offrot.py | fit_offset_and_rotation | def fit_offset_and_rotation(coords0, coords1):
"""Fit a rotation and a traslation between two sets points.
Fit a rotation matrix and a traslation bewtween two matched sets
consisting of M N-dimensional points
Parameters
----------
coords0 : (M, N) array_like
coords1 : (M, N) array_lke
... | python | def fit_offset_and_rotation(coords0, coords1):
"""Fit a rotation and a traslation between two sets points.
Fit a rotation matrix and a traslation bewtween two matched sets
consisting of M N-dimensional points
Parameters
----------
coords0 : (M, N) array_like
coords1 : (M, N) array_lke
... | [
"def",
"fit_offset_and_rotation",
"(",
"coords0",
",",
"coords1",
")",
":",
"coords0",
"=",
"numpy",
".",
"asarray",
"(",
"coords0",
")",
"coords1",
"=",
"numpy",
".",
"asarray",
"(",
"coords1",
")",
"cp",
"=",
"coords0",
".",
"mean",
"(",
"axis",
"=",
... | Fit a rotation and a traslation between two sets points.
Fit a rotation matrix and a traslation bewtween two matched sets
consisting of M N-dimensional points
Parameters
----------
coords0 : (M, N) array_like
coords1 : (M, N) array_lke
Returns
-------
offset : (N, ) array_like
... | [
"Fit",
"a",
"rotation",
"and",
"a",
"traslation",
"between",
"two",
"sets",
"points",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/offrot.py#L17-L71 | train |
ponty/eagexp | eagexp/image3d.py | pil_image3d | def pil_image3d(input, size=(800, 600), pcb_rotate=(0, 0, 0), timeout=20, showgui=False):
'''
same as export_image3d, but there is no output file, PIL object is returned instead
'''
f = tempfile.NamedTemporaryFile(suffix='.png', prefix='eagexp_')
output = f.name
export_image3d(input, output=out... | python | def pil_image3d(input, size=(800, 600), pcb_rotate=(0, 0, 0), timeout=20, showgui=False):
'''
same as export_image3d, but there is no output file, PIL object is returned instead
'''
f = tempfile.NamedTemporaryFile(suffix='.png', prefix='eagexp_')
output = f.name
export_image3d(input, output=out... | [
"def",
"pil_image3d",
"(",
"input",
",",
"size",
"=",
"(",
"800",
",",
"600",
")",
",",
"pcb_rotate",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
",",
"timeout",
"=",
"20",
",",
"showgui",
"=",
"False",
")",
":",
"f",
"=",
"tempfile",
".",
"NamedTe... | same as export_image3d, but there is no output file, PIL object is returned instead | [
"same",
"as",
"export_image3d",
"but",
"there",
"is",
"no",
"output",
"file",
"PIL",
"object",
"is",
"returned",
"instead"
] | 1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2 | https://github.com/ponty/eagexp/blob/1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2/eagexp/image3d.py#L80-L91 | train |
pylp/pylp | pylp/cli/logger.py | _make_color_fn | def _make_color_fn(color):
"""Create a function that set the foreground color."""
def _color(text = ""):
return (_color_sep + color + _color_sep2 + text +
_color_sep + "default" + _color_sep2)
return _color | python | def _make_color_fn(color):
"""Create a function that set the foreground color."""
def _color(text = ""):
return (_color_sep + color + _color_sep2 + text +
_color_sep + "default" + _color_sep2)
return _color | [
"def",
"_make_color_fn",
"(",
"color",
")",
":",
"def",
"_color",
"(",
"text",
"=",
"\"\"",
")",
":",
"return",
"(",
"_color_sep",
"+",
"color",
"+",
"_color_sep2",
"+",
"text",
"+",
"_color_sep",
"+",
"\"default\"",
"+",
"_color_sep2",
")",
"return",
"_... | Create a function that set the foreground color. | [
"Create",
"a",
"function",
"that",
"set",
"the",
"foreground",
"color",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/logger.py#L21-L26 | train |
pylp/pylp | pylp/cli/logger.py | just_log | def just_log(*texts, sep = ""):
"""Log a text without adding the current time."""
if config.silent:
return
text = _color_sep + "default" + _color_sep2 + sep.join(texts)
array = text.split(_color_sep)
for part in array:
parts = part.split(_color_sep2, 1)
if len(parts) != 2 or not parts[1]:
continue
if... | python | def just_log(*texts, sep = ""):
"""Log a text without adding the current time."""
if config.silent:
return
text = _color_sep + "default" + _color_sep2 + sep.join(texts)
array = text.split(_color_sep)
for part in array:
parts = part.split(_color_sep2, 1)
if len(parts) != 2 or not parts[1]:
continue
if... | [
"def",
"just_log",
"(",
"*",
"texts",
",",
"sep",
"=",
"\"\"",
")",
":",
"if",
"config",
".",
"silent",
":",
"return",
"text",
"=",
"_color_sep",
"+",
"\"default\"",
"+",
"_color_sep2",
"+",
"sep",
".",
"join",
"(",
"texts",
")",
"array",
"=",
"text"... | Log a text without adding the current time. | [
"Log",
"a",
"text",
"without",
"adding",
"the",
"current",
"time",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/logger.py#L34-L55 | train |
pylp/pylp | pylp/cli/logger.py | log | def log(*texts, sep = ""):
"""Log a text."""
text = sep.join(texts)
count = text.count("\n")
just_log("\n" * count, *get_time(), text.replace("\n", ""), sep=sep) | python | def log(*texts, sep = ""):
"""Log a text."""
text = sep.join(texts)
count = text.count("\n")
just_log("\n" * count, *get_time(), text.replace("\n", ""), sep=sep) | [
"def",
"log",
"(",
"*",
"texts",
",",
"sep",
"=",
"\"\"",
")",
":",
"text",
"=",
"sep",
".",
"join",
"(",
"texts",
")",
"count",
"=",
"text",
".",
"count",
"(",
"\"\\n\"",
")",
"just_log",
"(",
"\"\\n\"",
"*",
"count",
",",
"*",
"get_time",
"(",
... | Log a text. | [
"Log",
"a",
"text",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/logger.py#L63-L67 | train |
pylp/pylp | pylp/lib/src.py | find_files | def find_files(globs):
"""Find files to include."""
last_cwd = os.getcwd()
os.chdir(config.cwd)
gex, gin = separate_globs(globs)
# Find excluded files
exclude = []
for glob in gex:
parse_glob(glob, exclude)
files = []
include = []
order = 0
# Find included files and removed excluded files
for glob in... | python | def find_files(globs):
"""Find files to include."""
last_cwd = os.getcwd()
os.chdir(config.cwd)
gex, gin = separate_globs(globs)
# Find excluded files
exclude = []
for glob in gex:
parse_glob(glob, exclude)
files = []
include = []
order = 0
# Find included files and removed excluded files
for glob in... | [
"def",
"find_files",
"(",
"globs",
")",
":",
"last_cwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"config",
".",
"cwd",
")",
"gex",
",",
"gin",
"=",
"separate_globs",
"(",
"globs",
")",
"exclude",
"=",
"[",
"]",
"for",
"glob",
... | Find files to include. | [
"Find",
"files",
"to",
"include",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/src.py#L17-L45 | train |
pylp/pylp | pylp/lib/src.py | src | def src(globs, **options):
"""Read some files and return a stream."""
# Create an array of globs if only one string is given
if isinstance(globs, str):
globs = [ globs ]
# Find files
files = find_files(globs)
# Create a stream
stream = Stream()
# Options
options["cwd"] = config.cwd
if "base" in options... | python | def src(globs, **options):
"""Read some files and return a stream."""
# Create an array of globs if only one string is given
if isinstance(globs, str):
globs = [ globs ]
# Find files
files = find_files(globs)
# Create a stream
stream = Stream()
# Options
options["cwd"] = config.cwd
if "base" in options... | [
"def",
"src",
"(",
"globs",
",",
"**",
"options",
")",
":",
"if",
"isinstance",
"(",
"globs",
",",
"str",
")",
":",
"globs",
"=",
"[",
"globs",
"]",
"files",
"=",
"find_files",
"(",
"globs",
")",
"stream",
"=",
"Stream",
"(",
")",
"options",
"[",
... | Read some files and return a stream. | [
"Read",
"some",
"files",
"and",
"return",
"a",
"stream",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/src.py#L49-L82 | train |
guaix-ucm/numina | numina/logger.py | log_to_history | def log_to_history(logger, name):
"""Decorate function, adding a logger handler stored in FITS."""
def log_to_history_decorator(method):
def l2h_method(self, ri):
history_header = fits.Header()
fh = FITSHistoryHandler(history_header)
fh.setLevel(logging.INFO)
... | python | def log_to_history(logger, name):
"""Decorate function, adding a logger handler stored in FITS."""
def log_to_history_decorator(method):
def l2h_method(self, ri):
history_header = fits.Header()
fh = FITSHistoryHandler(history_header)
fh.setLevel(logging.INFO)
... | [
"def",
"log_to_history",
"(",
"logger",
",",
"name",
")",
":",
"def",
"log_to_history_decorator",
"(",
"method",
")",
":",
"def",
"l2h_method",
"(",
"self",
",",
"ri",
")",
":",
"history_header",
"=",
"fits",
".",
"Header",
"(",
")",
"fh",
"=",
"FITSHist... | Decorate function, adding a logger handler stored in FITS. | [
"Decorate",
"function",
"adding",
"a",
"logger",
"handler",
"stored",
"in",
"FITS",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/logger.py#L30-L54 | train |
guaix-ucm/numina | numina/types/base.py | DataTypeBase.create_db_info | def create_db_info():
"""Create metadata structure"""
result = {}
result['instrument'] = ''
result['uuid'] = ''
result['tags'] = {}
result['type'] = ''
result['mode'] = ''
result['observation_date'] = ""
result['origin'] = {}
return result | python | def create_db_info():
"""Create metadata structure"""
result = {}
result['instrument'] = ''
result['uuid'] = ''
result['tags'] = {}
result['type'] = ''
result['mode'] = ''
result['observation_date'] = ""
result['origin'] = {}
return result | [
"def",
"create_db_info",
"(",
")",
":",
"result",
"=",
"{",
"}",
"result",
"[",
"'instrument'",
"]",
"=",
"''",
"result",
"[",
"'uuid'",
"]",
"=",
"''",
"result",
"[",
"'tags'",
"]",
"=",
"{",
"}",
"result",
"[",
"'type'",
"]",
"=",
"''",
"result",... | Create metadata structure | [
"Create",
"metadata",
"structure"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/types/base.py#L151-L161 | train |
pylp/pylp | pylp/utils/decorators.py | task | def task(obj = None, deps = None):
"""Decorator for creating a task."""
# The decorator is not used as a function
if callable(obj):
__task(obj.__name__, obj)
return obj
# The decorator is used as a function
def __decorated(func):
__task(obj if obj else obj.__name__, deps, func)
return func
return __deco... | python | def task(obj = None, deps = None):
"""Decorator for creating a task."""
# The decorator is not used as a function
if callable(obj):
__task(obj.__name__, obj)
return obj
# The decorator is used as a function
def __decorated(func):
__task(obj if obj else obj.__name__, deps, func)
return func
return __deco... | [
"def",
"task",
"(",
"obj",
"=",
"None",
",",
"deps",
"=",
"None",
")",
":",
"if",
"callable",
"(",
"obj",
")",
":",
"__task",
"(",
"obj",
".",
"__name__",
",",
"obj",
")",
"return",
"obj",
"def",
"__decorated",
"(",
"func",
")",
":",
"__task",
"(... | Decorator for creating a task. | [
"Decorator",
"for",
"creating",
"a",
"task",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/utils/decorators.py#L18-L30 | train |
rfk/playitagainsam | playitagainsam/recorder.py | Recorder._read_one_byte | def _read_one_byte(self, fd):
"""Read a single byte, or raise OSError on failure."""
c = os.read(fd, 1)
if not c:
raise OSError
return c | python | def _read_one_byte(self, fd):
"""Read a single byte, or raise OSError on failure."""
c = os.read(fd, 1)
if not c:
raise OSError
return c | [
"def",
"_read_one_byte",
"(",
"self",
",",
"fd",
")",
":",
"c",
"=",
"os",
".",
"read",
"(",
"fd",
",",
"1",
")",
"if",
"not",
"c",
":",
"raise",
"OSError",
"return",
"c"
] | Read a single byte, or raise OSError on failure. | [
"Read",
"a",
"single",
"byte",
"or",
"raise",
"OSError",
"on",
"failure",
"."
] | 897cc8e8ca920a4afb8597b4a345361065a3f108 | https://github.com/rfk/playitagainsam/blob/897cc8e8ca920a4afb8597b4a345361065a3f108/playitagainsam/recorder.py#L141-L146 | train |
guaix-ucm/numina | numina/tools/arg_file_is_new.py | arg_file_is_new | def arg_file_is_new(parser, arg, mode='w'):
"""Auxiliary function to give an error if the file already exists.
Parameters
----------
parser : parser object
Instance of argparse.ArgumentParser()
arg : string
File name.
mode : string
Optional string that specifies the mode... | python | def arg_file_is_new(parser, arg, mode='w'):
"""Auxiliary function to give an error if the file already exists.
Parameters
----------
parser : parser object
Instance of argparse.ArgumentParser()
arg : string
File name.
mode : string
Optional string that specifies the mode... | [
"def",
"arg_file_is_new",
"(",
"parser",
",",
"arg",
",",
"mode",
"=",
"'w'",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"arg",
")",
":",
"parser",
".",
"error",
"(",
"\"\\nThe file \\\"%s\\\"\\nalready exists and \"",
"\"cannot be overwritten!\"",
... | Auxiliary function to give an error if the file already exists.
Parameters
----------
parser : parser object
Instance of argparse.ArgumentParser()
arg : string
File name.
mode : string
Optional string that specifies the mode in which the file is
opened.
Returns
... | [
"Auxiliary",
"function",
"to",
"give",
"an",
"error",
"if",
"the",
"file",
"already",
"exists",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/tools/arg_file_is_new.py#L17-L42 | train |
guaix-ucm/numina | numina/array/ccd_line.py | intersection_spectrail_arcline | def intersection_spectrail_arcline(spectrail, arcline):
"""Compute intersection of spectrum trail with arc line.
Parameters
----------
spectrail : SpectrumTrail object
Instance of SpectrumTrail class.
arcline : ArcLine object
Instance of ArcLine class
Returns
-------
xr... | python | def intersection_spectrail_arcline(spectrail, arcline):
"""Compute intersection of spectrum trail with arc line.
Parameters
----------
spectrail : SpectrumTrail object
Instance of SpectrumTrail class.
arcline : ArcLine object
Instance of ArcLine class
Returns
-------
xr... | [
"def",
"intersection_spectrail_arcline",
"(",
"spectrail",
",",
"arcline",
")",
":",
"expected_x",
"=",
"(",
"arcline",
".",
"xlower_line",
"+",
"arcline",
".",
"xupper_line",
")",
"/",
"2.0",
"rootfunct",
"=",
"arcline",
".",
"poly_funct",
"(",
"spectrail",
"... | Compute intersection of spectrum trail with arc line.
Parameters
----------
spectrail : SpectrumTrail object
Instance of SpectrumTrail class.
arcline : ArcLine object
Instance of ArcLine class
Returns
-------
xroot, yroot : tuple of floats
(X,Y) coordinates of the i... | [
"Compute",
"intersection",
"of",
"spectrum",
"trail",
"with",
"arc",
"line",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/ccd_line.py#L250-L286 | train |
guaix-ucm/numina | numina/array/ccd_line.py | CCDLine.offset | def offset(self, offset_value):
"""Return a copy of self, shifted a constant offset.
Parameters
----------
offset_value : float
Number of pixels to shift the CCDLine.
"""
new_instance = deepcopy(self)
new_instance.poly_funct.coef[0] += offset_value
... | python | def offset(self, offset_value):
"""Return a copy of self, shifted a constant offset.
Parameters
----------
offset_value : float
Number of pixels to shift the CCDLine.
"""
new_instance = deepcopy(self)
new_instance.poly_funct.coef[0] += offset_value
... | [
"def",
"offset",
"(",
"self",
",",
"offset_value",
")",
":",
"new_instance",
"=",
"deepcopy",
"(",
"self",
")",
"new_instance",
".",
"poly_funct",
".",
"coef",
"[",
"0",
"]",
"+=",
"offset_value",
"return",
"new_instance"
] | Return a copy of self, shifted a constant offset.
Parameters
----------
offset_value : float
Number of pixels to shift the CCDLine. | [
"Return",
"a",
"copy",
"of",
"self",
"shifted",
"a",
"constant",
"offset",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/ccd_line.py#L205-L217 | train |
guaix-ucm/numina | numina/tools/imath.py | compute_operation | def compute_operation(file1, file2, operation, output, display,
args_z1z2, args_bbox, args_keystitle, args_geometry):
"""Compute output = file1 operation file2.
Parameters
----------
file1 : file object
First FITS file.
file2 : file object
Second FITS file.
... | python | def compute_operation(file1, file2, operation, output, display,
args_z1z2, args_bbox, args_keystitle, args_geometry):
"""Compute output = file1 operation file2.
Parameters
----------
file1 : file object
First FITS file.
file2 : file object
Second FITS file.
... | [
"def",
"compute_operation",
"(",
"file1",
",",
"file2",
",",
"operation",
",",
"output",
",",
"display",
",",
"args_z1z2",
",",
"args_bbox",
",",
"args_keystitle",
",",
"args_geometry",
")",
":",
"with",
"fits",
".",
"open",
"(",
"file1",
")",
"as",
"hduli... | Compute output = file1 operation file2.
Parameters
----------
file1 : file object
First FITS file.
file2 : file object
Second FITS file.
operation : string
Mathematical operation.
output : file object
Output FITS file.
display : string
Character strin... | [
"Compute",
"output",
"=",
"file1",
"operation",
"file2",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/tools/imath.py#L25-L111 | train |
guaix-ucm/numina | numina/array/stats.py | robust_std | def robust_std(x, debug=False):
"""Compute a robust estimator of the standard deviation
See Eq. 3.36 (page 84) in Statistics, Data Mining, and Machine
in Astronomy, by Ivezic, Connolly, VanderPlas & Gray
Parameters
----------
x : 1d numpy array, float
Array of input values which standa... | python | def robust_std(x, debug=False):
"""Compute a robust estimator of the standard deviation
See Eq. 3.36 (page 84) in Statistics, Data Mining, and Machine
in Astronomy, by Ivezic, Connolly, VanderPlas & Gray
Parameters
----------
x : 1d numpy array, float
Array of input values which standa... | [
"def",
"robust_std",
"(",
"x",
",",
"debug",
"=",
"False",
")",
":",
"x",
"=",
"numpy",
".",
"asarray",
"(",
"x",
")",
"q25",
"=",
"numpy",
".",
"percentile",
"(",
"x",
",",
"25",
")",
"q75",
"=",
"numpy",
".",
"percentile",
"(",
"x",
",",
"75"... | Compute a robust estimator of the standard deviation
See Eq. 3.36 (page 84) in Statistics, Data Mining, and Machine
in Astronomy, by Ivezic, Connolly, VanderPlas & Gray
Parameters
----------
x : 1d numpy array, float
Array of input values which standard deviation is requested.
debug : ... | [
"Compute",
"a",
"robust",
"estimator",
"of",
"the",
"standard",
"deviation"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/stats.py#L17-L48 | train |
guaix-ucm/numina | numina/array/stats.py | summary | def summary(x, rm_nan=False, debug=False):
"""Compute basic statistical parameters.
Parameters
----------
x : 1d numpy array, float
Input array with values which statistical properties are
requested.
rm_nan : bool
If True, filter out NaN values before computing statistics.
... | python | def summary(x, rm_nan=False, debug=False):
"""Compute basic statistical parameters.
Parameters
----------
x : 1d numpy array, float
Input array with values which statistical properties are
requested.
rm_nan : bool
If True, filter out NaN values before computing statistics.
... | [
"def",
"summary",
"(",
"x",
",",
"rm_nan",
"=",
"False",
",",
"debug",
"=",
"False",
")",
":",
"if",
"type",
"(",
"x",
")",
"is",
"np",
".",
"ndarray",
":",
"xx",
"=",
"np",
".",
"copy",
"(",
"x",
")",
"else",
":",
"if",
"type",
"(",
"x",
"... | Compute basic statistical parameters.
Parameters
----------
x : 1d numpy array, float
Input array with values which statistical properties are
requested.
rm_nan : bool
If True, filter out NaN values before computing statistics.
debug : bool
If True prints computed v... | [
"Compute",
"basic",
"statistical",
"parameters",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/stats.py#L51-L126 | train |
guaix-ucm/numina | numina/array/trace/traces.py | fit_trace_polynomial | def fit_trace_polynomial(trace, deg, axis=0):
'''
Fit a trace information table to a polynomial.
Parameters
----------
trace
A 2D array, 2 columns and n rows
deg : int
Degree of polynomial
axis : {0, 1}
Spatial axis of the array (0 is Y, 1 is X).
'''
... | python | def fit_trace_polynomial(trace, deg, axis=0):
'''
Fit a trace information table to a polynomial.
Parameters
----------
trace
A 2D array, 2 columns and n rows
deg : int
Degree of polynomial
axis : {0, 1}
Spatial axis of the array (0 is Y, 1 is X).
'''
... | [
"def",
"fit_trace_polynomial",
"(",
"trace",
",",
"deg",
",",
"axis",
"=",
"0",
")",
":",
"dispaxis",
"=",
"axis_to_dispaxis",
"(",
"axis",
")",
"pfit",
"=",
"numpy",
".",
"polyfit",
"(",
"trace",
"[",
":",
",",
"0",
"]",
",",
"trace",
"[",
":",
",... | Fit a trace information table to a polynomial.
Parameters
----------
trace
A 2D array, 2 columns and n rows
deg : int
Degree of polynomial
axis : {0, 1}
Spatial axis of the array (0 is Y, 1 is X). | [
"Fit",
"a",
"trace",
"information",
"table",
"to",
"a",
"polynomial",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/trace/traces.py#L74-L94 | train |
druids/django-chamber | chamber/models/humanized_helpers/__init__.py | price_humanized | def price_humanized(value, inst, currency=None):
"""
Return a humanized price
"""
return (natural_number_with_currency(value, ugettext('CZK') if currency is None else currency) if value is not None
else ugettext('(None)')) | python | def price_humanized(value, inst, currency=None):
"""
Return a humanized price
"""
return (natural_number_with_currency(value, ugettext('CZK') if currency is None else currency) if value is not None
else ugettext('(None)')) | [
"def",
"price_humanized",
"(",
"value",
",",
"inst",
",",
"currency",
"=",
"None",
")",
":",
"return",
"(",
"natural_number_with_currency",
"(",
"value",
",",
"ugettext",
"(",
"'CZK'",
")",
"if",
"currency",
"is",
"None",
"else",
"currency",
")",
"if",
"va... | Return a humanized price | [
"Return",
"a",
"humanized",
"price"
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/models/humanized_helpers/__init__.py#L6-L11 | train |
guaix-ucm/numina | numina/datamodel.py | DataModel.get_imgid | def get_imgid(self, img):
"""Obtain a unique identifier of the image.
Parameters
----------
img : astropy.io.fits.HDUList
Returns
-------
str:
Identification of the image
"""
imgid = img.filename()
# More heuristics here...... | python | def get_imgid(self, img):
"""Obtain a unique identifier of the image.
Parameters
----------
img : astropy.io.fits.HDUList
Returns
-------
str:
Identification of the image
"""
imgid = img.filename()
# More heuristics here...... | [
"def",
"get_imgid",
"(",
"self",
",",
"img",
")",
":",
"imgid",
"=",
"img",
".",
"filename",
"(",
")",
"hdr",
"=",
"self",
".",
"get_header",
"(",
"img",
")",
"if",
"'checksum'",
"in",
"hdr",
":",
"return",
"hdr",
"[",
"'checksum'",
"]",
"if",
"'fi... | Obtain a unique identifier of the image.
Parameters
----------
img : astropy.io.fits.HDUList
Returns
-------
str:
Identification of the image | [
"Obtain",
"a",
"unique",
"identifier",
"of",
"the",
"image",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/datamodel.py#L164-L191 | train |
pylp/pylp | pylp/lib/runner.py | TaskRunner.log_starting | def log_starting(self):
"""Log that the task has started."""
self.start_time = time.perf_counter()
logger.log("Starting '", logger.cyan(self.name), "'...") | python | def log_starting(self):
"""Log that the task has started."""
self.start_time = time.perf_counter()
logger.log("Starting '", logger.cyan(self.name), "'...") | [
"def",
"log_starting",
"(",
"self",
")",
":",
"self",
".",
"start_time",
"=",
"time",
".",
"perf_counter",
"(",
")",
"logger",
".",
"log",
"(",
"\"Starting '\"",
",",
"logger",
".",
"cyan",
"(",
"self",
".",
"name",
")",
",",
"\"'...\"",
")"
] | Log that the task has started. | [
"Log",
"that",
"the",
"task",
"has",
"started",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/runner.py#L50-L53 | train |
pylp/pylp | pylp/lib/runner.py | TaskRunner.log_finished | def log_finished(self):
"""Log that this task is done."""
delta = time.perf_counter() - self.start_time
logger.log("Finished '", logger.cyan(self.name),
"' after ", logger.magenta(time_to_text(delta))) | python | def log_finished(self):
"""Log that this task is done."""
delta = time.perf_counter() - self.start_time
logger.log("Finished '", logger.cyan(self.name),
"' after ", logger.magenta(time_to_text(delta))) | [
"def",
"log_finished",
"(",
"self",
")",
":",
"delta",
"=",
"time",
".",
"perf_counter",
"(",
")",
"-",
"self",
".",
"start_time",
"logger",
".",
"log",
"(",
"\"Finished '\"",
",",
"logger",
".",
"cyan",
"(",
"self",
".",
"name",
")",
",",
"\"' after \... | Log that this task is done. | [
"Log",
"that",
"this",
"task",
"is",
"done",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/runner.py#L56-L60 | train |
pylp/pylp | pylp/lib/runner.py | TaskRunner.call_task_fn | def call_task_fn(self):
"""Call the function attached to the task."""
if not self.fn:
return self.log_finished()
future = asyncio.Future()
future.add_done_callback(lambda x: self.log_finished())
if inspect.iscoroutinefunction(self.fn):
f = asyncio.ensure_future(self.fn())
f.add_done_callback(lambda... | python | def call_task_fn(self):
"""Call the function attached to the task."""
if not self.fn:
return self.log_finished()
future = asyncio.Future()
future.add_done_callback(lambda x: self.log_finished())
if inspect.iscoroutinefunction(self.fn):
f = asyncio.ensure_future(self.fn())
f.add_done_callback(lambda... | [
"def",
"call_task_fn",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"fn",
":",
"return",
"self",
".",
"log_finished",
"(",
")",
"future",
"=",
"asyncio",
".",
"Future",
"(",
")",
"future",
".",
"add_done_callback",
"(",
"lambda",
"x",
":",
"self",
... | Call the function attached to the task. | [
"Call",
"the",
"function",
"attached",
"to",
"the",
"task",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/runner.py#L63-L77 | train |
pylp/pylp | pylp/lib/runner.py | TaskRunner.bind_end | def bind_end(self, stream, future):
"""Bind a 'TaskEndTransformer' to a stream."""
if not isinstance(stream, Stream):
future.set_result(None)
else:
stream.pipe(TaskEndTransformer(future)) | python | def bind_end(self, stream, future):
"""Bind a 'TaskEndTransformer' to a stream."""
if not isinstance(stream, Stream):
future.set_result(None)
else:
stream.pipe(TaskEndTransformer(future)) | [
"def",
"bind_end",
"(",
"self",
",",
"stream",
",",
"future",
")",
":",
"if",
"not",
"isinstance",
"(",
"stream",
",",
"Stream",
")",
":",
"future",
".",
"set_result",
"(",
"None",
")",
"else",
":",
"stream",
".",
"pipe",
"(",
"TaskEndTransformer",
"("... | Bind a 'TaskEndTransformer' to a stream. | [
"Bind",
"a",
"TaskEndTransformer",
"to",
"a",
"stream",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/runner.py#L80-L85 | train |
pylp/pylp | pylp/lib/runner.py | TaskRunner.start_deps | async def start_deps(self, deps):
"""Start running dependencies."""
# Get only new dependencies
deps = list(filter(lambda dep: dep not in self.called, deps))
self.called += deps
# Start only existing dependencies
runners = list(filter(lambda x: x and x.future, map(lambda dep: pylp.start(dep), deps)))
if... | python | async def start_deps(self, deps):
"""Start running dependencies."""
# Get only new dependencies
deps = list(filter(lambda dep: dep not in self.called, deps))
self.called += deps
# Start only existing dependencies
runners = list(filter(lambda x: x and x.future, map(lambda dep: pylp.start(dep), deps)))
if... | [
"async",
"def",
"start_deps",
"(",
"self",
",",
"deps",
")",
":",
"deps",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"dep",
":",
"dep",
"not",
"in",
"self",
".",
"called",
",",
"deps",
")",
")",
"self",
".",
"called",
"+=",
"deps",
"runners",
"=",
... | Start running dependencies. | [
"Start",
"running",
"dependencies",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/runner.py#L88-L103 | train |
xflr6/bitsets | bitsets/bases.py | MemberBits.frommembers | def frommembers(cls, members=()):
"""Create a set from an iterable of members."""
return cls.fromint(sum(map(cls._map.__getitem__, set(members)))) | python | def frommembers(cls, members=()):
"""Create a set from an iterable of members."""
return cls.fromint(sum(map(cls._map.__getitem__, set(members)))) | [
"def",
"frommembers",
"(",
"cls",
",",
"members",
"=",
"(",
")",
")",
":",
"return",
"cls",
".",
"fromint",
"(",
"sum",
"(",
"map",
"(",
"cls",
".",
"_map",
".",
"__getitem__",
",",
"set",
"(",
"members",
")",
")",
")",
")"
] | Create a set from an iterable of members. | [
"Create",
"a",
"set",
"from",
"an",
"iterable",
"of",
"members",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L31-L33 | train |
xflr6/bitsets | bitsets/bases.py | MemberBits.frombools | def frombools(cls, bools=()):
"""Create a set from an iterable of boolean evaluable items."""
return cls.fromint(sum(compress(cls._atoms, bools))) | python | def frombools(cls, bools=()):
"""Create a set from an iterable of boolean evaluable items."""
return cls.fromint(sum(compress(cls._atoms, bools))) | [
"def",
"frombools",
"(",
"cls",
",",
"bools",
"=",
"(",
")",
")",
":",
"return",
"cls",
".",
"fromint",
"(",
"sum",
"(",
"compress",
"(",
"cls",
".",
"_atoms",
",",
"bools",
")",
")",
")"
] | Create a set from an iterable of boolean evaluable items. | [
"Create",
"a",
"set",
"from",
"an",
"iterable",
"of",
"boolean",
"evaluable",
"items",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L36-L38 | train |
xflr6/bitsets | bitsets/bases.py | MemberBits.frombits | def frombits(cls, bits='0'):
"""Create a set from binary string."""
if len(bits) > cls._len:
raise ValueError('too many bits %r' % (bits,))
return cls.fromint(bits[::-1], 2) | python | def frombits(cls, bits='0'):
"""Create a set from binary string."""
if len(bits) > cls._len:
raise ValueError('too many bits %r' % (bits,))
return cls.fromint(bits[::-1], 2) | [
"def",
"frombits",
"(",
"cls",
",",
"bits",
"=",
"'0'",
")",
":",
"if",
"len",
"(",
"bits",
")",
">",
"cls",
".",
"_len",
":",
"raise",
"ValueError",
"(",
"'too many bits %r'",
"%",
"(",
"bits",
",",
")",
")",
"return",
"cls",
".",
"fromint",
"(",
... | Create a set from binary string. | [
"Create",
"a",
"set",
"from",
"binary",
"string",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L41-L45 | train |
xflr6/bitsets | bitsets/bases.py | MemberBits.atoms | def atoms(self, reverse=False):
"""Yield the singleton for every set member."""
if reverse:
return filter(self.__and__, reversed(self._atoms))
return filter(self.__and__, self._atoms) | python | def atoms(self, reverse=False):
"""Yield the singleton for every set member."""
if reverse:
return filter(self.__and__, reversed(self._atoms))
return filter(self.__and__, self._atoms) | [
"def",
"atoms",
"(",
"self",
",",
"reverse",
"=",
"False",
")",
":",
"if",
"reverse",
":",
"return",
"filter",
"(",
"self",
".",
"__and__",
",",
"reversed",
"(",
"self",
".",
"_atoms",
")",
")",
"return",
"filter",
"(",
"self",
".",
"__and__",
",",
... | Yield the singleton for every set member. | [
"Yield",
"the",
"singleton",
"for",
"every",
"set",
"member",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L77-L81 | train |
xflr6/bitsets | bitsets/bases.py | MemberBits.inatoms | def inatoms(self, reverse=False):
"""Yield the singleton for every non-member."""
if reverse:
return filterfalse(self.__and__, reversed(self._atoms))
return filterfalse(self.__and__, self._atoms) | python | def inatoms(self, reverse=False):
"""Yield the singleton for every non-member."""
if reverse:
return filterfalse(self.__and__, reversed(self._atoms))
return filterfalse(self.__and__, self._atoms) | [
"def",
"inatoms",
"(",
"self",
",",
"reverse",
"=",
"False",
")",
":",
"if",
"reverse",
":",
"return",
"filterfalse",
"(",
"self",
".",
"__and__",
",",
"reversed",
"(",
"self",
".",
"_atoms",
")",
")",
"return",
"filterfalse",
"(",
"self",
".",
"__and_... | Yield the singleton for every non-member. | [
"Yield",
"the",
"singleton",
"for",
"every",
"non",
"-",
"member",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L83-L87 | train |
xflr6/bitsets | bitsets/bases.py | MemberBits.powerset | def powerset(self, start=None, excludestart=False):
"""Yield combinations from start to self in short lexicographic order."""
if start is None:
start = self.infimum
other = self.atoms()
else:
if self | start != self:
raise ValueError('%r is no ... | python | def powerset(self, start=None, excludestart=False):
"""Yield combinations from start to self in short lexicographic order."""
if start is None:
start = self.infimum
other = self.atoms()
else:
if self | start != self:
raise ValueError('%r is no ... | [
"def",
"powerset",
"(",
"self",
",",
"start",
"=",
"None",
",",
"excludestart",
"=",
"False",
")",
":",
"if",
"start",
"is",
"None",
":",
"start",
"=",
"self",
".",
"infimum",
"other",
"=",
"self",
".",
"atoms",
"(",
")",
"else",
":",
"if",
"self",... | Yield combinations from start to self in short lexicographic order. | [
"Yield",
"combinations",
"from",
"start",
"to",
"self",
"in",
"short",
"lexicographic",
"order",
"."
] | ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf | https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L89-L98 | train |
druids/django-chamber | chamber/shortcuts.py | change | def change(obj, **changed_fields):
"""
Changes a given `changed_fields` on object and returns changed object.
"""
obj_field_names = {
field.name for field in obj._meta.fields
} | {
field.attname for field in obj._meta.fields
} | {'pk'}
for field_name, value in changed_fields... | python | def change(obj, **changed_fields):
"""
Changes a given `changed_fields` on object and returns changed object.
"""
obj_field_names = {
field.name for field in obj._meta.fields
} | {
field.attname for field in obj._meta.fields
} | {'pk'}
for field_name, value in changed_fields... | [
"def",
"change",
"(",
"obj",
",",
"**",
"changed_fields",
")",
":",
"obj_field_names",
"=",
"{",
"field",
".",
"name",
"for",
"field",
"in",
"obj",
".",
"_meta",
".",
"fields",
"}",
"|",
"{",
"field",
".",
"attname",
"for",
"field",
"in",
"obj",
".",... | Changes a given `changed_fields` on object and returns changed object. | [
"Changes",
"a",
"given",
"changed_fields",
"on",
"object",
"and",
"returns",
"changed",
"object",
"."
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/shortcuts.py#L54-L68 | train |
druids/django-chamber | chamber/shortcuts.py | change_and_save | def change_and_save(obj, update_only_changed_fields=False, save_kwargs=None, **changed_fields):
"""
Changes a given `changed_fields` on object, saves it and returns changed object.
"""
from chamber.models import SmartModel
change(obj, **changed_fields)
if update_only_changed_fields and not isin... | python | def change_and_save(obj, update_only_changed_fields=False, save_kwargs=None, **changed_fields):
"""
Changes a given `changed_fields` on object, saves it and returns changed object.
"""
from chamber.models import SmartModel
change(obj, **changed_fields)
if update_only_changed_fields and not isin... | [
"def",
"change_and_save",
"(",
"obj",
",",
"update_only_changed_fields",
"=",
"False",
",",
"save_kwargs",
"=",
"None",
",",
"**",
"changed_fields",
")",
":",
"from",
"chamber",
".",
"models",
"import",
"SmartModel",
"change",
"(",
"obj",
",",
"**",
"changed_f... | Changes a given `changed_fields` on object, saves it and returns changed object. | [
"Changes",
"a",
"given",
"changed_fields",
"on",
"object",
"saves",
"it",
"and",
"returns",
"changed",
"object",
"."
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/shortcuts.py#L71-L86 | train |
druids/django-chamber | chamber/shortcuts.py | bulk_change_and_save | def bulk_change_and_save(iterable, update_only_changed_fields=False, save_kwargs=None, **changed_fields):
"""
Changes a given `changed_fields` on each object in a given `iterable`, saves objects
and returns the changed objects.
"""
return [
change_and_save(obj, update_only_changed_fields=upd... | python | def bulk_change_and_save(iterable, update_only_changed_fields=False, save_kwargs=None, **changed_fields):
"""
Changes a given `changed_fields` on each object in a given `iterable`, saves objects
and returns the changed objects.
"""
return [
change_and_save(obj, update_only_changed_fields=upd... | [
"def",
"bulk_change_and_save",
"(",
"iterable",
",",
"update_only_changed_fields",
"=",
"False",
",",
"save_kwargs",
"=",
"None",
",",
"**",
"changed_fields",
")",
":",
"return",
"[",
"change_and_save",
"(",
"obj",
",",
"update_only_changed_fields",
"=",
"update_onl... | Changes a given `changed_fields` on each object in a given `iterable`, saves objects
and returns the changed objects. | [
"Changes",
"a",
"given",
"changed_fields",
"on",
"each",
"object",
"in",
"a",
"given",
"iterable",
"saves",
"objects",
"and",
"returns",
"the",
"changed",
"objects",
"."
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/shortcuts.py#L96-L105 | train |
guaix-ucm/numina | numina/modeling/gaussbox.py | gauss_box_model | def gauss_box_model(x, amplitude=1.0, mean=0.0, stddev=1.0, hpix=0.5):
"""Integrate a Gaussian profile."""
z = (x - mean) / stddev
z2 = z + hpix / stddev
z1 = z - hpix / stddev
return amplitude * (norm.cdf(z2) - norm.cdf(z1)) | python | def gauss_box_model(x, amplitude=1.0, mean=0.0, stddev=1.0, hpix=0.5):
"""Integrate a Gaussian profile."""
z = (x - mean) / stddev
z2 = z + hpix / stddev
z1 = z - hpix / stddev
return amplitude * (norm.cdf(z2) - norm.cdf(z1)) | [
"def",
"gauss_box_model",
"(",
"x",
",",
"amplitude",
"=",
"1.0",
",",
"mean",
"=",
"0.0",
",",
"stddev",
"=",
"1.0",
",",
"hpix",
"=",
"0.5",
")",
":",
"z",
"=",
"(",
"x",
"-",
"mean",
")",
"/",
"stddev",
"z2",
"=",
"z",
"+",
"hpix",
"/",
"s... | Integrate a Gaussian profile. | [
"Integrate",
"a",
"Gaussian",
"profile",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/modeling/gaussbox.py#L24-L29 | train |
guaix-ucm/numina | numina/modeling/gaussbox.py | gauss_box_model_deriv | def gauss_box_model_deriv(x, amplitude=1.0, mean=0.0, stddev=1.0, hpix=0.5):
"""Derivative of the integral of a Gaussian profile."""
z = (x - mean) / stddev
z2 = z + hpix / stddev
z1 = z - hpix / stddev
da = norm.cdf(z2) - norm.cdf(z1)
fp2 = norm_pdf_t(z2)
fp1 = norm_pdf_t(z1)
dl = -... | python | def gauss_box_model_deriv(x, amplitude=1.0, mean=0.0, stddev=1.0, hpix=0.5):
"""Derivative of the integral of a Gaussian profile."""
z = (x - mean) / stddev
z2 = z + hpix / stddev
z1 = z - hpix / stddev
da = norm.cdf(z2) - norm.cdf(z1)
fp2 = norm_pdf_t(z2)
fp1 = norm_pdf_t(z1)
dl = -... | [
"def",
"gauss_box_model_deriv",
"(",
"x",
",",
"amplitude",
"=",
"1.0",
",",
"mean",
"=",
"0.0",
",",
"stddev",
"=",
"1.0",
",",
"hpix",
"=",
"0.5",
")",
":",
"z",
"=",
"(",
"x",
"-",
"mean",
")",
"/",
"stddev",
"z2",
"=",
"z",
"+",
"hpix",
"/"... | Derivative of the integral of a Gaussian profile. | [
"Derivative",
"of",
"the",
"integral",
"of",
"a",
"Gaussian",
"profile",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/modeling/gaussbox.py#L32-L47 | train |
guaix-ucm/numina | numina/array/wavecalib/peaks_spectrum.py | find_peaks_spectrum | def find_peaks_spectrum(sx, nwinwidth, threshold=0, debugplot=0):
"""Find peaks in array.
The algorithm imposes that the signal at both sides of the peak
decreases monotonically.
Parameters
----------
sx : 1d numpy array, floats
Input array.
nwinwidth : int
Width of the win... | python | def find_peaks_spectrum(sx, nwinwidth, threshold=0, debugplot=0):
"""Find peaks in array.
The algorithm imposes that the signal at both sides of the peak
decreases monotonically.
Parameters
----------
sx : 1d numpy array, floats
Input array.
nwinwidth : int
Width of the win... | [
"def",
"find_peaks_spectrum",
"(",
"sx",
",",
"nwinwidth",
",",
"threshold",
"=",
"0",
",",
"debugplot",
"=",
"0",
")",
":",
"if",
"type",
"(",
"sx",
")",
"is",
"not",
"np",
".",
"ndarray",
":",
"raise",
"ValueError",
"(",
"\"sx=\"",
"+",
"str",
"(",... | Find peaks in array.
The algorithm imposes that the signal at both sides of the peak
decreases monotonically.
Parameters
----------
sx : 1d numpy array, floats
Input array.
nwinwidth : int
Width of the window where each peak must be found.
threshold : float
Minimum ... | [
"Find",
"peaks",
"in",
"array",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/peaks_spectrum.py#L19-L106 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.