repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
guaix-ucm/numina | numina/array/display/pause_debugplot.py | pause_debugplot | def pause_debugplot(debugplot, optional_prompt=None, pltshow=False,
tight_layout=True):
"""Ask the user to press RETURN to continue after plotting.
Parameters
----------
debugplot : int
Determines whether intermediate computations and/or plots
are displayed:
... | python | def pause_debugplot(debugplot, optional_prompt=None, pltshow=False,
tight_layout=True):
"""Ask the user to press RETURN to continue after plotting.
Parameters
----------
debugplot : int
Determines whether intermediate computations and/or plots
are displayed:
... | [
"def",
"pause_debugplot",
"(",
"debugplot",
",",
"optional_prompt",
"=",
"None",
",",
"pltshow",
"=",
"False",
",",
"tight_layout",
"=",
"True",
")",
":",
"if",
"debugplot",
"not",
"in",
"DEBUGPLOT_CODES",
":",
"raise",
"ValueError",
"(",
"'Invalid debugplot val... | Ask the user to press RETURN to continue after plotting.
Parameters
----------
debugplot : int
Determines whether intermediate computations and/or plots
are displayed:
00 : no debug, no plots
01 : no debug, plots without pauses
02 : no debug, plots with pauses
... | [
"Ask",
"the",
"user",
"to",
"press",
"RETURN",
"to",
"continue",
"after",
"plotting",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/pause_debugplot.py#L21-L82 | train | Ask the user to continue after plotting. |
guaix-ucm/numina | numina/array/mode.py | mode_half_sample | def mode_half_sample(a, is_sorted=False):
'''
Estimate the mode using the Half Sample mode.
A method to estimate the mode, as described in
D. R. Bickel and R. Frühwirth (contributed equally),
"On a fast, robust estimator of the mode: Comparisons to other
robust estimators with applications,"
... | python | def mode_half_sample(a, is_sorted=False):
'''
Estimate the mode using the Half Sample mode.
A method to estimate the mode, as described in
D. R. Bickel and R. Frühwirth (contributed equally),
"On a fast, robust estimator of the mode: Comparisons to other
robust estimators with applications,"
... | [
"def",
"mode_half_sample",
"(",
"a",
",",
"is_sorted",
"=",
"False",
")",
":",
"a",
"=",
"np",
".",
"asanyarray",
"(",
"a",
")",
"if",
"not",
"is_sorted",
":",
"sdata",
"=",
"np",
".",
"sort",
"(",
"a",
")",
"else",
":",
"sdata",
"=",
"a",
"n",
... | Estimate the mode using the Half Sample mode.
A method to estimate the mode, as described in
D. R. Bickel and R. Frühwirth (contributed equally),
"On a fast, robust estimator of the mode: Comparisons to other
robust estimators with applications,"
Computational Statistics and Data Analysis 50, 3500-... | [
"Estimate",
"the",
"mode",
"using",
"the",
"Half",
"Sample",
"mode",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/mode.py#L21-L69 | train | Estimate the mode using the Half Sample mode. |
guaix-ucm/numina | numina/array/display/overplot_ds9reg.py | overplot_ds9reg | def overplot_ds9reg(filename, ax):
"""Overplot a ds9 region file.
Parameters
----------
filename : str
File name of the ds9 region file.
ax : matplotlib axes instance
Matplotlib axes instance.
"""
# read ds9 region file
with open(filename) as f:
file_content = ... | python | def overplot_ds9reg(filename, ax):
"""Overplot a ds9 region file.
Parameters
----------
filename : str
File name of the ds9 region file.
ax : matplotlib axes instance
Matplotlib axes instance.
"""
# read ds9 region file
with open(filename) as f:
file_content = ... | [
"def",
"overplot_ds9reg",
"(",
"filename",
",",
"ax",
")",
":",
"# read ds9 region file",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"file_content",
"=",
"f",
".",
"read",
"(",
")",
".",
"splitlines",
"(",
")",
"# check first line",
"first_line",
... | Overplot a ds9 region file.
Parameters
----------
filename : str
File name of the ds9 region file.
ax : matplotlib axes instance
Matplotlib axes instance. | [
"Overplot",
"a",
"ds9",
"region",
"file",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/overplot_ds9reg.py#L14-L64 | train | Overplot a ds9 region file. |
guaix-ucm/numina | numina/array/peaks/peakdet.py | find_peaks_indexes | def find_peaks_indexes(arr, window_width=5, threshold=0.0, fpeak=0):
"""Find indexes of peaks in a 1d array.
Note that window_width must be an odd number. The function imposes that the
fluxes in the window_width /2 points to the left (and right) of the peak
decrease monotonously as one moves away from ... | python | def find_peaks_indexes(arr, window_width=5, threshold=0.0, fpeak=0):
"""Find indexes of peaks in a 1d array.
Note that window_width must be an odd number. The function imposes that the
fluxes in the window_width /2 points to the left (and right) of the peak
decrease monotonously as one moves away from ... | [
"def",
"find_peaks_indexes",
"(",
"arr",
",",
"window_width",
"=",
"5",
",",
"threshold",
"=",
"0.0",
",",
"fpeak",
"=",
"0",
")",
":",
"_check_window_width",
"(",
"window_width",
")",
"if",
"(",
"fpeak",
"<",
"0",
"or",
"fpeak",
"+",
"1",
">=",
"windo... | Find indexes of peaks in a 1d array.
Note that window_width must be an odd number. The function imposes that the
fluxes in the window_width /2 points to the left (and right) of the peak
decrease monotonously as one moves away from the peak, except that
it allows fpeak constant values around the peak.
... | [
"Find",
"indexes",
"of",
"peaks",
"in",
"a",
"1d",
"array",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/peaks/peakdet.py#L61-L98 | train | Find indexes of peaks in a 1D array. |
guaix-ucm/numina | numina/array/peaks/peakdet.py | refine_peaks | def refine_peaks(arr, ipeaks, window_width):
"""Refine the peak location previously found by find_peaks_indexes
Parameters
----------
arr : 1d numpy array, float
Input 1D spectrum.
ipeaks : 1d numpy array (int)
Indices of the input array arr in which the peaks were initially found.
... | python | def refine_peaks(arr, ipeaks, window_width):
"""Refine the peak location previously found by find_peaks_indexes
Parameters
----------
arr : 1d numpy array, float
Input 1D spectrum.
ipeaks : 1d numpy array (int)
Indices of the input array arr in which the peaks were initially found.
... | [
"def",
"refine_peaks",
"(",
"arr",
",",
"ipeaks",
",",
"window_width",
")",
":",
"_check_window_width",
"(",
"window_width",
")",
"step",
"=",
"window_width",
"//",
"2",
"ipeaks",
"=",
"filter_array_margins",
"(",
"arr",
",",
"ipeaks",
",",
"window_width",
")"... | Refine the peak location previously found by find_peaks_indexes
Parameters
----------
arr : 1d numpy array, float
Input 1D spectrum.
ipeaks : 1d numpy array (int)
Indices of the input array arr in which the peaks were initially found.
window_width : int
Width of the window w... | [
"Refine",
"the",
"peak",
"location",
"previously",
"found",
"by",
"find_peaks_indexes"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/peaks/peakdet.py#L137-L174 | train | Refine the peak location previously found by find_peaks_indexes. |
guaix-ucm/numina | numina/user/clirun.py | complete_config | def complete_config(config):
"""Complete config with default values"""
if not config.has_section('run'):
config.add_section('run')
values = {
'basedir': os.getcwd(),
'task_control': 'control.yaml',
}
for k, v in values.items():
if not config.has_option('run', k):
... | python | def complete_config(config):
"""Complete config with default values"""
if not config.has_section('run'):
config.add_section('run')
values = {
'basedir': os.getcwd(),
'task_control': 'control.yaml',
}
for k, v in values.items():
if not config.has_option('run', k):
... | [
"def",
"complete_config",
"(",
"config",
")",
":",
"if",
"not",
"config",
".",
"has_section",
"(",
"'run'",
")",
":",
"config",
".",
"add_section",
"(",
"'run'",
")",
"values",
"=",
"{",
"'basedir'",
":",
"os",
".",
"getcwd",
"(",
")",
",",
"'task_cont... | Complete config with default values | [
"Complete",
"config",
"with",
"default",
"values"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/user/clirun.py#L17-L32 | train | Complete config with default values |
guaix-ucm/numina | numina/array/recenter.py | centering_centroid | def centering_centroid(data, xi, yi, box, nloop=10, toldist=1e-3,
maxdist=10.0):
'''
returns x, y, background, status, message
status is:
* 0: not recentering
* 1: recentering successful
* 2: maximum distance reached
* 3: not converged
... | python | def centering_centroid(data, xi, yi, box, nloop=10, toldist=1e-3,
maxdist=10.0):
'''
returns x, y, background, status, message
status is:
* 0: not recentering
* 1: recentering successful
* 2: maximum distance reached
* 3: not converged
... | [
"def",
"centering_centroid",
"(",
"data",
",",
"xi",
",",
"yi",
",",
"box",
",",
"nloop",
"=",
"10",
",",
"toldist",
"=",
"1e-3",
",",
"maxdist",
"=",
"10.0",
")",
":",
"# Store original center",
"cxy",
"=",
"(",
"xi",
",",
"yi",
")",
"origin",
"=",
... | returns x, y, background, status, message
status is:
* 0: not recentering
* 1: recentering successful
* 2: maximum distance reached
* 3: not converged | [
"returns",
"x",
"y",
"background",
"status",
"message"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/recenter.py#L57-L94 | train | Return the center of the user s sanic acid ionic acid in a box. |
twiebe/Flask-CacheControl | src/flask_cachecontrol/cache.py | cache_for | def cache_for(**timedelta_kw):
"""
Set Cache-Control headers and Expires-header.
Expects a timedelta instance.
"""
max_age_timedelta = timedelta(**timedelta_kw)
def decorate_func(func):
@wraps(func)
def decorate_func_call(*a, **kw):
callback = SetCacheControlHeaders... | python | def cache_for(**timedelta_kw):
"""
Set Cache-Control headers and Expires-header.
Expects a timedelta instance.
"""
max_age_timedelta = timedelta(**timedelta_kw)
def decorate_func(func):
@wraps(func)
def decorate_func_call(*a, **kw):
callback = SetCacheControlHeaders... | [
"def",
"cache_for",
"(",
"*",
"*",
"timedelta_kw",
")",
":",
"max_age_timedelta",
"=",
"timedelta",
"(",
"*",
"*",
"timedelta_kw",
")",
"def",
"decorate_func",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorate_func_call",
"(",
"*",
... | Set Cache-Control headers and Expires-header.
Expects a timedelta instance. | [
"Set",
"Cache",
"-",
"Control",
"headers",
"and",
"Expires",
"-",
"header",
"."
] | 8376156fafe3358b5a1201d348afb12994172962 | https://github.com/twiebe/Flask-CacheControl/blob/8376156fafe3358b5a1201d348afb12994172962/src/flask_cachecontrol/cache.py#L20-L37 | train | Decorator for adding a callback to the Cache - Control headers and Expires - header. |
twiebe/Flask-CacheControl | src/flask_cachecontrol/cache.py | cache | def cache(*cache_control_items, **cache_control_kw):
"""
Set Cache-Control headers.
Expects keyword arguments and/or an item list.
Each pair is used to set Flask Response.cache_control attributes,
where the key is the attribute name and the value is its value.
Use True as value for attributes... | python | def cache(*cache_control_items, **cache_control_kw):
"""
Set Cache-Control headers.
Expects keyword arguments and/or an item list.
Each pair is used to set Flask Response.cache_control attributes,
where the key is the attribute name and the value is its value.
Use True as value for attributes... | [
"def",
"cache",
"(",
"*",
"cache_control_items",
",",
"*",
"*",
"cache_control_kw",
")",
":",
"cache_control_kw",
".",
"update",
"(",
"cache_control_items",
")",
"def",
"decorate_func",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorate_... | Set Cache-Control headers.
Expects keyword arguments and/or an item list.
Each pair is used to set Flask Response.cache_control attributes,
where the key is the attribute name and the value is its value.
Use True as value for attributes without values.
In case of an invalid attribute, CacheContr... | [
"Set",
"Cache",
"-",
"Control",
"headers",
"."
] | 8376156fafe3358b5a1201d348afb12994172962 | https://github.com/twiebe/Flask-CacheControl/blob/8376156fafe3358b5a1201d348afb12994172962/src/flask_cachecontrol/cache.py#L41-L66 | train | Decorator for Flask Response. cache. |
twiebe/Flask-CacheControl | src/flask_cachecontrol/cache.py | dont_cache | def dont_cache():
"""
Set Cache-Control headers for no caching
Will generate proxy-revalidate, no-cache, no-store, must-revalidate,
max-age=0.
"""
def decorate_func(func):
@wraps(func)
def decorate_func_call(*a, **kw):
callback = SetCacheControlHeadersForNoCachingCal... | python | def dont_cache():
"""
Set Cache-Control headers for no caching
Will generate proxy-revalidate, no-cache, no-store, must-revalidate,
max-age=0.
"""
def decorate_func(func):
@wraps(func)
def decorate_func_call(*a, **kw):
callback = SetCacheControlHeadersForNoCachingCal... | [
"def",
"dont_cache",
"(",
")",
":",
"def",
"decorate_func",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorate_func_call",
"(",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"callback",
"=",
"SetCacheControlHeadersForNoCachingCallback",
"("... | Set Cache-Control headers for no caching
Will generate proxy-revalidate, no-cache, no-store, must-revalidate,
max-age=0. | [
"Set",
"Cache",
"-",
"Control",
"headers",
"for",
"no",
"caching"
] | 8376156fafe3358b5a1201d348afb12994172962 | https://github.com/twiebe/Flask-CacheControl/blob/8376156fafe3358b5a1201d348afb12994172962/src/flask_cachecontrol/cache.py#L70-L86 | train | Decorator to disable caching for a single object. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | filter_empty_parameters | def filter_empty_parameters(func):
"""Decorator that is filtering empty parameters.
:param func: function that you want wrapping
:type func: function
"""
@wraps(func)
def func_wrapper(self, *args, **kwargs):
my_kwargs = {key: value for key, value in kwargs.items()
i... | python | def filter_empty_parameters(func):
"""Decorator that is filtering empty parameters.
:param func: function that you want wrapping
:type func: function
"""
@wraps(func)
def func_wrapper(self, *args, **kwargs):
my_kwargs = {key: value for key, value in kwargs.items()
i... | [
"def",
"filter_empty_parameters",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"func_wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"my_kwargs",
"=",
"{",
"key",
":",
"value",
"for",
"key",
",",
"value",
... | Decorator that is filtering empty parameters.
:param func: function that you want wrapping
:type func: function | [
"Decorator",
"that",
"is",
"filtering",
"empty",
"parameters",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L330-L348 | train | Decorator that is filtering empty parameters. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | author_id_normalize_and_schema | def author_id_normalize_and_schema(uid, schema=None):
"""Detect and normalize an author UID schema.
Args:
uid (string): a UID string
schema (string): try to resolve to schema
Returns:
Tuple[string, string]: a tuple (uid, schema) where:
- uid: the UID normalized to comply wi... | python | def author_id_normalize_and_schema(uid, schema=None):
"""Detect and normalize an author UID schema.
Args:
uid (string): a UID string
schema (string): try to resolve to schema
Returns:
Tuple[string, string]: a tuple (uid, schema) where:
- uid: the UID normalized to comply wi... | [
"def",
"author_id_normalize_and_schema",
"(",
"uid",
",",
"schema",
"=",
"None",
")",
":",
"def",
"_get_uid_normalized_in_schema",
"(",
"_uid",
",",
"_schema",
")",
":",
"regex",
",",
"template",
"=",
"_RE_AUTHORS_UID",
"[",
"_schema",
"]",
"match",
"=",
"rege... | Detect and normalize an author UID schema.
Args:
uid (string): a UID string
schema (string): try to resolve to schema
Returns:
Tuple[string, string]: a tuple (uid, schema) where:
- uid: the UID normalized to comply with the id.json schema
- schema: a schema of the UID o... | [
"Detect",
"and",
"normalize",
"an",
"author",
"UID",
"schema",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L351-L401 | train | Detect and normalize an author UID string and schema. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | normalize_arxiv_category | def normalize_arxiv_category(category):
"""Normalize arXiv category to be schema compliant.
This properly capitalizes the category and replaces the dash by a dot if
needed. If the category is obsolete, it also gets converted it to its
current equivalent.
Example:
>>> from inspire_schemas.u... | python | def normalize_arxiv_category(category):
"""Normalize arXiv category to be schema compliant.
This properly capitalizes the category and replaces the dash by a dot if
needed. If the category is obsolete, it also gets converted it to its
current equivalent.
Example:
>>> from inspire_schemas.u... | [
"def",
"normalize_arxiv_category",
"(",
"category",
")",
":",
"category",
"=",
"_NEW_CATEGORIES",
".",
"get",
"(",
"category",
".",
"lower",
"(",
")",
",",
"category",
")",
"for",
"valid_category",
"in",
"valid_arxiv_categories",
"(",
")",
":",
"if",
"(",
"c... | Normalize arXiv category to be schema compliant.
This properly capitalizes the category and replaces the dash by a dot if
needed. If the category is obsolete, it also gets converted it to its
current equivalent.
Example:
>>> from inspire_schemas.utils import normalize_arxiv_category
>>... | [
"Normalize",
"arXiv",
"category",
"to",
"be",
"schema",
"compliant",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L404-L422 | train | Normalize arXiv category to be schema compliant. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | valid_arxiv_categories | def valid_arxiv_categories():
"""List of all arXiv categories that ever existed.
Example:
>>> from inspire_schemas.utils import valid_arxiv_categories
>>> 'funct-an' in valid_arxiv_categories()
True
"""
schema = load_schema('elements/arxiv_categories')
categories = schema['... | python | def valid_arxiv_categories():
"""List of all arXiv categories that ever existed.
Example:
>>> from inspire_schemas.utils import valid_arxiv_categories
>>> 'funct-an' in valid_arxiv_categories()
True
"""
schema = load_schema('elements/arxiv_categories')
categories = schema['... | [
"def",
"valid_arxiv_categories",
"(",
")",
":",
"schema",
"=",
"load_schema",
"(",
"'elements/arxiv_categories'",
")",
"categories",
"=",
"schema",
"[",
"'enum'",
"]",
"categories",
".",
"extend",
"(",
"_NEW_CATEGORIES",
".",
"keys",
"(",
")",
")",
"return",
"... | List of all arXiv categories that ever existed.
Example:
>>> from inspire_schemas.utils import valid_arxiv_categories
>>> 'funct-an' in valid_arxiv_categories()
True | [
"List",
"of",
"all",
"arXiv",
"categories",
"that",
"ever",
"existed",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L425-L438 | train | List of all arXiv categories that ever existed. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | classify_field | def classify_field(value):
"""Normalize ``value`` to an Inspire category.
Args:
value(str): an Inspire category to properly case, or an arXiv category
to translate to the corresponding Inspire category.
Returns:
str: ``None`` if ``value`` is not a non-empty string,
... | python | def classify_field(value):
"""Normalize ``value`` to an Inspire category.
Args:
value(str): an Inspire category to properly case, or an arXiv category
to translate to the corresponding Inspire category.
Returns:
str: ``None`` if ``value`` is not a non-empty string,
... | [
"def",
"classify_field",
"(",
"value",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
"and",
"value",
")",
":",
"return",
"schema",
"=",
"load_schema",
"(",
"'elements/inspire_field'",
")",
"inspire_categories",
... | Normalize ``value`` to an Inspire category.
Args:
value(str): an Inspire category to properly case, or an arXiv category
to translate to the corresponding Inspire category.
Returns:
str: ``None`` if ``value`` is not a non-empty string,
otherwise the corresponding Inspir... | [
"Normalize",
"value",
"to",
"an",
"Inspire",
"category",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L441-L464 | train | Normalize value to an Inspire category or an arXiv category. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | split_page_artid | def split_page_artid(page_artid):
"""Split page_artid into page_start/end and artid."""
page_start = None
page_end = None
artid = None
if not page_artid:
return None, None, None
# normalize unicode dashes
page_artid = unidecode(six.text_type(page_artid))
if '-' in page_artid:
... | python | def split_page_artid(page_artid):
"""Split page_artid into page_start/end and artid."""
page_start = None
page_end = None
artid = None
if not page_artid:
return None, None, None
# normalize unicode dashes
page_artid = unidecode(six.text_type(page_artid))
if '-' in page_artid:
... | [
"def",
"split_page_artid",
"(",
"page_artid",
")",
":",
"page_start",
"=",
"None",
"page_end",
"=",
"None",
"artid",
"=",
"None",
"if",
"not",
"page_artid",
":",
"return",
"None",
",",
"None",
",",
"None",
"# normalize unicode dashes",
"page_artid",
"=",
"unid... | Split page_artid into page_start/end and artid. | [
"Split",
"page_artid",
"into",
"page_start",
"/",
"end",
"and",
"artid",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L467-L498 | train | Split page_artid into page_start end and artid. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | split_pubnote | def split_pubnote(pubnote_str):
"""Split pubnote into journal information."""
pubnote = {}
parts = pubnote_str.split(',')
if len(parts) > 2:
pubnote['journal_title'] = parts[0]
pubnote['journal_volume'] = parts[1]
pubnote['page_start'], pubnote['page_end'], pubnote['artid'] = sp... | python | def split_pubnote(pubnote_str):
"""Split pubnote into journal information."""
pubnote = {}
parts = pubnote_str.split(',')
if len(parts) > 2:
pubnote['journal_title'] = parts[0]
pubnote['journal_volume'] = parts[1]
pubnote['page_start'], pubnote['page_end'], pubnote['artid'] = sp... | [
"def",
"split_pubnote",
"(",
"pubnote_str",
")",
":",
"pubnote",
"=",
"{",
"}",
"parts",
"=",
"pubnote_str",
".",
"split",
"(",
"','",
")",
"if",
"len",
"(",
"parts",
")",
">",
"2",
":",
"pubnote",
"[",
"'journal_title'",
"]",
"=",
"parts",
"[",
"0",... | Split pubnote into journal information. | [
"Split",
"pubnote",
"into",
"journal",
"information",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L501-L511 | train | Split pubnote into journal information. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | build_pubnote | def build_pubnote(title, volume, page_start=None, page_end=None, artid=None):
"""Build pubnote string from parts (reverse of split_pubnote)."""
if title and volume and artid and artid != page_start:
pubnote_format = u'{title},{volume},{artid}'
elif title and volume and page_start and page_end:
... | python | def build_pubnote(title, volume, page_start=None, page_end=None, artid=None):
"""Build pubnote string from parts (reverse of split_pubnote)."""
if title and volume and artid and artid != page_start:
pubnote_format = u'{title},{volume},{artid}'
elif title and volume and page_start and page_end:
... | [
"def",
"build_pubnote",
"(",
"title",
",",
"volume",
",",
"page_start",
"=",
"None",
",",
"page_end",
"=",
"None",
",",
"artid",
"=",
"None",
")",
":",
"if",
"title",
"and",
"volume",
"and",
"artid",
"and",
"artid",
"!=",
"page_start",
":",
"pubnote_form... | Build pubnote string from parts (reverse of split_pubnote). | [
"Build",
"pubnote",
"string",
"from",
"parts",
"(",
"reverse",
"of",
"split_pubnote",
")",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L514-L529 | train | Build a pubnote string from parts. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | get_schema_path | def get_schema_path(schema, resolved=False):
"""Retrieve the installed path for the given schema.
Args:
schema(str): relative or absolute url of the schema to validate, for
example, 'records/authors.json' or 'jobs.json', or just the name of the
schema, like 'jobs'.
resol... | python | def get_schema_path(schema, resolved=False):
"""Retrieve the installed path for the given schema.
Args:
schema(str): relative or absolute url of the schema to validate, for
example, 'records/authors.json' or 'jobs.json', or just the name of the
schema, like 'jobs'.
resol... | [
"def",
"get_schema_path",
"(",
"schema",
",",
"resolved",
"=",
"False",
")",
":",
"def",
"_strip_first_path_elem",
"(",
"path",
")",
":",
"\"\"\"Pass doctests.\n\n Strip the first element of the given path, returning an empty string if\n there are no more elements. For ... | Retrieve the installed path for the given schema.
Args:
schema(str): relative or absolute url of the schema to validate, for
example, 'records/authors.json' or 'jobs.json', or just the name of the
schema, like 'jobs'.
resolved(bool): if True, the returned path points to a fu... | [
"Retrieve",
"the",
"installed",
"path",
"for",
"the",
"given",
"schema",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L545-L598 | train | Retrieve the installed path for the given schema. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | load_schema | def load_schema(schema_name, resolved=False):
"""Load the given schema from wherever it's installed.
Args:
schema_name(str): Name of the schema to load, for example 'authors'.
resolved(bool): If True will return the resolved schema, that is with
all the $refs replaced by their targe... | python | def load_schema(schema_name, resolved=False):
"""Load the given schema from wherever it's installed.
Args:
schema_name(str): Name of the schema to load, for example 'authors'.
resolved(bool): If True will return the resolved schema, that is with
all the $refs replaced by their targe... | [
"def",
"load_schema",
"(",
"schema_name",
",",
"resolved",
"=",
"False",
")",
":",
"schema_data",
"=",
"''",
"with",
"open",
"(",
"get_schema_path",
"(",
"schema_name",
",",
"resolved",
")",
")",
"as",
"schema_fd",
":",
"schema_data",
"=",
"json",
".",
"lo... | Load the given schema from wherever it's installed.
Args:
schema_name(str): Name of the schema to load, for example 'authors'.
resolved(bool): If True will return the resolved schema, that is with
all the $refs replaced by their targets.
Returns:
dict: the schema with the g... | [
"Load",
"the",
"given",
"schema",
"from",
"wherever",
"it",
"s",
"installed",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L601-L616 | train | Load the given schema from wherever it s installed. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | _load_schema_for_record | def _load_schema_for_record(data, schema=None):
"""Load the schema from a given record.
Args:
data (dict): record data.
schema (Union[dict, str]): schema to validate against.
Returns:
dict: the loaded schema.
Raises:
SchemaNotFound: if the given schema was not found.
... | python | def _load_schema_for_record(data, schema=None):
"""Load the schema from a given record.
Args:
data (dict): record data.
schema (Union[dict, str]): schema to validate against.
Returns:
dict: the loaded schema.
Raises:
SchemaNotFound: if the given schema was not found.
... | [
"def",
"_load_schema_for_record",
"(",
"data",
",",
"schema",
"=",
"None",
")",
":",
"if",
"schema",
"is",
"None",
":",
"if",
"'$schema'",
"not",
"in",
"data",
":",
"raise",
"SchemaKeyNotFound",
"(",
"data",
"=",
"data",
")",
"schema",
"=",
"data",
"[",
... | Load the schema from a given record.
Args:
data (dict): record data.
schema (Union[dict, str]): schema to validate against.
Returns:
dict: the loaded schema.
Raises:
SchemaNotFound: if the given schema was not found.
SchemaKeyNotFound: if ``schema`` is ``None`` and... | [
"Load",
"the",
"schema",
"from",
"a",
"given",
"record",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L627-L650 | train | Load the schema for a given record. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | validate | def validate(data, schema=None):
"""Validate the given dictionary against the given schema.
Args:
data (dict): record to validate.
schema (Union[dict, str]): schema to validate against. If it is a
string, it is intepreted as the name of the schema to load (e.g.
``authors... | python | def validate(data, schema=None):
"""Validate the given dictionary against the given schema.
Args:
data (dict): record to validate.
schema (Union[dict, str]): schema to validate against. If it is a
string, it is intepreted as the name of the schema to load (e.g.
``authors... | [
"def",
"validate",
"(",
"data",
",",
"schema",
"=",
"None",
")",
":",
"schema",
"=",
"_load_schema_for_record",
"(",
"data",
",",
"schema",
")",
"return",
"jsonschema_validate",
"(",
"instance",
"=",
"data",
",",
"schema",
"=",
"schema",
",",
"resolver",
"... | Validate the given dictionary against the given schema.
Args:
data (dict): record to validate.
schema (Union[dict, str]): schema to validate against. If it is a
string, it is intepreted as the name of the schema to load (e.g.
``authors`` or ``jobs``). If it is ``None``, the ... | [
"Validate",
"the",
"given",
"dictionary",
"against",
"the",
"given",
"schema",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L653-L678 | train | Validate the given dictionary against the given schema. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | get_validation_errors | def get_validation_errors(data, schema=None):
"""Validation errors for a given record.
Args:
data (dict): record to validate.
schema (Union[dict, str]): schema to validate against. If it is a
string, it is intepreted as the name of the schema to load (e.g.
``authors`` or... | python | def get_validation_errors(data, schema=None):
"""Validation errors for a given record.
Args:
data (dict): record to validate.
schema (Union[dict, str]): schema to validate against. If it is a
string, it is intepreted as the name of the schema to load (e.g.
``authors`` or... | [
"def",
"get_validation_errors",
"(",
"data",
",",
"schema",
"=",
"None",
")",
":",
"schema",
"=",
"_load_schema_for_record",
"(",
"data",
",",
"schema",
")",
"errors",
"=",
"Draft4Validator",
"(",
"schema",
",",
"resolver",
"=",
"LocalRefResolver",
".",
"from_... | Validation errors for a given record.
Args:
data (dict): record to validate.
schema (Union[dict, str]): schema to validate against. If it is a
string, it is intepreted as the name of the schema to load (e.g.
``authors`` or ``jobs``). If it is ``None``, the schema is taken
... | [
"Validation",
"errors",
"for",
"a",
"given",
"record",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L681-L707 | train | Returns validation errors for a given record. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | normalize_collaboration | def normalize_collaboration(collaboration):
"""Normalize collaboration string.
Args:
collaboration: a string containing collaboration(s) or None
Returns:
list: List of extracted and normalized collaborations
Examples:
>>> from inspire_schemas.utils import normalize_collaborati... | python | def normalize_collaboration(collaboration):
"""Normalize collaboration string.
Args:
collaboration: a string containing collaboration(s) or None
Returns:
list: List of extracted and normalized collaborations
Examples:
>>> from inspire_schemas.utils import normalize_collaborati... | [
"def",
"normalize_collaboration",
"(",
"collaboration",
")",
":",
"if",
"not",
"collaboration",
":",
"return",
"[",
"]",
"collaboration",
"=",
"collaboration",
".",
"strip",
"(",
")",
"if",
"collaboration",
".",
"startswith",
"(",
"'('",
")",
"and",
"collabora... | Normalize collaboration string.
Args:
collaboration: a string containing collaboration(s) or None
Returns:
list: List of extracted and normalized collaborations
Examples:
>>> from inspire_schemas.utils import normalize_collaboration
>>> normalize_collaboration('for the CMS... | [
"Normalize",
"collaboration",
"string",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L710-L737 | train | Normalizes a string containing collaborations. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | get_license_from_url | def get_license_from_url(url):
"""Get the license abbreviation from an URL.
Args:
url(str): canonical url of the license.
Returns:
str: the corresponding license abbreviation.
Raises:
ValueError: when the url is not recognized
"""
if not url:
return
split_... | python | def get_license_from_url(url):
"""Get the license abbreviation from an URL.
Args:
url(str): canonical url of the license.
Returns:
str: the corresponding license abbreviation.
Raises:
ValueError: when the url is not recognized
"""
if not url:
return
split_... | [
"def",
"get_license_from_url",
"(",
"url",
")",
":",
"if",
"not",
"url",
":",
"return",
"split_url",
"=",
"urlsplit",
"(",
"url",
",",
"scheme",
"=",
"'http'",
")",
"if",
"split_url",
".",
"netloc",
".",
"lower",
"(",
")",
"==",
"'creativecommons.org'",
... | Get the license abbreviation from an URL.
Args:
url(str): canonical url of the license.
Returns:
str: the corresponding license abbreviation.
Raises:
ValueError: when the url is not recognized | [
"Get",
"the",
"license",
"abbreviation",
"from",
"an",
"URL",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L740-L776 | train | Get the license abbreviation from an URL. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | convert_old_publication_info_to_new | def convert_old_publication_info_to_new(publication_infos):
"""Convert a ``publication_info`` value from the old format to the new.
On Legacy different series of the same journal were modeled by adding the
letter part of the name to the journal volume. For example, a paper published
in Physical Review ... | python | def convert_old_publication_info_to_new(publication_infos):
"""Convert a ``publication_info`` value from the old format to the new.
On Legacy different series of the same journal were modeled by adding the
letter part of the name to the journal volume. For example, a paper published
in Physical Review ... | [
"def",
"convert_old_publication_info_to_new",
"(",
"publication_infos",
")",
":",
"result",
"=",
"[",
"]",
"hidden_publication_infos",
"=",
"[",
"]",
"for",
"publication_info",
"in",
"publication_infos",
":",
"_publication_info",
"=",
"copy",
".",
"deepcopy",
"(",
"... | Convert a ``publication_info`` value from the old format to the new.
On Legacy different series of the same journal were modeled by adding the
letter part of the name to the journal volume. For example, a paper published
in Physical Review D contained::
{
'publication_info': [
... | [
"Convert",
"a",
"publication_info",
"value",
"from",
"the",
"old",
"format",
"to",
"the",
"new",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L779-L872 | train | Convert a publication_info value from the old format to the new format. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | convert_new_publication_info_to_old | def convert_new_publication_info_to_old(publication_infos):
"""Convert back a ``publication_info`` value from the new format to the old.
Does the inverse transformation of :func:`convert_old_publication_info_to_new`,
to be used whenever we are sending back records from Labs to Legacy.
Args:
pu... | python | def convert_new_publication_info_to_old(publication_infos):
"""Convert back a ``publication_info`` value from the new format to the old.
Does the inverse transformation of :func:`convert_old_publication_info_to_new`,
to be used whenever we are sending back records from Labs to Legacy.
Args:
pu... | [
"def",
"convert_new_publication_info_to_old",
"(",
"publication_infos",
")",
":",
"def",
"_needs_a_hidden_pubnote",
"(",
"journal_title",
",",
"journal_volume",
")",
":",
"return",
"(",
"journal_title",
"in",
"_JOURNALS_THAT_NEED_A_HIDDEN_PUBNOTE",
"and",
"journal_volume",
... | Convert back a ``publication_info`` value from the new format to the old.
Does the inverse transformation of :func:`convert_old_publication_info_to_new`,
to be used whenever we are sending back records from Labs to Legacy.
Args:
publication_infos: a ``publication_info`` in the new format.
Ret... | [
"Convert",
"back",
"a",
"publication_info",
"value",
"from",
"the",
"new",
"format",
"to",
"the",
"old",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L875-L934 | train | Convert a list of publication_info values from the new format to the old format. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | fix_reference_url | def fix_reference_url(url):
"""Used to parse an incorect url to try to fix it with the most common ocurrences for errors.
If the fixed url is still incorrect, it returns ``None``.
Returns:
String containing the fixed url or the original one if it could not be fixed.
"""
new_url = url
n... | python | def fix_reference_url(url):
"""Used to parse an incorect url to try to fix it with the most common ocurrences for errors.
If the fixed url is still incorrect, it returns ``None``.
Returns:
String containing the fixed url or the original one if it could not be fixed.
"""
new_url = url
n... | [
"def",
"fix_reference_url",
"(",
"url",
")",
":",
"new_url",
"=",
"url",
"new_url",
"=",
"fix_url_bars_instead_of_slashes",
"(",
"new_url",
")",
"new_url",
"=",
"fix_url_add_http_if_missing",
"(",
"new_url",
")",
"new_url",
"=",
"fix_url_replace_tilde",
"(",
"new_ur... | Used to parse an incorect url to try to fix it with the most common ocurrences for errors.
If the fixed url is still incorrect, it returns ``None``.
Returns:
String containing the fixed url or the original one if it could not be fixed. | [
"Used",
"to",
"parse",
"an",
"incorect",
"url",
"to",
"try",
"to",
"fix",
"it",
"with",
"the",
"most",
"common",
"ocurrences",
"for",
"errors",
".",
"If",
"the",
"fixed",
"url",
"is",
"still",
"incorrect",
"it",
"returns",
"None",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L957-L976 | train | Try to fix a reference url. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | is_arxiv | def is_arxiv(obj):
"""Return ``True`` if ``obj`` contains an arXiv identifier.
The ``idutils`` library's ``is_arxiv`` function has been
modified here to work with two regular expressions instead
of three and adding a check for valid arxiv categories only"""
arxiv_test = obj.split()
if not arxiv... | python | def is_arxiv(obj):
"""Return ``True`` if ``obj`` contains an arXiv identifier.
The ``idutils`` library's ``is_arxiv`` function has been
modified here to work with two regular expressions instead
of three and adding a check for valid arxiv categories only"""
arxiv_test = obj.split()
if not arxiv... | [
"def",
"is_arxiv",
"(",
"obj",
")",
":",
"arxiv_test",
"=",
"obj",
".",
"split",
"(",
")",
"if",
"not",
"arxiv_test",
":",
"return",
"False",
"matched_arxiv",
"=",
"(",
"RE_ARXIV_PRE_2007_CLASS",
".",
"match",
"(",
"arxiv_test",
"[",
"0",
"]",
")",
"or",... | Return ``True`` if ``obj`` contains an arXiv identifier.
The ``idutils`` library's ``is_arxiv`` function has been
modified here to work with two regular expressions instead
of three and adding a check for valid arxiv categories only | [
"Return",
"True",
"if",
"obj",
"contains",
"an",
"arXiv",
"identifier",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L987-L1009 | train | Return True if obj contains an arXiv identifier. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | normalize_arxiv | def normalize_arxiv(obj):
"""Return a normalized arXiv identifier from ``obj``."""
obj = obj.split()[0]
matched_arxiv_pre = RE_ARXIV_PRE_2007_CLASS.match(obj)
if matched_arxiv_pre:
return ('/'.join(matched_arxiv_pre.group("extraidentifier", "identifier"))).lower()
matched_arxiv_post = RE_A... | python | def normalize_arxiv(obj):
"""Return a normalized arXiv identifier from ``obj``."""
obj = obj.split()[0]
matched_arxiv_pre = RE_ARXIV_PRE_2007_CLASS.match(obj)
if matched_arxiv_pre:
return ('/'.join(matched_arxiv_pre.group("extraidentifier", "identifier"))).lower()
matched_arxiv_post = RE_A... | [
"def",
"normalize_arxiv",
"(",
"obj",
")",
":",
"obj",
"=",
"obj",
".",
"split",
"(",
")",
"[",
"0",
"]",
"matched_arxiv_pre",
"=",
"RE_ARXIV_PRE_2007_CLASS",
".",
"match",
"(",
"obj",
")",
"if",
"matched_arxiv_pre",
":",
"return",
"(",
"'/'",
".",
"join... | Return a normalized arXiv identifier from ``obj``. | [
"Return",
"a",
"normalized",
"arXiv",
"identifier",
"from",
"obj",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L1012-L1024 | train | Return a normalized arXiv identifier from obj. |
inspirehep/inspire-schemas | inspire_schemas/utils.py | LocalRefResolver.resolve_remote | def resolve_remote(self, uri):
"""Resolve a uri or relative path to a schema."""
try:
return super(LocalRefResolver, self).resolve_remote(uri)
except ValueError:
return super(LocalRefResolver, self).resolve_remote(
'file://' + get_schema_path(uri.rsplit('.... | python | def resolve_remote(self, uri):
"""Resolve a uri or relative path to a schema."""
try:
return super(LocalRefResolver, self).resolve_remote(uri)
except ValueError:
return super(LocalRefResolver, self).resolve_remote(
'file://' + get_schema_path(uri.rsplit('.... | [
"def",
"resolve_remote",
"(",
"self",
",",
"uri",
")",
":",
"try",
":",
"return",
"super",
"(",
"LocalRefResolver",
",",
"self",
")",
".",
"resolve_remote",
"(",
"uri",
")",
"except",
"ValueError",
":",
"return",
"super",
"(",
"LocalRefResolver",
",",
"sel... | Resolve a uri or relative path to a schema. | [
"Resolve",
"a",
"uri",
"or",
"relative",
"path",
"to",
"a",
"schema",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/utils.py#L535-L542 | train | Resolve a uri or relative path to a schema. |
pylp/pylp | pylp/lib/file.py | File.set_path | def set_path(self, path):
"""Set the path of the file."""
if os.path.isabs(path):
path = os.path.normpath(os.path.join(self.cwd, path))
self.path = path
self.relative = os.path.relpath(self.path, self.base) | python | def set_path(self, path):
"""Set the path of the file."""
if os.path.isabs(path):
path = os.path.normpath(os.path.join(self.cwd, path))
self.path = path
self.relative = os.path.relpath(self.path, self.base) | [
"def",
"set_path",
"(",
"self",
",",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"path",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"cwd",
",",
"path",
"... | Set the path of the file. | [
"Set",
"the",
"path",
"of",
"the",
"file",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/file.py#L44-L50 | train | Set the path of the file. |
pylp/pylp | pylp/lib/file.py | File.clone | def clone(self, path = None, *, with_contents = True, **options):
"""Clone the file."""
file = File(path if path else self.path, cwd=options.get("cwd", self.cwd))
file.base = options.get("base", self.base)
if with_contents:
file.contents = options.get("contents", self.contents)
return file | python | def clone(self, path = None, *, with_contents = True, **options):
"""Clone the file."""
file = File(path if path else self.path, cwd=options.get("cwd", self.cwd))
file.base = options.get("base", self.base)
if with_contents:
file.contents = options.get("contents", self.contents)
return file | [
"def",
"clone",
"(",
"self",
",",
"path",
"=",
"None",
",",
"*",
",",
"with_contents",
"=",
"True",
",",
"*",
"*",
"options",
")",
":",
"file",
"=",
"File",
"(",
"path",
"if",
"path",
"else",
"self",
".",
"path",
",",
"cwd",
"=",
"options",
".",
... | Clone the file. | [
"Clone",
"the",
"file",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/file.py#L53-L61 | train | Clone the file. |
pylp/pylp | pylp/lib/file.py | FileReader.transform | async def transform(self, file):
"""Function called when a file need to be transformed."""
file.contents = await self.loop.run_in_executor(self.exe, read_file, file.path)
return file | python | async def transform(self, file):
"""Function called when a file need to be transformed."""
file.contents = await self.loop.run_in_executor(self.exe, read_file, file.path)
return file | [
"async",
"def",
"transform",
"(",
"self",
",",
"file",
")",
":",
"file",
".",
"contents",
"=",
"await",
"self",
".",
"loop",
".",
"run_in_executor",
"(",
"self",
".",
"exe",
",",
"read_file",
",",
"file",
".",
"path",
")",
"return",
"file"
] | Function called when a file need to be transformed. | [
"Function",
"called",
"when",
"a",
"file",
"need",
"to",
"be",
"transformed",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/file.py#L75-L78 | train | Function called when a file need to be transformed. |
pylp/pylp | pylp/cli/cli.py | launch_cli | def launch_cli():
"""Launch the CLI."""
# Create the CLI argument parser
parser = argparse.ArgumentParser(
prog="pylp",
description="Call some tasks defined in your pylpfile."
)
# Version of Pylp
parser.add_argument("-v", "--version",
action="version",
version="Pylp %s" % version,
help="get the Pylp ... | python | def launch_cli():
"""Launch the CLI."""
# Create the CLI argument parser
parser = argparse.ArgumentParser(
prog="pylp",
description="Call some tasks defined in your pylpfile."
)
# Version of Pylp
parser.add_argument("-v", "--version",
action="version",
version="Pylp %s" % version,
help="get the Pylp ... | [
"def",
"launch_cli",
"(",
")",
":",
"# Create the CLI argument parser",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"\"pylp\"",
",",
"description",
"=",
"\"Call some tasks defined in your pylpfile.\"",
")",
"# Version of Pylp",
"parser",
".",
"ad... | Launch the CLI. | [
"Launch",
"the",
"CLI",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/cli.py#L29-L110 | train | Launch the CLI. |
guaix-ucm/numina | numina/array/display/ximshow.py | ximshow | def ximshow(image2d, title=None, show=True,
cbar_label=None, cbar_orientation=None,
z1z2=None, cmap="hot",
image_bbox=None, first_pixel=(1,1),
crpix1=None, crval1=None, cdelt1=None,
ds9regfile=None,
geometry=(0, 0, 640, 480), tight_layout=True,
... | python | def ximshow(image2d, title=None, show=True,
cbar_label=None, cbar_orientation=None,
z1z2=None, cmap="hot",
image_bbox=None, first_pixel=(1,1),
crpix1=None, crval1=None, cdelt1=None,
ds9regfile=None,
geometry=(0, 0, 640, 480), tight_layout=True,
... | [
"def",
"ximshow",
"(",
"image2d",
",",
"title",
"=",
"None",
",",
"show",
"=",
"True",
",",
"cbar_label",
"=",
"None",
",",
"cbar_orientation",
"=",
"None",
",",
"z1z2",
"=",
"None",
",",
"cmap",
"=",
"\"hot\"",
",",
"image_bbox",
"=",
"None",
",",
"... | Auxiliary function to display a numpy 2d array.
Parameters
----------
image2d : 2d numpy array, float
2d image to be displayed.
title : string
Plot title.
cbar_label : string
Color bar label.
cbar_orientation : string
Color bar orientation: valid options are 'hor... | [
"Auxiliary",
"function",
"to",
"display",
"a",
"numpy",
"2d",
"array",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/ximshow.py#L36-L369 | train | Auxiliary function to display a numpy 2d array. |
guaix-ucm/numina | numina/array/display/ximshow.py | ximshow_file | def ximshow_file(singlefile,
args_cbar_label=None, args_cbar_orientation=None,
args_z1z2=None, args_bbox=None, args_firstpix=None,
args_keystitle=None, args_ds9reg=None,
args_geometry="0,0,640,480", pdf=None, show=True,
debugplot=None,... | python | def ximshow_file(singlefile,
args_cbar_label=None, args_cbar_orientation=None,
args_z1z2=None, args_bbox=None, args_firstpix=None,
args_keystitle=None, args_ds9reg=None,
args_geometry="0,0,640,480", pdf=None, show=True,
debugplot=None,... | [
"def",
"ximshow_file",
"(",
"singlefile",
",",
"args_cbar_label",
"=",
"None",
",",
"args_cbar_orientation",
"=",
"None",
",",
"args_z1z2",
"=",
"None",
",",
"args_bbox",
"=",
"None",
",",
"args_firstpix",
"=",
"None",
",",
"args_keystitle",
"=",
"None",
",",
... | Function to execute ximshow() as called from command line.
Parameters
----------
singlefile : string
Name of the FITS file to be displayed.
args_cbar_label : string
Color bar label.
args_cbar_orientation : string
Color bar orientation: valid options are 'horizontal' or
... | [
"Function",
"to",
"execute",
"ximshow",
"()",
"as",
"called",
"from",
"command",
"line",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/ximshow.py#L372-L552 | train | Function to execute ximshow function for a single file. |
inspirehep/inspire-schemas | inspire_schemas/builders/signatures.py | SignatureBuilder.add_affiliation | def add_affiliation(self, value, curated_relation=None, record=None):
"""Add an affiliation.
Args:
value (string): affiliation value
curated_relation (bool): is relation curated
record (dict): affiliation JSON reference
"""
if value:
affil... | python | def add_affiliation(self, value, curated_relation=None, record=None):
"""Add an affiliation.
Args:
value (string): affiliation value
curated_relation (bool): is relation curated
record (dict): affiliation JSON reference
"""
if value:
affil... | [
"def",
"add_affiliation",
"(",
"self",
",",
"value",
",",
"curated_relation",
"=",
"None",
",",
"record",
"=",
"None",
")",
":",
"if",
"value",
":",
"affiliation",
"=",
"{",
"'value'",
":",
"value",
"}",
"if",
"record",
":",
"affiliation",
"[",
"'record'... | Add an affiliation.
Args:
value (string): affiliation value
curated_relation (bool): is relation curated
record (dict): affiliation JSON reference | [
"Add",
"an",
"affiliation",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/signatures.py#L69-L85 | train | Adds an affiliation to the list of affiliations. |
inspirehep/inspire-schemas | inspire_schemas/builders/signatures.py | SignatureBuilder.set_uid | def set_uid(self, uid, schema=None):
"""Set a unique ID.
If a UID of a given schema already exists in a record it will
be overwritten, otherwise it will be appended to the record.
Args:
uid (string): unique identifier.
schema (Optional[string]): schema of the un... | python | def set_uid(self, uid, schema=None):
"""Set a unique ID.
If a UID of a given schema already exists in a record it will
be overwritten, otherwise it will be appended to the record.
Args:
uid (string): unique identifier.
schema (Optional[string]): schema of the un... | [
"def",
"set_uid",
"(",
"self",
",",
"uid",
",",
"schema",
"=",
"None",
")",
":",
"try",
":",
"uid",
",",
"schema",
"=",
"author_id_normalize_and_schema",
"(",
"uid",
",",
"schema",
")",
"except",
"UnknownUIDSchema",
":",
"# Explicit schema wasn't provided, and t... | Set a unique ID.
If a UID of a given schema already exists in a record it will
be overwritten, otherwise it will be appended to the record.
Args:
uid (string): unique identifier.
schema (Optional[string]): schema of the unique identifier. If
``None``, th... | [
"Set",
"a",
"unique",
"ID",
"."
] | 34bc124b62fba565b6b40d1a3c15103a23a05edb | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/signatures.py#L111-L136 | train | Set a unique ID. |
druids/django-chamber | chamber/utils/decorators.py | singleton | def singleton(klass):
"""
Create singleton from class
"""
instances = {}
def getinstance(*args, **kwargs):
if klass not in instances:
instances[klass] = klass(*args, **kwargs)
return instances[klass]
return wraps(klass)(getinstance) | python | def singleton(klass):
"""
Create singleton from class
"""
instances = {}
def getinstance(*args, **kwargs):
if klass not in instances:
instances[klass] = klass(*args, **kwargs)
return instances[klass]
return wraps(klass)(getinstance) | [
"def",
"singleton",
"(",
"klass",
")",
":",
"instances",
"=",
"{",
"}",
"def",
"getinstance",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"klass",
"not",
"in",
"instances",
":",
"instances",
"[",
"klass",
"]",
"=",
"klass",
"(",
"*",... | Create singleton from class | [
"Create",
"singleton",
"from",
"class"
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/utils/decorators.py#L13-L23 | train | Create singleton from class
|
druids/django-chamber | chamber/utils/decorators.py | translation_activate_block | def translation_activate_block(function=None, language=None):
"""
Activate language only for one method or function
"""
def _translation_activate_block(function):
def _decorator(*args, **kwargs):
tmp_language = translation.get_language()
try:
translation.... | python | def translation_activate_block(function=None, language=None):
"""
Activate language only for one method or function
"""
def _translation_activate_block(function):
def _decorator(*args, **kwargs):
tmp_language = translation.get_language()
try:
translation.... | [
"def",
"translation_activate_block",
"(",
"function",
"=",
"None",
",",
"language",
"=",
"None",
")",
":",
"def",
"_translation_activate_block",
"(",
"function",
")",
":",
"def",
"_decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"tmp_languag... | Activate language only for one method or function | [
"Activate",
"language",
"only",
"for",
"one",
"method",
"or",
"function"
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/utils/decorators.py#L26-L44 | train | Decorator that activates language only for one method or function |
bachya/pyopenuv | pyopenuv/client.py | Client.request | async def request(
self,
method: str,
endpoint: str,
*,
headers: dict = None,
params: dict = None) -> dict:
"""Make a request against air-matters.com."""
url = '{0}/{1}'.format(API_URL_SCAFFOLD, endpoint)
if not headers:
... | python | async def request(
self,
method: str,
endpoint: str,
*,
headers: dict = None,
params: dict = None) -> dict:
"""Make a request against air-matters.com."""
url = '{0}/{1}'.format(API_URL_SCAFFOLD, endpoint)
if not headers:
... | [
"async",
"def",
"request",
"(",
"self",
",",
"method",
":",
"str",
",",
"endpoint",
":",
"str",
",",
"*",
",",
"headers",
":",
"dict",
"=",
"None",
",",
"params",
":",
"dict",
"=",
"None",
")",
"->",
"dict",
":",
"url",
"=",
"'{0}/{1}'",
".",
"fo... | Make a request against air-matters.com. | [
"Make",
"a",
"request",
"against",
"air",
"-",
"matters",
".",
"com",
"."
] | f7c2f9dd99dd4e3b8b1f9e501ea17ce62a7ace46 | https://github.com/bachya/pyopenuv/blob/f7c2f9dd99dd4e3b8b1f9e501ea17ce62a7ace46/pyopenuv/client.py#L27-L59 | train | Make a request against air - matters. com. |
bachya/pyopenuv | pyopenuv/client.py | Client.uv_protection_window | async def uv_protection_window(
self, low: float = 3.5, high: float = 3.5) -> dict:
"""Get data on when a UV protection window is."""
return await self.request(
'get', 'protection', params={
'from': str(low),
'to': str(high)
}) | python | async def uv_protection_window(
self, low: float = 3.5, high: float = 3.5) -> dict:
"""Get data on when a UV protection window is."""
return await self.request(
'get', 'protection', params={
'from': str(low),
'to': str(high)
}) | [
"async",
"def",
"uv_protection_window",
"(",
"self",
",",
"low",
":",
"float",
"=",
"3.5",
",",
"high",
":",
"float",
"=",
"3.5",
")",
"->",
"dict",
":",
"return",
"await",
"self",
".",
"request",
"(",
"'get'",
",",
"'protection'",
",",
"params",
"=",
... | Get data on when a UV protection window is. | [
"Get",
"data",
"on",
"when",
"a",
"UV",
"protection",
"window",
"is",
"."
] | f7c2f9dd99dd4e3b8b1f9e501ea17ce62a7ace46 | https://github.com/bachya/pyopenuv/blob/f7c2f9dd99dd4e3b8b1f9e501ea17ce62a7ace46/pyopenuv/client.py#L69-L76 | train | Get data on when a UV protection window is is. |
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 | Return the run number and the file name. |
guaix-ucm/numina | numina/dal/dictdal.py | BaseDictDAL.search_prod_obsid | def search_prod_obsid(self, ins, obsid, pipeline):
"""Returns the first coincidence..."""
ins_prod = self.prod_table[ins]
# search results of these OBs
for prod in ins_prod:
if prod['ob'] == obsid:
# We have found the result, no more checks
re... | python | def search_prod_obsid(self, ins, obsid, pipeline):
"""Returns the first coincidence..."""
ins_prod = self.prod_table[ins]
# search results of these OBs
for prod in ins_prod:
if prod['ob'] == obsid:
# We have found the result, no more checks
re... | [
"def",
"search_prod_obsid",
"(",
"self",
",",
"ins",
",",
"obsid",
",",
"pipeline",
")",
":",
"ins_prod",
"=",
"self",
".",
"prod_table",
"[",
"ins",
"]",
"# search results of these OBs",
"for",
"prod",
"in",
"ins_prod",
":",
"if",
"prod",
"[",
"'ob'",
"]"... | Returns the first coincidence... | [
"Returns",
"the",
"first",
"coincidence",
"..."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/dal/dictdal.py#L58-L68 | train | Search the product table for the given product ID and pipeline. |
guaix-ucm/numina | numina/dal/dictdal.py | BaseDictDAL.search_prod_type_tags | def search_prod_type_tags(self, tipo, ins, tags, pipeline):
"""Returns the first coincidence..."""
drp = self.drps.query_by_name(ins)
label = drp.product_label(tipo)
# Strip () is present
if label.endswith("()"):
label_alt = label[:-2]
else:
labe... | python | def search_prod_type_tags(self, tipo, ins, tags, pipeline):
"""Returns the first coincidence..."""
drp = self.drps.query_by_name(ins)
label = drp.product_label(tipo)
# Strip () is present
if label.endswith("()"):
label_alt = label[:-2]
else:
labe... | [
"def",
"search_prod_type_tags",
"(",
"self",
",",
"tipo",
",",
"ins",
",",
"tags",
",",
"pipeline",
")",
":",
"drp",
"=",
"self",
".",
"drps",
".",
"query_by_name",
"(",
"ins",
")",
"label",
"=",
"drp",
".",
"product_label",
"(",
"tipo",
")",
"# Strip ... | Returns the first coincidence... | [
"Returns",
"the",
"first",
"coincidence",
"..."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/dal/dictdal.py#L78-L103 | train | Search for a product with the given type and tags. |
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 | Return an observation resource object for the given ID. |
guaix-ucm/numina | numina/dal/dictdal.py | HybridDAL._search_prod_table | def _search_prod_table(self, name, tipo, obsres):
"""Returns the first coincidence..."""
instrument = obsres.instrument
conf = obsres.configuration.uuid
drp = self.drps.query_by_name(instrument)
label = drp.product_label(tipo)
# Strip () is present
if label.end... | python | def _search_prod_table(self, name, tipo, obsres):
"""Returns the first coincidence..."""
instrument = obsres.instrument
conf = obsres.configuration.uuid
drp = self.drps.query_by_name(instrument)
label = drp.product_label(tipo)
# Strip () is present
if label.end... | [
"def",
"_search_prod_table",
"(",
"self",
",",
"name",
",",
"tipo",
",",
"obsres",
")",
":",
"instrument",
"=",
"obsres",
".",
"instrument",
"conf",
"=",
"obsres",
".",
"configuration",
".",
"uuid",
"drp",
"=",
"self",
".",
"drps",
".",
"query_by_name",
... | Returns the first coincidence... | [
"Returns",
"the",
"first",
"coincidence",
"..."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/dal/dictdal.py#L394-L433 | train | Search the product table for a given product name and tipo. |
guaix-ucm/numina | numina/dal/dictdal.py | HybridDAL._search_result | def _search_result(self, name, tipo, obsres, resultid):
"""Returns the first coincidence..."""
instrument = obsres.instrument
conf = obsres.configuration.uuid
drp = self.drps.query_by_name(instrument)
label = drp.product_label(tipo)
# search results of these OBs
... | python | def _search_result(self, name, tipo, obsres, resultid):
"""Returns the first coincidence..."""
instrument = obsres.instrument
conf = obsres.configuration.uuid
drp = self.drps.query_by_name(instrument)
label = drp.product_label(tipo)
# search results of these OBs
... | [
"def",
"_search_result",
"(",
"self",
",",
"name",
",",
"tipo",
",",
"obsres",
",",
"resultid",
")",
":",
"instrument",
"=",
"obsres",
".",
"instrument",
"conf",
"=",
"obsres",
".",
"configuration",
".",
"uuid",
"drp",
"=",
"self",
".",
"drps",
".",
"q... | Returns the first coincidence... | [
"Returns",
"the",
"first",
"coincidence",
"..."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/dal/dictdal.py#L565-L594 | train | Search the result table for a given resultid. |
zzyztyy/pyIGRF | pyIGRF/loadCoeffs.py | loadCoeffs | def loadCoeffs(filename):
"""
load igrf12 coeffs from file
:param filename: file which save coeffs (str)
:return: g and h list one by one (list(float))
"""
gh = []
gh2arr = []
with open(filename) as f:
text = f.readlines()
for a in text:
if a[:2] == 'g ' or a[... | python | def loadCoeffs(filename):
"""
load igrf12 coeffs from file
:param filename: file which save coeffs (str)
:return: g and h list one by one (list(float))
"""
gh = []
gh2arr = []
with open(filename) as f:
text = f.readlines()
for a in text:
if a[:2] == 'g ' or a[... | [
"def",
"loadCoeffs",
"(",
"filename",
")",
":",
"gh",
"=",
"[",
"]",
"gh2arr",
"=",
"[",
"]",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"text",
"=",
"f",
".",
"readlines",
"(",
")",
"for",
"a",
"in",
"text",
":",
"if",
"a",
"[",
"... | load igrf12 coeffs from file
:param filename: file which save coeffs (str)
:return: g and h list one by one (list(float)) | [
"load",
"igrf12",
"coeffs",
"from",
"file",
":",
"param",
"filename",
":",
"file",
"which",
"save",
"coeffs",
"(",
"str",
")",
":",
"return",
":",
"g",
"and",
"h",
"list",
"one",
"by",
"one",
"(",
"list",
"(",
"float",
"))"
] | 3369ccafec34d18ca2c57f48b867cb2417078866 | https://github.com/zzyztyy/pyIGRF/blob/3369ccafec34d18ca2c57f48b867cb2417078866/pyIGRF/loadCoeffs.py#L8-L33 | train | load igrf12 coeffs from file |
zzyztyy/pyIGRF | pyIGRF/loadCoeffs.py | getCoeffs | def getCoeffs(date):
"""
:param gh: list from loadCoeffs
:param date: float
:return: list: g, list: h
"""
if date < 1900.0 or date > 2025.0:
print('This subroutine will not work with a date of ' + str(date))
print('Date must be in the range 1900.0 <= date <= 2025.0')
prin... | python | def getCoeffs(date):
"""
:param gh: list from loadCoeffs
:param date: float
:return: list: g, list: h
"""
if date < 1900.0 or date > 2025.0:
print('This subroutine will not work with a date of ' + str(date))
print('Date must be in the range 1900.0 <= date <= 2025.0')
prin... | [
"def",
"getCoeffs",
"(",
"date",
")",
":",
"if",
"date",
"<",
"1900.0",
"or",
"date",
">",
"2025.0",
":",
"print",
"(",
"'This subroutine will not work with a date of '",
"+",
"str",
"(",
"date",
")",
")",
"print",
"(",
"'Date must be in the range 1900.0 <= date <... | :param gh: list from loadCoeffs
:param date: float
:return: list: g, list: h | [
":",
"param",
"gh",
":",
"list",
"from",
"loadCoeffs",
":",
"param",
"date",
":",
"float",
":",
"return",
":",
"list",
":",
"g",
"list",
":",
"h"
] | 3369ccafec34d18ca2c57f48b867cb2417078866 | https://github.com/zzyztyy/pyIGRF/blob/3369ccafec34d18ca2c57f48b867cb2417078866/pyIGRF/loadCoeffs.py#L39-L96 | train | get the G and H terms for a given date |
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 | Apply function to nodes |
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",
":",
"# this works in python > 3.3",
"# yield from filter_tree(condition, node)",
"for",
"n",
"in",
"filter_tree",
... | 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 | Return parts of the tree that fulfill condition |
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 | Substitute Placeholder nodes by its value in tags |
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 | Take a list of molecules and return just a list of atomic
symbols possibly adding hydrogen
|
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 | Take a list of symbols and construct gas phase
references system |
SUNCAT-Center/CatHub | cathub/ase_tools/gas_phase_references.py | get_atomic_stoichiometry | def get_atomic_stoichiometry(references):
"""Given a list of references (tuples of (symbol, molecule))
return stoichiometry matrix that connects atomic symbols
to its molecular references.
"""
n = len(references)
stoichiometry = np.ndarray((n, n), float)
stoichiometry[:] = 0.
key_index =... | python | def get_atomic_stoichiometry(references):
"""Given a list of references (tuples of (symbol, molecule))
return stoichiometry matrix that connects atomic symbols
to its molecular references.
"""
n = len(references)
stoichiometry = np.ndarray((n, n), float)
stoichiometry[:] = 0.
key_index =... | [
"def",
"get_atomic_stoichiometry",
"(",
"references",
")",
":",
"n",
"=",
"len",
"(",
"references",
")",
"stoichiometry",
"=",
"np",
".",
"ndarray",
"(",
"(",
"n",
",",
"n",
")",
",",
"float",
")",
"stoichiometry",
"[",
":",
"]",
"=",
"0.",
"key_index"... | Given a list of references (tuples of (symbol, molecule))
return stoichiometry matrix that connects atomic symbols
to its molecular references. | [
"Given",
"a",
"list",
"of",
"references",
"(",
"tuples",
"of",
"(",
"symbol",
"molecule",
"))",
"return",
"stoichiometry",
"matrix",
"that",
"connects",
"atomic",
"symbols",
"to",
"its",
"molecular",
"references",
"."
] | 324625d1d8e740673f139658b2de4c9e1059739e | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/ase_tools/gas_phase_references.py#L109-L129 | train | Given a list of references returns a matrix that connects atomic symbols
to its molecular references. |
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 | Take a list of adsorabtes and a corresponding reference
system and return a list of dictionaries encoding the adsorbates and references to the corresponding reference
system and return a list of dictionaries encoding the adsorbates and references to the corresponding reference
system. |
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 | Returns a dict of field name and cleaned value pairs to initialize the model. |
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",
":",
"# StructDataValue",
"obj",
"=",
"{",
"}"... | 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 | Process a node in result. json structure |
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 | Create a dictionary with the contents of result. json |
guaix-ucm/numina | numina/drps/drpsystem.py | DrpSystem.load | def load(self):
"""Load all available DRPs in 'entry_point'."""
for drpins in self.iload(self.entry):
self.drps[drpins.name] = drpins
return self | python | def load(self):
"""Load all available DRPs in 'entry_point'."""
for drpins in self.iload(self.entry):
self.drps[drpins.name] = drpins
return self | [
"def",
"load",
"(",
"self",
")",
":",
"for",
"drpins",
"in",
"self",
".",
"iload",
"(",
"self",
".",
"entry",
")",
":",
"self",
".",
"drps",
"[",
"drpins",
".",
"name",
"]",
"=",
"drpins",
"return",
"self"
] | Load all available DRPs in 'entry_point'. | [
"Load",
"all",
"available",
"DRPs",
"in",
"entry_point",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/drps/drpsystem.py#L27-L33 | train | Load all available DRPs in entry_point. |
guaix-ucm/numina | numina/drps/drpsystem.py | DrpSystem.load_drp | def load_drp(self, name, entry_point='numina.pipeline.1'):
"""Load all available DRPs in 'entry_point'."""
for drpins in self.iload(entry_point):
if drpins.name == name:
return drpins
else:
raise KeyError('{}'.format(name)) | python | def load_drp(self, name, entry_point='numina.pipeline.1'):
"""Load all available DRPs in 'entry_point'."""
for drpins in self.iload(entry_point):
if drpins.name == name:
return drpins
else:
raise KeyError('{}'.format(name)) | [
"def",
"load_drp",
"(",
"self",
",",
"name",
",",
"entry_point",
"=",
"'numina.pipeline.1'",
")",
":",
"for",
"drpins",
"in",
"self",
".",
"iload",
"(",
"entry_point",
")",
":",
"if",
"drpins",
".",
"name",
"==",
"name",
":",
"return",
"drpins",
"else",
... | Load all available DRPs in 'entry_point'. | [
"Load",
"all",
"available",
"DRPs",
"in",
"entry_point",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/drps/drpsystem.py#L36-L43 | train | Load all available DRPs in entry_point. |
guaix-ucm/numina | numina/drps/drpsystem.py | DrpSystem.iload | def iload(cls, entry_point='numina.pipeline.1'):
"""Load all available DRPs in 'entry_point'."""
for entry in pkg_resources.iter_entry_points(group=entry_point):
try:
drp_loader = entry.load()
drpins = drp_loader()
if cls.instrumentdrp_check(d... | python | def iload(cls, entry_point='numina.pipeline.1'):
"""Load all available DRPs in 'entry_point'."""
for entry in pkg_resources.iter_entry_points(group=entry_point):
try:
drp_loader = entry.load()
drpins = drp_loader()
if cls.instrumentdrp_check(d... | [
"def",
"iload",
"(",
"cls",
",",
"entry_point",
"=",
"'numina.pipeline.1'",
")",
":",
"for",
"entry",
"in",
"pkg_resources",
".",
"iter_entry_points",
"(",
"group",
"=",
"entry_point",
")",
":",
"try",
":",
"drp_loader",
"=",
"entry",
".",
"load",
"(",
")"... | Load all available DRPs in 'entry_point'. | [
"Load",
"all",
"available",
"DRPs",
"in",
"entry_point",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/drps/drpsystem.py#L46-L57 | train | Load all available DRPs in entry_point. |
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 | Access all the instance descriptors and raise an exception if a required ArcGIS message is not set |
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",
")",
"# Run checks de... | Validate myself. | [
"Validate",
"myself",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/recipeinout.py#L70-L78 | train | Validate myself. |
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",
")",
... | 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 | Decorate run method inputs and outputs are validated |
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 | Convert a scalar validator in a list validator |
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 | Generates a function that validates that a number is within a given range. |
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",
")",
":",
"# Test if the pylpfile exists",
"readable_path",
"=",
"make_readable_path",
"(",
"path",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"logger",
".",
"log",
"(",
"logger",
"... | Run a pylpfile. | [
"Run",
"a",
"pylpfile",
"."
] | 7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4 | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/run.py#L18-L45 | train | Run a pylpfile. |
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 | Wait until all task are executed. |
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 | Return True if a record is published. |
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 | Return the page range or article id of a publication_info entry. |
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 | Return the page range or article id of a record. |
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 | Yield integers of dtype bit - length reverting their bit - order. |
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 | Return integer concatenating integer chunks of r > 0 bit - length. |
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 | Yield r > 0 bit - length integers splitting n into chunks. |
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 | Yield integers concatenating bools in chunks of dtype bit - length. |
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 | Yields booleans unpacking integers of dtype bit - length. |
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 | Select information from valid arc lines to facilitate posterior fits. |
guaix-ucm/numina | numina/array/wavecalib/arccalibration.py | fit_list_of_wvfeatures | def fit_list_of_wvfeatures(list_of_wvfeatures,
naxis1_arc,
crpix1,
poly_degree_wfit,
weighted=False,
plot_title=None,
geometry=None,
... | python | def fit_list_of_wvfeatures(list_of_wvfeatures,
naxis1_arc,
crpix1,
poly_degree_wfit,
weighted=False,
plot_title=None,
geometry=None,
... | [
"def",
"fit_list_of_wvfeatures",
"(",
"list_of_wvfeatures",
",",
"naxis1_arc",
",",
"crpix1",
",",
"poly_degree_wfit",
",",
"weighted",
"=",
"False",
",",
"plot_title",
"=",
"None",
",",
"geometry",
"=",
"None",
",",
"debugplot",
"=",
"0",
")",
":",
"nlines_ar... | Fit polynomial to arc calibration list_of_wvfeatures.
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 relevant informati... | [
"Fit",
"polynomial",
"to",
"arc",
"calibration",
"list_of_wvfeatures",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/arccalibration.py#L85-L321 | train | Fit a list of WavecalFeatures to a single arc. |
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",
"# Check that the wavelengths in the master table are sorted",
"wv_previous",
"=",
"wv_master",
"[",
"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.
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 | Generate all possible triplets from the wavelengths in the master table. |
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 | This function is used to calculate the arc line calibration for the arc lines. |
guaix-ucm/numina | numina/array/wavecalib/arccalibration.py | arccalibration_direct | def arccalibration_direct(wv_master,
ntriplets_master,
ratios_master_sorted,
triplets_master_sorted_list,
xpos_arc,
naxis1_arc,
crpix1,
wv... | python | def arccalibration_direct(wv_master,
ntriplets_master,
ratios_master_sorted,
triplets_master_sorted_list,
xpos_arc,
naxis1_arc,
crpix1,
wv... | [
"def",
"arccalibration_direct",
"(",
"wv_master",
",",
"ntriplets_master",
",",
"ratios_master_sorted",
",",
"triplets_master_sorted_list",
",",
"xpos_arc",
",",
"naxis1_arc",
",",
"crpix1",
",",
"wv_ini_search",
",",
"wv_end_search",
",",
"wvmin_useful",
"=",
"None",
... | Performs line identification for arc calibration using line triplets.
This function assumes that a previous call to the function
responsible for the computation of information related to the
triplets derived from the master table has been previously
executed.
Parameters
----------
wv_maste... | [
"Performs",
"line",
"identification",
"for",
"arc",
"calibration",
"using",
"line",
"triplets",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/arccalibration.py#L546-L1516 | train | This function is used to calculate arc calibration using line triplets. |
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",
")",
":",
"# initialize the output array to zero",
"wv_verified_all_peaks",
"=",
"np",
".",
"zeros_like",
"(",
"wv_expected_all_peaks",
")",
"# initialize to True array to indicate th... | 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 | Match two lists with wavelengths. |
guaix-ucm/numina | numina/array/wavecalib/arccalibration.py | refine_arccalibration | def refine_arccalibration(sp, poly_initial, wv_master, poldeg,
nrepeat=3,
ntimes_match_wv=2,
nwinwidth_initial=7,
nwinwidth_refined=5,
times_sigma_reject=5,
interac... | python | def refine_arccalibration(sp, poly_initial, wv_master, poldeg,
nrepeat=3,
ntimes_match_wv=2,
nwinwidth_initial=7,
nwinwidth_refined=5,
times_sigma_reject=5,
interac... | [
"def",
"refine_arccalibration",
"(",
"sp",
",",
"poly_initial",
",",
"wv_master",
",",
"poldeg",
",",
"nrepeat",
"=",
"3",
",",
"ntimes_match_wv",
"=",
"2",
",",
"nwinwidth_initial",
"=",
"7",
",",
"nwinwidth_refined",
"=",
"5",
",",
"times_sigma_reject",
"=",... | Refine wavelength calibration using an initial polynomial.
Parameters
----------
sp : numpy array
1D array of length NAXIS1 containing the input spectrum.
poly_initial : Polynomial instance
Initial wavelength calibration polynomial, providing the
wavelength as a function of pixe... | [
"Refine",
"wavelength",
"calibration",
"using",
"an",
"initial",
"polynomial",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/arccalibration.py#L1603-L2114 | train | Refine arc calibration using an initial polynomial. |
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 | Set the geometry of the window. |
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 | Parse a fixed width line. |
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",
"[",
... | Parse nonlinear curves block. | [
"Parse",
"nonlinear",
"curves",
"block",
"."
] | c72fd389d6c15203c0c00728ac00f101bae6369d | https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/tools.py#L62-L80 | train | Parse nonlinear curves block. |
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 | Parse the soil profile block. |
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",
")",
",",
"(",
... | Parse motin specification block. | [
"Parse",
"motin",
"specification",
"block",
"."
] | c72fd389d6c15203c0c00728ac00f101bae6369d | https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/tools.py#L126-L154 | train | Parse motin specification block. |
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",
".",
"locati... | Parse input location block. | [
"Parse",
"input",
"location",
"block",
"."
] | c72fd389d6c15203c0c00728ac00f101bae6369d | https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/tools.py#L157-L163 | train | Parse input location block. |
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 | Parse a run control block. |
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",
")",
":",
"\"\"\"Compute recursively the numeric intervals\n\n \"\"\"",
"a",
",",
"b",
"=",
"x",
"if",
"b",
"-",
"a",
"<=",
"blk",
":",
"return",
"[",... | 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 | Generate a list of slices for a single block of size size. |
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 | Generate a list of slice tuples to be used by combine. |
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 | Return the part of a 1d array covered by a block. |
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 | Return the maximum shape of an array covered by a block. |
guaix-ucm/numina | numina/array/blocks.py | blk_1d_short | def blk_1d_short(blk, shape):
"""Iterate through the slices that recover a line.
This function is used by :func:`blk_nd_short` as a base 1d case.
The function stops yielding slices when the size of
the remaining slice is lesser than `blk`.
:param blk: the size of the block
:param shape: the s... | python | def blk_1d_short(blk, shape):
"""Iterate through the slices that recover a line.
This function is used by :func:`blk_nd_short` as a base 1d case.
The function stops yielding slices when the size of
the remaining slice is lesser than `blk`.
:param blk: the size of the block
:param shape: the s... | [
"def",
"blk_1d_short",
"(",
"blk",
",",
"shape",
")",
":",
"maxpix",
",",
"_",
"=",
"blk_coverage_1d",
"(",
"blk",
",",
"shape",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"maxpix",
",",
"blk",
")",
":",
"yield",
"slice",
"(",
"i",
",",
"i",
... | Iterate through the slices that recover a line.
This function is used by :func:`blk_nd_short` as a base 1d case.
The function stops yielding slices when the size of
the remaining slice is lesser than `blk`.
:param blk: the size of the block
:param shape: the size of the array
:return: a gener... | [
"Iterate",
"through",
"the",
"slices",
"that",
"recover",
"a",
"line",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/blocks.py#L120-L134 | train | Iterate through the slices that recover a line. |
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 | Iterate trough the blocks that strictly cover an array. |
guaix-ucm/numina | numina/array/blocks.py | blk_1d | def blk_1d(blk, shape):
"""Iterate through the slices that recover a line.
This function is used by :func:`blk_nd` as a base 1d case.
The last slice is returned even if is lesser than blk.
:param blk: the size of the block
:param shape: the size of the array
:return: a generator that yields ... | python | def blk_1d(blk, shape):
"""Iterate through the slices that recover a line.
This function is used by :func:`blk_nd` as a base 1d case.
The last slice is returned even if is lesser than blk.
:param blk: the size of the block
:param shape: the size of the array
:return: a generator that yields ... | [
"def",
"blk_1d",
"(",
"blk",
",",
"shape",
")",
":",
"maxpix",
",",
"rem",
"=",
"blk_coverage_1d",
"(",
"blk",
",",
"shape",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"maxpix",
",",
"blk",
")",
":",
"yield",
"slice",
"(",
"i",
",",
"i",
"+... | Iterate through the slices that recover a line.
This function is used by :func:`blk_nd` as a base 1d case.
The last slice is returned even if is lesser than blk.
:param blk: the size of the block
:param shape: the size of the array
:return: a generator that yields the slices | [
"Iterate",
"through",
"the",
"slices",
"that",
"recover",
"a",
"line",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/blocks.py#L172-L189 | train | Iterate through the slices that recover a line. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.