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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
JensRantil/rewind | rewind/server/eventstores.py | RotatedEventStore.from_config | def from_config(config, **options):
"""Instantiate an `RotatedEventStore` from config.
Parameters:
_config -- the configuration file options read from file(s).
**options -- various options given to the specific event store. Shall
not be used with this event store... | python | def from_config(config, **options):
"""Instantiate an `RotatedEventStore` from config.
Parameters:
_config -- the configuration file options read from file(s).
**options -- various options given to the specific event store. Shall
not be used with this event store... | [
"def",
"from_config",
"(",
"config",
",",
"*",
"*",
"options",
")",
":",
"expected_args",
"=",
"(",
"'prefix'",
",",
"'realclass'",
")",
"for",
"arg",
"in",
"expected_args",
":",
"if",
"arg",
"not",
"in",
"options",
":",
"msg",
"=",
"\"Required option miss... | Instantiate an `RotatedEventStore` from config.
Parameters:
_config -- the configuration file options read from file(s).
**options -- various options given to the specific event store. Shall
not be used with this event store. Warning will be logged
f... | [
"Instantiate",
"an",
"RotatedEventStore",
"from",
"config",
"."
] | 7f645d20186c1db55cfe53a0310c9fd6292f91ea | https://github.com/JensRantil/rewind/blob/7f645d20186c1db55cfe53a0310c9fd6292f91ea/rewind/server/eventstores.py#L711-L740 | train | Instantiate an event store from a configuration file. |
JensRantil/rewind | rewind/server/eventstores.py | RotatedEventStore._construct_filename | def _construct_filename(self, batchno):
"""Construct a filename for a database.
Parameters:
batchno -- batch number for the rotated database.
Returns the constructed path as a string.
"""
return os.path.join(self.dirpath,
"{0}.{1}".format(se... | python | def _construct_filename(self, batchno):
"""Construct a filename for a database.
Parameters:
batchno -- batch number for the rotated database.
Returns the constructed path as a string.
"""
return os.path.join(self.dirpath,
"{0}.{1}".format(se... | [
"def",
"_construct_filename",
"(",
"self",
",",
"batchno",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"dirpath",
",",
"\"{0}.{1}\"",
".",
"format",
"(",
"self",
".",
"prefix",
",",
"batchno",
")",
")"
] | Construct a filename for a database.
Parameters:
batchno -- batch number for the rotated database.
Returns the constructed path as a string. | [
"Construct",
"a",
"filename",
"for",
"a",
"database",
"."
] | 7f645d20186c1db55cfe53a0310c9fd6292f91ea | https://github.com/JensRantil/rewind/blob/7f645d20186c1db55cfe53a0310c9fd6292f91ea/rewind/server/eventstores.py#L773-L783 | train | Construct a filename for a database. |
JensRantil/rewind | rewind/server/eventstores.py | RotatedEventStore.rotate | def rotate(self):
"""Rotate the files to disk.
This is done by calling `store.close()` on each store, bumping the
batchno and reopening the stores using their factories.
"""
self._logger.info('Rotating data files. New batch number will be: %s',
self.ba... | python | def rotate(self):
"""Rotate the files to disk.
This is done by calling `store.close()` on each store, bumping the
batchno and reopening the stores using their factories.
"""
self._logger.info('Rotating data files. New batch number will be: %s',
self.ba... | [
"def",
"rotate",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"'Rotating data files. New batch number will be: %s'",
",",
"self",
".",
"batchno",
"+",
"1",
")",
"self",
".",
"estore",
".",
"close",
"(",
")",
"self",
".",
"estore",
"=",
... | Rotate the files to disk.
This is done by calling `store.close()` on each store, bumping the
batchno and reopening the stores using their factories. | [
"Rotate",
"the",
"files",
"to",
"disk",
"."
] | 7f645d20186c1db55cfe53a0310c9fd6292f91ea | https://github.com/JensRantil/rewind/blob/7f645d20186c1db55cfe53a0310c9fd6292f91ea/rewind/server/eventstores.py#L785-L797 | train | Rotate the files to disk. |
JensRantil/rewind | rewind/server/eventstores.py | RotatedEventStore._find_batch_containing_event | def _find_batch_containing_event(self, uuid):
"""Find the batch number that contains a certain event.
Parameters:
uuid -- the event uuid to search for.
returns -- a batch number, or None if not found.
"""
if self.estore.key_exists(uuid):
# Reusing alread... | python | def _find_batch_containing_event(self, uuid):
"""Find the batch number that contains a certain event.
Parameters:
uuid -- the event uuid to search for.
returns -- a batch number, or None if not found.
"""
if self.estore.key_exists(uuid):
# Reusing alread... | [
"def",
"_find_batch_containing_event",
"(",
"self",
",",
"uuid",
")",
":",
"if",
"self",
".",
"estore",
".",
"key_exists",
"(",
"uuid",
")",
":",
"# Reusing already opened DB if possible",
"return",
"self",
".",
"batchno",
"else",
":",
"for",
"batchno",
"in",
... | Find the batch number that contains a certain event.
Parameters:
uuid -- the event uuid to search for.
returns -- a batch number, or None if not found. | [
"Find",
"the",
"batch",
"number",
"that",
"contains",
"a",
"certain",
"event",
"."
] | 7f645d20186c1db55cfe53a0310c9fd6292f91ea | https://github.com/JensRantil/rewind/blob/7f645d20186c1db55cfe53a0310c9fd6292f91ea/rewind/server/eventstores.py#L803-L823 | train | Find the batch number that contains a certain event. |
JensRantil/rewind | rewind/server/eventstores.py | RotatedEventStore.get_events | def get_events(self, from_=None, to=None):
"""Query a slice of the events.
Events are always returned in the order the were added.
It also queries older event archives until it finds the event UUIDs
necessary.
Parameters:
from_ -- if not None, return only events adde... | python | def get_events(self, from_=None, to=None):
"""Query a slice of the events.
Events are always returned in the order the were added.
It also queries older event archives until it finds the event UUIDs
necessary.
Parameters:
from_ -- if not None, return only events adde... | [
"def",
"get_events",
"(",
"self",
",",
"from_",
"=",
"None",
",",
"to",
"=",
"None",
")",
":",
"if",
"from_",
":",
"frombatchno",
"=",
"self",
".",
"_find_batch_containing_event",
"(",
"from_",
")",
"if",
"frombatchno",
"is",
"None",
":",
"msg",
"=",
"... | Query a slice of the events.
Events are always returned in the order the were added.
It also queries older event archives until it finds the event UUIDs
necessary.
Parameters:
from_ -- if not None, return only events added after the event with
id `from_`. ... | [
"Query",
"a",
"slice",
"of",
"the",
"events",
"."
] | 7f645d20186c1db55cfe53a0310c9fd6292f91ea | https://github.com/JensRantil/rewind/blob/7f645d20186c1db55cfe53a0310c9fd6292f91ea/rewind/server/eventstores.py#L825-L872 | train | Query a slice of the events. |
JensRantil/rewind | rewind/server/eventstores.py | SyncedRotationEventStores.from_config | def from_config(config, **options):
"""Instantiate an `SyncedRotationEventStores` from config.
Parameters:
config -- the configuration file options read from file(s).
**options -- various options given to the specific event store. Shall
not be used with this even... | python | def from_config(config, **options):
"""Instantiate an `SyncedRotationEventStores` from config.
Parameters:
config -- the configuration file options read from file(s).
**options -- various options given to the specific event store. Shall
not be used with this even... | [
"def",
"from_config",
"(",
"config",
",",
"*",
"*",
"options",
")",
":",
"required_args",
"=",
"(",
"'storage-backends'",
",",
")",
"optional_args",
"=",
"{",
"'events_per_batch'",
":",
"25000",
"}",
"rconfig",
".",
"check_config_options",
"(",
"\"SyncedRotation... | Instantiate an `SyncedRotationEventStores` from config.
Parameters:
config -- the configuration file options read from file(s).
**options -- various options given to the specific event store. Shall
not be used with this event store. Warning will be logged
... | [
"Instantiate",
"an",
"SyncedRotationEventStores",
"from",
"config",
"."
] | 7f645d20186c1db55cfe53a0310c9fd6292f91ea | https://github.com/JensRantil/rewind/blob/7f645d20186c1db55cfe53a0310c9fd6292f91ea/rewind/server/eventstores.py#L915-L951 | train | Instantiate an SyncedRotationEventStores from a configuration file. |
JensRantil/rewind | rewind/server/eventstores.py | SyncedRotationEventStores.add_event | def add_event(self, key, event):
"""Add an event and its corresponding key to the store."""
if self.key_exists(key):
# This check might actually also be done further up in the chain
# (read: SQLiteEventStore). Could potentially be removed if it
# requires a lot of pro... | python | def add_event(self, key, event):
"""Add an event and its corresponding key to the store."""
if self.key_exists(key):
# This check might actually also be done further up in the chain
# (read: SQLiteEventStore). Could potentially be removed if it
# requires a lot of pro... | [
"def",
"add_event",
"(",
"self",
",",
"key",
",",
"event",
")",
":",
"if",
"self",
".",
"key_exists",
"(",
"key",
")",
":",
"# This check might actually also be done further up in the chain",
"# (read: SQLiteEventStore). Could potentially be removed if it",
"# requires a lot ... | Add an event and its corresponding key to the store. | [
"Add",
"an",
"event",
"and",
"its",
"corresponding",
"key",
"to",
"the",
"store",
"."
] | 7f645d20186c1db55cfe53a0310c9fd6292f91ea | https://github.com/JensRantil/rewind/blob/7f645d20186c1db55cfe53a0310c9fd6292f91ea/rewind/server/eventstores.py#L981-L997 | train | Add an event and its corresponding key to the store. |
tehmaze/natural | natural/data.py | _termsize | def _termsize():
'''
Get the current terminal size, returns a ``(height, width)`` tuple.
'''
try:
return struct.unpack(
'hh',
fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, '1234')
)
except:
return (
int(os.environ.get('LINES', 25)),... | python | def _termsize():
'''
Get the current terminal size, returns a ``(height, width)`` tuple.
'''
try:
return struct.unpack(
'hh',
fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, '1234')
)
except:
return (
int(os.environ.get('LINES', 25)),... | [
"def",
"_termsize",
"(",
")",
":",
"try",
":",
"return",
"struct",
".",
"unpack",
"(",
"'hh'",
",",
"fcntl",
".",
"ioctl",
"(",
"sys",
".",
"stdout",
".",
"fileno",
"(",
")",
",",
"termios",
".",
"TIOCGWINSZ",
",",
"'1234'",
")",
")",
"except",
":"... | Get the current terminal size, returns a ``(height, width)`` tuple. | [
"Get",
"the",
"current",
"terminal",
"size",
"returns",
"a",
"(",
"height",
"width",
")",
"tuple",
"."
] | d7a1fc9de712f9bcf68884a80826a7977df356fb | https://github.com/tehmaze/natural/blob/d7a1fc9de712f9bcf68884a80826a7977df356fb/natural/data.py#L22-L36 | train | Get the current terminal size returns a tuple. |
tehmaze/natural | natural/data.py | hexdump | def hexdump(stream):
'''
Display stream contents in hexadecimal and ASCII format. The ``stream``
specified must either be a file-like object that supports the ``read``
method to receive bytes, or it can be a string.
To dump a file::
>>> hexdump(file(filename)) # doctest: +SKIP
Or ... | python | def hexdump(stream):
'''
Display stream contents in hexadecimal and ASCII format. The ``stream``
specified must either be a file-like object that supports the ``read``
method to receive bytes, or it can be a string.
To dump a file::
>>> hexdump(file(filename)) # doctest: +SKIP
Or ... | [
"def",
"hexdump",
"(",
"stream",
")",
":",
"if",
"isinstance",
"(",
"stream",
",",
"six",
".",
"string_types",
")",
":",
"stream",
"=",
"BytesIO",
"(",
"stream",
")",
"row",
"=",
"0",
"while",
"True",
":",
"data",
"=",
"stream",
".",
"read",
"(",
"... | Display stream contents in hexadecimal and ASCII format. The ``stream``
specified must either be a file-like object that supports the ``read``
method to receive bytes, or it can be a string.
To dump a file::
>>> hexdump(file(filename)) # doctest: +SKIP
Or to dump stdin::
>>> impo... | [
"Display",
"stream",
"contents",
"in",
"hexadecimal",
"and",
"ASCII",
"format",
".",
"The",
"stream",
"specified",
"must",
"either",
"be",
"a",
"file",
"-",
"like",
"object",
"that",
"supports",
"the",
"read",
"method",
"to",
"receive",
"bytes",
"or",
"it",
... | d7a1fc9de712f9bcf68884a80826a7977df356fb | https://github.com/tehmaze/natural/blob/d7a1fc9de712f9bcf68884a80826a7977df356fb/natural/data.py#L39-L75 | train | Display stream contents in hexadecimal and ASCII format. |
tehmaze/natural | natural/data.py | printable | def printable(sequence):
'''
Return a printable string from the input ``sequence``
:param sequence: byte or string sequence
>>> print(printable('\\x1b[1;34mtest\\x1b[0m'))
.[1;34mtest.[0m
>>> printable('\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x06') == '........'
True
>>> print(printable(... | python | def printable(sequence):
'''
Return a printable string from the input ``sequence``
:param sequence: byte or string sequence
>>> print(printable('\\x1b[1;34mtest\\x1b[0m'))
.[1;34mtest.[0m
>>> printable('\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x06') == '........'
True
>>> print(printable(... | [
"def",
"printable",
"(",
"sequence",
")",
":",
"return",
"''",
".",
"join",
"(",
"list",
"(",
"map",
"(",
"lambda",
"c",
":",
"c",
"if",
"c",
"in",
"PRINTABLE",
"else",
"'.'",
",",
"sequence",
")",
")",
")"
] | Return a printable string from the input ``sequence``
:param sequence: byte or string sequence
>>> print(printable('\\x1b[1;34mtest\\x1b[0m'))
.[1;34mtest.[0m
>>> printable('\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x06') == '........'
True
>>> print(printable('12345678'))
12345678
>>> pri... | [
"Return",
"a",
"printable",
"string",
"from",
"the",
"input",
"sequence"
] | d7a1fc9de712f9bcf68884a80826a7977df356fb | https://github.com/tehmaze/natural/blob/d7a1fc9de712f9bcf68884a80826a7977df356fb/natural/data.py#L78-L97 | train | Return a printable string from the input sequence. |
tehmaze/natural | natural/data.py | sparkline | def sparkline(data):
'''
Return a spark line for the given data set.
:value data: sequence of numeric values
>>> print sparkline([1, 2, 3, 4, 5, 6, 5, 4, 3, 1, 5, 6]) # doctest: +SKIP
▁▂▃▄▅▆▅▄▃▁▅▆
'''
min_value = float(min(data))
max_value = float(max(data))
steps = (max_value -... | python | def sparkline(data):
'''
Return a spark line for the given data set.
:value data: sequence of numeric values
>>> print sparkline([1, 2, 3, 4, 5, 6, 5, 4, 3, 1, 5, 6]) # doctest: +SKIP
▁▂▃▄▅▆▅▄▃▁▅▆
'''
min_value = float(min(data))
max_value = float(max(data))
steps = (max_value -... | [
"def",
"sparkline",
"(",
"data",
")",
":",
"min_value",
"=",
"float",
"(",
"min",
"(",
"data",
")",
")",
"max_value",
"=",
"float",
"(",
"max",
"(",
"data",
")",
")",
"steps",
"=",
"(",
"max_value",
"-",
"min_value",
")",
"/",
"float",
"(",
"len",
... | Return a spark line for the given data set.
:value data: sequence of numeric values
>>> print sparkline([1, 2, 3, 4, 5, 6, 5, 4, 3, 1, 5, 6]) # doctest: +SKIP
▁▂▃▄▅▆▅▄▃▁▅▆ | [
"Return",
"a",
"spark",
"line",
"for",
"the",
"given",
"data",
"set",
"."
] | d7a1fc9de712f9bcf68884a80826a7977df356fb | https://github.com/tehmaze/natural/blob/d7a1fc9de712f9bcf68884a80826a7977df356fb/natural/data.py#L100-L117 | train | Return a sparkline for the given data set. |
tehmaze/natural | natural/data.py | throughput | def throughput(sample, window=1, format='decimal'):
'''
Return the throughput in (intelli)bytes per second.
:param sample: number of samples sent
:param window: default 1, sample window in seconds or
:class:`datetime.timedelta` object
:param format: default 'decimal', see :func:`... | python | def throughput(sample, window=1, format='decimal'):
'''
Return the throughput in (intelli)bytes per second.
:param sample: number of samples sent
:param window: default 1, sample window in seconds or
:class:`datetime.timedelta` object
:param format: default 'decimal', see :func:`... | [
"def",
"throughput",
"(",
"sample",
",",
"window",
"=",
"1",
",",
"format",
"=",
"'decimal'",
")",
":",
"if",
"isinstance",
"(",
"window",
",",
"datetime",
".",
"timedelta",
")",
":",
"window",
"=",
"float",
"(",
"window",
".",
"days",
"*",
"86400",
... | Return the throughput in (intelli)bytes per second.
:param sample: number of samples sent
:param window: default 1, sample window in seconds or
:class:`datetime.timedelta` object
:param format: default 'decimal', see :func:`natural.size.filesize`
>>> print(throughput(123456, 42))
... | [
"Return",
"the",
"throughput",
"in",
"(",
"intelli",
")",
"bytes",
"per",
"second",
"."
] | d7a1fc9de712f9bcf68884a80826a7977df356fb | https://github.com/tehmaze/natural/blob/d7a1fc9de712f9bcf68884a80826a7977df356fb/natural/data.py#L120-L139 | train | Return the throughput in intelli bytes per second. |
yeraydiazdiaz/lunr.py | lunr/languages/stemmer.py | get_language_stemmer | def get_language_stemmer(language):
"""Retrieves the SnowballStemmer for a particular language.
Args:
language (str): ISO-639-1 code of the language.
"""
from lunr.languages import SUPPORTED_LANGUAGES
from nltk.stem.snowball import SnowballStemmer
return SnowballStemmer(SUPPORTED_LANGU... | python | def get_language_stemmer(language):
"""Retrieves the SnowballStemmer for a particular language.
Args:
language (str): ISO-639-1 code of the language.
"""
from lunr.languages import SUPPORTED_LANGUAGES
from nltk.stem.snowball import SnowballStemmer
return SnowballStemmer(SUPPORTED_LANGU... | [
"def",
"get_language_stemmer",
"(",
"language",
")",
":",
"from",
"lunr",
".",
"languages",
"import",
"SUPPORTED_LANGUAGES",
"from",
"nltk",
".",
"stem",
".",
"snowball",
"import",
"SnowballStemmer",
"return",
"SnowballStemmer",
"(",
"SUPPORTED_LANGUAGES",
"[",
"lan... | Retrieves the SnowballStemmer for a particular language.
Args:
language (str): ISO-639-1 code of the language. | [
"Retrieves",
"the",
"SnowballStemmer",
"for",
"a",
"particular",
"language",
"."
] | 28ec3f6d4888295eed730211ee9617aa488d6ba3 | https://github.com/yeraydiazdiaz/lunr.py/blob/28ec3f6d4888295eed730211ee9617aa488d6ba3/lunr/languages/stemmer.py#L1-L10 | train | Returns the SnowballStemmer object for a particular language. |
yeraydiazdiaz/lunr.py | lunr/languages/stemmer.py | nltk_stemmer | def nltk_stemmer(stemmer, token, i=None, tokens=None):
"""Wrapper around a NLTK SnowballStemmer, which includes stop words for
each language.
Args:
stemmer (SnowballStemmer): Stemmer instance that performs the stemming.
token (lunr.Token): The token to stem.
i (int): The index of th... | python | def nltk_stemmer(stemmer, token, i=None, tokens=None):
"""Wrapper around a NLTK SnowballStemmer, which includes stop words for
each language.
Args:
stemmer (SnowballStemmer): Stemmer instance that performs the stemming.
token (lunr.Token): The token to stem.
i (int): The index of th... | [
"def",
"nltk_stemmer",
"(",
"stemmer",
",",
"token",
",",
"i",
"=",
"None",
",",
"tokens",
"=",
"None",
")",
":",
"def",
"wrapped_stem",
"(",
"token",
",",
"metadata",
"=",
"None",
")",
":",
"return",
"stemmer",
".",
"stem",
"(",
"token",
")",
"retur... | Wrapper around a NLTK SnowballStemmer, which includes stop words for
each language.
Args:
stemmer (SnowballStemmer): Stemmer instance that performs the stemming.
token (lunr.Token): The token to stem.
i (int): The index of the token in a set.
tokens (list): A list of tokens repr... | [
"Wrapper",
"around",
"a",
"NLTK",
"SnowballStemmer",
"which",
"includes",
"stop",
"words",
"for",
"each",
"language",
"."
] | 28ec3f6d4888295eed730211ee9617aa488d6ba3 | https://github.com/yeraydiazdiaz/lunr.py/blob/28ec3f6d4888295eed730211ee9617aa488d6ba3/lunr/languages/stemmer.py#L13-L27 | train | A wrapper around a NLTK SnowballStemmer that performs the stemming of a token. |
Othernet-Project/sqlize | sqlize/builder.py | is_seq | def is_seq(obj):
""" Returns True if object is not a string but is iterable """
if not hasattr(obj, '__iter__'):
return False
if isinstance(obj, basestring):
return False
return True | python | def is_seq(obj):
""" Returns True if object is not a string but is iterable """
if not hasattr(obj, '__iter__'):
return False
if isinstance(obj, basestring):
return False
return True | [
"def",
"is_seq",
"(",
"obj",
")",
":",
"if",
"not",
"hasattr",
"(",
"obj",
",",
"'__iter__'",
")",
":",
"return",
"False",
"if",
"isinstance",
"(",
"obj",
",",
"basestring",
")",
":",
"return",
"False",
"return",
"True"
] | Returns True if object is not a string but is iterable | [
"Returns",
"True",
"if",
"object",
"is",
"not",
"a",
"string",
"but",
"is",
"iterable"
] | f32cb38e4245800ece339b998ae6647c207a8ca5 | https://github.com/Othernet-Project/sqlize/blob/f32cb38e4245800ece339b998ae6647c207a8ca5/sqlize/builder.py#L26-L32 | train | Returns True if object is a string but is iterable |
jaraco/jaraco.mongodb | jaraco/mongodb/migration.py | Manager.register | def register(cls, func):
"""
Decorate a migration function with this method
to make it available for migrating cases.
"""
cls._add_version_info(func)
cls._upgrade_funcs.add(func)
return func | python | def register(cls, func):
"""
Decorate a migration function with this method
to make it available for migrating cases.
"""
cls._add_version_info(func)
cls._upgrade_funcs.add(func)
return func | [
"def",
"register",
"(",
"cls",
",",
"func",
")",
":",
"cls",
".",
"_add_version_info",
"(",
"func",
")",
"cls",
".",
"_upgrade_funcs",
".",
"add",
"(",
"func",
")",
"return",
"func"
] | Decorate a migration function with this method
to make it available for migrating cases. | [
"Decorate",
"a",
"migration",
"function",
"with",
"this",
"method",
"to",
"make",
"it",
"available",
"for",
"migrating",
"cases",
"."
] | 280f17894941f4babf2e97db033dbb1fd2b9f705 | https://github.com/jaraco/jaraco.mongodb/blob/280f17894941f4babf2e97db033dbb1fd2b9f705/jaraco/mongodb/migration.py#L69-L76 | train | Decorate a migration function with this method
to make it available for migrating cases. |
jaraco/jaraco.mongodb | jaraco/mongodb/migration.py | Manager._add_version_info | def _add_version_info(func):
"""
Add .source and .target attributes to the registered function.
"""
pattern = r'v(?P<source>\d+)_to_(?P<target>\d+)$'
match = re.match(pattern, func.__name__)
if not match:
raise ValueError("migration function name must match " + pattern)
func.source, func.target = map(i... | python | def _add_version_info(func):
"""
Add .source and .target attributes to the registered function.
"""
pattern = r'v(?P<source>\d+)_to_(?P<target>\d+)$'
match = re.match(pattern, func.__name__)
if not match:
raise ValueError("migration function name must match " + pattern)
func.source, func.target = map(i... | [
"def",
"_add_version_info",
"(",
"func",
")",
":",
"pattern",
"=",
"r'v(?P<source>\\d+)_to_(?P<target>\\d+)$'",
"match",
"=",
"re",
".",
"match",
"(",
"pattern",
",",
"func",
".",
"__name__",
")",
"if",
"not",
"match",
":",
"raise",
"ValueError",
"(",
"\"migra... | Add .source and .target attributes to the registered function. | [
"Add",
".",
"source",
"and",
".",
"target",
"attributes",
"to",
"the",
"registered",
"function",
"."
] | 280f17894941f4babf2e97db033dbb1fd2b9f705 | https://github.com/jaraco/jaraco.mongodb/blob/280f17894941f4babf2e97db033dbb1fd2b9f705/jaraco/mongodb/migration.py#L79-L87 | train | Add version info to the registered function. |
jaraco/jaraco.mongodb | jaraco/mongodb/migration.py | Manager.migrate_doc | def migrate_doc(self, doc):
"""
Migrate the doc from its current version to the target version
and return it.
"""
orig_ver = doc.get(self.version_attribute_name, 0)
funcs = self._get_migrate_funcs(orig_ver, self.target_version)
for func in funcs:
func(self, doc)
doc[self.version_attribute_name] = fu... | python | def migrate_doc(self, doc):
"""
Migrate the doc from its current version to the target version
and return it.
"""
orig_ver = doc.get(self.version_attribute_name, 0)
funcs = self._get_migrate_funcs(orig_ver, self.target_version)
for func in funcs:
func(self, doc)
doc[self.version_attribute_name] = fu... | [
"def",
"migrate_doc",
"(",
"self",
",",
"doc",
")",
":",
"orig_ver",
"=",
"doc",
".",
"get",
"(",
"self",
".",
"version_attribute_name",
",",
"0",
")",
"funcs",
"=",
"self",
".",
"_get_migrate_funcs",
"(",
"orig_ver",
",",
"self",
".",
"target_version",
... | Migrate the doc from its current version to the target version
and return it. | [
"Migrate",
"the",
"doc",
"from",
"its",
"current",
"version",
"to",
"the",
"target",
"version",
"and",
"return",
"it",
"."
] | 280f17894941f4babf2e97db033dbb1fd2b9f705 | https://github.com/jaraco/jaraco.mongodb/blob/280f17894941f4babf2e97db033dbb1fd2b9f705/jaraco/mongodb/migration.py#L89-L99 | train | Migrate the doc from its current version to the target version and return it. |
jaraco/jaraco.mongodb | jaraco/mongodb/migration.py | Manager._get_migrate_funcs | def _get_migrate_funcs(cls, orig_version, target_version):
"""
>>> @Manager.register
... def v1_to_2(manager, doc):
... doc['foo'] = 'bar'
>>> @Manager.register
... def v2_to_1(manager, doc):
... del doc['foo']
>>> @Manager.register
... def v2_to_3(manager, doc):
... doc['foo'] = doc['fo... | python | def _get_migrate_funcs(cls, orig_version, target_version):
"""
>>> @Manager.register
... def v1_to_2(manager, doc):
... doc['foo'] = 'bar'
>>> @Manager.register
... def v2_to_1(manager, doc):
... del doc['foo']
>>> @Manager.register
... def v2_to_3(manager, doc):
... doc['foo'] = doc['fo... | [
"def",
"_get_migrate_funcs",
"(",
"cls",
",",
"orig_version",
",",
"target_version",
")",
":",
"direction",
"=",
"1",
"if",
"target_version",
">",
"orig_version",
"else",
"-",
"1",
"versions",
"=",
"range",
"(",
"orig_version",
",",
"target_version",
"+",
"dir... | >>> @Manager.register
... def v1_to_2(manager, doc):
... doc['foo'] = 'bar'
>>> @Manager.register
... def v2_to_1(manager, doc):
... del doc['foo']
>>> @Manager.register
... def v2_to_3(manager, doc):
... doc['foo'] = doc['foo'] + ' baz'
>>> funcs = list(Manager._get_migrate_funcs(1, 3))
... | [
">>>",
"@Manager",
".",
"register",
"...",
"def",
"v1_to_2",
"(",
"manager",
"doc",
")",
":",
"...",
"doc",
"[",
"foo",
"]",
"=",
"bar",
">>>",
"@Manager",
".",
"register",
"...",
"def",
"v2_to_1",
"(",
"manager",
"doc",
")",
":",
"...",
"del",
"doc"... | 280f17894941f4babf2e97db033dbb1fd2b9f705 | https://github.com/jaraco/jaraco.mongodb/blob/280f17894941f4babf2e97db033dbb1fd2b9f705/jaraco/mongodb/migration.py#L102-L129 | train | Get the functions that will be executed when a migration is done. |
jaraco/jaraco.mongodb | jaraco/mongodb/migration.py | Manager._get_func | def _get_func(cls, source_ver, target_ver):
"""
Return exactly one function to convert from source to target
"""
matches = (
func for func in cls._upgrade_funcs
if func.source == source_ver and func.target == target_ver
)
try:
match, = matches
except ValueError:
raise ValueError(
f"No migr... | python | def _get_func(cls, source_ver, target_ver):
"""
Return exactly one function to convert from source to target
"""
matches = (
func for func in cls._upgrade_funcs
if func.source == source_ver and func.target == target_ver
)
try:
match, = matches
except ValueError:
raise ValueError(
f"No migr... | [
"def",
"_get_func",
"(",
"cls",
",",
"source_ver",
",",
"target_ver",
")",
":",
"matches",
"=",
"(",
"func",
"for",
"func",
"in",
"cls",
".",
"_upgrade_funcs",
"if",
"func",
".",
"source",
"==",
"source_ver",
"and",
"func",
".",
"target",
"==",
"target_v... | Return exactly one function to convert from source to target | [
"Return",
"exactly",
"one",
"function",
"to",
"convert",
"from",
"source",
"to",
"target"
] | 280f17894941f4babf2e97db033dbb1fd2b9f705 | https://github.com/jaraco/jaraco.mongodb/blob/280f17894941f4babf2e97db033dbb1fd2b9f705/jaraco/mongodb/migration.py#L132-L145 | train | Return exactly one function to convert from source to target |
senaite/senaite.api | src/senaite/api/__init__.py | get_object | def get_object(brain_or_object):
"""Get the full content object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: PortalObject/ATContentType/DexterityContentType
/CatalogBrain
:returns: The full object
"""
if not is_object(brain_or_object):
fail... | python | def get_object(brain_or_object):
"""Get the full content object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: PortalObject/ATContentType/DexterityContentType
/CatalogBrain
:returns: The full object
"""
if not is_object(brain_or_object):
fail... | [
"def",
"get_object",
"(",
"brain_or_object",
")",
":",
"if",
"not",
"is_object",
"(",
"brain_or_object",
")",
":",
"fail",
"(",
"\"{} is not supported.\"",
".",
"format",
"(",
"repr",
"(",
"brain_or_object",
")",
")",
")",
"if",
"is_brain",
"(",
"brain_or_obje... | Get the full content object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: PortalObject/ATContentType/DexterityContentType
/CatalogBrain
:returns: The full object | [
"Get",
"the",
"full",
"content",
"object"
] | c79c53abcbe6e3a5ab3ced86d2f455275efa20cf | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L203-L215 | train | Get the full content object
|
senaite/senaite.api | src/senaite/api/__init__.py | get_uid | def get_uid(brain_or_object):
"""Get the Plone UID for this object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Plone UID
:rtype: string
"""
if is_portal(brain_or_object):
return '0'... | python | def get_uid(brain_or_object):
"""Get the Plone UID for this object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Plone UID
:rtype: string
"""
if is_portal(brain_or_object):
return '0'... | [
"def",
"get_uid",
"(",
"brain_or_object",
")",
":",
"if",
"is_portal",
"(",
"brain_or_object",
")",
":",
"return",
"'0'",
"if",
"is_brain",
"(",
"brain_or_object",
")",
"and",
"base_hasattr",
"(",
"brain_or_object",
",",
"\"UID\"",
")",
":",
"return",
"brain_o... | Get the Plone UID for this object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Plone UID
:rtype: string | [
"Get",
"the",
"Plone",
"UID",
"for",
"this",
"object"
] | c79c53abcbe6e3a5ab3ced86d2f455275efa20cf | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L366-L378 | train | Get the Plone UID for this object |
senaite/senaite.api | src/senaite/api/__init__.py | get_icon | def get_icon(brain_or_object, html_tag=True):
"""Get the icon of the content object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param html_tag: A value of 'True' returns the HTML tag, else the image url
:ty... | python | def get_icon(brain_or_object, html_tag=True):
"""Get the icon of the content object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param html_tag: A value of 'True' returns the HTML tag, else the image url
:ty... | [
"def",
"get_icon",
"(",
"brain_or_object",
",",
"html_tag",
"=",
"True",
")",
":",
"# Manual approach, because `plone.app.layout.getIcon` does not reliable",
"# work for Bika Contents coming from other catalogs than the",
"# `portal_catalog`",
"portal_types",
"=",
"get_tool",
"(",
... | Get the icon of the content object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param html_tag: A value of 'True' returns the HTML tag, else the image url
:type html_tag: bool
:returns: HTML '<img>' tag if '... | [
"Get",
"the",
"icon",
"of",
"the",
"content",
"object"
] | c79c53abcbe6e3a5ab3ced86d2f455275efa20cf | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L394-L417 | train | Get the icon of the content object |
senaite/senaite.api | src/senaite/api/__init__.py | get_object_by_uid | def get_object_by_uid(uid, default=_marker):
"""Find an object by a given UID
:param uid: The UID of the object to find
:type uid: string
:returns: Found Object or None
"""
# nothing to do here
if not uid:
if default is not _marker:
return default
fail("get_obje... | python | def get_object_by_uid(uid, default=_marker):
"""Find an object by a given UID
:param uid: The UID of the object to find
:type uid: string
:returns: Found Object or None
"""
# nothing to do here
if not uid:
if default is not _marker:
return default
fail("get_obje... | [
"def",
"get_object_by_uid",
"(",
"uid",
",",
"default",
"=",
"_marker",
")",
":",
"# nothing to do here",
"if",
"not",
"uid",
":",
"if",
"default",
"is",
"not",
"_marker",
":",
"return",
"default",
"fail",
"(",
"\"get_object_by_uid requires UID as first argument; go... | Find an object by a given UID
:param uid: The UID of the object to find
:type uid: string
:returns: Found Object or None | [
"Find",
"an",
"object",
"by",
"a",
"given",
"UID"
] | c79c53abcbe6e3a5ab3ced86d2f455275efa20cf | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L420-L455 | train | Find an object by the UID |
senaite/senaite.api | src/senaite/api/__init__.py | get_object_by_path | def get_object_by_path(path, default=_marker):
"""Find an object by a given physical path or absolute_url
:param path: The physical path of the object to find
:type path: string
:returns: Found Object or None
"""
# nothing to do here
if not path:
if default is not _marker:
... | python | def get_object_by_path(path, default=_marker):
"""Find an object by a given physical path or absolute_url
:param path: The physical path of the object to find
:type path: string
:returns: Found Object or None
"""
# nothing to do here
if not path:
if default is not _marker:
... | [
"def",
"get_object_by_path",
"(",
"path",
",",
"default",
"=",
"_marker",
")",
":",
"# nothing to do here",
"if",
"not",
"path",
":",
"if",
"default",
"is",
"not",
"_marker",
":",
"return",
"default",
"fail",
"(",
"\"get_object_by_path first argument must be a path;... | Find an object by a given physical path or absolute_url
:param path: The physical path of the object to find
:type path: string
:returns: Found Object or None | [
"Find",
"an",
"object",
"by",
"a",
"given",
"physical",
"path",
"or",
"absolute_url"
] | c79c53abcbe6e3a5ab3ced86d2f455275efa20cf | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L458-L496 | train | Find an object by a given physical path or absolute_url. |
senaite/senaite.api | src/senaite/api/__init__.py | get_path | def get_path(brain_or_object):
"""Calculate the physical path of this object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Physical path of the object
:rtype: string
"""
if is_brain(brain_or_... | python | def get_path(brain_or_object):
"""Calculate the physical path of this object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Physical path of the object
:rtype: string
"""
if is_brain(brain_or_... | [
"def",
"get_path",
"(",
"brain_or_object",
")",
":",
"if",
"is_brain",
"(",
"brain_or_object",
")",
":",
"path",
"=",
"brain_or_object",
".",
"getPath",
"(",
")",
"portal_path",
"=",
"get_path",
"(",
"get_portal",
"(",
")",
")",
"if",
"portal_path",
"not",
... | Calculate the physical path of this object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Physical path of the object
:rtype: string | [
"Calculate",
"the",
"physical",
"path",
"of",
"this",
"object"
] | c79c53abcbe6e3a5ab3ced86d2f455275efa20cf | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L499-L513 | train | Calculate the physical path of the object |
senaite/senaite.api | src/senaite/api/__init__.py | get_review_history | def get_review_history(brain_or_object, rev=True):
"""Get the review history for the given brain or context.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Workflow history
:rtype: [{}, ...]
"""
... | python | def get_review_history(brain_or_object, rev=True):
"""Get the review history for the given brain or context.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Workflow history
:rtype: [{}, ...]
"""
... | [
"def",
"get_review_history",
"(",
"brain_or_object",
",",
"rev",
"=",
"True",
")",
":",
"obj",
"=",
"get_object",
"(",
"brain_or_object",
")",
"review_history",
"=",
"[",
"]",
"try",
":",
"workflow",
"=",
"get_tool",
"(",
"\"portal_workflow\"",
")",
"review_hi... | Get the review history for the given brain or context.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Workflow history
:rtype: [{}, ...] | [
"Get",
"the",
"review",
"history",
"for",
"the",
"given",
"brain",
"or",
"context",
"."
] | c79c53abcbe6e3a5ab3ced86d2f455275efa20cf | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L658-L681 | train | Returns the review_history for the given brain or content object |
senaite/senaite.api | src/senaite/api/__init__.py | get_workflow_status_of | def get_workflow_status_of(brain_or_object, state_var="review_state"):
"""Get the current workflow status of the given brain or context.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param state_var: The name of ... | python | def get_workflow_status_of(brain_or_object, state_var="review_state"):
"""Get the current workflow status of the given brain or context.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param state_var: The name of ... | [
"def",
"get_workflow_status_of",
"(",
"brain_or_object",
",",
"state_var",
"=",
"\"review_state\"",
")",
":",
"workflow",
"=",
"get_tool",
"(",
"\"portal_workflow\"",
")",
"obj",
"=",
"get_object",
"(",
"brain_or_object",
")",
"return",
"workflow",
".",
"getInfoFor"... | Get the current workflow status of the given brain or context.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param state_var: The name of the state variable
:type state_var: string
:returns: Status
:rtype... | [
"Get",
"the",
"current",
"workflow",
"status",
"of",
"the",
"given",
"brain",
"or",
"context",
"."
] | c79c53abcbe6e3a5ab3ced86d2f455275efa20cf | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L714-L726 | train | Returns the current workflow status of the given object |
senaite/senaite.api | src/senaite/api/__init__.py | get_cancellation_status | def get_cancellation_status(brain_or_object, default="active"):
"""Get the `cancellation_state` of an object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Value of the review_status variable
:rtype: ... | python | def get_cancellation_status(brain_or_object, default="active"):
"""Get the `cancellation_state` of an object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Value of the review_status variable
:rtype: ... | [
"def",
"get_cancellation_status",
"(",
"brain_or_object",
",",
"default",
"=",
"\"active\"",
")",
":",
"if",
"is_brain",
"(",
"brain_or_object",
")",
":",
"return",
"getattr",
"(",
"brain_or_object",
",",
"\"cancellation_state\"",
",",
"default",
")",
"workflows",
... | Get the `cancellation_state` of an object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Value of the review_status variable
:rtype: String | [
"Get",
"the",
"cancellation_state",
"of",
"an",
"object"
] | c79c53abcbe6e3a5ab3ced86d2f455275efa20cf | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L759-L772 | train | Get the cancellation_state of an object |
senaite/senaite.api | src/senaite/api/__init__.py | get_inactive_status | def get_inactive_status(brain_or_object, default="active"):
"""Get the `cancellation_state` of an objct
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Value of the review_status variable
:rtype: Strin... | python | def get_inactive_status(brain_or_object, default="active"):
"""Get the `cancellation_state` of an objct
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Value of the review_status variable
:rtype: Strin... | [
"def",
"get_inactive_status",
"(",
"brain_or_object",
",",
"default",
"=",
"\"active\"",
")",
":",
"if",
"is_brain",
"(",
"brain_or_object",
")",
":",
"return",
"getattr",
"(",
"brain_or_object",
",",
"\"inactive_state\"",
",",
"default",
")",
"workflows",
"=",
... | Get the `cancellation_state` of an objct
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Value of the review_status variable
:rtype: String | [
"Get",
"the",
"cancellation_state",
"of",
"an",
"objct"
] | c79c53abcbe6e3a5ab3ced86d2f455275efa20cf | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L792-L805 | train | Get the cancellation_state of an object |
senaite/senaite.api | src/senaite/api/__init__.py | do_transition_for | def do_transition_for(brain_or_object, transition):
"""Performs a workflow transition for the passed in object.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: The object where the transtion was performed
... | python | def do_transition_for(brain_or_object, transition):
"""Performs a workflow transition for the passed in object.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: The object where the transtion was performed
... | [
"def",
"do_transition_for",
"(",
"brain_or_object",
",",
"transition",
")",
":",
"if",
"not",
"isinstance",
"(",
"transition",
",",
"basestring",
")",
":",
"fail",
"(",
"\"Transition type needs to be string, got '%s'\"",
"%",
"type",
"(",
"transition",
")",
")",
"... | Performs a workflow transition for the passed in object.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: The object where the transtion was performed | [
"Performs",
"a",
"workflow",
"transition",
"for",
"the",
"passed",
"in",
"object",
"."
] | c79c53abcbe6e3a5ab3ced86d2f455275efa20cf | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L869-L880 | train | Performs a workflow transition for the passed in object. |
senaite/senaite.api | src/senaite/api/__init__.py | to_date | def to_date(value, default=None):
"""Tries to convert the passed in value to Zope's DateTime
:param value: The value to be converted to a valid DateTime
:type value: str, DateTime or datetime
:return: The DateTime representation of the value passed in or default
"""
if isinstance(value, DateTim... | python | def to_date(value, default=None):
"""Tries to convert the passed in value to Zope's DateTime
:param value: The value to be converted to a valid DateTime
:type value: str, DateTime or datetime
:return: The DateTime representation of the value passed in or default
"""
if isinstance(value, DateTim... | [
"def",
"to_date",
"(",
"value",
",",
"default",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"DateTime",
")",
":",
"return",
"value",
"if",
"not",
"value",
":",
"if",
"default",
"is",
"None",
":",
"return",
"None",
"return",
"to_date",... | Tries to convert the passed in value to Zope's DateTime
:param value: The value to be converted to a valid DateTime
:type value: str, DateTime or datetime
:return: The DateTime representation of the value passed in or default | [
"Tries",
"to",
"convert",
"the",
"passed",
"in",
"value",
"to",
"Zope",
"s",
"DateTime"
] | c79c53abcbe6e3a5ab3ced86d2f455275efa20cf | https://github.com/senaite/senaite.api/blob/c79c53abcbe6e3a5ab3ced86d2f455275efa20cf/src/senaite/api/__init__.py#L1163-L1182 | train | Tries to convert the passed in value to a valid DateTime |
wroberts/fsed | fsed/fsed.py | set_log_level | def set_log_level(verbose, quiet):
'''
Ses the logging level of the script based on command line options.
Arguments:
- `verbose`:
- `quiet`:
'''
if quiet:
verbose = -1
if verbose < 0:
verbose = logging.CRITICAL
elif verbose == 0:
verbose = logging.WARNING
... | python | def set_log_level(verbose, quiet):
'''
Ses the logging level of the script based on command line options.
Arguments:
- `verbose`:
- `quiet`:
'''
if quiet:
verbose = -1
if verbose < 0:
verbose = logging.CRITICAL
elif verbose == 0:
verbose = logging.WARNING
... | [
"def",
"set_log_level",
"(",
"verbose",
",",
"quiet",
")",
":",
"if",
"quiet",
":",
"verbose",
"=",
"-",
"1",
"if",
"verbose",
"<",
"0",
":",
"verbose",
"=",
"logging",
".",
"CRITICAL",
"elif",
"verbose",
"==",
"0",
":",
"verbose",
"=",
"logging",
".... | Ses the logging level of the script based on command line options.
Arguments:
- `verbose`:
- `quiet`: | [
"Ses",
"the",
"logging",
"level",
"of",
"the",
"script",
"based",
"on",
"command",
"line",
"options",
"."
] | c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2 | https://github.com/wroberts/fsed/blob/c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2/fsed/fsed.py#L23-L41 | train | Sets the logging level of the script based on command line options. |
wroberts/fsed | fsed/fsed.py | detect_pattern_format | def detect_pattern_format(pattern_filename, encoding, on_word_boundaries):
'''
Automatically detects the pattern file format, and determines
whether the Aho-Corasick string matching should pay attention to
word boundaries or not.
Arguments:
- `pattern_filename`:
- `encoding`:
- `on_word... | python | def detect_pattern_format(pattern_filename, encoding, on_word_boundaries):
'''
Automatically detects the pattern file format, and determines
whether the Aho-Corasick string matching should pay attention to
word boundaries or not.
Arguments:
- `pattern_filename`:
- `encoding`:
- `on_word... | [
"def",
"detect_pattern_format",
"(",
"pattern_filename",
",",
"encoding",
",",
"on_word_boundaries",
")",
":",
"tsv",
"=",
"True",
"boundaries",
"=",
"on_word_boundaries",
"with",
"open_file",
"(",
"pattern_filename",
")",
"as",
"input_file",
":",
"for",
"line",
"... | Automatically detects the pattern file format, and determines
whether the Aho-Corasick string matching should pay attention to
word boundaries or not.
Arguments:
- `pattern_filename`:
- `encoding`:
- `on_word_boundaries`: | [
"Automatically",
"detects",
"the",
"pattern",
"file",
"format",
"and",
"determines",
"whether",
"the",
"Aho",
"-",
"Corasick",
"string",
"matching",
"should",
"pay",
"attention",
"to",
"word",
"boundaries",
"or",
"not",
"."
] | c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2 | https://github.com/wroberts/fsed/blob/c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2/fsed/fsed.py#L43-L65 | train | Detects the pattern file format and determines if it should pay attention to the word boundaries or not. |
wroberts/fsed | fsed/fsed.py | sub_escapes | def sub_escapes(sval):
'''
Process escaped characters in ``sval``.
Arguments:
- `sval`:
'''
sval = sval.replace('\\a', '\a')
sval = sval.replace('\\b', '\x00')
sval = sval.replace('\\f', '\f')
sval = sval.replace('\\n', '\n')
sval = sval.replace('\\r', '\r')
sval = sval.repl... | python | def sub_escapes(sval):
'''
Process escaped characters in ``sval``.
Arguments:
- `sval`:
'''
sval = sval.replace('\\a', '\a')
sval = sval.replace('\\b', '\x00')
sval = sval.replace('\\f', '\f')
sval = sval.replace('\\n', '\n')
sval = sval.replace('\\r', '\r')
sval = sval.repl... | [
"def",
"sub_escapes",
"(",
"sval",
")",
":",
"sval",
"=",
"sval",
".",
"replace",
"(",
"'\\\\a'",
",",
"'\\a'",
")",
"sval",
"=",
"sval",
".",
"replace",
"(",
"'\\\\b'",
",",
"'\\x00'",
")",
"sval",
"=",
"sval",
".",
"replace",
"(",
"'\\\\f'",
",",
... | Process escaped characters in ``sval``.
Arguments:
- `sval`: | [
"Process",
"escaped",
"characters",
"in",
"sval",
"."
] | c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2 | https://github.com/wroberts/fsed/blob/c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2/fsed/fsed.py#L67-L82 | train | Process escaped characters in sval. |
wroberts/fsed | fsed/fsed.py | build_trie | def build_trie(pattern_filename, pattern_format, encoding, on_word_boundaries):
'''
Constructs a finite state machine for performing string rewriting.
Arguments:
- `pattern_filename`:
- `pattern_format`:
- `encoding`:
- `on_word_boundaries`:
'''
boundaries = on_word_boundaries
i... | python | def build_trie(pattern_filename, pattern_format, encoding, on_word_boundaries):
'''
Constructs a finite state machine for performing string rewriting.
Arguments:
- `pattern_filename`:
- `pattern_format`:
- `encoding`:
- `on_word_boundaries`:
'''
boundaries = on_word_boundaries
i... | [
"def",
"build_trie",
"(",
"pattern_filename",
",",
"pattern_format",
",",
"encoding",
",",
"on_word_boundaries",
")",
":",
"boundaries",
"=",
"on_word_boundaries",
"if",
"pattern_format",
"==",
"'auto'",
"or",
"not",
"on_word_boundaries",
":",
"tsv",
",",
"boundarie... | Constructs a finite state machine for performing string rewriting.
Arguments:
- `pattern_filename`:
- `pattern_format`:
- `encoding`:
- `on_word_boundaries`: | [
"Constructs",
"a",
"finite",
"state",
"machine",
"for",
"performing",
"string",
"rewriting",
"."
] | c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2 | https://github.com/wroberts/fsed/blob/c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2/fsed/fsed.py#L84-L148 | train | Builds a finite state machine for performing string rewriting. |
wroberts/fsed | fsed/fsed.py | warn_prefix_values | def warn_prefix_values(trie):
'''
Prints warning messages for every node that has both a value and a
longest_prefix.
'''
for current, _parent in trie.dfs():
if current.has_value and current.longest_prefix is not None:
LOGGER.warn(('pattern {} (value {}) is a superstring of patter... | python | def warn_prefix_values(trie):
'''
Prints warning messages for every node that has both a value and a
longest_prefix.
'''
for current, _parent in trie.dfs():
if current.has_value and current.longest_prefix is not None:
LOGGER.warn(('pattern {} (value {}) is a superstring of patter... | [
"def",
"warn_prefix_values",
"(",
"trie",
")",
":",
"for",
"current",
",",
"_parent",
"in",
"trie",
".",
"dfs",
"(",
")",
":",
"if",
"current",
".",
"has_value",
"and",
"current",
".",
"longest_prefix",
"is",
"not",
"None",
":",
"LOGGER",
".",
"warn",
... | Prints warning messages for every node that has both a value and a
longest_prefix. | [
"Prints",
"warning",
"messages",
"for",
"every",
"node",
"that",
"has",
"both",
"a",
"value",
"and",
"a",
"longest_prefix",
"."
] | c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2 | https://github.com/wroberts/fsed/blob/c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2/fsed/fsed.py#L150-L160 | train | Prints warning messages for every node that has both a value and longest_prefix. |
wroberts/fsed | fsed/fsed.py | rewrite_str_with_trie | def rewrite_str_with_trie(sval, trie, boundaries = False, slow = False):
'''
Rewrites a string using the given trie object.
Arguments:
- `sval`:
- `trie`:
- `boundaries`:
- `slow`:
'''
if boundaries:
sval = fsed.ahocorasick.boundary_transform(sval)
if slow:
sval ... | python | def rewrite_str_with_trie(sval, trie, boundaries = False, slow = False):
'''
Rewrites a string using the given trie object.
Arguments:
- `sval`:
- `trie`:
- `boundaries`:
- `slow`:
'''
if boundaries:
sval = fsed.ahocorasick.boundary_transform(sval)
if slow:
sval ... | [
"def",
"rewrite_str_with_trie",
"(",
"sval",
",",
"trie",
",",
"boundaries",
"=",
"False",
",",
"slow",
"=",
"False",
")",
":",
"if",
"boundaries",
":",
"sval",
"=",
"fsed",
".",
"ahocorasick",
".",
"boundary_transform",
"(",
"sval",
")",
"if",
"slow",
"... | Rewrites a string using the given trie object.
Arguments:
- `sval`:
- `trie`:
- `boundaries`:
- `slow`: | [
"Rewrites",
"a",
"string",
"using",
"the",
"given",
"trie",
"object",
"."
] | c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2 | https://github.com/wroberts/fsed/blob/c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2/fsed/fsed.py#L162-L180 | train | Rewrites a string using the given trie object. |
wroberts/fsed | fsed/fsed.py | main | def main(pattern_filename, input_filenames, pattern_format,
output_filename,
encoding, words, by_line, slow, verbose, quiet):
'''
Search and replace on INPUT_FILE(s) (or standard input), with
matching on fixed strings.
'''
set_log_level(verbose, quiet)
if slow:
by_line ... | python | def main(pattern_filename, input_filenames, pattern_format,
output_filename,
encoding, words, by_line, slow, verbose, quiet):
'''
Search and replace on INPUT_FILE(s) (or standard input), with
matching on fixed strings.
'''
set_log_level(verbose, quiet)
if slow:
by_line ... | [
"def",
"main",
"(",
"pattern_filename",
",",
"input_filenames",
",",
"pattern_format",
",",
"output_filename",
",",
"encoding",
",",
"words",
",",
"by_line",
",",
"slow",
",",
"verbose",
",",
"quiet",
")",
":",
"set_log_level",
"(",
"verbose",
",",
"quiet",
... | Search and replace on INPUT_FILE(s) (or standard input), with
matching on fixed strings. | [
"Search",
"and",
"replace",
"on",
"INPUT_FILE",
"(",
"s",
")",
"(",
"or",
"standard",
"input",
")",
"with",
"matching",
"on",
"fixed",
"strings",
"."
] | c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2 | https://github.com/wroberts/fsed/blob/c0c1c5e0ea3a413ef679fdf71635f7f2e5d79ca2/fsed/fsed.py#L211-L249 | train | Main function for the pattern_filename. |
yeraydiazdiaz/lunr.py | lunr/pipeline.py | Pipeline.register_function | def register_function(cls, fn, label):
"""Register a function with the pipeline."""
if label in cls.registered_functions:
log.warning("Overwriting existing registered function %s", label)
fn.label = label
cls.registered_functions[fn.label] = fn | python | def register_function(cls, fn, label):
"""Register a function with the pipeline."""
if label in cls.registered_functions:
log.warning("Overwriting existing registered function %s", label)
fn.label = label
cls.registered_functions[fn.label] = fn | [
"def",
"register_function",
"(",
"cls",
",",
"fn",
",",
"label",
")",
":",
"if",
"label",
"in",
"cls",
".",
"registered_functions",
":",
"log",
".",
"warning",
"(",
"\"Overwriting existing registered function %s\"",
",",
"label",
")",
"fn",
".",
"label",
"=",
... | Register a function with the pipeline. | [
"Register",
"a",
"function",
"with",
"the",
"pipeline",
"."
] | 28ec3f6d4888295eed730211ee9617aa488d6ba3 | https://github.com/yeraydiazdiaz/lunr.py/blob/28ec3f6d4888295eed730211ee9617aa488d6ba3/lunr/pipeline.py#L34-L40 | train | Register a function with the pipeline. |
yeraydiazdiaz/lunr.py | lunr/pipeline.py | Pipeline.load | def load(cls, serialised):
"""Loads a previously serialised pipeline."""
pipeline = cls()
for fn_name in serialised:
try:
fn = cls.registered_functions[fn_name]
except KeyError:
raise BaseLunrException(
"Cannot load unre... | python | def load(cls, serialised):
"""Loads a previously serialised pipeline."""
pipeline = cls()
for fn_name in serialised:
try:
fn = cls.registered_functions[fn_name]
except KeyError:
raise BaseLunrException(
"Cannot load unre... | [
"def",
"load",
"(",
"cls",
",",
"serialised",
")",
":",
"pipeline",
"=",
"cls",
"(",
")",
"for",
"fn_name",
"in",
"serialised",
":",
"try",
":",
"fn",
"=",
"cls",
".",
"registered_functions",
"[",
"fn_name",
"]",
"except",
"KeyError",
":",
"raise",
"Ba... | Loads a previously serialised pipeline. | [
"Loads",
"a",
"previously",
"serialised",
"pipeline",
"."
] | 28ec3f6d4888295eed730211ee9617aa488d6ba3 | https://github.com/yeraydiazdiaz/lunr.py/blob/28ec3f6d4888295eed730211ee9617aa488d6ba3/lunr/pipeline.py#L43-L56 | train | Loads a previously serialised pipeline. |
yeraydiazdiaz/lunr.py | lunr/pipeline.py | Pipeline.add | def add(self, *args):
"""Adds new functions to the end of the pipeline.
Functions must accept three arguments:
- Token: A lunr.Token object which will be updated
- i: The index of the token in the set
- tokens: A list of tokens representing the set
"""
for fn in ... | python | def add(self, *args):
"""Adds new functions to the end of the pipeline.
Functions must accept three arguments:
- Token: A lunr.Token object which will be updated
- i: The index of the token in the set
- tokens: A list of tokens representing the set
"""
for fn in ... | [
"def",
"add",
"(",
"self",
",",
"*",
"args",
")",
":",
"for",
"fn",
"in",
"args",
":",
"self",
".",
"warn_if_function_not_registered",
"(",
"fn",
")",
"self",
".",
"_stack",
".",
"append",
"(",
"fn",
")"
] | Adds new functions to the end of the pipeline.
Functions must accept three arguments:
- Token: A lunr.Token object which will be updated
- i: The index of the token in the set
- tokens: A list of tokens representing the set | [
"Adds",
"new",
"functions",
"to",
"the",
"end",
"of",
"the",
"pipeline",
"."
] | 28ec3f6d4888295eed730211ee9617aa488d6ba3 | https://github.com/yeraydiazdiaz/lunr.py/blob/28ec3f6d4888295eed730211ee9617aa488d6ba3/lunr/pipeline.py#L58-L68 | train | Adds new functions to the end of the pipeline. |
yeraydiazdiaz/lunr.py | lunr/pipeline.py | Pipeline.after | def after(self, existing_fn, new_fn):
"""Adds a single function after a function that already exists in the
pipeline."""
self.warn_if_function_not_registered(new_fn)
try:
index = self._stack.index(existing_fn)
self._stack.insert(index + 1, new_fn)
except V... | python | def after(self, existing_fn, new_fn):
"""Adds a single function after a function that already exists in the
pipeline."""
self.warn_if_function_not_registered(new_fn)
try:
index = self._stack.index(existing_fn)
self._stack.insert(index + 1, new_fn)
except V... | [
"def",
"after",
"(",
"self",
",",
"existing_fn",
",",
"new_fn",
")",
":",
"self",
".",
"warn_if_function_not_registered",
"(",
"new_fn",
")",
"try",
":",
"index",
"=",
"self",
".",
"_stack",
".",
"index",
"(",
"existing_fn",
")",
"self",
".",
"_stack",
"... | Adds a single function after a function that already exists in the
pipeline. | [
"Adds",
"a",
"single",
"function",
"after",
"a",
"function",
"that",
"already",
"exists",
"in",
"the",
"pipeline",
"."
] | 28ec3f6d4888295eed730211ee9617aa488d6ba3 | https://github.com/yeraydiazdiaz/lunr.py/blob/28ec3f6d4888295eed730211ee9617aa488d6ba3/lunr/pipeline.py#L81-L89 | train | Adds a single function after an existing function that already exists in the list of functions in the pipeline. |
yeraydiazdiaz/lunr.py | lunr/pipeline.py | Pipeline.run | def run(self, tokens):
"""Runs the current list of functions that make up the pipeline against
the passed tokens."""
for fn in self._stack:
results = []
for i, token in enumerate(tokens):
# JS ignores additional arguments to the functions but we
... | python | def run(self, tokens):
"""Runs the current list of functions that make up the pipeline against
the passed tokens."""
for fn in self._stack:
results = []
for i, token in enumerate(tokens):
# JS ignores additional arguments to the functions but we
... | [
"def",
"run",
"(",
"self",
",",
"tokens",
")",
":",
"for",
"fn",
"in",
"self",
".",
"_stack",
":",
"results",
"=",
"[",
"]",
"for",
"i",
",",
"token",
"in",
"enumerate",
"(",
"tokens",
")",
":",
"# JS ignores additional arguments to the functions but we",
... | Runs the current list of functions that make up the pipeline against
the passed tokens. | [
"Runs",
"the",
"current",
"list",
"of",
"functions",
"that",
"make",
"up",
"the",
"pipeline",
"against",
"the",
"passed",
"tokens",
"."
] | 28ec3f6d4888295eed730211ee9617aa488d6ba3 | https://github.com/yeraydiazdiaz/lunr.py/blob/28ec3f6d4888295eed730211ee9617aa488d6ba3/lunr/pipeline.py#L110-L128 | train | Runs the current list of functions that make up the pipeline against
the passed tokens. |
yeraydiazdiaz/lunr.py | lunr/pipeline.py | Pipeline.run_string | def run_string(self, string, metadata=None):
"""Convenience method for passing a string through a pipeline and
getting strings out. This method takes care of wrapping the passed
string in a token and mapping the resulting tokens back to strings."""
token = Token(string, metadata)
... | python | def run_string(self, string, metadata=None):
"""Convenience method for passing a string through a pipeline and
getting strings out. This method takes care of wrapping the passed
string in a token and mapping the resulting tokens back to strings."""
token = Token(string, metadata)
... | [
"def",
"run_string",
"(",
"self",
",",
"string",
",",
"metadata",
"=",
"None",
")",
":",
"token",
"=",
"Token",
"(",
"string",
",",
"metadata",
")",
"return",
"[",
"str",
"(",
"tkn",
")",
"for",
"tkn",
"in",
"self",
".",
"run",
"(",
"[",
"token",
... | Convenience method for passing a string through a pipeline and
getting strings out. This method takes care of wrapping the passed
string in a token and mapping the resulting tokens back to strings. | [
"Convenience",
"method",
"for",
"passing",
"a",
"string",
"through",
"a",
"pipeline",
"and",
"getting",
"strings",
"out",
".",
"This",
"method",
"takes",
"care",
"of",
"wrapping",
"the",
"passed",
"string",
"in",
"a",
"token",
"and",
"mapping",
"the",
"resul... | 28ec3f6d4888295eed730211ee9617aa488d6ba3 | https://github.com/yeraydiazdiaz/lunr.py/blob/28ec3f6d4888295eed730211ee9617aa488d6ba3/lunr/pipeline.py#L130-L135 | train | Convenience method for passing a string through a pipeline and
returning a list of strings out. |
jaraco/jaraco.mongodb | jaraco/mongodb/pmxbot.py | get_client | def get_client():
"""
Use the same MongoDB client as pmxbot if available.
"""
with contextlib.suppress(Exception):
store = Storage.from_URI()
assert isinstance(store, pmxbot.storage.MongoDBStorage)
return store.db.database.client | python | def get_client():
"""
Use the same MongoDB client as pmxbot if available.
"""
with contextlib.suppress(Exception):
store = Storage.from_URI()
assert isinstance(store, pmxbot.storage.MongoDBStorage)
return store.db.database.client | [
"def",
"get_client",
"(",
")",
":",
"with",
"contextlib",
".",
"suppress",
"(",
"Exception",
")",
":",
"store",
"=",
"Storage",
".",
"from_URI",
"(",
")",
"assert",
"isinstance",
"(",
"store",
",",
"pmxbot",
".",
"storage",
".",
"MongoDBStorage",
")",
"r... | Use the same MongoDB client as pmxbot if available. | [
"Use",
"the",
"same",
"MongoDB",
"client",
"as",
"pmxbot",
"if",
"available",
"."
] | 280f17894941f4babf2e97db033dbb1fd2b9f705 | https://github.com/jaraco/jaraco.mongodb/blob/280f17894941f4babf2e97db033dbb1fd2b9f705/jaraco/mongodb/pmxbot.py#L13-L20 | train | Get the client for this connection. |
jaraco/jaraco.mongodb | jaraco/mongodb/pmxbot.py | cdbs | def cdbs(client, event, channel, nick, rest):
"""
Create a database in a shard. !create-db-in-shard {db name} {shard name}
"""
db_name, shard = shlex.split(rest)
return sharding.create_db_in_shard(db_name, shard, client=get_client()) | python | def cdbs(client, event, channel, nick, rest):
"""
Create a database in a shard. !create-db-in-shard {db name} {shard name}
"""
db_name, shard = shlex.split(rest)
return sharding.create_db_in_shard(db_name, shard, client=get_client()) | [
"def",
"cdbs",
"(",
"client",
",",
"event",
",",
"channel",
",",
"nick",
",",
"rest",
")",
":",
"db_name",
",",
"shard",
"=",
"shlex",
".",
"split",
"(",
"rest",
")",
"return",
"sharding",
".",
"create_db_in_shard",
"(",
"db_name",
",",
"shard",
",",
... | Create a database in a shard. !create-db-in-shard {db name} {shard name} | [
"Create",
"a",
"database",
"in",
"a",
"shard",
".",
"!create",
"-",
"db",
"-",
"in",
"-",
"shard",
"{",
"db",
"name",
"}",
"{",
"shard",
"name",
"}"
] | 280f17894941f4babf2e97db033dbb1fd2b9f705 | https://github.com/jaraco/jaraco.mongodb/blob/280f17894941f4babf2e97db033dbb1fd2b9f705/jaraco/mongodb/pmxbot.py#L24-L29 | train | !create - db - in - shard |
jaraco/jaraco.mongodb | jaraco/mongodb/sharding.py | create_db_in_shard | def create_db_in_shard(db_name, shard, client=None):
"""
In a sharded cluster, create a database in a particular shard.
"""
client = client or pymongo.MongoClient()
# flush the router config to ensure it's not stale
res = client.admin.command('flushRouterConfig')
if not res.get('ok'):
... | python | def create_db_in_shard(db_name, shard, client=None):
"""
In a sharded cluster, create a database in a particular shard.
"""
client = client or pymongo.MongoClient()
# flush the router config to ensure it's not stale
res = client.admin.command('flushRouterConfig')
if not res.get('ok'):
... | [
"def",
"create_db_in_shard",
"(",
"db_name",
",",
"shard",
",",
"client",
"=",
"None",
")",
":",
"client",
"=",
"client",
"or",
"pymongo",
".",
"MongoClient",
"(",
")",
"# flush the router config to ensure it's not stale",
"res",
"=",
"client",
".",
"admin",
"."... | In a sharded cluster, create a database in a particular shard. | [
"In",
"a",
"sharded",
"cluster",
"create",
"a",
"database",
"in",
"a",
"particular",
"shard",
"."
] | 280f17894941f4babf2e97db033dbb1fd2b9f705 | https://github.com/jaraco/jaraco.mongodb/blob/280f17894941f4babf2e97db033dbb1fd2b9f705/jaraco/mongodb/sharding.py#L16-L43 | train | Create a database in a particular shard. |
tehmaze/natural | natural/util.py | luhn_checksum | def luhn_checksum(number, chars=DIGITS):
'''
Calculates the Luhn checksum for `number`
:param number: string or int
:param chars: string
>>> luhn_checksum(1234)
4
'''
length = len(chars)
number = [chars.index(n) for n in reversed(str(number))]
return (
sum(number[::2])... | python | def luhn_checksum(number, chars=DIGITS):
'''
Calculates the Luhn checksum for `number`
:param number: string or int
:param chars: string
>>> luhn_checksum(1234)
4
'''
length = len(chars)
number = [chars.index(n) for n in reversed(str(number))]
return (
sum(number[::2])... | [
"def",
"luhn_checksum",
"(",
"number",
",",
"chars",
"=",
"DIGITS",
")",
":",
"length",
"=",
"len",
"(",
"chars",
")",
"number",
"=",
"[",
"chars",
".",
"index",
"(",
"n",
")",
"for",
"n",
"in",
"reversed",
"(",
"str",
"(",
"number",
")",
")",
"]... | Calculates the Luhn checksum for `number`
:param number: string or int
:param chars: string
>>> luhn_checksum(1234)
4 | [
"Calculates",
"the",
"Luhn",
"checksum",
"for",
"number"
] | d7a1fc9de712f9bcf68884a80826a7977df356fb | https://github.com/tehmaze/natural/blob/d7a1fc9de712f9bcf68884a80826a7977df356fb/natural/util.py#L9-L25 | train | Calculates the Luhn checksum for number |
tehmaze/natural | natural/util.py | luhn_calc | def luhn_calc(number, chars=DIGITS):
'''
Calculate the Luhn check digit for ``number``.
:param number: string
:param chars: string
>>> luhn_calc('42')
'2'
'''
checksum = luhn_checksum(str(number) + chars[0], chars)
return chars[-checksum] | python | def luhn_calc(number, chars=DIGITS):
'''
Calculate the Luhn check digit for ``number``.
:param number: string
:param chars: string
>>> luhn_calc('42')
'2'
'''
checksum = luhn_checksum(str(number) + chars[0], chars)
return chars[-checksum] | [
"def",
"luhn_calc",
"(",
"number",
",",
"chars",
"=",
"DIGITS",
")",
":",
"checksum",
"=",
"luhn_checksum",
"(",
"str",
"(",
"number",
")",
"+",
"chars",
"[",
"0",
"]",
",",
"chars",
")",
"return",
"chars",
"[",
"-",
"checksum",
"]"
] | Calculate the Luhn check digit for ``number``.
:param number: string
:param chars: string
>>> luhn_calc('42')
'2' | [
"Calculate",
"the",
"Luhn",
"check",
"digit",
"for",
"number",
"."
] | d7a1fc9de712f9bcf68884a80826a7977df356fb | https://github.com/tehmaze/natural/blob/d7a1fc9de712f9bcf68884a80826a7977df356fb/natural/util.py#L28-L41 | train | Calculates the Luhn check digit for number. |
tehmaze/natural | natural/util.py | to_decimal | def to_decimal(number, strip='- '):
'''
Converts a number to a string of decimals in base 10.
>>> to_decimal(123)
'123'
>>> to_decimal('o123')
'83'
>>> to_decimal('b101010')
'42'
>>> to_decimal('0x2a')
'42'
'''
if isinstance(number, six.integer_types):
return str... | python | def to_decimal(number, strip='- '):
'''
Converts a number to a string of decimals in base 10.
>>> to_decimal(123)
'123'
>>> to_decimal('o123')
'83'
>>> to_decimal('b101010')
'42'
>>> to_decimal('0x2a')
'42'
'''
if isinstance(number, six.integer_types):
return str... | [
"def",
"to_decimal",
"(",
"number",
",",
"strip",
"=",
"'- '",
")",
":",
"if",
"isinstance",
"(",
"number",
",",
"six",
".",
"integer_types",
")",
":",
"return",
"str",
"(",
"number",
")",
"number",
"=",
"str",
"(",
"number",
")",
"number",
"=",
"re"... | Converts a number to a string of decimals in base 10.
>>> to_decimal(123)
'123'
>>> to_decimal('o123')
'83'
>>> to_decimal('b101010')
'42'
>>> to_decimal('0x2a')
'42' | [
"Converts",
"a",
"number",
"to",
"a",
"string",
"of",
"decimals",
"in",
"base",
"10",
"."
] | d7a1fc9de712f9bcf68884a80826a7977df356fb | https://github.com/tehmaze/natural/blob/d7a1fc9de712f9bcf68884a80826a7977df356fb/natural/util.py#L71-L103 | train | Converts a number to a string of decimal in base 10. |
rmst/chi | chi/util.py | output_redirect | def output_redirect(stdout, stderr):
"""
thread safe redirect of stdout and stderr
:param stdout:
:param stderr:
:return:
"""
import sys
import threading
if not redirect:
originals = (sys.stdout.write, sys.stderr.write)
class Logger:
def __init__(self, fun):
self.buffer = ""
... | python | def output_redirect(stdout, stderr):
"""
thread safe redirect of stdout and stderr
:param stdout:
:param stderr:
:return:
"""
import sys
import threading
if not redirect:
originals = (sys.stdout.write, sys.stderr.write)
class Logger:
def __init__(self, fun):
self.buffer = ""
... | [
"def",
"output_redirect",
"(",
"stdout",
",",
"stderr",
")",
":",
"import",
"sys",
"import",
"threading",
"if",
"not",
"redirect",
":",
"originals",
"=",
"(",
"sys",
".",
"stdout",
".",
"write",
",",
"sys",
".",
"stderr",
".",
"write",
")",
"class",
"L... | thread safe redirect of stdout and stderr
:param stdout:
:param stderr:
:return: | [
"thread",
"safe",
"redirect",
"of",
"stdout",
"and",
"stderr",
":",
"param",
"stdout",
":",
":",
"param",
"stderr",
":",
":",
"return",
":"
] | b9205127f3736eb6ebbf6bb2960c4bbb747142b7 | https://github.com/rmst/chi/blob/b9205127f3736eb6ebbf6bb2960c4bbb747142b7/chi/util.py#L34-L100 | train | thread safe redirect of stdout and stderr |
druids/django-chamber | chamber/utils/__init__.py | get_class_method | def get_class_method(cls_or_inst, method_name):
"""
Returns a method from a given class or instance. When the method doest not exist, it returns `None`. Also works with
properties and cached properties.
"""
cls = cls_or_inst if isinstance(cls_or_inst, type) else cls_or_inst.__class__
meth = geta... | python | def get_class_method(cls_or_inst, method_name):
"""
Returns a method from a given class or instance. When the method doest not exist, it returns `None`. Also works with
properties and cached properties.
"""
cls = cls_or_inst if isinstance(cls_or_inst, type) else cls_or_inst.__class__
meth = geta... | [
"def",
"get_class_method",
"(",
"cls_or_inst",
",",
"method_name",
")",
":",
"cls",
"=",
"cls_or_inst",
"if",
"isinstance",
"(",
"cls_or_inst",
",",
"type",
")",
"else",
"cls_or_inst",
".",
"__class__",
"meth",
"=",
"getattr",
"(",
"cls",
",",
"method_name",
... | Returns a method from a given class or instance. When the method doest not exist, it returns `None`. Also works with
properties and cached properties. | [
"Returns",
"a",
"method",
"from",
"a",
"given",
"class",
"or",
"instance",
".",
"When",
"the",
"method",
"doest",
"not",
"exist",
"it",
"returns",
"None",
".",
"Also",
"works",
"with",
"properties",
"and",
"cached",
"properties",
"."
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/utils/__init__.py#L17-L28 | train | Returns a method from a given class or instance. |
guaix-ucm/numina | numina/frame/combine.py | combine | def combine(method, images, masks=None, dtype=None,
region=None, zeros=None, scales=None, weights=None,
include_variance=True, datamodel=None, method_name=""):
"""Combine HDUList objects using algorithm 'method'"""
import numina.datamodel
nimages = len(images)
# processing mas... | python | def combine(method, images, masks=None, dtype=None,
region=None, zeros=None, scales=None, weights=None,
include_variance=True, datamodel=None, method_name=""):
"""Combine HDUList objects using algorithm 'method'"""
import numina.datamodel
nimages = len(images)
# processing mas... | [
"def",
"combine",
"(",
"method",
",",
"images",
",",
"masks",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"region",
"=",
"None",
",",
"zeros",
"=",
"None",
",",
"scales",
"=",
"None",
",",
"weights",
"=",
"None",
",",
"include_variance",
"=",
"True"... | Combine HDUList objects using algorithm 'method | [
"Combine",
"HDUList",
"objects",
"using",
"algorithm",
"method"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/frame/combine.py#L86-L181 | train | Combine HDUList objects using algorithm method. |
guaix-ucm/numina | numina/frame/combine.py | manage_fits | def manage_fits(list_of_frame):
"""Manage a list of FITS resources"""
import astropy.io.fits as fits
import numina.types.dataframe as df
refs = []
for frame in list_of_frame:
if isinstance(frame, str):
ref = fits.open(frame)
refs.append(ref)
elif isinstance(... | python | def manage_fits(list_of_frame):
"""Manage a list of FITS resources"""
import astropy.io.fits as fits
import numina.types.dataframe as df
refs = []
for frame in list_of_frame:
if isinstance(frame, str):
ref = fits.open(frame)
refs.append(ref)
elif isinstance(... | [
"def",
"manage_fits",
"(",
"list_of_frame",
")",
":",
"import",
"astropy",
".",
"io",
".",
"fits",
"as",
"fits",
"import",
"numina",
".",
"types",
".",
"dataframe",
"as",
"df",
"refs",
"=",
"[",
"]",
"for",
"frame",
"in",
"list_of_frame",
":",
"if",
"i... | Manage a list of FITS resources | [
"Manage",
"a",
"list",
"of",
"FITS",
"resources"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/frame/combine.py#L185-L208 | train | Manage a list of FITS resources |
guaix-ucm/numina | numina/types/linescatalog.py | LinesCatalog.extract_db_info | def extract_db_info(self, obj, keys):
"""Extract metadata from serialized file"""
objl = self.convert(obj)
result = super(LinesCatalog, self).extract_db_info(objl, keys)
result['tags'] = {}
result['type'] = 'LinesCatalog'
result['uuid'] = str(uuid.uuid1())
resu... | python | def extract_db_info(self, obj, keys):
"""Extract metadata from serialized file"""
objl = self.convert(obj)
result = super(LinesCatalog, self).extract_db_info(objl, keys)
result['tags'] = {}
result['type'] = 'LinesCatalog'
result['uuid'] = str(uuid.uuid1())
resu... | [
"def",
"extract_db_info",
"(",
"self",
",",
"obj",
",",
"keys",
")",
":",
"objl",
"=",
"self",
".",
"convert",
"(",
"obj",
")",
"result",
"=",
"super",
"(",
"LinesCatalog",
",",
"self",
")",
".",
"extract_db_info",
"(",
"objl",
",",
"keys",
")",
"res... | Extract metadata from serialized file | [
"Extract",
"metadata",
"from",
"serialized",
"file"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/types/linescatalog.py#L34-L48 | train | Extract metadata from serialized file |
guaix-ucm/numina | numina/array/display/logging_from_debugplot.py | logging_from_debugplot | def logging_from_debugplot(debugplot):
"""Set debugging level based on debugplot value.
Parameters
----------
debugplot : int
Debugging level for messages and plots. For details see
'numina.array.display.pause_debugplot.py'.
"""
if isinstance(debugplot, int):
if... | python | def logging_from_debugplot(debugplot):
"""Set debugging level based on debugplot value.
Parameters
----------
debugplot : int
Debugging level for messages and plots. For details see
'numina.array.display.pause_debugplot.py'.
"""
if isinstance(debugplot, int):
if... | [
"def",
"logging_from_debugplot",
"(",
"debugplot",
")",
":",
"if",
"isinstance",
"(",
"debugplot",
",",
"int",
")",
":",
"if",
"abs",
"(",
"debugplot",
")",
">=",
"10",
":",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"DEBUG",
")",
... | Set debugging level based on debugplot value.
Parameters
----------
debugplot : int
Debugging level for messages and plots. For details see
'numina.array.display.pause_debugplot.py'. | [
"Set",
"debugging",
"level",
"based",
"on",
"debugplot",
"value",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/logging_from_debugplot.py#L26-L42 | train | Set debugging level based on debugplot value. |
guaix-ucm/numina | numina/tools/r6_insert_keyword.py | add_key_val | def add_key_val(keyname, keyval, keytype, filename, extnum):
"""Add/replace FITS key
Add/replace the key keyname with value keyval of type keytype in filename.
Parameters:
----------
keyname : str
FITS Keyword name.
keyval : str
FITS keyword value.
keytype: str
FITS... | python | def add_key_val(keyname, keyval, keytype, filename, extnum):
"""Add/replace FITS key
Add/replace the key keyname with value keyval of type keytype in filename.
Parameters:
----------
keyname : str
FITS Keyword name.
keyval : str
FITS keyword value.
keytype: str
FITS... | [
"def",
"add_key_val",
"(",
"keyname",
",",
"keyval",
",",
"keytype",
",",
"filename",
",",
"extnum",
")",
":",
"funtype",
"=",
"{",
"'int'",
":",
"int",
",",
"'float'",
":",
"float",
",",
"'str'",
":",
"str",
",",
"'bool'",
":",
"bool",
"}",
"if",
... | Add/replace FITS key
Add/replace the key keyname with value keyval of type keytype in filename.
Parameters:
----------
keyname : str
FITS Keyword name.
keyval : str
FITS keyword value.
keytype: str
FITS keyword type: int, float, str or bool.
filaname : str
F... | [
"Add",
"/",
"replace",
"FITS",
"key"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/tools/r6_insert_keyword.py#L8-L34 | train | Add the key keyname with value keyval of type keytype in filename. |
guaix-ucm/numina | numina/array/display/ximplot.py | ximplot | def ximplot(ycut, title=None, show=True, plot_bbox=(0, 0),
geometry=(0, 0, 640, 480), tight_layout=True,
debugplot=None):
"""Auxiliary function to display 1d plot.
Parameters
----------
ycut : 1d numpy array, float
Array to be displayed.
title : string
Plot t... | python | def ximplot(ycut, title=None, show=True, plot_bbox=(0, 0),
geometry=(0, 0, 640, 480), tight_layout=True,
debugplot=None):
"""Auxiliary function to display 1d plot.
Parameters
----------
ycut : 1d numpy array, float
Array to be displayed.
title : string
Plot t... | [
"def",
"ximplot",
"(",
"ycut",
",",
"title",
"=",
"None",
",",
"show",
"=",
"True",
",",
"plot_bbox",
"=",
"(",
"0",
",",
"0",
")",
",",
"geometry",
"=",
"(",
"0",
",",
"0",
",",
"640",
",",
"480",
")",
",",
"tight_layout",
"=",
"True",
",",
... | Auxiliary function to display 1d plot.
Parameters
----------
ycut : 1d numpy array, float
Array to be displayed.
title : string
Plot title.
show : bool
If True, the function shows the displayed image. Otherwise
plt.show() is expected to be executed outside.
plot_... | [
"Auxiliary",
"function",
"to",
"display",
"1d",
"plot",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/ximplot.py#L19-L112 | train | Auxiliary function to display 1d plot. |
guaix-ucm/numina | numina/core/taggers.py | get_tags_from_full_ob | def get_tags_from_full_ob(ob, reqtags=None):
"""
Parameters
----------
ob (ObservationResult): Observation result
reqtags (dict): Keywords
Returns
-------
A dictionary
"""
# each instrument should have one
# perhaps each mode...
files = ob.frames
cfiles = ob.childre... | python | def get_tags_from_full_ob(ob, reqtags=None):
"""
Parameters
----------
ob (ObservationResult): Observation result
reqtags (dict): Keywords
Returns
-------
A dictionary
"""
# each instrument should have one
# perhaps each mode...
files = ob.frames
cfiles = ob.childre... | [
"def",
"get_tags_from_full_ob",
"(",
"ob",
",",
"reqtags",
"=",
"None",
")",
":",
"# each instrument should have one",
"# perhaps each mode...",
"files",
"=",
"ob",
".",
"frames",
"cfiles",
"=",
"ob",
".",
"children",
"alltags",
"=",
"{",
"}",
"if",
"reqtags",
... | Parameters
----------
ob (ObservationResult): Observation result
reqtags (dict): Keywords
Returns
-------
A dictionary | [
"Parameters",
"----------",
"ob",
"(",
"ObservationResult",
")",
":",
"Observation",
"result",
"reqtags",
"(",
"dict",
")",
":",
"Keywords"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/taggers.py#L13-L65 | train | Returns a dictionary of all tags from an observation result. |
guaix-ucm/numina | numina/array/wavecalib/resample.py | oversample1d | def oversample1d(sp, crval1, cdelt1, oversampling=1, debugplot=0):
"""Oversample spectrum.
Parameters
----------
sp : numpy array
Spectrum to be oversampled.
crval1 : float
Abscissae of the center of the first pixel in the original
spectrum 'sp'.
cdelt1 : float
A... | python | def oversample1d(sp, crval1, cdelt1, oversampling=1, debugplot=0):
"""Oversample spectrum.
Parameters
----------
sp : numpy array
Spectrum to be oversampled.
crval1 : float
Abscissae of the center of the first pixel in the original
spectrum 'sp'.
cdelt1 : float
A... | [
"def",
"oversample1d",
"(",
"sp",
",",
"crval1",
",",
"cdelt1",
",",
"oversampling",
"=",
"1",
",",
"debugplot",
"=",
"0",
")",
":",
"if",
"sp",
".",
"ndim",
"!=",
"1",
":",
"raise",
"ValueError",
"(",
"'Unexpected array dimensions'",
")",
"naxis1",
"=",... | Oversample spectrum.
Parameters
----------
sp : numpy array
Spectrum to be oversampled.
crval1 : float
Abscissae of the center of the first pixel in the original
spectrum 'sp'.
cdelt1 : float
Abscissae increment corresponding to 1 pixel in the original
spectr... | [
"Oversample",
"spectrum",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/resample.py#L22-L78 | train | Oversample spectrum sp into 1D array. |
guaix-ucm/numina | numina/array/wavecalib/resample.py | shiftx_image2d_flux | def shiftx_image2d_flux(image2d_orig, xoffset):
"""Resample 2D image using a shift in the x direction (flux is preserved).
Parameters
----------
image2d_orig : numpy array
2D image to be resampled.
xoffset : float
Offset to be applied.
Returns
-------
image2d_resampled ... | python | def shiftx_image2d_flux(image2d_orig, xoffset):
"""Resample 2D image using a shift in the x direction (flux is preserved).
Parameters
----------
image2d_orig : numpy array
2D image to be resampled.
xoffset : float
Offset to be applied.
Returns
-------
image2d_resampled ... | [
"def",
"shiftx_image2d_flux",
"(",
"image2d_orig",
",",
"xoffset",
")",
":",
"if",
"image2d_orig",
".",
"ndim",
"==",
"1",
":",
"naxis1",
"=",
"image2d_orig",
".",
"size",
"elif",
"image2d_orig",
".",
"ndim",
"==",
"2",
":",
"naxis2",
",",
"naxis1",
"=",
... | Resample 2D image using a shift in the x direction (flux is preserved).
Parameters
----------
image2d_orig : numpy array
2D image to be resampled.
xoffset : float
Offset to be applied.
Returns
-------
image2d_resampled : numpy array
Resampled 2D image. | [
"Resample",
"2D",
"image",
"using",
"a",
"shift",
"in",
"the",
"x",
"direction",
"(",
"flux",
"is",
"preserved",
")",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/resample.py#L102-L132 | train | Resample 2D image using a shift in the x direction. |
guaix-ucm/numina | numina/array/wavecalib/resample.py | resample_image2d_flux | def resample_image2d_flux(image2d_orig,
naxis1, cdelt1, crval1, crpix1, coeff):
"""Resample a 1D/2D image using NAXIS1, CDELT1, CRVAL1, and CRPIX1.
The same NAXIS1, CDELT1, CRVAL1, and CRPIX1 are employed for all
the scans (rows) of the original 'image2d'. The wavelength
calib... | python | def resample_image2d_flux(image2d_orig,
naxis1, cdelt1, crval1, crpix1, coeff):
"""Resample a 1D/2D image using NAXIS1, CDELT1, CRVAL1, and CRPIX1.
The same NAXIS1, CDELT1, CRVAL1, and CRPIX1 are employed for all
the scans (rows) of the original 'image2d'. The wavelength
calib... | [
"def",
"resample_image2d_flux",
"(",
"image2d_orig",
",",
"naxis1",
",",
"cdelt1",
",",
"crval1",
",",
"crpix1",
",",
"coeff",
")",
":",
"# duplicate input array, avoiding problems when using as input",
"# 1d numpy arrays with shape (nchan,) instead of a 2d numpy",
"# array with ... | Resample a 1D/2D image using NAXIS1, CDELT1, CRVAL1, and CRPIX1.
The same NAXIS1, CDELT1, CRVAL1, and CRPIX1 are employed for all
the scans (rows) of the original 'image2d'. The wavelength
calibrated output image has dimensions NAXIS1 * NSCAN, where NSCAN
is the original number of scans (rows) of the o... | [
"Resample",
"a",
"1D",
"/",
"2D",
"image",
"using",
"NAXIS1",
"CDELT1",
"CRVAL1",
"and",
"CRPIX1",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/resample.py#L135-L212 | train | Resample a 1D or 2D image using NAXIS1 CDELT1 CRVAL1 and CRPIX1. |
guaix-ucm/numina | numina/array/wavecalib/resample.py | map_borders | def map_borders(wls):
"""Compute borders of pixels for interpolation.
The border of the pixel is assumed to be midway of the wls
"""
midpt_wl = 0.5 * (wls[1:] + wls[:-1])
all_borders = np.zeros((wls.shape[0] + 1,))
all_borders[1:-1] = midpt_wl
all_borders[0] = 2 * wls[0] - midpt_wl[0]
a... | python | def map_borders(wls):
"""Compute borders of pixels for interpolation.
The border of the pixel is assumed to be midway of the wls
"""
midpt_wl = 0.5 * (wls[1:] + wls[:-1])
all_borders = np.zeros((wls.shape[0] + 1,))
all_borders[1:-1] = midpt_wl
all_borders[0] = 2 * wls[0] - midpt_wl[0]
a... | [
"def",
"map_borders",
"(",
"wls",
")",
":",
"midpt_wl",
"=",
"0.5",
"*",
"(",
"wls",
"[",
"1",
":",
"]",
"+",
"wls",
"[",
":",
"-",
"1",
"]",
")",
"all_borders",
"=",
"np",
".",
"zeros",
"(",
"(",
"wls",
".",
"shape",
"[",
"0",
"]",
"+",
"1... | Compute borders of pixels for interpolation.
The border of the pixel is assumed to be midway of the wls | [
"Compute",
"borders",
"of",
"pixels",
"for",
"interpolation",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/resample.py#L215-L225 | train | Compute borders of pixels for interpolation. |
guaix-ucm/numina | numina/util/objimport.py | import_object | def import_object(path):
"""Import an object given its fully qualified name."""
spl = path.split('.')
if len(spl) == 1:
return importlib.import_module(path)
# avoid last part for the moment
cls = spl[-1]
mods = '.'.join(spl[:-1])
mm = importlib.import_module(mods)
# try to get t... | python | def import_object(path):
"""Import an object given its fully qualified name."""
spl = path.split('.')
if len(spl) == 1:
return importlib.import_module(path)
# avoid last part for the moment
cls = spl[-1]
mods = '.'.join(spl[:-1])
mm = importlib.import_module(mods)
# try to get t... | [
"def",
"import_object",
"(",
"path",
")",
":",
"spl",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"spl",
")",
"==",
"1",
":",
"return",
"importlib",
".",
"import_module",
"(",
"path",
")",
"# avoid last part for the moment",
"cls",
"=",... | Import an object given its fully qualified name. | [
"Import",
"an",
"object",
"given",
"its",
"fully",
"qualified",
"name",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/util/objimport.py#L17-L36 | train | Import an object given its fully qualified name. |
ckan/losser | losser/cli.py | make_parser | def make_parser(add_help=True, exclude_args=None):
"""Return an argparse.ArgumentParser object with losser's arguments.
Other projects can call this to get an ArgumentParser with losser's
command line interface to use as a parent parser for their own parser.
For example::
parent_parser = losse... | python | def make_parser(add_help=True, exclude_args=None):
"""Return an argparse.ArgumentParser object with losser's arguments.
Other projects can call this to get an ArgumentParser with losser's
command line interface to use as a parent parser for their own parser.
For example::
parent_parser = losse... | [
"def",
"make_parser",
"(",
"add_help",
"=",
"True",
",",
"exclude_args",
"=",
"None",
")",
":",
"if",
"exclude_args",
"is",
"None",
":",
"exclude_args",
"=",
"[",
"]",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"add_help",
"=",
"add_help",
")",... | Return an argparse.ArgumentParser object with losser's arguments.
Other projects can call this to get an ArgumentParser with losser's
command line interface to use as a parent parser for their own parser.
For example::
parent_parser = losser.cli.make_parser(
add_help=False, exclude_arg... | [
"Return",
"an",
"argparse",
".",
"ArgumentParser",
"object",
"with",
"losser",
"s",
"arguments",
"."
] | fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f | https://github.com/ckan/losser/blob/fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f/losser/cli.py#L153-L211 | train | Return an ArgumentParser with losser s command line interface. |
ckan/losser | losser/cli.py | parse | def parse(parser=None, args=None):
"""Parse the command line arguments, return an argparse namespace object.
Other projects can call this function and pass in their own ArgumentParser
object (which should have a losser ArgumentParser from make_parser() above
as parent) to do the argument parsing and ge... | python | def parse(parser=None, args=None):
"""Parse the command line arguments, return an argparse namespace object.
Other projects can call this function and pass in their own ArgumentParser
object (which should have a losser ArgumentParser from make_parser() above
as parent) to do the argument parsing and ge... | [
"def",
"parse",
"(",
"parser",
"=",
"None",
",",
"args",
"=",
"None",
")",
":",
"if",
"not",
"parser",
":",
"parser",
"=",
"make_parser",
"(",
")",
"try",
":",
"parsed_args",
"=",
"parser",
".",
"parse_args",
"(",
"args",
")",
"except",
"SystemExit",
... | Parse the command line arguments, return an argparse namespace object.
Other projects can call this function and pass in their own ArgumentParser
object (which should have a losser ArgumentParser from make_parser() above
as parent) to do the argument parsing and get the result (this does some
custom po... | [
"Parse",
"the",
"command",
"line",
"arguments",
"return",
"an",
"argparse",
"namespace",
"object",
"."
] | fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f | https://github.com/ckan/losser/blob/fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f/losser/cli.py#L214-L282 | train | Parse the command line arguments and return an argparse namespace object. |
ckan/losser | losser/cli.py | do | def do(parser=None, args=None, in_=None, table_function=None):
"""Read command-line args and stdin, return the result.
Read the command line arguments and the input data from stdin, pass them to
the table() function to do the filter and transform, and return the string
of CSV- or JSON-formatted text th... | python | def do(parser=None, args=None, in_=None, table_function=None):
"""Read command-line args and stdin, return the result.
Read the command line arguments and the input data from stdin, pass them to
the table() function to do the filter and transform, and return the string
of CSV- or JSON-formatted text th... | [
"def",
"do",
"(",
"parser",
"=",
"None",
",",
"args",
"=",
"None",
",",
"in_",
"=",
"None",
",",
"table_function",
"=",
"None",
")",
":",
"in_",
"=",
"in_",
"or",
"sys",
".",
"stdin",
"table_function",
"=",
"table_function",
"or",
"losser",
".",
"tab... | Read command-line args and stdin, return the result.
Read the command line arguments and the input data from stdin, pass them to
the table() function to do the filter and transform, and return the string
of CSV- or JSON-formatted text that should be written to stdout.
Note that although the output dat... | [
"Read",
"command",
"-",
"line",
"args",
"and",
"stdin",
"return",
"the",
"result",
"."
] | fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f | https://github.com/ckan/losser/blob/fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f/losser/cli.py#L285-L314 | train | Parse command - line arguments and stdin and return the result. |
ckan/losser | losser/cli.py | main | def main():
"""Call do() and if it raises an exception then sys.exit() appropriately.
This makes sure that any usage and error messages are printed correctly,
and that the exit code is right.
do() itself doesn't call sys.exit() because we want it to be callable from
tests that check that it raises... | python | def main():
"""Call do() and if it raises an exception then sys.exit() appropriately.
This makes sure that any usage and error messages are printed correctly,
and that the exit code is right.
do() itself doesn't call sys.exit() because we want it to be callable from
tests that check that it raises... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"make_parser",
"(",
")",
"try",
":",
"output",
"=",
"do",
"(",
"parser",
"=",
"parser",
")",
"except",
"CommandLineExit",
"as",
"err",
":",
"sys",
".",
"exit",
"(",
"err",
".",
"code",
")",
"except",
"Co... | Call do() and if it raises an exception then sys.exit() appropriately.
This makes sure that any usage and error messages are printed correctly,
and that the exit code is right.
do() itself doesn't call sys.exit() because we want it to be callable from
tests that check that it raises the right exceptio... | [
"Call",
"do",
"()",
"and",
"if",
"it",
"raises",
"an",
"exception",
"then",
"sys",
".",
"exit",
"()",
"appropriately",
"."
] | fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f | https://github.com/ckan/losser/blob/fd0832d9fa93cabe9ce9a9153dc923f2cf39cb5f/losser/cli.py#L317-L336 | train | This is the main function for the main function of the main function. |
guaix-ucm/numina | numina/tools/r6_imcombine.py | compute_abba_result | def compute_abba_result(list_of_fileinfo, outfile, extnum=0, noheader=False,
save_partial=False, debugplot=0):
"""Compute A-B-(B-A).
Note that 'list_of_fileinfo' must contain 4 file names.
Parameters
----------
list_of_fileinfo : list of strings
List of the for file... | python | def compute_abba_result(list_of_fileinfo, outfile, extnum=0, noheader=False,
save_partial=False, debugplot=0):
"""Compute A-B-(B-A).
Note that 'list_of_fileinfo' must contain 4 file names.
Parameters
----------
list_of_fileinfo : list of strings
List of the for file... | [
"def",
"compute_abba_result",
"(",
"list_of_fileinfo",
",",
"outfile",
",",
"extnum",
"=",
"0",
",",
"noheader",
"=",
"False",
",",
"save_partial",
"=",
"False",
",",
"debugplot",
"=",
"0",
")",
":",
"# check number of images",
"if",
"len",
"(",
"list_of_filei... | Compute A-B-(B-A).
Note that 'list_of_fileinfo' must contain 4 file names.
Parameters
----------
list_of_fileinfo : list of strings
List of the for files corresponding to the ABBA observation.
outfile : string
Base name for the output FITS file name.
extnum : int
Extens... | [
"Compute",
"A",
"-",
"B",
"-",
"(",
"B",
"-",
"A",
")",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/tools/r6_imcombine.py#L15-L120 | train | Compute A - B - A result. |
guaix-ucm/numina | numina/instrument/simulation/atmosphere.py | generate_gaussian_profile | def generate_gaussian_profile(seeing_fwhm):
"""Generate a normalized Gaussian profile from its FWHM"""
FWHM_G = 2 * math.sqrt(2 * math.log(2))
sigma = seeing_fwhm / FWHM_G
amplitude = 1.0 / (2 * math.pi * sigma * sigma)
seeing_model = Gaussian2D(amplitude=amplitude,
x_m... | python | def generate_gaussian_profile(seeing_fwhm):
"""Generate a normalized Gaussian profile from its FWHM"""
FWHM_G = 2 * math.sqrt(2 * math.log(2))
sigma = seeing_fwhm / FWHM_G
amplitude = 1.0 / (2 * math.pi * sigma * sigma)
seeing_model = Gaussian2D(amplitude=amplitude,
x_m... | [
"def",
"generate_gaussian_profile",
"(",
"seeing_fwhm",
")",
":",
"FWHM_G",
"=",
"2",
"*",
"math",
".",
"sqrt",
"(",
"2",
"*",
"math",
".",
"log",
"(",
"2",
")",
")",
"sigma",
"=",
"seeing_fwhm",
"/",
"FWHM_G",
"amplitude",
"=",
"1.0",
"/",
"(",
"2",... | Generate a normalized Gaussian profile from its FWHM | [
"Generate",
"a",
"normalized",
"Gaussian",
"profile",
"from",
"its",
"FWHM"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/instrument/simulation/atmosphere.py#L65-L75 | train | Generate a normalized Gaussian profile from its FWHM |
guaix-ucm/numina | numina/instrument/simulation/atmosphere.py | generate_moffat_profile | def generate_moffat_profile(seeing_fwhm, alpha):
"""Generate a normalized Moffat profile from its FWHM and alpha"""
scale = 2 * math.sqrt(2**(1.0 / alpha) - 1)
gamma = seeing_fwhm / scale
amplitude = 1.0 / math.pi * (alpha - 1) / gamma**2
seeing_model = Moffat2D(amplitude=amplitude,
... | python | def generate_moffat_profile(seeing_fwhm, alpha):
"""Generate a normalized Moffat profile from its FWHM and alpha"""
scale = 2 * math.sqrt(2**(1.0 / alpha) - 1)
gamma = seeing_fwhm / scale
amplitude = 1.0 / math.pi * (alpha - 1) / gamma**2
seeing_model = Moffat2D(amplitude=amplitude,
... | [
"def",
"generate_moffat_profile",
"(",
"seeing_fwhm",
",",
"alpha",
")",
":",
"scale",
"=",
"2",
"*",
"math",
".",
"sqrt",
"(",
"2",
"**",
"(",
"1.0",
"/",
"alpha",
")",
"-",
"1",
")",
"gamma",
"=",
"seeing_fwhm",
"/",
"scale",
"amplitude",
"=",
"1.0... | Generate a normalized Moffat profile from its FWHM and alpha | [
"Generate",
"a",
"normalized",
"Moffat",
"profile",
"from",
"its",
"FWHM",
"and",
"alpha"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/instrument/simulation/atmosphere.py#L78-L89 | train | Generate a normalized Moffat profile from its FWHM and alpha |
druids/django-chamber | chamber/models/__init__.py | field_to_dict | def field_to_dict(field, instance):
"""
Converts a model field to a dictionary
"""
# avoid a circular import
from django.db.models.fields.related import ManyToManyField
return (many_to_many_field_to_dict(field, instance) if isinstance(field, ManyToManyField)
else field.value_from_ob... | python | def field_to_dict(field, instance):
"""
Converts a model field to a dictionary
"""
# avoid a circular import
from django.db.models.fields.related import ManyToManyField
return (many_to_many_field_to_dict(field, instance) if isinstance(field, ManyToManyField)
else field.value_from_ob... | [
"def",
"field_to_dict",
"(",
"field",
",",
"instance",
")",
":",
"# avoid a circular import",
"from",
"django",
".",
"db",
".",
"models",
".",
"fields",
".",
"related",
"import",
"ManyToManyField",
"return",
"(",
"many_to_many_field_to_dict",
"(",
"field",
",",
... | Converts a model field to a dictionary | [
"Converts",
"a",
"model",
"field",
"to",
"a",
"dictionary"
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/models/__init__.py#L37-L45 | train | Converts a model field to a dictionary |
druids/django-chamber | chamber/models/__init__.py | model_to_dict | def model_to_dict(instance, fields=None, exclude=None):
"""
The same implementation as django model_to_dict but editable fields are allowed
"""
return {
field.name: field_to_dict(field, instance)
for field in chain(instance._meta.concrete_fields, instance._meta.many_to_many) # pylint: ... | python | def model_to_dict(instance, fields=None, exclude=None):
"""
The same implementation as django model_to_dict but editable fields are allowed
"""
return {
field.name: field_to_dict(field, instance)
for field in chain(instance._meta.concrete_fields, instance._meta.many_to_many) # pylint: ... | [
"def",
"model_to_dict",
"(",
"instance",
",",
"fields",
"=",
"None",
",",
"exclude",
"=",
"None",
")",
":",
"return",
"{",
"field",
".",
"name",
":",
"field_to_dict",
"(",
"field",
",",
"instance",
")",
"for",
"field",
"in",
"chain",
"(",
"instance",
"... | The same implementation as django model_to_dict but editable fields are allowed | [
"The",
"same",
"implementation",
"as",
"django",
"model_to_dict",
"but",
"editable",
"fields",
"are",
"allowed"
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/models/__init__.py#L70-L79 | train | Returns a dictionary representation of the given model instance. |
druids/django-chamber | chamber/models/__init__.py | SmartQuerySet.fast_distinct | def fast_distinct(self):
"""
Because standard distinct used on the all fields are very slow and works only with PostgreSQL database
this method provides alternative to the standard distinct method.
:return: qs with unique objects
"""
return self.model.objects.filter(pk__i... | python | def fast_distinct(self):
"""
Because standard distinct used on the all fields are very slow and works only with PostgreSQL database
this method provides alternative to the standard distinct method.
:return: qs with unique objects
"""
return self.model.objects.filter(pk__i... | [
"def",
"fast_distinct",
"(",
"self",
")",
":",
"return",
"self",
".",
"model",
".",
"objects",
".",
"filter",
"(",
"pk__in",
"=",
"self",
".",
"values_list",
"(",
"'pk'",
",",
"flat",
"=",
"True",
")",
")"
] | Because standard distinct used on the all fields are very slow and works only with PostgreSQL database
this method provides alternative to the standard distinct method.
:return: qs with unique objects | [
"Because",
"standard",
"distinct",
"used",
"on",
"the",
"all",
"fields",
"are",
"very",
"slow",
"and",
"works",
"only",
"with",
"PostgreSQL",
"database",
"this",
"method",
"provides",
"alternative",
"to",
"the",
"standard",
"distinct",
"method",
".",
":",
"ret... | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/models/__init__.py#L250-L256 | train | This method is used to fastly select unique objects from the database. |
druids/django-chamber | chamber/models/__init__.py | SmartQuerySet.change_and_save | def change_and_save(self, update_only_changed_fields=False, **changed_fields):
"""
Changes a given `changed_fields` on each object in the queryset, saves objects
and returns the changed objects in the queryset.
"""
bulk_change_and_save(self, update_only_changed_fields=update_only... | python | def change_and_save(self, update_only_changed_fields=False, **changed_fields):
"""
Changes a given `changed_fields` on each object in the queryset, saves objects
and returns the changed objects in the queryset.
"""
bulk_change_and_save(self, update_only_changed_fields=update_only... | [
"def",
"change_and_save",
"(",
"self",
",",
"update_only_changed_fields",
"=",
"False",
",",
"*",
"*",
"changed_fields",
")",
":",
"bulk_change_and_save",
"(",
"self",
",",
"update_only_changed_fields",
"=",
"update_only_changed_fields",
",",
"*",
"*",
"changed_fields... | Changes a given `changed_fields` on each object in the queryset, saves objects
and returns the changed objects in the queryset. | [
"Changes",
"a",
"given",
"changed_fields",
"on",
"each",
"object",
"in",
"the",
"queryset",
"saves",
"objects",
"and",
"returns",
"the",
"changed",
"objects",
"in",
"the",
"queryset",
"."
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/models/__init__.py#L258-L264 | train | Changes a given changed_fields on each object in the queryset saves the changed objects on each object in the queryset and returns the changed objects in the queryset. |
druids/django-chamber | chamber/models/__init__.py | SmartModel.change_and_save | def change_and_save(self, update_only_changed_fields=False, **changed_fields):
"""
Changes a given `changed_fields` on this object, saves it and returns itself.
:param update_only_changed_fields: only changed fields will be updated in the database.
:param changed_fields: fields to change... | python | def change_and_save(self, update_only_changed_fields=False, **changed_fields):
"""
Changes a given `changed_fields` on this object, saves it and returns itself.
:param update_only_changed_fields: only changed fields will be updated in the database.
:param changed_fields: fields to change... | [
"def",
"change_and_save",
"(",
"self",
",",
"update_only_changed_fields",
"=",
"False",
",",
"*",
"*",
"changed_fields",
")",
":",
"change_and_save",
"(",
"self",
",",
"update_only_changed_fields",
"=",
"update_only_changed_fields",
",",
"*",
"*",
"changed_fields",
... | Changes a given `changed_fields` on this object, saves it and returns itself.
:param update_only_changed_fields: only changed fields will be updated in the database.
:param changed_fields: fields to change.
:return: self | [
"Changes",
"a",
"given",
"changed_fields",
"on",
"this",
"object",
"saves",
"it",
"and",
"returns",
"itself",
".",
":",
"param",
"update_only_changed_fields",
":",
"only",
"changed",
"fields",
"will",
"be",
"updated",
"in",
"the",
"database",
".",
":",
"param"... | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/models/__init__.py#L475-L483 | train | Changes a given changed_fields on this object saves it and returns itself. |
guaix-ucm/numina | numina/tools/r6_replace_image.py | insert_image | def insert_image(filename, extnum_filename, auximage, extnum_auximage):
"""Replace image in filename by another image (same size) in newimage.
Parameters
----------
filename : str
File name where the new image will be inserted.
extnum_filename : int
Extension number in filename wher... | python | def insert_image(filename, extnum_filename, auximage, extnum_auximage):
"""Replace image in filename by another image (same size) in newimage.
Parameters
----------
filename : str
File name where the new image will be inserted.
extnum_filename : int
Extension number in filename wher... | [
"def",
"insert_image",
"(",
"filename",
",",
"extnum_filename",
",",
"auximage",
",",
"extnum_auximage",
")",
":",
"# read the new image",
"with",
"fits",
".",
"open",
"(",
"auximage",
")",
"as",
"hdulist",
":",
"newimage",
"=",
"hdulist",
"[",
"extnum_auximage"... | Replace image in filename by another image (same size) in newimage.
Parameters
----------
filename : str
File name where the new image will be inserted.
extnum_filename : int
Extension number in filename where the new image will be
inserted. Note that the first extension is 1 (a... | [
"Replace",
"image",
"in",
"filename",
"by",
"another",
"image",
"(",
"same",
"size",
")",
"in",
"newimage",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/tools/r6_replace_image.py#L8-L41 | train | Insert an image in filename by another image in auximage. |
guaix-ucm/numina | numina/array/bbox.py | BoundingBox.extent | def extent(self):
"""Helper for matplotlib imshow"""
return (
self.intervals[1].pix1 - 0.5,
self.intervals[1].pix2 - 0.5,
self.intervals[0].pix1 - 0.5,
self.intervals[0].pix2 - 0.5,
) | python | def extent(self):
"""Helper for matplotlib imshow"""
return (
self.intervals[1].pix1 - 0.5,
self.intervals[1].pix2 - 0.5,
self.intervals[0].pix1 - 0.5,
self.intervals[0].pix2 - 0.5,
) | [
"def",
"extent",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"intervals",
"[",
"1",
"]",
".",
"pix1",
"-",
"0.5",
",",
"self",
".",
"intervals",
"[",
"1",
"]",
".",
"pix2",
"-",
"0.5",
",",
"self",
".",
"intervals",
"[",
"0",
"]",
".",
... | Helper for matplotlib imshow | [
"Helper",
"for",
"matplotlib",
"imshow"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/bbox.py#L214-L221 | train | Helper for matplotlib imshow |
guaix-ucm/numina | numina/instrument/components/detector.py | DetectorBase.readout | def readout(self):
"""Readout the detector."""
elec = self.simulate_poisson_variate()
elec_pre = self.saturate(elec)
elec_f = self.pre_readout(elec_pre)
adu_r = self.base_readout(elec_f)
adu_p = self.post_readout(adu_r)
self.clean_up()
return adu_p | python | def readout(self):
"""Readout the detector."""
elec = self.simulate_poisson_variate()
elec_pre = self.saturate(elec)
elec_f = self.pre_readout(elec_pre)
adu_r = self.base_readout(elec_f)
adu_p = self.post_readout(adu_r)
self.clean_up()
return adu_p | [
"def",
"readout",
"(",
"self",
")",
":",
"elec",
"=",
"self",
".",
"simulate_poisson_variate",
"(",
")",
"elec_pre",
"=",
"self",
".",
"saturate",
"(",
"elec",
")",
"elec_f",
"=",
"self",
".",
"pre_readout",
"(",
"elec_pre",
")",
"adu_r",
"=",
"self",
... | Readout the detector. | [
"Readout",
"the",
"detector",
"."
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/instrument/components/detector.py#L94-L109 | train | Readout the detector. |
druids/django-chamber | chamber/multidomains/auth/backends.py | ModelBackend.get_group_permissions | def get_group_permissions(self, user_obj, obj=None):
"""
Returns a set of permission strings that this user has through his/her
groups.
"""
if user_obj.is_anonymous() or obj is not None:
return set()
if not hasattr(user_obj, '_group_perm_cache'):
i... | python | def get_group_permissions(self, user_obj, obj=None):
"""
Returns a set of permission strings that this user has through his/her
groups.
"""
if user_obj.is_anonymous() or obj is not None:
return set()
if not hasattr(user_obj, '_group_perm_cache'):
i... | [
"def",
"get_group_permissions",
"(",
"self",
",",
"user_obj",
",",
"obj",
"=",
"None",
")",
":",
"if",
"user_obj",
".",
"is_anonymous",
"(",
")",
"or",
"obj",
"is",
"not",
"None",
":",
"return",
"set",
"(",
")",
"if",
"not",
"hasattr",
"(",
"user_obj",... | Returns a set of permission strings that this user has through his/her
groups. | [
"Returns",
"a",
"set",
"of",
"permission",
"strings",
"that",
"this",
"user",
"has",
"through",
"his",
"/",
"her",
"groups",
"."
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/multidomains/auth/backends.py#L25-L41 | train | Returns a set of permission strings that this user has through his / her
groups. |
guaix-ucm/numina | numina/util/parser.py | parse_arg_line | def parse_arg_line(fargs):
"""parse limited form of arguments of function
in the form a=1, b='c'
as a dictionary
"""
# Convert to literal dict
fargs = fargs.strip()
if fargs == '':
return {}
pairs = [s.strip() for s in fargs.split(',')]
# find first "="
result = []
... | python | def parse_arg_line(fargs):
"""parse limited form of arguments of function
in the form a=1, b='c'
as a dictionary
"""
# Convert to literal dict
fargs = fargs.strip()
if fargs == '':
return {}
pairs = [s.strip() for s in fargs.split(',')]
# find first "="
result = []
... | [
"def",
"parse_arg_line",
"(",
"fargs",
")",
":",
"# Convert to literal dict",
"fargs",
"=",
"fargs",
".",
"strip",
"(",
")",
"if",
"fargs",
"==",
"''",
":",
"return",
"{",
"}",
"pairs",
"=",
"[",
"s",
".",
"strip",
"(",
")",
"for",
"s",
"in",
"fargs"... | parse limited form of arguments of function
in the form a=1, b='c'
as a dictionary | [
"parse",
"limited",
"form",
"of",
"arguments",
"of",
"function"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/util/parser.py#L27-L54 | train | parse limited form of arguments of function
in the form a = 1 b = c |
druids/django-chamber | chamber/formatters/__init__.py | natural_number_with_currency | def natural_number_with_currency(number, currency, show_decimal_place=True, use_nbsp=True):
"""
Return a given `number` formatter a price for humans.
"""
humanized = '{} {}'.format(
numberformat.format(
number=number,
decimal_sep=',',
decimal_pos=2 if show_dec... | python | def natural_number_with_currency(number, currency, show_decimal_place=True, use_nbsp=True):
"""
Return a given `number` formatter a price for humans.
"""
humanized = '{} {}'.format(
numberformat.format(
number=number,
decimal_sep=',',
decimal_pos=2 if show_dec... | [
"def",
"natural_number_with_currency",
"(",
"number",
",",
"currency",
",",
"show_decimal_place",
"=",
"True",
",",
"use_nbsp",
"=",
"True",
")",
":",
"humanized",
"=",
"'{} {}'",
".",
"format",
"(",
"numberformat",
".",
"format",
"(",
"number",
"=",
"number",... | Return a given `number` formatter a price for humans. | [
"Return",
"a",
"given",
"number",
"formatter",
"a",
"price",
"for",
"humans",
"."
] | eef4169923557e96877a664fa254e8c0814f3f23 | https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/formatters/__init__.py#L6-L21 | train | Return a given number formatted with a currency. |
guaix-ucm/numina | numina/types/frame.py | DataFrameType.convert | def convert(self, obj):
"""Convert"""
# We accept None representing No Image
if obj is None:
return None
elif isinstance(obj, six.string_types):
return DataFrame(filename=obj)
elif isinstance(obj, DataFrame):
return obj
elif isinstance(... | python | def convert(self, obj):
"""Convert"""
# We accept None representing No Image
if obj is None:
return None
elif isinstance(obj, six.string_types):
return DataFrame(filename=obj)
elif isinstance(obj, DataFrame):
return obj
elif isinstance(... | [
"def",
"convert",
"(",
"self",
",",
"obj",
")",
":",
"# We accept None representing No Image",
"if",
"obj",
"is",
"None",
":",
"return",
"None",
"elif",
"isinstance",
"(",
"obj",
",",
"six",
".",
"string_types",
")",
":",
"return",
"DataFrame",
"(",
"filenam... | Convert | [
"Convert"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/types/frame.py#L59-L74 | train | Convert object to DataFrame. |
guaix-ucm/numina | numina/types/frame.py | DataFrameType.validate | def validate(self, value):
"""validate"""
# obj can be None or a DataFrame
if value is None:
return True
else:
try:
with value.open() as hdulist:
self.validate_hdulist(hdulist)
except Exception:
_type... | python | def validate(self, value):
"""validate"""
# obj can be None or a DataFrame
if value is None:
return True
else:
try:
with value.open() as hdulist:
self.validate_hdulist(hdulist)
except Exception:
_type... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"# obj can be None or a DataFrame",
"if",
"value",
"is",
"None",
":",
"return",
"True",
"else",
":",
"try",
":",
"with",
"value",
".",
"open",
"(",
")",
"as",
"hdulist",
":",
"self",
".",
"validate_... | validate | [
"validate"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/types/frame.py#L76-L87 | train | Validate the object. |
guaix-ucm/numina | numina/types/frame.py | DataFrameType.extract_db_info | def extract_db_info(self, obj, keys):
"""Extract tags from serialized file"""
objl = self.convert(obj)
result = super(DataFrameType, self).extract_db_info(objl, keys)
ext = self.datamodel.extractor_map['fits']
if objl:
with objl.open() as hdulist:
fo... | python | def extract_db_info(self, obj, keys):
"""Extract tags from serialized file"""
objl = self.convert(obj)
result = super(DataFrameType, self).extract_db_info(objl, keys)
ext = self.datamodel.extractor_map['fits']
if objl:
with objl.open() as hdulist:
fo... | [
"def",
"extract_db_info",
"(",
"self",
",",
"obj",
",",
"keys",
")",
":",
"objl",
"=",
"self",
".",
"convert",
"(",
"obj",
")",
"result",
"=",
"super",
"(",
"DataFrameType",
",",
"self",
")",
".",
"extract_db_info",
"(",
"objl",
",",
"keys",
")",
"ex... | Extract tags from serialized file | [
"Extract",
"tags",
"from",
"serialized",
"file"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/types/frame.py#L101-L119 | train | Extract tags from serialized file |
guaix-ucm/numina | numina/array/display/iofunctions.py | readc | def readc(prompt, default=None, valid=None, question_mark=True):
"""Return a single character read from keyboard
Parameters
----------
prompt : str
Prompt string.
default : str
Default value.
valid : str
String providing valid characters. If None, all characters are
... | python | def readc(prompt, default=None, valid=None, question_mark=True):
"""Return a single character read from keyboard
Parameters
----------
prompt : str
Prompt string.
default : str
Default value.
valid : str
String providing valid characters. If None, all characters are
... | [
"def",
"readc",
"(",
"prompt",
",",
"default",
"=",
"None",
",",
"valid",
"=",
"None",
",",
"question_mark",
"=",
"True",
")",
":",
"cresult",
"=",
"None",
"# Avoid PyCharm warning",
"# question mark",
"if",
"question_mark",
":",
"cquestion_mark",
"=",
"' ? '"... | Return a single character read from keyboard
Parameters
----------
prompt : str
Prompt string.
default : str
Default value.
valid : str
String providing valid characters. If None, all characters are
valid (default).
question_mark : bool
If True, display q... | [
"Return",
"a",
"single",
"character",
"read",
"from",
"keyboard"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/iofunctions.py#L7-L67 | train | Read a single character from keyboard and return it. |
guaix-ucm/numina | numina/array/display/iofunctions.py | readi | def readi(prompt, default=None, minval=None, maxval=None,
allowed_single_chars=None, question_mark=True):
"""Return integer value read from keyboard
Parameters
----------
prompt : str
Prompt string.
default : integer, str or None
Default value.
minval : integer or Non... | python | def readi(prompt, default=None, minval=None, maxval=None,
allowed_single_chars=None, question_mark=True):
"""Return integer value read from keyboard
Parameters
----------
prompt : str
Prompt string.
default : integer, str or None
Default value.
minval : integer or Non... | [
"def",
"readi",
"(",
"prompt",
",",
"default",
"=",
"None",
",",
"minval",
"=",
"None",
",",
"maxval",
"=",
"None",
",",
"allowed_single_chars",
"=",
"None",
",",
"question_mark",
"=",
"True",
")",
":",
"return",
"read_value",
"(",
"ftype",
"=",
"int",
... | Return integer value read from keyboard
Parameters
----------
prompt : str
Prompt string.
default : integer, str or None
Default value.
minval : integer or None
Mininum allowed value.
maxval : integer or None
Maximum allowed value.
allowed_single_chars : st... | [
"Return",
"integer",
"value",
"read",
"from",
"keyboard"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/iofunctions.py#L70-L102 | train | Read an integer value from keyboard and return it. |
guaix-ucm/numina | numina/array/display/iofunctions.py | readf | def readf(prompt, default=None, minval=None, maxval=None,
allowed_single_chars=None, question_mark=True):
"""Return integer value read from keyboard
Parameters
----------
prompt : str
Prompt string.
default : float or None
Default value.
minval : float or None
... | python | def readf(prompt, default=None, minval=None, maxval=None,
allowed_single_chars=None, question_mark=True):
"""Return integer value read from keyboard
Parameters
----------
prompt : str
Prompt string.
default : float or None
Default value.
minval : float or None
... | [
"def",
"readf",
"(",
"prompt",
",",
"default",
"=",
"None",
",",
"minval",
"=",
"None",
",",
"maxval",
"=",
"None",
",",
"allowed_single_chars",
"=",
"None",
",",
"question_mark",
"=",
"True",
")",
":",
"return",
"read_value",
"(",
"ftype",
"=",
"float",... | Return integer value read from keyboard
Parameters
----------
prompt : str
Prompt string.
default : float or None
Default value.
minval : float or None
Mininum allowed value.
maxval : float or None
Maximum allowed value.
allowed_single_chars : str
S... | [
"Return",
"integer",
"value",
"read",
"from",
"keyboard"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/iofunctions.py#L105-L137 | train | Read integer value from keyboard and return it as float. |
guaix-ucm/numina | numina/array/display/iofunctions.py | read_value | def read_value(ftype, prompt, default=None, minval=None, maxval=None,
allowed_single_chars=None, question_mark=True):
"""Return value read from keyboard
Parameters
----------
ftype : int() or float()
Function defining the expected type.
prompt : str
Prompt string.
... | python | def read_value(ftype, prompt, default=None, minval=None, maxval=None,
allowed_single_chars=None, question_mark=True):
"""Return value read from keyboard
Parameters
----------
ftype : int() or float()
Function defining the expected type.
prompt : str
Prompt string.
... | [
"def",
"read_value",
"(",
"ftype",
",",
"prompt",
",",
"default",
"=",
"None",
",",
"minval",
"=",
"None",
",",
"maxval",
"=",
"None",
",",
"allowed_single_chars",
"=",
"None",
",",
"question_mark",
"=",
"True",
")",
":",
"# avoid PyCharm warning 'might be ref... | Return value read from keyboard
Parameters
----------
ftype : int() or float()
Function defining the expected type.
prompt : str
Prompt string.
default : int or None
Default value.
minval : int or None
Mininum allowed value.
maxval : int or None
Maxim... | [
"Return",
"value",
"read",
"from",
"keyboard"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/iofunctions.py#L140-L256 | train | Read a value from a keyboard. |
guaix-ucm/numina | numina/core/pipeline.py | Pipeline.get_recipe_object | def get_recipe_object(self, mode):
"""Load recipe object, according to observing mode"""
if isinstance(mode, ObservingMode):
key_mode = mode.key
elif isinstance(mode, str):
key_mode = mode
else:
key_mode = mode
recipe_entry = self.recipes[key... | python | def get_recipe_object(self, mode):
"""Load recipe object, according to observing mode"""
if isinstance(mode, ObservingMode):
key_mode = mode.key
elif isinstance(mode, str):
key_mode = mode
else:
key_mode = mode
recipe_entry = self.recipes[key... | [
"def",
"get_recipe_object",
"(",
"self",
",",
"mode",
")",
":",
"if",
"isinstance",
"(",
"mode",
",",
"ObservingMode",
")",
":",
"key_mode",
"=",
"mode",
".",
"key",
"elif",
"isinstance",
"(",
"mode",
",",
"str",
")",
":",
"key_mode",
"=",
"mode",
"els... | Load recipe object, according to observing mode | [
"Load",
"recipe",
"object",
"according",
"to",
"observing",
"mode"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipeline.py#L66-L83 | train | Load a recipe object according to observing mode |
guaix-ucm/numina | numina/core/pipeline.py | Pipeline.load_product_object | def load_product_object(self, name):
"""Load product object, according to name"""
product_entry = self.products[name]
product = self._get_base_object(product_entry)
return product | python | def load_product_object(self, name):
"""Load product object, according to name"""
product_entry = self.products[name]
product = self._get_base_object(product_entry)
return product | [
"def",
"load_product_object",
"(",
"self",
",",
"name",
")",
":",
"product_entry",
"=",
"self",
".",
"products",
"[",
"name",
"]",
"product",
"=",
"self",
".",
"_get_base_object",
"(",
"product_entry",
")",
"return",
"product"
] | Load product object, according to name | [
"Load",
"product",
"object",
"according",
"to",
"name"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipeline.py#L87-L94 | train | Load product object according to name |
guaix-ucm/numina | numina/core/pipeline.py | Pipeline.load_product_class | def load_product_class(self, mode):
"""Load recipe object, according to observing mode"""
product_entry = self.products[mode]
return self._get_base_class(product_entry) | python | def load_product_class(self, mode):
"""Load recipe object, according to observing mode"""
product_entry = self.products[mode]
return self._get_base_class(product_entry) | [
"def",
"load_product_class",
"(",
"self",
",",
"mode",
")",
":",
"product_entry",
"=",
"self",
".",
"products",
"[",
"mode",
"]",
"return",
"self",
".",
"_get_base_class",
"(",
"product_entry",
")"
] | Load recipe object, according to observing mode | [
"Load",
"recipe",
"object",
"according",
"to",
"observing",
"mode"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipeline.py#L96-L101 | train | Load recipe object according to observing mode |
guaix-ucm/numina | numina/core/pipeline.py | Pipeline.depsolve | def depsolve(self):
"""Load all recipes to search for products"""
# load everything
requires = {}
provides = {}
for mode, r in self.recipes.items():
l = self.load_recipe_object(mode)
for field, vv in l.requirements().items():
if vv.type.is... | python | def depsolve(self):
"""Load all recipes to search for products"""
# load everything
requires = {}
provides = {}
for mode, r in self.recipes.items():
l = self.load_recipe_object(mode)
for field, vv in l.requirements().items():
if vv.type.is... | [
"def",
"depsolve",
"(",
"self",
")",
":",
"# load everything",
"requires",
"=",
"{",
"}",
"provides",
"=",
"{",
"}",
"for",
"mode",
",",
"r",
"in",
"self",
".",
"recipes",
".",
"items",
"(",
")",
":",
"l",
"=",
"self",
".",
"load_recipe_object",
"(",... | Load all recipes to search for products | [
"Load",
"all",
"recipes",
"to",
"search",
"for",
"products"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipeline.py#L109-L129 | train | Load all recipes to search for products |
guaix-ucm/numina | numina/core/pipeline.py | InstrumentDRP.query_provides | def query_provides(self, product, pipeline='default', search=False):
"""Return the mode that provides a given product"""
if search:
return self.search_mode_provides(product)
pipe = self.pipelines[pipeline]
try:
return pipe.who_provides(product)
except Ke... | python | def query_provides(self, product, pipeline='default', search=False):
"""Return the mode that provides a given product"""
if search:
return self.search_mode_provides(product)
pipe = self.pipelines[pipeline]
try:
return pipe.who_provides(product)
except Ke... | [
"def",
"query_provides",
"(",
"self",
",",
"product",
",",
"pipeline",
"=",
"'default'",
",",
"search",
"=",
"False",
")",
":",
"if",
"search",
":",
"return",
"self",
".",
"search_mode_provides",
"(",
"product",
")",
"pipe",
"=",
"self",
".",
"pipelines",
... | Return the mode that provides a given product | [
"Return",
"the",
"mode",
"that",
"provides",
"a",
"given",
"product"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipeline.py#L208-L218 | train | Query the mode that provides a given product |
guaix-ucm/numina | numina/core/pipeline.py | InstrumentDRP.search_mode_provides | def search_mode_provides(self, product, pipeline='default'):
"""Search the mode that provides a given product"""
pipeline = self.pipelines[pipeline]
for obj, mode, field in self.iterate_mode_provides(self.modes, pipeline):
# extract name from obj
if obj.name() == product... | python | def search_mode_provides(self, product, pipeline='default'):
"""Search the mode that provides a given product"""
pipeline = self.pipelines[pipeline]
for obj, mode, field in self.iterate_mode_provides(self.modes, pipeline):
# extract name from obj
if obj.name() == product... | [
"def",
"search_mode_provides",
"(",
"self",
",",
"product",
",",
"pipeline",
"=",
"'default'",
")",
":",
"pipeline",
"=",
"self",
".",
"pipelines",
"[",
"pipeline",
"]",
"for",
"obj",
",",
"mode",
",",
"field",
"in",
"self",
".",
"iterate_mode_provides",
"... | Search the mode that provides a given product | [
"Search",
"the",
"mode",
"that",
"provides",
"a",
"given",
"product"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipeline.py#L220-L229 | train | Search the mode that provides a given product |
guaix-ucm/numina | numina/core/pipeline.py | InstrumentDRP.iterate_mode_provides | def iterate_mode_provides(self, modes, pipeline):
"""Return the mode that provides a given product"""
for mode_key, mode in modes.items():
try:
recipe = pipeline.get_recipe_object(mode_key)
for key, provide in recipe.products().items():
if... | python | def iterate_mode_provides(self, modes, pipeline):
"""Return the mode that provides a given product"""
for mode_key, mode in modes.items():
try:
recipe = pipeline.get_recipe_object(mode_key)
for key, provide in recipe.products().items():
if... | [
"def",
"iterate_mode_provides",
"(",
"self",
",",
"modes",
",",
"pipeline",
")",
":",
"for",
"mode_key",
",",
"mode",
"in",
"modes",
".",
"items",
"(",
")",
":",
"try",
":",
"recipe",
"=",
"pipeline",
".",
"get_recipe_object",
"(",
"mode_key",
")",
"for"... | Return the mode that provides a given product | [
"Return",
"the",
"mode",
"that",
"provides",
"a",
"given",
"product"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipeline.py#L231-L241 | train | Iterate over the modes that provides a given product |
guaix-ucm/numina | numina/core/pipeline.py | InstrumentDRP.select_configuration | def select_configuration(self, obresult):
"""Select instrument configuration based on OB"""
logger = logging.getLogger(__name__)
logger.debug('calling default configuration selector')
# get first possible image
ref = obresult.get_sample_frame()
extr = self.datamodel.ext... | python | def select_configuration(self, obresult):
"""Select instrument configuration based on OB"""
logger = logging.getLogger(__name__)
logger.debug('calling default configuration selector')
# get first possible image
ref = obresult.get_sample_frame()
extr = self.datamodel.ext... | [
"def",
"select_configuration",
"(",
"self",
",",
"obresult",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"'calling default configuration selector'",
")",
"# get first possible image",
"ref",
"=",
"obresult... | Select instrument configuration based on OB | [
"Select",
"instrument",
"configuration",
"based",
"on",
"OB"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipeline.py#L251-L292 | train | Select instrument configuration based on OB result. |
guaix-ucm/numina | numina/core/pipeline.py | InstrumentDRP.select_profile | def select_profile(self, obresult):
"""Select instrument profile based on OB"""
logger = logging.getLogger(__name__)
logger.debug('calling default profile selector')
# check configuration
insconf = obresult.configuration
if insconf != 'default':
key = insconf... | python | def select_profile(self, obresult):
"""Select instrument profile based on OB"""
logger = logging.getLogger(__name__)
logger.debug('calling default profile selector')
# check configuration
insconf = obresult.configuration
if insconf != 'default':
key = insconf... | [
"def",
"select_profile",
"(",
"self",
",",
"obresult",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"'calling default profile selector'",
")",
"# check configuration",
"insconf",
"=",
"obresult",
".",
"... | Select instrument profile based on OB | [
"Select",
"instrument",
"profile",
"based",
"on",
"OB"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipeline.py#L294-L323 | train | Select instrument profile based on OB result |
guaix-ucm/numina | numina/core/pipeline.py | InstrumentDRP.get_recipe_object | def get_recipe_object(self, mode_name, pipeline_name='default'):
"""Build a recipe object from a given mode name"""
active_mode = self.modes[mode_name]
active_pipeline = self.pipelines[pipeline_name]
recipe = active_pipeline.get_recipe_object(active_mode)
return recipe | python | def get_recipe_object(self, mode_name, pipeline_name='default'):
"""Build a recipe object from a given mode name"""
active_mode = self.modes[mode_name]
active_pipeline = self.pipelines[pipeline_name]
recipe = active_pipeline.get_recipe_object(active_mode)
return recipe | [
"def",
"get_recipe_object",
"(",
"self",
",",
"mode_name",
",",
"pipeline_name",
"=",
"'default'",
")",
":",
"active_mode",
"=",
"self",
".",
"modes",
"[",
"mode_name",
"]",
"active_pipeline",
"=",
"self",
".",
"pipelines",
"[",
"pipeline_name",
"]",
"recipe",... | Build a recipe object from a given mode name | [
"Build",
"a",
"recipe",
"object",
"from",
"a",
"given",
"mode",
"name"
] | 6c829495df8937f77c2de9383c1038ffb3e713e3 | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/pipeline.py#L325-L330 | train | Build a recipe object from a given mode name and pipeline name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.