hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
0bf300bd7a2a73b4e8790f58766473ae74211404
ArcetriAdaptiveOptics/arte
arte/photometry/mag_estimator.py
[ "MIT" ]
Python
photons_per_second
<not_specific>
def photons_per_second(self): '''Photons/sec detected by sensor''' ph_subap_frame = self.photons_per_subap_per_frame() freq = self._detector_freq.to('1/s') nsubaps = self._detector_nsubaps transmission = self._wfs_transmission return ph_subap_frame * freq * nsubaps / tr...
Photons/sec detected by sensor
Photons/sec detected by sensor
[ "Photons", "/", "sec", "detected", "by", "sensor" ]
def photons_per_second(self): ph_subap_frame = self.photons_per_subap_per_frame() freq = self._detector_freq.to('1/s') nsubaps = self._detector_nsubaps transmission = self._wfs_transmission return ph_subap_frame * freq * nsubaps / transmission
[ "def", "photons_per_second", "(", "self", ")", ":", "ph_subap_frame", "=", "self", ".", "photons_per_subap_per_frame", "(", ")", "freq", "=", "self", ".", "_detector_freq", ".", "to", "(", "'1/s'", ")", "nsubaps", "=", "self", ".", "_detector_nsubaps", "transm...
Photons/sec detected by sensor
[ "Photons", "/", "sec", "detected", "by", "sensor" ]
[ "'''Photons/sec detected by sensor'''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0d049b545c8134542a42da4d200551328105e3ab
ArcetriAdaptiveOptics/arte
arte/utils/help.py
[ "MIT" ]
Python
add_help
<not_specific>
def add_help(cls=None, *, help_function='help', classmethod=False): ''' Decorator to add interactive help to a class Parameters ---------- help_function: str, optional Name of the method that will be added to the class. Defaults to "help" classmethod: bool, optional If True, the...
Decorator to add interactive help to a class Parameters ---------- help_function: str, optional Name of the method that will be added to the class. Defaults to "help" classmethod: bool, optional If True, the help method will be added as a classmethod. Default False Returns ...
Decorator to add interactive help to a class Parameters str, optional Name of the method that will be added to the class. Defaults to "help" classmethod: bool, optional If True, the help method will be added as a classmethod. Default False Returns class The decorated class type
[ "Decorator", "to", "add", "interactive", "help", "to", "a", "class", "Parameters", "str", "optional", "Name", "of", "the", "method", "that", "will", "be", "added", "to", "the", "class", ".", "Defaults", "to", "\"", "help", "\"", "classmethod", ":", "bool",...
def add_help(cls=None, *, help_function='help', classmethod=False): if cls is not None: return add_help()(cls) def help(self, search='', prefix=''): methods = {k: getattr(self, k) for k in dir(self) if callable(getattr(self, k))} members = {k: getattr(self, k) for k in dir(self) if not c...
[ "def", "add_help", "(", "cls", "=", "None", ",", "*", ",", "help_function", "=", "'help'", ",", "classmethod", "=", "False", ")", ":", "if", "cls", "is", "not", "None", ":", "return", "add_help", "(", ")", "(", "cls", ")", "def", "help", "(", "self...
Decorator to add interactive help to a class Parameters
[ "Decorator", "to", "add", "interactive", "help", "to", "a", "class", "Parameters" ]
[ "'''\n Decorator to add interactive help to a class\n\n Parameters\n ----------\n help_function: str, optional\n Name of the method that will be added to the class. Defaults to \"help\"\n classmethod: bool, optional\n If True, the help method will be added as a classmethod. Default Fals...
[ { "param": "cls", "type": null }, { "param": "help_function", "type": null }, { "param": "classmethod", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "help_function", "type": null, "docstring": null, "docstring_to...
0d049b545c8134542a42da4d200551328105e3ab
ArcetriAdaptiveOptics/arte
arte/utils/help.py
[ "MIT" ]
Python
help
null
def help(self, search='', prefix=''): ''' Interactive help Prints on stdout a list of methods that match the *search* substring or all of them if *search* is left to the default value of an empty string, together with a one-line help taken from the first line of their do...
Interactive help Prints on stdout a list of methods that match the *search* substring or all of them if *search* is left to the default value of an empty string, together with a one-line help taken from the first line of their docstring, if any. The *prefix* argument i...
Interactive help Prints on stdout a list of methods that match the *search* substring or all of them if *search* is left to the default value of an empty string, together with a one-line help taken from the first line of their docstring, if any. The *prefix* argument is prepended to the method name and is used for rec...
[ "Interactive", "help", "Prints", "on", "stdout", "a", "list", "of", "methods", "that", "match", "the", "*", "search", "*", "substring", "or", "all", "of", "them", "if", "*", "search", "*", "is", "left", "to", "the", "default", "value", "of", "an", "emp...
def help(self, search='', prefix=''): methods = {k: getattr(self, k) for k in dir(self) if callable(getattr(self, k))} members = {k: getattr(self, k) for k in dir(self) if not callable(getattr(self, k))} properties = ({k: getattr(self.__class__, k) for k in dir(self.__class...
[ "def", "help", "(", "self", ",", "search", "=", "''", ",", "prefix", "=", "''", ")", ":", "methods", "=", "{", "k", ":", "getattr", "(", "self", ",", "k", ")", "for", "k", "in", "dir", "(", "self", ")", "if", "callable", "(", "getattr", "(", ...
Interactive help Prints on stdout a list of methods that match the *search* substring or all of them if *search* is left to the default value of an empty string, together with a one-line help taken from the first line of their docstring, if any.
[ "Interactive", "help", "Prints", "on", "stdout", "a", "list", "of", "methods", "that", "match", "the", "*", "search", "*", "substring", "or", "all", "of", "them", "if", "*", "search", "*", "is", "left", "to", "the", "default", "value", "of", "an", "emp...
[ "'''\n Interactive help\n\n Prints on stdout a list of methods that match the *search* substring\n or all of them if *search* is left to the default value of an empty\n string, together with a one-line help taken from the first line\n of their docstring, if any.\n\n The *pr...
[ { "param": "self", "type": null }, { "param": "search", "type": null }, { "param": "prefix", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "search", "type": null, "docstring": null, "docstring_tokens":...
a51a7586aed2cdeead6e75a750d668e60072fc48
ArcetriAdaptiveOptics/arte
arte/contrib/chunk_iterator.py
[ "MIT" ]
Python
chunk_iterator
<not_specific>
def chunk_iterator(n, iterable): ''' From: https://stackoverflow.com/questions/8991506/iterate-an-iterator-by-chunks-of-n-in-python - without permission Splits an iterable in chunks of N elements each (but for the last one, which might be shorter if needed). Returns an iterator for each chunk. ...
From: https://stackoverflow.com/questions/8991506/iterate-an-iterator-by-chunks-of-n-in-python - without permission Splits an iterable in chunks of N elements each (but for the last one, which might be shorter if needed). Returns an iterator for each chunk. Example: >>> for a in chunk_iterator...
Splits an iterable in chunks of N elements each (but for the last one, which might be shorter if needed). Returns an iterator for each chunk.
[ "Splits", "an", "iterable", "in", "chunks", "of", "N", "elements", "each", "(", "but", "for", "the", "last", "one", "which", "might", "be", "shorter", "if", "needed", ")", ".", "Returns", "an", "iterator", "for", "each", "chunk", "." ]
def chunk_iterator(n, iterable): it = iter(iterable) while True: chunk_it = itertools.islice(it, n) try: first_el = next(chunk_it) except StopIteration: return yield itertools.chain((first_el,), chunk_it)
[ "def", "chunk_iterator", "(", "n", ",", "iterable", ")", ":", "it", "=", "iter", "(", "iterable", ")", "while", "True", ":", "chunk_it", "=", "itertools", ".", "islice", "(", "it", ",", "n", ")", "try", ":", "first_el", "=", "next", "(", "chunk_it", ...
From: https://stackoverflow.com/questions/8991506/iterate-an-iterator-by-chunks-of-n-in-python without permission
[ "From", ":", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "8991506", "/", "iterate", "-", "an", "-", "iterator", "-", "by", "-", "chunks", "-", "of", "-", "n", "-", "in", "-", "python", "without", "permission" ]
[ "'''\n From: https://stackoverflow.com/questions/8991506/iterate-an-iterator-by-chunks-of-n-in-python\n - without permission\n\n Splits an iterable in chunks of N elements each (but for the last one,\n which might be shorter if needed). Returns an iterator for each chunk.\n Example:\n >>> for a in...
[ { "param": "n", "type": null }, { "param": "iterable", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "n", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "iterable", "type": null, "docstring": null, "docstring_tokens": ...
19a8883907da7d28b440e50908089207faf6ffd3
ArcetriAdaptiveOptics/arte
arte/math/toccd.py
[ "MIT" ]
Python
toccd
<not_specific>
def toccd(a, newshape, set_total=None): ''' Clone of oaalib's toccd() function, using least common multiple to rebin an array similar to opencv's INTER_AREA interpolation. ''' if a.shape == newshape: return a if len(a.shape) != 2: raise ValueError('Input array shape is %s instea...
Clone of oaalib's toccd() function, using least common multiple to rebin an array similar to opencv's INTER_AREA interpolation.
Clone of oaalib's toccd() function, using least common multiple to rebin an array similar to opencv's INTER_AREA interpolation.
[ "Clone", "of", "oaalib", "'", "s", "toccd", "()", "function", "using", "least", "common", "multiple", "to", "rebin", "an", "array", "similar", "to", "opencv", "'", "s", "INTER_AREA", "interpolation", "." ]
def toccd(a, newshape, set_total=None): if a.shape == newshape: return a if len(a.shape) != 2: raise ValueError('Input array shape is %s instead of 2d, cannot continue:' % str(a.shape)) if len(newshape) != 2: raise ValueError('Output shape is %s instead of 2d, cannot continue' % str(...
[ "def", "toccd", "(", "a", ",", "newshape", ",", "set_total", "=", "None", ")", ":", "if", "a", ".", "shape", "==", "newshape", ":", "return", "a", "if", "len", "(", "a", ".", "shape", ")", "!=", "2", ":", "raise", "ValueError", "(", "'Input array s...
Clone of oaalib's toccd() function, using least common multiple to rebin an array similar to opencv's INTER_AREA interpolation.
[ "Clone", "of", "oaalib", "'", "s", "toccd", "()", "function", "using", "least", "common", "multiple", "to", "rebin", "an", "array", "similar", "to", "opencv", "'", "s", "INTER_AREA", "interpolation", "." ]
[ "'''\n Clone of oaalib's toccd() function, using least common multiple\n to rebin an array similar to opencv's INTER_AREA interpolation.\n '''" ]
[ { "param": "a", "type": null }, { "param": "newshape", "type": null }, { "param": "set_total", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "newshape", "type": null, "docstring": null, "docstring_tokens": ...
da03a720e1201b75129e50d9d4fe093cba9a4cf8
ArcetriAdaptiveOptics/arte
arte/utils/gpu.py
[ "MIT" ]
Python
is_numpy_or_cupy_array
<not_specific>
def is_numpy_or_cupy_array(arr): '''Returns True if the argument is either a numpy or a cupy array The check is performed looking at object attributes, therefore can be called without importing the cupy module. ''' return hasattr(arr, '__array_function__') and \ hasattr(arr, '__array_ufu...
Returns True if the argument is either a numpy or a cupy array The check is performed looking at object attributes, therefore can be called without importing the cupy module.
Returns True if the argument is either a numpy or a cupy array The check is performed looking at object attributes, therefore can be called without importing the cupy module.
[ "Returns", "True", "if", "the", "argument", "is", "either", "a", "numpy", "or", "a", "cupy", "array", "The", "check", "is", "performed", "looking", "at", "object", "attributes", "therefore", "can", "be", "called", "without", "importing", "the", "cupy", "modu...
def is_numpy_or_cupy_array(arr): return hasattr(arr, '__array_function__') and \ hasattr(arr, '__array_ufunc__')
[ "def", "is_numpy_or_cupy_array", "(", "arr", ")", ":", "return", "hasattr", "(", "arr", ",", "'__array_function__'", ")", "and", "hasattr", "(", "arr", ",", "'__array_ufunc__'", ")" ]
Returns True if the argument is either a numpy or a cupy array The check is performed looking at object attributes, therefore can be called without importing the cupy module.
[ "Returns", "True", "if", "the", "argument", "is", "either", "a", "numpy", "or", "a", "cupy", "array", "The", "check", "is", "performed", "looking", "at", "object", "attributes", "therefore", "can", "be", "called", "without", "importing", "the", "cupy", "modu...
[ "'''Returns True if the argument is either a numpy or a cupy array\n\n The check is performed looking at object attributes, therefore\n can be called without importing the cupy module.\n '''" ]
[ { "param": "arr", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "arr", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
da03a720e1201b75129e50d9d4fe093cba9a4cf8
ArcetriAdaptiveOptics/arte
arte/utils/gpu.py
[ "MIT" ]
Python
is_cupy_array
<not_specific>
def is_cupy_array(arr): '''Returns True if the argument is a cupy array. The check is performed looking at object attributes, therefore can be called without importing the cupy module. ''' return hasattr(arr, '__array_function__') and \ hasattr(arr, '__array_ufunc__') and \ ha...
Returns True if the argument is a cupy array. The check is performed looking at object attributes, therefore can be called without importing the cupy module.
Returns True if the argument is a cupy array. The check is performed looking at object attributes, therefore can be called without importing the cupy module.
[ "Returns", "True", "if", "the", "argument", "is", "a", "cupy", "array", ".", "The", "check", "is", "performed", "looking", "at", "object", "attributes", "therefore", "can", "be", "called", "without", "importing", "the", "cupy", "module", "." ]
def is_cupy_array(arr): return hasattr(arr, '__array_function__') and \ hasattr(arr, '__array_ufunc__') and \ hasattr(arr, 'device')
[ "def", "is_cupy_array", "(", "arr", ")", ":", "return", "hasattr", "(", "arr", ",", "'__array_function__'", ")", "and", "hasattr", "(", "arr", ",", "'__array_ufunc__'", ")", "and", "hasattr", "(", "arr", ",", "'device'", ")" ]
Returns True if the argument is a cupy array.
[ "Returns", "True", "if", "the", "argument", "is", "a", "cupy", "array", "." ]
[ "'''Returns True if the argument is a cupy array.\n\n The check is performed looking at object attributes, therefore\n can be called without importing the cupy module.\n '''" ]
[ { "param": "arr", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "arr", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
da03a720e1201b75129e50d9d4fe093cba9a4cf8
ArcetriAdaptiveOptics/arte
arte/utils/gpu.py
[ "MIT" ]
Python
is_numpy_array
<not_specific>
def is_numpy_array(arr): '''Returns True if the argument is a numpy array. The check is performed looking at object attributes, therefore can be called without importing the cupy module. ''' return hasattr(arr, '__array_function__') and \ hasattr(arr, '__array_ufunc__') and \ ...
Returns True if the argument is a numpy array. The check is performed looking at object attributes, therefore can be called without importing the cupy module.
Returns True if the argument is a numpy array. The check is performed looking at object attributes, therefore can be called without importing the cupy module.
[ "Returns", "True", "if", "the", "argument", "is", "a", "numpy", "array", ".", "The", "check", "is", "performed", "looking", "at", "object", "attributes", "therefore", "can", "be", "called", "without", "importing", "the", "cupy", "module", "." ]
def is_numpy_array(arr): return hasattr(arr, '__array_function__') and \ hasattr(arr, '__array_ufunc__') and \ not hasattr(arr, 'device')
[ "def", "is_numpy_array", "(", "arr", ")", ":", "return", "hasattr", "(", "arr", ",", "'__array_function__'", ")", "and", "hasattr", "(", "arr", ",", "'__array_ufunc__'", ")", "and", "not", "hasattr", "(", "arr", ",", "'device'", ")" ]
Returns True if the argument is a numpy array.
[ "Returns", "True", "if", "the", "argument", "is", "a", "numpy", "array", "." ]
[ "'''Returns True if the argument is a numpy array.\n\n The check is performed looking at object attributes, therefore\n can be called without importing the cupy module.\n '''" ]
[ { "param": "arr", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "arr", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
da03a720e1201b75129e50d9d4fe093cba9a4cf8
ArcetriAdaptiveOptics/arte
arte/utils/gpu.py
[ "MIT" ]
Python
from_GPU
<not_specific>
def from_GPU(value, owner=None, quiet=False): ''' If *value* is a cupy array, transfer it to the host and return the corresponding numpy array. All other values are left alone. It is safe to call this function with any kind of object, and also when cupy is not installed. In the latter case, of ...
If *value* is a cupy array, transfer it to the host and return the corresponding numpy array. All other values are left alone. It is safe to call this function with any kind of object, and also when cupy is not installed. In the latter case, of course no transfer will be done.
If *value* is a cupy array, transfer it to the host and return the corresponding numpy array. All other values are left alone. It is safe to call this function with any kind of object, and also when cupy is not installed. In the latter case, of course no transfer will be done.
[ "If", "*", "value", "*", "is", "a", "cupy", "array", "transfer", "it", "to", "the", "host", "and", "return", "the", "corresponding", "numpy", "array", ".", "All", "other", "values", "are", "left", "alone", ".", "It", "is", "safe", "to", "call", "this",...
def from_GPU(value, owner=None, quiet=False): if is_cupy_array(value): if not quiet: import cupy infostr = 'from_GPU: transferring %s %s' % (value.shape, value.dtype) infostr += ' from device %d' % cupy.cuda.runtime.getDevice() infostr += ' (owner %s)' % _form...
[ "def", "from_GPU", "(", "value", ",", "owner", "=", "None", ",", "quiet", "=", "False", ")", ":", "if", "is_cupy_array", "(", "value", ")", ":", "if", "not", "quiet", ":", "import", "cupy", "infostr", "=", "'from_GPU: transferring %s %s'", "%", "(", "val...
If *value* is a cupy array, transfer it to the host and return the corresponding numpy array.
[ "If", "*", "value", "*", "is", "a", "cupy", "array", "transfer", "it", "to", "the", "host", "and", "return", "the", "corresponding", "numpy", "array", "." ]
[ "'''\n If *value* is a cupy array, transfer it to the host\n and return the corresponding numpy array.\n\n All other values are left alone. It is safe to call\n this function with any kind of object, and also when\n cupy is not installed. In the latter case, of course\n no transfer will be done.\n...
[ { "param": "value", "type": null }, { "param": "owner", "type": null }, { "param": "quiet", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "value", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "owner", "type": null, "docstring": null, "docstring_tokens":...
da03a720e1201b75129e50d9d4fe093cba9a4cf8
ArcetriAdaptiveOptics/arte
arte/utils/gpu.py
[ "MIT" ]
Python
to_GPU
<not_specific>
def to_GPU(array, owner=None, quiet=False): ''' Transfer *array* to the GPU and return the corresponding cupy array. ''' if array is None: return array if not is_cupy_array(array): import cupy if not quiet: if is_numpy_array(array): infostr = 'to...
Transfer *array* to the GPU and return the corresponding cupy array.
Transfer *array* to the GPU and return the corresponding cupy array.
[ "Transfer", "*", "array", "*", "to", "the", "GPU", "and", "return", "the", "corresponding", "cupy", "array", "." ]
def to_GPU(array, owner=None, quiet=False): if array is None: return array if not is_cupy_array(array): import cupy if not quiet: if is_numpy_array(array): infostr = 'to_GPU: transferring %s %s' % (array.shape, array.dtype) else: in...
[ "def", "to_GPU", "(", "array", ",", "owner", "=", "None", ",", "quiet", "=", "False", ")", ":", "if", "array", "is", "None", ":", "return", "array", "if", "not", "is_cupy_array", "(", "array", ")", ":", "import", "cupy", "if", "not", "quiet", ":", ...
Transfer *array* to the GPU and return the corresponding cupy array.
[ "Transfer", "*", "array", "*", "to", "the", "GPU", "and", "return", "the", "corresponding", "cupy", "array", "." ]
[ "'''\n Transfer *array* to the GPU and return the corresponding cupy array.\n '''" ]
[ { "param": "array", "type": null }, { "param": "owner", "type": null }, { "param": "quiet", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "array", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "owner", "type": null, "docstring": null, "docstring_tokens":...
da03a720e1201b75129e50d9d4fe093cba9a4cf8
ArcetriAdaptiveOptics/arte
arte/utils/gpu.py
[ "MIT" ]
Python
_make_sure_first_arg_is_little_endian
<not_specific>
def _make_sure_first_arg_is_little_endian(f): ''' Decorator to enforce little endianess with cupy. This is a workaround for the cupy issue with FITS files: https://github.com/cupy/cupy/issues/3652 It will analyze the first argument and, if it is a big-endian array (like the ones returned by as...
Decorator to enforce little endianess with cupy. This is a workaround for the cupy issue with FITS files: https://github.com/cupy/cupy/issues/3652 It will analyze the first argument and, if it is a big-endian array (like the ones returned by astropy.io.fits.getdata), convert it to a little-en...
Decorator to enforce little endianess with cupy. It will analyze the first argument and, if it is a big-endian array (like the ones returned by astropy.io.fits.getdata), convert it to a little-endian one before passing it to the function. Can be used to "patch" the cupy routines as follows:.
[ "Decorator", "to", "enforce", "little", "endianess", "with", "cupy", ".", "It", "will", "analyze", "the", "first", "argument", "and", "if", "it", "is", "a", "big", "-", "endian", "array", "(", "like", "the", "ones", "returned", "by", "astropy", ".", "io"...
def _make_sure_first_arg_is_little_endian(f): @wraps(f) def wrapper(data, *args, **kwargs): import sys import numpy if isinstance(data, numpy.ndarray): endianess_map = { '>': 'big', '<': 'little', '=': sys.byteorder, ...
[ "def", "_make_sure_first_arg_is_little_endian", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "data", ",", "*", "args", ",", "**", "kwargs", ")", ":", "import", "sys", "import", "numpy", "if", "isinstance", "(", "data", ",", "...
Decorator to enforce little endianess with cupy.
[ "Decorator", "to", "enforce", "little", "endianess", "with", "cupy", "." ]
[ "'''\n Decorator to enforce little endianess with cupy.\n\n This is a workaround for the cupy issue with FITS files:\n https://github.com/cupy/cupy/issues/3652\n\n It will analyze the first argument and, if it is\n a big-endian array (like the ones returned by astropy.io.fits.getdata),\n convert i...
[ { "param": "f", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "f", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
da03a720e1201b75129e50d9d4fe093cba9a4cf8
ArcetriAdaptiveOptics/arte
arte/utils/gpu.py
[ "MIT" ]
Python
cupy_patch
null
def cupy_patch(cupy): ''' Patch the passed cupy module with our workarounds for FITS files. ''' cupy.array = _make_sure_first_arg_is_little_endian(cupy.array) cupy.asarray = _make_sure_first_arg_is_little_endian(cupy.asarray)
Patch the passed cupy module with our workarounds for FITS files.
Patch the passed cupy module with our workarounds for FITS files.
[ "Patch", "the", "passed", "cupy", "module", "with", "our", "workarounds", "for", "FITS", "files", "." ]
def cupy_patch(cupy): cupy.array = _make_sure_first_arg_is_little_endian(cupy.array) cupy.asarray = _make_sure_first_arg_is_little_endian(cupy.asarray)
[ "def", "cupy_patch", "(", "cupy", ")", ":", "cupy", ".", "array", "=", "_make_sure_first_arg_is_little_endian", "(", "cupy", ".", "array", ")", "cupy", ".", "asarray", "=", "_make_sure_first_arg_is_little_endian", "(", "cupy", ".", "asarray", ")" ]
Patch the passed cupy module with our workarounds for FITS files.
[ "Patch", "the", "passed", "cupy", "module", "with", "our", "workarounds", "for", "FITS", "files", "." ]
[ "'''\n Patch the passed cupy module with our workarounds for FITS files.\n '''" ]
[ { "param": "cupy", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cupy", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
af688fedc0c6cd269824661497a3eb22408a0478
ArcetriAdaptiveOptics/arte
arte/contrib/if_.py
[ "MIT" ]
Python
if_
<not_specific>
def if_(condition, warning=None): ''' Decorator to turn a function into a NO-OP if the condition is not met. Source: https://stackoverflow.com/questions/17946024/deactivate-function-with-decorator Example: @if_(global_enable) def do_something(): ... ''' def noop_decorator(f...
Decorator to turn a function into a NO-OP if the condition is not met. Source: https://stackoverflow.com/questions/17946024/deactivate-function-with-decorator Example: @if_(global_enable) def do_something(): ...
Decorator to turn a function into a NO-OP if the condition is not met.
[ "Decorator", "to", "turn", "a", "function", "into", "a", "NO", "-", "OP", "if", "the", "condition", "is", "not", "met", "." ]
def if_(condition, warning=None): def noop_decorator(func): return func def neutered_function(func): def neutered(*args, **kw): if warning: logging.warn(warning) return None return neutered return noop_decorator if condition else neutered_fun...
[ "def", "if_", "(", "condition", ",", "warning", "=", "None", ")", ":", "def", "noop_decorator", "(", "func", ")", ":", "return", "func", "def", "neutered_function", "(", "func", ")", ":", "def", "neutered", "(", "*", "args", ",", "**", "kw", ")", ":"...
Decorator to turn a function into a NO-OP if the condition is not met.
[ "Decorator", "to", "turn", "a", "function", "into", "a", "NO", "-", "OP", "if", "the", "condition", "is", "not", "met", "." ]
[ "'''\n Decorator to turn a function into a NO-OP\n if the condition is not met.\n Source: https://stackoverflow.com/questions/17946024/deactivate-function-with-decorator\n\n Example:\n @if_(global_enable)\n def do_something():\n ...\n\n '''", "# pass through" ]
[ { "param": "condition", "type": null }, { "param": "warning", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "condition", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "warning", "type": null, "docstring": null, "docstring_to...
110de5a25375e0858fdc698c6d470979f49ee62d
ArcetriAdaptiveOptics/arte
arte/utils/rebin.py
[ "MIT" ]
Python
rebin
<not_specific>
def rebin(a, new_shape, sample=False): """ Replacement of IDL's rebin() function for 2d arrays. Resizes a 2d array by averaging or repeating elements. New dimensions must be integral factors of original dimensions, otherwise a ValueError exception will be raised. Parameters ---------- ...
Replacement of IDL's rebin() function for 2d arrays. Resizes a 2d array by averaging or repeating elements. New dimensions must be integral factors of original dimensions, otherwise a ValueError exception will be raised. Parameters ---------- a : ndarray Input array. new_shape...
Replacement of IDL's rebin() function for 2d arrays. Resizes a 2d array by averaging or repeating elements. New dimensions must be integral factors of original dimensions, otherwise a ValueError exception will be raised. Parameters a : ndarray Input array. new_shape : 2-elements sequence Shape of the output array sam...
[ "Replacement", "of", "IDL", "'", "s", "rebin", "()", "function", "for", "2d", "arrays", ".", "Resizes", "a", "2d", "array", "by", "averaging", "or", "repeating", "elements", ".", "New", "dimensions", "must", "be", "integral", "factors", "of", "original", "...
def rebin(a, new_shape, sample=False): m, n = map(int, new_shape) if a.shape == (m, n): return a M, N = a.shape if m <= M and n <= M: if (M//m != M/m) or (N//n != N/n): raise ValueError('Cannot downsample by non-integer factors') elif M <= m and M <= m: if (m//M !...
[ "def", "rebin", "(", "a", ",", "new_shape", ",", "sample", "=", "False", ")", ":", "m", ",", "n", "=", "map", "(", "int", ",", "new_shape", ")", "if", "a", ".", "shape", "==", "(", "m", ",", "n", ")", ":", "return", "a", "M", ",", "N", "=",...
Replacement of IDL's rebin() function for 2d arrays.
[ "Replacement", "of", "IDL", "'", "s", "rebin", "()", "function", "for", "2d", "arrays", "." ]
[ "\"\"\"\n Replacement of IDL's rebin() function for 2d arrays.\n\n Resizes a 2d array by averaging or repeating elements.\n New dimensions must be integral factors of original dimensions,\n otherwise a ValueError exception will be raised.\n\n Parameters\n ----------\n a : ndarray\n Input...
[ { "param": "a", "type": null }, { "param": "new_shape", "type": null }, { "param": "sample", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "new_shape", "type": null, "docstring": null, "docstring_tokens":...
1e5656ff9a00e3763ed52d83833a6165e4c306d6
ArcetriAdaptiveOptics/arte
arte/code_convention.py
[ "MIT" ]
Python
_say_something_private
null
def _say_something_private(self, x): """ A private method. A leading underscore denotes private methods. """ print(x)
A private method. A leading underscore denotes private methods.
A private method. A leading underscore denotes private methods.
[ "A", "private", "method", ".", "A", "leading", "underscore", "denotes", "private", "methods", "." ]
def _say_something_private(self, x): print(x)
[ "def", "_say_something_private", "(", "self", ",", "x", ")", ":", "print", "(", "x", ")" ]
A private method.
[ "A", "private", "method", "." ]
[ "\"\"\"\n A private method.\n A leading underscore denotes private methods.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "x", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], ...
c961a0ee9834f78334ec6f5ca9f22dac5ea0485a
ArcetriAdaptiveOptics/arte
arte/utils/shared_array.py
[ "MIT" ]
Python
ndarray
<not_specific>
def ndarray(self, realloc=False): ''' Returns a new numpy wrapper around the buffer contents. Call this function after a task has been spawned the multiprocessing module in order to have access to the shared memory segment. If the array had already been accessed before passing ...
Returns a new numpy wrapper around the buffer contents. Call this function after a task has been spawned the multiprocessing module in order to have access to the shared memory segment. If the array had already been accessed before passing it to the multiprocessing task, the t...
Returns a new numpy wrapper around the buffer contents. Call this function after a task has been spawned the multiprocessing module in order to have access to the shared memory segment. If the array had already been accessed before passing it to the multiprocessing task, the task has to set `realloc` to True in order ...
[ "Returns", "a", "new", "numpy", "wrapper", "around", "the", "buffer", "contents", ".", "Call", "this", "function", "after", "a", "task", "has", "been", "spawned", "the", "multiprocessing", "module", "in", "order", "to", "have", "access", "to", "the", "shared...
def ndarray(self, realloc=False): if (self._ndarray is None) or realloc: arr = np.frombuffer(self._shared_buf, dtype=self.dtype) self._ndarray = arr.reshape(self.shape) return self._ndarray
[ "def", "ndarray", "(", "self", ",", "realloc", "=", "False", ")", ":", "if", "(", "self", ".", "_ndarray", "is", "None", ")", "or", "realloc", ":", "arr", "=", "np", ".", "frombuffer", "(", "self", ".", "_shared_buf", ",", "dtype", "=", "self", "."...
Returns a new numpy wrapper around the buffer contents.
[ "Returns", "a", "new", "numpy", "wrapper", "around", "the", "buffer", "contents", "." ]
[ "'''\n Returns a new numpy wrapper around the buffer contents.\n\n Call this function after a task has been spawned the multiprocessing\n module in order to have access to the shared memory segment.\n\n If the array had already been accessed before passing it to the\n multiprocess...
[ { "param": "self", "type": null }, { "param": "realloc", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "realloc", "type": null, "docstring": null, "docstring_tokens"...
664c0108b718c4ab36b3a07dba57251eac2adc4b
ArcetriAdaptiveOptics/arte
arte/utils/shape_fitter.py
[ "MIT" ]
Python
fit_circle_ransac
null
def fit_circle_ransac(self, apply_canny=True, sigma=3, display=False, **keywords): '''Perform a circle fitting on the current mask using RANSAC algorithm Parameters ---------- app...
Perform a circle fitting on the current mask using RANSAC algorithm Parameters ---------- apply_canny: bool, default=True apply Canny edge detection before performing the fit. sigma: float, default=10 if apply_canny is True, you can decide the Can...
Perform a circle fitting on the current mask using RANSAC algorithm Parameters bool, default=True apply Canny edge detection before performing the fit. sigma: float, default=10 if apply_canny is True, you can decide the Canny kernel size. display: bool, default=False it shows the result of the fit.
[ "Perform", "a", "circle", "fitting", "on", "the", "current", "mask", "using", "RANSAC", "algorithm", "Parameters", "bool", "default", "=", "True", "apply", "Canny", "edge", "detection", "before", "performing", "the", "fit", ".", "sigma", ":", "float", "default...
def fit_circle_ransac(self, apply_canny=True, sigma=3, display=False, **keywords): self._shape_fitted = 'circle' self._method = 'ransac' img = np.asarray(self._mask.copy(), dtype=float) ...
[ "def", "fit_circle_ransac", "(", "self", ",", "apply_canny", "=", "True", ",", "sigma", "=", "3", ",", "display", "=", "False", ",", "**", "keywords", ")", ":", "self", ".", "_shape_fitted", "=", "'circle'", "self", ".", "_method", "=", "'ransac'", "img"...
Perform a circle fitting on the current mask using RANSAC algorithm Parameters
[ "Perform", "a", "circle", "fitting", "on", "the", "current", "mask", "using", "RANSAC", "algorithm", "Parameters" ]
[ "'''Perform a circle fitting on the current mask using RANSAC algorithm\n\n Parameters\n ----------\n apply_canny: bool, default=True\n apply Canny edge detection before performing the fit.\n sigma: float, default=10\n if apply_canny is True, you can...
[ { "param": "self", "type": null }, { "param": "apply_canny", "type": null }, { "param": "sigma", "type": null }, { "param": "display", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "apply_canny", "type": null, "docstring": null, "docstring_tok...
664c0108b718c4ab36b3a07dba57251eac2adc4b
ArcetriAdaptiveOptics/arte
arte/utils/shape_fitter.py
[ "MIT" ]
Python
fit_circle_correlation
<not_specific>
def fit_circle_correlation(self, method='Nelder-Mead', display=False, **keywords): '''Perform a circle fitting on the current mask using minimization algorithm with correlation merit functions. Tested...
Perform a circle fitting on the current mask using minimization algorithm with correlation merit functions. Tested with following minimizations methods: 'Nelder-Mead'. Relative precision of 1% reached on synthetic images without noise. Parameters ---------- metho...
Perform a circle fitting on the current mask using minimization algorithm with correlation merit functions. Tested with following minimizations methods: 'Nelder-Mead'. Relative precision of 1% reached on synthetic images without noise. Parameters
[ "Perform", "a", "circle", "fitting", "on", "the", "current", "mask", "using", "minimization", "algorithm", "with", "correlation", "merit", "functions", ".", "Tested", "with", "following", "minimizations", "methods", ":", "'", "Nelder", "-", "Mead", "'", ".", "...
def fit_circle_correlation(self, method='Nelder-Mead', display=False, **keywords): self._method = 'correlation ' + method img = np.asarray(self._mask.copy(), dtype=int) regions = measure.regionprops(img)...
[ "def", "fit_circle_correlation", "(", "self", ",", "method", "=", "'Nelder-Mead'", ",", "display", "=", "False", ",", "**", "keywords", ")", ":", "self", ".", "_method", "=", "'correlation '", "+", "method", "img", "=", "np", ".", "asarray", "(", "self", ...
Perform a circle fitting on the current mask using minimization algorithm with correlation merit functions.
[ "Perform", "a", "circle", "fitting", "on", "the", "current", "mask", "using", "minimization", "algorithm", "with", "correlation", "merit", "functions", "." ]
[ "'''Perform a circle fitting on the current mask using minimization \n algorithm with correlation merit functions.\n\n Tested with following minimizations methods: 'Nelder-Mead'. Relative \n precision of 1% reached on synthetic images without noise.\n\n Parameters\n ----------\n ...
[ { "param": "self", "type": null }, { "param": "method", "type": null }, { "param": "display", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "method", "type": null, "docstring": null, "docstring_tokens":...
664c0108b718c4ab36b3a07dba57251eac2adc4b
ArcetriAdaptiveOptics/arte
arte/utils/shape_fitter.py
[ "MIT" ]
Python
fit_annular_correlation
<not_specific>
def fit_annular_correlation(self, method='Nelder-Mead', display=False, **keywords): '''Perform a annular circle fitting on the current mask using minimization algorithm with correlation merit functions. ...
Perform a annular circle fitting on the current mask using minimization algorithm with correlation merit functions. Tested with following minimizations methods: 'Nelder-Mead'. Relative precision of 1% reached on synthetic images without noise. Parameters ---------- ...
Perform a annular circle fitting on the current mask using minimization algorithm with correlation merit functions. Tested with following minimizations methods: 'Nelder-Mead'. Relative precision of 1% reached on synthetic images without noise. Parameters
[ "Perform", "a", "annular", "circle", "fitting", "on", "the", "current", "mask", "using", "minimization", "algorithm", "with", "correlation", "merit", "functions", ".", "Tested", "with", "following", "minimizations", "methods", ":", "'", "Nelder", "-", "Mead", "'...
def fit_annular_correlation(self, method='Nelder-Mead', display=False, **keywords): self._method = 'correlation ' + method img = np.asarray(self._mask.copy(), dtype=int) regions = measure.regionprops(...
[ "def", "fit_annular_correlation", "(", "self", ",", "method", "=", "'Nelder-Mead'", ",", "display", "=", "False", ",", "**", "keywords", ")", ":", "self", ".", "_method", "=", "'correlation '", "+", "method", "img", "=", "np", ".", "asarray", "(", "self", ...
Perform a annular circle fitting on the current mask using minimization algorithm with correlation merit functions.
[ "Perform", "a", "annular", "circle", "fitting", "on", "the", "current", "mask", "using", "minimization", "algorithm", "with", "correlation", "merit", "functions", "." ]
[ "'''Perform a annular circle fitting on the current mask using \n minimization algorithm with correlation merit functions.\n\n Tested with following minimizations methods: 'Nelder-Mead'. Relative \n precision of 1% reached on synthetic images without noise.\n\n Parameters\n -----...
[ { "param": "self", "type": null }, { "param": "method", "type": null }, { "param": "display", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "method", "type": null, "docstring": null, "docstring_tokens":...
77ff4f6c72e6b02b94290f2cb8fba003ddf0c962
ArcetriAdaptiveOptics/arte
arte/utils/multiton.py
[ "MIT" ]
Python
multiton
<not_specific>
def multiton(cls): ''' Multiton decorator Decorator that returns the same instance of a class every time it is instantiated with the same parameters. All parameters must be able to be passed to str() in order to build an hashable key. As a side effect, the class name becomes a function ...
Multiton decorator Decorator that returns the same instance of a class every time it is instantiated with the same parameters. All parameters must be able to be passed to str() in order to build an hashable key. As a side effect, the class name becomes a function that returns an instance,...
Multiton decorator Decorator that returns the same instance of a class every time it is instantiated with the same parameters. All parameters must be able to be passed to str() in order to build an hashable key. As a side effect, the class name becomes a function that returns an instance, rather than a class type inst...
[ "Multiton", "decorator", "Decorator", "that", "returns", "the", "same", "instance", "of", "a", "class", "every", "time", "it", "is", "instantiated", "with", "the", "same", "parameters", ".", "All", "parameters", "must", "be", "able", "to", "be", "passed", "t...
def multiton(cls): instances = {} def getinstance(*args): key = '.'.join(map(str, args)) if key not in instances: instances[key] = cls(*(args[1:])) return instances[key] return getinstance
[ "def", "multiton", "(", "cls", ")", ":", "instances", "=", "{", "}", "def", "getinstance", "(", "*", "args", ")", ":", "key", "=", "'.'", ".", "join", "(", "map", "(", "str", ",", "args", ")", ")", "if", "key", "not", "in", "instances", ":", "i...
Multiton decorator Decorator that returns the same instance of a class every time it is instantiated with the same parameters.
[ "Multiton", "decorator", "Decorator", "that", "returns", "the", "same", "instance", "of", "a", "class", "every", "time", "it", "is", "instantiated", "with", "the", "same", "parameters", "." ]
[ "'''\n Multiton decorator\n\n Decorator that returns the same instance of a class\n every time it is instantiated with the same parameters.\n\n All parameters must be able to be passed to str() in order\n to build an hashable key.\n As a side effect, the class name becomes a function\n that ret...
[ { "param": "cls", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
77ff4f6c72e6b02b94290f2cb8fba003ddf0c962
ArcetriAdaptiveOptics/arte
arte/utils/multiton.py
[ "MIT" ]
Python
multiton_id
<not_specific>
def multiton_id(cls): ''' Multiton decorator for mutable types Decorator that returns the same instance of a class every time it is instantiated with the same parameters. Similar to "multiton", but uses the id of each argument to build an hashable key. This allows to pass things like dicti...
Multiton decorator for mutable types Decorator that returns the same instance of a class every time it is instantiated with the same parameters. Similar to "multiton", but uses the id of each argument to build an hashable key. This allows to pass things like dictionaries that will be recogniz...
Multiton decorator for mutable types Decorator that returns the same instance of a class every time it is instantiated with the same parameters. Similar to "multiton", but uses the id of each argument to build an hashable key. This allows to pass things like dictionaries that will be recognized as identical even if th...
[ "Multiton", "decorator", "for", "mutable", "types", "Decorator", "that", "returns", "the", "same", "instance", "of", "a", "class", "every", "time", "it", "is", "instantiated", "with", "the", "same", "parameters", ".", "Similar", "to", "\"", "multiton", "\"", ...
def multiton_id(cls): instances = {} def getinstance(*args): ids = [str(id(x)) for x in args] key = '.'.join(ids) if key not in instances: instances[key] = cls(*(args[1:])) return instances[key] return getinstance
[ "def", "multiton_id", "(", "cls", ")", ":", "instances", "=", "{", "}", "def", "getinstance", "(", "*", "args", ")", ":", "ids", "=", "[", "str", "(", "id", "(", "x", ")", ")", "for", "x", "in", "args", "]", "key", "=", "'.'", ".", "join", "(...
Multiton decorator for mutable types Decorator that returns the same instance of a class every time it is instantiated with the same parameters.
[ "Multiton", "decorator", "for", "mutable", "types", "Decorator", "that", "returns", "the", "same", "instance", "of", "a", "class", "every", "time", "it", "is", "instantiated", "with", "the", "same", "parameters", "." ]
[ "'''\n Multiton decorator for mutable types\n\n Decorator that returns the same instance of a class\n every time it is instantiated with the same parameters.\n\n Similar to \"multiton\", but uses the id of each argument\n to build an hashable key. This allows to pass things\n like dictionaries tha...
[ { "param": "cls", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d69662b09537672a0d9127c08d8cb7c2a94e8fef
ArcetriAdaptiveOptics/arte
arte/atmo/cn2_profile.py
[ "MIT" ]
Python
from_r0s
<not_specific>
def from_r0s(cls, layersR0, layersL0, layersAltitude, layersWindSpeed, layersWindDirection): """ Cn2 profile constructor from r0 values of each layer Parameters ---------- layersR0: :class:`...
Cn2 profile constructor from r0 values of each layer Parameters ---------- layersR0: :class:`~numpy:numpy.ndarray` array of layers r0 in meters at 500nm layersL0: :class:`~numpy:numpy.ndarray` array of layers outer-scale L0 in...
Cn2 profile constructor from r0 values of each layer Parameters Every array must be 1D and have the same size, defining the number of layers of the profile All parameters must be defined at zenith
[ "Cn2", "profile", "constructor", "from", "r0", "values", "of", "each", "layer", "Parameters", "Every", "array", "must", "be", "1D", "and", "have", "the", "same", "size", "defining", "the", "number", "of", "layers", "of", "the", "profile", "All", "parameters"...
def from_r0s(cls, layersR0, layersL0, layersAltitude, layersWindSpeed, layersWindDirection): layersR0 = cls._quantitiesToValue(layersR0) layersL0 = cls._quantitiesToValue(layersL0) layersAltitude = cls._quantiti...
[ "def", "from_r0s", "(", "cls", ",", "layersR0", ",", "layersL0", ",", "layersAltitude", ",", "layersWindSpeed", ",", "layersWindDirection", ")", ":", "layersR0", "=", "cls", ".", "_quantitiesToValue", "(", "layersR0", ")", "layersL0", "=", "cls", ".", "_quanti...
Cn2 profile constructor from r0 values of each layer Parameters
[ "Cn2", "profile", "constructor", "from", "r0", "values", "of", "each", "layer", "Parameters" ]
[ "\"\"\"\n Cn2 profile constructor from r0 values of each layer\n\n Parameters\n ----------\n layersR0: :class:`~numpy:numpy.ndarray`\n array of layers r0 in meters at 500nm\n layersL0: :class:`~numpy:numpy.ndarray`\n array of layer...
[ { "param": "cls", "type": null }, { "param": "layersR0", "type": null }, { "param": "layersL0", "type": null }, { "param": "layersAltitude", "type": null }, { "param": "layersWindSpeed", "type": null }, { "param": "layersWindDirection", "type": nul...
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "layersR0", "type": null, "docstring": null, "docstring_tokens"...
d69662b09537672a0d9127c08d8cb7c2a94e8fef
ArcetriAdaptiveOptics/arte
arte/atmo/cn2_profile.py
[ "MIT" ]
Python
from_fractional_j
<not_specific>
def from_fractional_j(cls, r0AtZenith, layersFractionalJ, layersL0, layersAltitude, layersWindSpeed, layersWindDirection): """ Cn2 profile construct...
Cn2 profile constructor from total r0 at zenith and fractional J of each layer Parameters ---------- r0AtZenith: float overall r0 at zenith [m] layersFractionalJ: :class:`~numpy:numpy.ndarray` array of J val...
Cn2 profile constructor from total r0 at zenith and fractional J of each layer Parameters float overall r0 at zenith [m] layersFractionalJ: :class:`~numpy:numpy.ndarray` array of J values for each layer. Every array must be 1D and have the same size, defining the number of layers of the profile All parameters must ...
[ "Cn2", "profile", "constructor", "from", "total", "r0", "at", "zenith", "and", "fractional", "J", "of", "each", "layer", "Parameters", "float", "overall", "r0", "at", "zenith", "[", "m", "]", "layersFractionalJ", ":", ":", "class", ":", "`", "~numpy", ":",...
def from_fractional_j(cls, r0AtZenith, layersFractionalJ, layersL0, layersAltitude, layersWindSpeed, layersWindDirection): r0AtZenith = cls._quantitiesToVal...
[ "def", "from_fractional_j", "(", "cls", ",", "r0AtZenith", ",", "layersFractionalJ", ",", "layersL0", ",", "layersAltitude", ",", "layersWindSpeed", ",", "layersWindDirection", ")", ":", "r0AtZenith", "=", "cls", ".", "_quantitiesToValue", "(", "r0AtZenith", ")", ...
Cn2 profile constructor from total r0 at zenith and fractional J of each layer
[ "Cn2", "profile", "constructor", "from", "total", "r0", "at", "zenith", "and", "fractional", "J", "of", "each", "layer" ]
[ "\"\"\"\n Cn2 profile constructor from total r0 at zenith and fractional J of\n each layer\n\n Parameters\n ----------\n r0AtZenith: float\n overall r0 at zenith [m]\n layersFractionalJ: :class:`~numpy:numpy.ndarray`\n ...
[ { "param": "cls", "type": null }, { "param": "r0AtZenith", "type": null }, { "param": "layersFractionalJ", "type": null }, { "param": "layersL0", "type": null }, { "param": "layersAltitude", "type": null }, { "param": "layersWindSpeed", "type": nul...
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "r0AtZenith", "type": null, "docstring": null, "docstring_token...
d69662b09537672a0d9127c08d8cb7c2a94e8fef
ArcetriAdaptiveOptics/arte
arte/atmo/cn2_profile.py
[ "MIT" ]
Python
airmass
<not_specific>
def airmass(self): ''' Returns ------- airmass: float airmass at specified zenith angle ''' return self._airmass * u.dimensionless_unscaled
Returns ------- airmass: float airmass at specified zenith angle
Returns airmass: float airmass at specified zenith angle
[ "Returns", "airmass", ":", "float", "airmass", "at", "specified", "zenith", "angle" ]
def airmass(self): return self._airmass * u.dimensionless_unscaled
[ "def", "airmass", "(", "self", ")", ":", "return", "self", ".", "_airmass", "*", "u", ".", "dimensionless_unscaled" ]
Returns airmass: float airmass at specified zenith angle
[ "Returns", "airmass", ":", "float", "airmass", "at", "specified", "zenith", "angle" ]
[ "'''\n Returns\n -------\n airmass: float\n airmass at specified zenith angle\n '''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d69662b09537672a0d9127c08d8cb7c2a94e8fef
ArcetriAdaptiveOptics/arte
arte/atmo/cn2_profile.py
[ "MIT" ]
Python
r0
<not_specific>
def r0(self): ''' Returns ------- r0: :class:`~astropy:astropy.units.quantity.Quantity` equivalent to meters Fried parameter at defined wavelength and zenith angle ''' return (0.422727 * self._airmass * (2 * np.pi / self._lambda) ** 2 * ...
Returns ------- r0: :class:`~astropy:astropy.units.quantity.Quantity` equivalent to meters Fried parameter at defined wavelength and zenith angle
Returns r0: :class:`~astropy:astropy.units.quantity.Quantity` equivalent to meters Fried parameter at defined wavelength and zenith angle
[ "Returns", "r0", ":", ":", "class", ":", "`", "~astropy", ":", "astropy", ".", "units", ".", "quantity", ".", "Quantity", "`", "equivalent", "to", "meters", "Fried", "parameter", "at", "defined", "wavelength", "and", "zenith", "angle" ]
def r0(self): return (0.422727 * self._airmass * (2 * np.pi / self._lambda) ** 2 * np.sum(self._layersJs)) ** (-3. / 5) * u.m
[ "def", "r0", "(", "self", ")", ":", "return", "(", "0.422727", "*", "self", ".", "_airmass", "*", "(", "2", "*", "np", ".", "pi", "/", "self", ".", "_lambda", ")", "**", "2", "*", "np", ".", "sum", "(", "self", ".", "_layersJs", ")", ")", "**...
Returns r0: :class:`~astropy:astropy.units.quantity.Quantity` equivalent to meters Fried parameter at defined wavelength and zenith angle
[ "Returns", "r0", ":", ":", "class", ":", "`", "~astropy", ":", "astropy", ".", "units", ".", "quantity", ".", "Quantity", "`", "equivalent", "to", "meters", "Fried", "parameter", "at", "defined", "wavelength", "and", "zenith", "angle" ]
[ "'''\n Returns\n -------\n r0: :class:`~astropy:astropy.units.quantity.Quantity` equivalent to meters\n Fried parameter at defined wavelength and zenith angle\n '''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d69662b09537672a0d9127c08d8cb7c2a94e8fef
ArcetriAdaptiveOptics/arte
arte/atmo/cn2_profile.py
[ "MIT" ]
Python
MaunaKea
<not_specific>
def MaunaKea(cls): ''' From Brent L. Ellerbroek, Francois J. Rigaut, "Scaling multiconjugate adaptive optics performance estimates to extremely large telescopes," Proc. SPIE 4007, Adaptive Optical Systems Technology, (7 July 2000); doi: 10.1117/12.390314 ''' ...
From Brent L. Ellerbroek, Francois J. Rigaut, "Scaling multiconjugate adaptive optics performance estimates to extremely large telescopes," Proc. SPIE 4007, Adaptive Optical Systems Technology, (7 July 2000); doi: 10.1117/12.390314
From Brent L. Ellerbroek, Francois J. Rigaut, "Scaling multiconjugate adaptive optics performance estimates to extremely large telescopes," Proc.
[ "From", "Brent", "L", ".", "Ellerbroek", "Francois", "J", ".", "Rigaut", "\"", "Scaling", "multiconjugate", "adaptive", "optics", "performance", "estimates", "to", "extremely", "large", "telescopes", "\"", "Proc", "." ]
def MaunaKea(cls): r0 = 0.236 hs = np.array([0.09, 1.826, 2.72, 4.256, 6.269, 8.34, 10.546, 12.375, 14.61, 16.471, 17.028]) * 1000 js = [0.003, 0.136, 0.163, 0.161, 0.167, 0.234, 0.068, 0.032, 0.023, 0.006, 0.007] windSpeed = np.ones(len(js)) * 10.0 ...
[ "def", "MaunaKea", "(", "cls", ")", ":", "r0", "=", "0.236", "hs", "=", "np", ".", "array", "(", "[", "0.09", ",", "1.826", ",", "2.72", ",", "4.256", ",", "6.269", ",", "8.34", ",", "10.546", ",", "12.375", ",", "14.61", ",", "16.471", ",", "1...
From Brent L. Ellerbroek, Francois J. Rigaut, "Scaling multiconjugate adaptive optics performance estimates to extremely large telescopes," Proc.
[ "From", "Brent", "L", ".", "Ellerbroek", "Francois", "J", ".", "Rigaut", "\"", "Scaling", "multiconjugate", "adaptive", "optics", "performance", "estimates", "to", "extremely", "large", "telescopes", "\"", "Proc", "." ]
[ "'''\n From Brent L. Ellerbroek, Francois J. Rigaut,\n \"Scaling multiconjugate adaptive optics performance estimates\n to extremely large telescopes,\"\n Proc. SPIE 4007, Adaptive Optical Systems Technology,\n (7 July 2000); doi: 10.1117/12.390314\n '''" ]
[ { "param": "cls", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fd7acd5e8c24068cf48745258a0dd70fd5941843
ArcetriAdaptiveOptics/arte
arte/contrib/interpolated_array.py
[ "MIT" ]
Python
_GetBoundingPoints
<not_specific>
def _GetBoundingPoints(self, x): """Get the lower/upper points that bound x.""" lower_point = None upper_point = self.points[0] for point in self.points[1:]: lower_point = upper_point upper_point = point if x <= upper_point[0]: break return lower_point, upper_point
Get the lower/upper points that bound x.
Get the lower/upper points that bound x.
[ "Get", "the", "lower", "/", "upper", "points", "that", "bound", "x", "." ]
def _GetBoundingPoints(self, x): lower_point = None upper_point = self.points[0] for point in self.points[1:]: lower_point = upper_point upper_point = point if x <= upper_point[0]: break return lower_point, upper_point
[ "def", "_GetBoundingPoints", "(", "self", ",", "x", ")", ":", "lower_point", "=", "None", "upper_point", "=", "self", ".", "points", "[", "0", "]", "for", "point", "in", "self", ".", "points", "[", "1", ":", "]", ":", "lower_point", "=", "upper_point",...
Get the lower/upper points that bound x.
[ "Get", "the", "lower", "/", "upper", "points", "that", "bound", "x", "." ]
[ "\"\"\"Get the lower/upper points that bound x.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "x", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], ...
fd7acd5e8c24068cf48745258a0dd70fd5941843
ArcetriAdaptiveOptics/arte
arte/contrib/interpolated_array.py
[ "MIT" ]
Python
_Interpolate
<not_specific>
def _Interpolate(self, x, lower_point, upper_point): """Interpolate a Y value for x given lower & upper bounding points.""" slope = (float(upper_point[1] - lower_point[1]) / (upper_point[0] - lower_point[0])) return lower_point[1] + (slope * (x - lower_point[0]))
Interpolate a Y value for x given lower & upper bounding points.
Interpolate a Y value for x given lower & upper bounding points.
[ "Interpolate", "a", "Y", "value", "for", "x", "given", "lower", "&", "upper", "bounding", "points", "." ]
def _Interpolate(self, x, lower_point, upper_point): slope = (float(upper_point[1] - lower_point[1]) / (upper_point[0] - lower_point[0])) return lower_point[1] + (slope * (x - lower_point[0]))
[ "def", "_Interpolate", "(", "self", ",", "x", ",", "lower_point", ",", "upper_point", ")", ":", "slope", "=", "(", "float", "(", "upper_point", "[", "1", "]", "-", "lower_point", "[", "1", "]", ")", "/", "(", "upper_point", "[", "0", "]", "-", "low...
Interpolate a Y value for x given lower & upper bounding points.
[ "Interpolate", "a", "Y", "value", "for", "x", "given", "lower", "&", "upper", "bounding", "points", "." ]
[ "\"\"\"Interpolate a Y value for x given lower & upper\n bounding points.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "x", "type": null }, { "param": "lower_point", "type": null }, { "param": "upper_point", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], ...
27991f7f358639e599b474388496b927f5eb6ed5
ArcetriAdaptiveOptics/arte
arte/utils/decorator.py
[ "MIT" ]
Python
cache_on_disk
<not_specific>
def cache_on_disk(fname=None, fname_func=None, adapter=FitsFileCache): ''' Decorator that caches a function result into a local file. The file can be specified as either a constant filename, or a function that returns a filename. The second form is useful if the filename is not known when the funct...
Decorator that caches a function result into a local file. The file can be specified as either a constant filename, or a function that returns a filename. The second form is useful if the filename is not known when the function is defined, but only at runtime. Roughly equivalent to: if a...
Decorator that caches a function result into a local file. The file can be specified as either a constant filename, or a function that returns a filename. The second form is useful if the filename is not known when the function is defined, but only at runtime. Roughly equivalent to. Parameters fname : str, optiona...
[ "Decorator", "that", "caches", "a", "function", "result", "into", "a", "local", "file", ".", "The", "file", "can", "be", "specified", "as", "either", "a", "constant", "filename", "or", "a", "function", "that", "returns", "a", "filename", ".", "The", "secon...
def cache_on_disk(fname=None, fname_func=None, adapter=FitsFileCache): if (fname is None and fname_func is None) or \ (fname is not None and fname_func is not None): raise ValueError('One of filename and fname_func must be specified') if fname: def fname_func(): return fname ...
[ "def", "cache_on_disk", "(", "fname", "=", "None", ",", "fname_func", "=", "None", ",", "adapter", "=", "FitsFileCache", ")", ":", "if", "(", "fname", "is", "None", "and", "fname_func", "is", "None", ")", "or", "(", "fname", "is", "not", "None", "and",...
Decorator that caches a function result into a local file.
[ "Decorator", "that", "caches", "a", "function", "result", "into", "a", "local", "file", "." ]
[ "'''\n Decorator that caches a function result into a local file.\n\n The file can be specified as either a constant filename, or a function\n that returns a filename. The second form is useful if the filename is not\n known when the function is defined, but only at runtime.\n\n Roughly equivalent to...
[ { "param": "fname", "type": null }, { "param": "fname_func", "type": null }, { "param": "adapter", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fname", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fname_func", "type": null, "docstring": null, "docstring_tok...
676e628b4e380837f77c3215dec41fdbb7bf88b7
ArcetriAdaptiveOptics/arte
arte/types/domainxy.py
[ "MIT" ]
Python
from_extent
<not_specific>
def from_extent(cls, xmin, xmax, ymin, ymax, npoints): '''Build a domain from a bounding box''' npoints = _accept_one_or_two_elements(npoints, 'npoints') x = np.linspace(xmin, xmax, npoints[0]) y = np.linspace(ymin, ymax, npoints[1]) return cls(x, y)
Build a domain from a bounding box
Build a domain from a bounding box
[ "Build", "a", "domain", "from", "a", "bounding", "box" ]
def from_extent(cls, xmin, xmax, ymin, ymax, npoints): npoints = _accept_one_or_two_elements(npoints, 'npoints') x = np.linspace(xmin, xmax, npoints[0]) y = np.linspace(ymin, ymax, npoints[1]) return cls(x, y)
[ "def", "from_extent", "(", "cls", ",", "xmin", ",", "xmax", ",", "ymin", ",", "ymax", ",", "npoints", ")", ":", "npoints", "=", "_accept_one_or_two_elements", "(", "npoints", ",", "'npoints'", ")", "x", "=", "np", ".", "linspace", "(", "xmin", ",", "xm...
Build a domain from a bounding box
[ "Build", "a", "domain", "from", "a", "bounding", "box" ]
[ "'''Build a domain from a bounding box'''" ]
[ { "param": "cls", "type": null }, { "param": "xmin", "type": null }, { "param": "xmax", "type": null }, { "param": "ymin", "type": null }, { "param": "ymax", "type": null }, { "param": "npoints", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "xmin", "type": null, "docstring": null, "docstring_tokens": []...
676e628b4e380837f77c3215dec41fdbb7bf88b7
ArcetriAdaptiveOptics/arte
arte/types/domainxy.py
[ "MIT" ]
Python
from_shape
<not_specific>
def from_shape(cls, shape, pixel_size=1): '''Build a domain from a shape and a pixel size''' pixel_size = _accept_one_or_two_elements(pixel_size, 'pixel_size') tot_size = (shape[0] * pixel_size[0], shape[1] * pixel_size[1]) # a shape is (rows, cols), so equivalent to (y,x) y =...
Build a domain from a shape and a pixel size
Build a domain from a shape and a pixel size
[ "Build", "a", "domain", "from", "a", "shape", "and", "a", "pixel", "size" ]
def from_shape(cls, shape, pixel_size=1): pixel_size = _accept_one_or_two_elements(pixel_size, 'pixel_size') tot_size = (shape[0] * pixel_size[0], shape[1] * pixel_size[1]) y = np.linspace(-(tot_size[0] - pixel_size[0]) / 2, (tot_size[0] - pixel_size[0]) / 2, ...
[ "def", "from_shape", "(", "cls", ",", "shape", ",", "pixel_size", "=", "1", ")", ":", "pixel_size", "=", "_accept_one_or_two_elements", "(", "pixel_size", ",", "'pixel_size'", ")", "tot_size", "=", "(", "shape", "[", "0", "]", "*", "pixel_size", "[", "0", ...
Build a domain from a shape and a pixel size
[ "Build", "a", "domain", "from", "a", "shape", "and", "a", "pixel", "size" ]
[ "'''Build a domain from a shape and a pixel size'''", "# a shape is (rows, cols), so equivalent to (y,x)" ]
[ { "param": "cls", "type": null }, { "param": "shape", "type": null }, { "param": "pixel_size", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "shape", "type": null, "docstring": null, "docstring_tokens": [...
676e628b4e380837f77c3215dec41fdbb7bf88b7
ArcetriAdaptiveOptics/arte
arte/types/domainxy.py
[ "MIT" ]
Python
from_xy_maps
<not_specific>
def from_xy_maps(cls, xmap, ymap): '''Build a domain from two 2d maps (like the ones from make_xy)''' xcoord_vector = xmap[0, :] ycoord_vector = ymap[:, 0] return cls(xcoord_vector, ycoord_vector)
Build a domain from two 2d maps (like the ones from make_xy)
Build a domain from two 2d maps (like the ones from make_xy)
[ "Build", "a", "domain", "from", "two", "2d", "maps", "(", "like", "the", "ones", "from", "make_xy", ")" ]
def from_xy_maps(cls, xmap, ymap): xcoord_vector = xmap[0, :] ycoord_vector = ymap[:, 0] return cls(xcoord_vector, ycoord_vector)
[ "def", "from_xy_maps", "(", "cls", ",", "xmap", ",", "ymap", ")", ":", "xcoord_vector", "=", "xmap", "[", "0", ",", ":", "]", "ycoord_vector", "=", "ymap", "[", ":", ",", "0", "]", "return", "cls", "(", "xcoord_vector", ",", "ycoord_vector", ")" ]
Build a domain from two 2d maps (like the ones from make_xy)
[ "Build", "a", "domain", "from", "two", "2d", "maps", "(", "like", "the", "ones", "from", "make_xy", ")" ]
[ "'''Build a domain from two 2d maps (like the ones from make_xy)'''" ]
[ { "param": "cls", "type": null }, { "param": "xmap", "type": null }, { "param": "ymap", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "xmap", "type": null, "docstring": null, "docstring_tokens": []...
676e628b4e380837f77c3215dec41fdbb7bf88b7
ArcetriAdaptiveOptics/arte
arte/types/domainxy.py
[ "MIT" ]
Python
contains
<not_specific>
def contains(self, x, y): '''Returns True if the coordinates are inside the domain''' assert_unit_is_equivalent(x, ref=self._xcoord) assert_unit_is_equivalent(y, ref=self._ycoord) return (x >= self._xcoord.min()) and (x <= self._xcoord.max()) and \ (y >= self._ycoord.min...
Returns True if the coordinates are inside the domain
Returns True if the coordinates are inside the domain
[ "Returns", "True", "if", "the", "coordinates", "are", "inside", "the", "domain" ]
def contains(self, x, y): assert_unit_is_equivalent(x, ref=self._xcoord) assert_unit_is_equivalent(y, ref=self._ycoord) return (x >= self._xcoord.min()) and (x <= self._xcoord.max()) and \ (y >= self._ycoord.min()) and (y <= self._ycoord.max())
[ "def", "contains", "(", "self", ",", "x", ",", "y", ")", ":", "assert_unit_is_equivalent", "(", "x", ",", "ref", "=", "self", ".", "_xcoord", ")", "assert_unit_is_equivalent", "(", "y", ",", "ref", "=", "self", ".", "_ycoord", ")", "return", "(", "x", ...
Returns True if the coordinates are inside the domain
[ "Returns", "True", "if", "the", "coordinates", "are", "inside", "the", "domain" ]
[ "'''Returns True if the coordinates are inside the domain'''" ]
[ { "param": "self", "type": null }, { "param": "x", "type": null }, { "param": "y", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], ...
676e628b4e380837f77c3215dec41fdbb7bf88b7
ArcetriAdaptiveOptics/arte
arte/types/domainxy.py
[ "MIT" ]
Python
restrict
<not_specific>
def restrict(self, x, y): '''(x,y) = new coordinates restricted to be inside this domain''' assert_unit_is_equivalent(x, ref=self._xcoord) assert_unit_is_equivalent(y, ref=self._ycoord) x = max(x, self._xcoord.min()) y = max(y, self._ycoord.min()) x = min(x, self._xcoor...
(x,y) = new coordinates restricted to be inside this domain
(x,y) = new coordinates restricted to be inside this domain
[ "(", "x", "y", ")", "=", "new", "coordinates", "restricted", "to", "be", "inside", "this", "domain" ]
def restrict(self, x, y): assert_unit_is_equivalent(x, ref=self._xcoord) assert_unit_is_equivalent(y, ref=self._ycoord) x = max(x, self._xcoord.min()) y = max(y, self._ycoord.min()) x = min(x, self._xcoord.max()) y = min(y, self._ycoord.max()) return x, y
[ "def", "restrict", "(", "self", ",", "x", ",", "y", ")", ":", "assert_unit_is_equivalent", "(", "x", ",", "ref", "=", "self", ".", "_xcoord", ")", "assert_unit_is_equivalent", "(", "y", ",", "ref", "=", "self", ".", "_ycoord", ")", "x", "=", "max", "...
(x,y) = new coordinates restricted to be inside this domain
[ "(", "x", "y", ")", "=", "new", "coordinates", "restricted", "to", "be", "inside", "this", "domain" ]
[ "'''(x,y) = new coordinates restricted to be inside this domain'''" ]
[ { "param": "self", "type": null }, { "param": "x", "type": null }, { "param": "y", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], ...
676e628b4e380837f77c3215dec41fdbb7bf88b7
ArcetriAdaptiveOptics/arte
arte/types/domainxy.py
[ "MIT" ]
Python
_indices
<not_specific>
def _indices(self, xmin, xmax, ymin, ymax, boundary_check=True): '''Returns the outer indices that correspond to a bounding box''' # Indexes must be unitless assert_unit_is_equivalent(xmin, ref=self._xcoord) assert_unit_is_equivalent(xmax, ref=self._xcoord) assert_unit_is_equiva...
Returns the outer indices that correspond to a bounding box
Returns the outer indices that correspond to a bounding box
[ "Returns", "the", "outer", "indices", "that", "correspond", "to", "a", "bounding", "box" ]
def _indices(self, xmin, xmax, ymin, ymax, boundary_check=True): assert_unit_is_equivalent(xmin, ref=self._xcoord) assert_unit_is_equivalent(xmax, ref=self._xcoord) assert_unit_is_equivalent(ymin, ref=self._ycoord) assert_unit_is_equivalent(ymax, ref=self._ycoord) xlo = np.argmin...
[ "def", "_indices", "(", "self", ",", "xmin", ",", "xmax", ",", "ymin", ",", "ymax", ",", "boundary_check", "=", "True", ")", ":", "assert_unit_is_equivalent", "(", "xmin", ",", "ref", "=", "self", ".", "_xcoord", ")", "assert_unit_is_equivalent", "(", "xma...
Returns the outer indices that correspond to a bounding box
[ "Returns", "the", "outer", "indices", "that", "correspond", "to", "a", "bounding", "box" ]
[ "'''Returns the outer indices that correspond to a bounding box'''", "# Indexes must be unitless" ]
[ { "param": "self", "type": null }, { "param": "xmin", "type": null }, { "param": "xmax", "type": null }, { "param": "ymin", "type": null }, { "param": "ymax", "type": null }, { "param": "boundary_check", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "xmin", "type": null, "docstring": null, "docstring_tokens": [...
676e628b4e380837f77c3215dec41fdbb7bf88b7
ArcetriAdaptiveOptics/arte
arte/types/domainxy.py
[ "MIT" ]
Python
cropped
<not_specific>
def cropped(self, xmin, xmax, ymin, ymax): '''Returns a new cropped DomainXY object''' xlo, xhi, ylo, yhi = self._indices(xmin, xmax, ymin, ymax) xc = self.xcoord[xlo:xhi] yc = self.ycoord[ylo:yhi] return DomainXY.from_xy_vectors(xc, yc)
Returns a new cropped DomainXY object
Returns a new cropped DomainXY object
[ "Returns", "a", "new", "cropped", "DomainXY", "object" ]
def cropped(self, xmin, xmax, ymin, ymax): xlo, xhi, ylo, yhi = self._indices(xmin, xmax, ymin, ymax) xc = self.xcoord[xlo:xhi] yc = self.ycoord[ylo:yhi] return DomainXY.from_xy_vectors(xc, yc)
[ "def", "cropped", "(", "self", ",", "xmin", ",", "xmax", ",", "ymin", ",", "ymax", ")", ":", "xlo", ",", "xhi", ",", "ylo", ",", "yhi", "=", "self", ".", "_indices", "(", "xmin", ",", "xmax", ",", "ymin", ",", "ymax", ")", "xc", "=", "self", ...
Returns a new cropped DomainXY object
[ "Returns", "a", "new", "cropped", "DomainXY", "object" ]
[ "'''Returns a new cropped DomainXY object'''" ]
[ { "param": "self", "type": null }, { "param": "xmin", "type": null }, { "param": "xmax", "type": null }, { "param": "ymin", "type": null }, { "param": "ymax", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "xmin", "type": null, "docstring": null, "docstring_tokens": [...
6aae1e3fae36e8eec28ced6c081c219a11fb284c
ArcetriAdaptiveOptics/arte
arte/photometry/spectral_types.py
[ "MIT" ]
Python
filename
<not_specific>
def filename(cls, spectralType): """ Return URL to access Pickels UVKLIB spectra at STScI To be used with synphot.SourceSpectrum.from_file() """ return "%s%s.fits" % (cls.baseUrl(), cls._spectralTypeDict()[spectralType])
Return URL to access Pickels UVKLIB spectra at STScI To be used with synphot.SourceSpectrum.from_file()
Return URL to access Pickels UVKLIB spectra at STScI To be used with synphot.SourceSpectrum.from_file()
[ "Return", "URL", "to", "access", "Pickels", "UVKLIB", "spectra", "at", "STScI", "To", "be", "used", "with", "synphot", ".", "SourceSpectrum", ".", "from_file", "()" ]
def filename(cls, spectralType): return "%s%s.fits" % (cls.baseUrl(), cls._spectralTypeDict()[spectralType])
[ "def", "filename", "(", "cls", ",", "spectralType", ")", ":", "return", "\"%s%s.fits\"", "%", "(", "cls", ".", "baseUrl", "(", ")", ",", "cls", ".", "_spectralTypeDict", "(", ")", "[", "spectralType", "]", ")" ]
Return URL to access Pickels UVKLIB spectra at STScI To be used with synphot.SourceSpectrum.from_file()
[ "Return", "URL", "to", "access", "Pickels", "UVKLIB", "spectra", "at", "STScI", "To", "be", "used", "with", "synphot", ".", "SourceSpectrum", ".", "from_file", "()" ]
[ "\"\"\"\n Return URL to access Pickels UVKLIB spectra at STScI\n To be used with synphot.SourceSpectrum.from_file()\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "spectralType", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "spectralType", "type": null, "docstring": null, "docstring_tok...
c87bb087de280a287551e58dbf9bb333b84e2d78
ArcetriAdaptiveOptics/arte
arte/utils/locate.py
[ "MIT" ]
Python
locate
null
def locate(pattern, rootdir=None): '''Generator similar to Unix's *locate* utility Locates all files matching a pattern, inside and below the root directory. If no root directory is given, the current directory is used instead. Parameters ---------- pattern: string the filename pattern...
Generator similar to Unix's *locate* utility Locates all files matching a pattern, inside and below the root directory. If no root directory is given, the current directory is used instead. Parameters ---------- pattern: string the filename pattern to match. Unix wildcards are allowed ...
Generator similar to Unix's *locate* utility Locates all files matching a pattern, inside and below the root directory. If no root directory is given, the current directory is used instead. Parameters string the filename pattern to match. Unix wildcards are allowed rootdir: string, optional the root directory where t...
[ "Generator", "similar", "to", "Unix", "'", "s", "*", "locate", "*", "utility", "Locates", "all", "files", "matching", "a", "pattern", "inside", "and", "below", "the", "root", "directory", ".", "If", "no", "root", "directory", "is", "given", "the", "current...
def locate(pattern, rootdir=None): if rootdir is None: rootdir = os.curdir for path, dirs, files in os.walk(rootdir): for filename in fnmatch.filter(files, pattern): yield os.path.join(path, filename)
[ "def", "locate", "(", "pattern", ",", "rootdir", "=", "None", ")", ":", "if", "rootdir", "is", "None", ":", "rootdir", "=", "os", ".", "curdir", "for", "path", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "rootdir", ")", ":", "for", "...
Generator similar to Unix's *locate* utility Locates all files matching a pattern, inside and below the root directory.
[ "Generator", "similar", "to", "Unix", "'", "s", "*", "locate", "*", "utility", "Locates", "all", "files", "matching", "a", "pattern", "inside", "and", "below", "the", "root", "directory", "." ]
[ "'''Generator similar to Unix's *locate* utility\n\n Locates all files matching a pattern, inside and below the root directory.\n If no root directory is given, the current directory is used instead.\n\n Parameters\n ----------\n pattern: string\n the filename pattern to match. Unix wildcards ...
[ { "param": "pattern", "type": null }, { "param": "rootdir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pattern", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rootdir", "type": null, "docstring": null, "docstring_toke...
c87bb087de280a287551e58dbf9bb333b84e2d78
ArcetriAdaptiveOptics/arte
arte/utils/locate.py
[ "MIT" ]
Python
locate_first
<not_specific>
def locate_first(pattern, rootdir=None): '''Locate the first filename matching *pattern* Locate the first file a matching, inside and below the root directory. If no root directory is given, the current directory is used instead. Parameters ---------- pattern: string the filename patte...
Locate the first filename matching *pattern* Locate the first file a matching, inside and below the root directory. If no root directory is given, the current directory is used instead. Parameters ---------- pattern: string the filename pattern to match. Unix wildcards are allowed root...
Locate the first filename matching *pattern Locate the first file a matching, inside and below the root directory. If no root directory is given, the current directory is used instead. Parameters string the filename pattern to match. Unix wildcards are allowed rootdir: string, optional the root directory where the se...
[ "Locate", "the", "first", "filename", "matching", "*", "pattern", "Locate", "the", "first", "file", "a", "matching", "inside", "and", "below", "the", "root", "directory", ".", "If", "no", "root", "directory", "is", "given", "the", "current", "directory", "is...
def locate_first(pattern, rootdir=None): loc = locate(pattern, rootdir) try: return next(loc) except StopIteration: return None
[ "def", "locate_first", "(", "pattern", ",", "rootdir", "=", "None", ")", ":", "loc", "=", "locate", "(", "pattern", ",", "rootdir", ")", "try", ":", "return", "next", "(", "loc", ")", "except", "StopIteration", ":", "return", "None" ]
Locate the first filename matching *pattern Locate the first file a matching, inside and below the root directory.
[ "Locate", "the", "first", "filename", "matching", "*", "pattern", "Locate", "the", "first", "file", "a", "matching", "inside", "and", "below", "the", "root", "directory", "." ]
[ "'''Locate the first filename matching *pattern*\n\n Locate the first file a matching, inside and below the root directory.\n If no root directory is given, the current directory is used instead.\n\n Parameters\n ----------\n pattern: string\n the filename pattern to match. Unix wildcards are ...
[ { "param": "pattern", "type": null }, { "param": "rootdir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pattern", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rootdir", "type": null, "docstring": null, "docstring_toke...
c87bb087de280a287551e58dbf9bb333b84e2d78
ArcetriAdaptiveOptics/arte
arte/utils/locate.py
[ "MIT" ]
Python
replace_in_file
null
def replace_in_file(filename, search, replace): '''Replaces a string inside a file''' filedata = None with open(filename, 'r') as f: filedata = f.read() # Replace the target string filedata = filedata.replace(search, replace) # Write the file out again with open(filename, 'w') as ...
Replaces a string inside a file
Replaces a string inside a file
[ "Replaces", "a", "string", "inside", "a", "file" ]
def replace_in_file(filename, search, replace): filedata = None with open(filename, 'r') as f: filedata = f.read() filedata = filedata.replace(search, replace) with open(filename, 'w') as f: f.write(filedata)
[ "def", "replace_in_file", "(", "filename", ",", "search", ",", "replace", ")", ":", "filedata", "=", "None", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "filedata", "=", "f", ".", "read", "(", ")", "filedata", "=", "filedata", "...
Replaces a string inside a file
[ "Replaces", "a", "string", "inside", "a", "file" ]
[ "'''Replaces a string inside a file'''", "# Replace the target string", "# Write the file out again" ]
[ { "param": "filename", "type": null }, { "param": "search", "type": null }, { "param": "replace", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "search", "type": null, "docstring": null, "docstring_toke...
3898067099ce77cea28cbdc539b051b6d72ea8d3
ArcetriAdaptiveOptics/arte
test/utils/shared_array_test.py
[ "MIT" ]
Python
task
null
def task(arr, trig): ''' A task that polls on a trigger for max 5 seconds, and when triggered, modifies the input array. ''' timeout = 5 now = time.time() while True: if trig[0] == 1: break ...
A task that polls on a trigger for max 5 seconds, and when triggered, modifies the input array.
A task that polls on a trigger for max 5 seconds, and when triggered, modifies the input array.
[ "A", "task", "that", "polls", "on", "a", "trigger", "for", "max", "5", "seconds", "and", "when", "triggered", "modifies", "the", "input", "array", "." ]
def task(arr, trig): timeout = 5 now = time.time() while True: if trig[0] == 1: break time.sleep(0.01) if time.time() - now >= timeout: raise TimeoutError arr[1] = arr[0] + 1
[ "def", "task", "(", "arr", ",", "trig", ")", ":", "timeout", "=", "5", "now", "=", "time", ".", "time", "(", ")", "while", "True", ":", "if", "trig", "[", "0", "]", "==", "1", ":", "break", "time", ".", "sleep", "(", "0.01", ")", "if", "time"...
A task that polls on a trigger for max 5 seconds, and when triggered, modifies the input array.
[ "A", "task", "that", "polls", "on", "a", "trigger", "for", "max", "5", "seconds", "and", "when", "triggered", "modifies", "the", "input", "array", "." ]
[ "'''\n A task that polls on a trigger for max 5 seconds,\n and when triggered, modifies the input array.\n '''" ]
[ { "param": "arr", "type": null }, { "param": "trig", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "arr", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "trig", "type": null, "docstring": null, "docstring_tokens": []...
3f82c7aecd54a6c407c3e0f1ead3d54e5ebf26df
thanethomson/haproxy-session-mon
haproxysessionmon/config.py
[ "MIT", "MIT-0", "Unlicense" ]
Python
load_haproxysessionmon_config
<not_specific>
def load_haproxysessionmon_config(s): """Loads the HAProxy Session Monitor configuration from the given string, filling in defaults where necessary. Args: s: The string from which to load configuration. Returns: A Python dictionary containing the configuration. """ try: ...
Loads the HAProxy Session Monitor configuration from the given string, filling in defaults where necessary. Args: s: The string from which to load configuration. Returns: A Python dictionary containing the configuration.
Loads the HAProxy Session Monitor configuration from the given string, filling in defaults where necessary.
[ "Loads", "the", "HAProxy", "Session", "Monitor", "configuration", "from", "the", "given", "string", "filling", "in", "defaults", "where", "necessary", "." ]
def load_haproxysessionmon_config(s): try: config = yaml.load(s) except: raise ConfigError("YAML data seems broken", traceback=traceback.format_exc()) if 'backends' not in config or 'servers' not in config: raise ConfigError("Both the \"backends\" and \"servers\" sections are compuls...
[ "def", "load_haproxysessionmon_config", "(", "s", ")", ":", "try", ":", "config", "=", "yaml", ".", "load", "(", "s", ")", "except", ":", "raise", "ConfigError", "(", "\"YAML data seems broken\"", ",", "traceback", "=", "traceback", ".", "format_exc", "(", "...
Loads the HAProxy Session Monitor configuration from the given string, filling in defaults where necessary.
[ "Loads", "the", "HAProxy", "Session", "Monitor", "configuration", "from", "the", "given", "string", "filling", "in", "defaults", "where", "necessary", "." ]
[ "\"\"\"Loads the HAProxy Session Monitor configuration from the given string, filling in defaults\n where necessary.\n\n Args:\n s: The string from which to load configuration.\n\n Returns:\n A Python dictionary containing the configuration.\n \"\"\"" ]
[ { "param": "s", "type": null } ]
{ "returns": [ { "docstring": "A Python dictionary containing the configuration.", "docstring_tokens": [ "A", "Python", "dictionary", "containing", "the", "configuration", "." ], "type": null } ], "raises": [], "params": [ ...
a6c62071d0099ae2802e90dc71adccfde348c31a
thanethomson/haproxy-session-mon
haproxysessionmon/core.py
[ "MIT", "MIT-0", "Unlicense" ]
Python
create_monitors
<not_specific>
def create_monitors(config, loop): """Creates the HAProxy server monitors from the given configuration object.""" backends = dict() monitors = dict() for backend_id, backend_config in config['backends'].items(): logger.debug("Creating backend {} ({})".format(backend_id, backend_config['type']))...
Creates the HAProxy server monitors from the given configuration object.
Creates the HAProxy server monitors from the given configuration object.
[ "Creates", "the", "HAProxy", "server", "monitors", "from", "the", "given", "configuration", "object", "." ]
def create_monitors(config, loop): backends = dict() monitors = dict() for backend_id, backend_config in config['backends'].items(): logger.debug("Creating backend {} ({})".format(backend_id, backend_config['type'])) if backend_config['type'] == CONFIG_BACKEND_TYPE_GELF: backends...
[ "def", "create_monitors", "(", "config", ",", "loop", ")", ":", "backends", "=", "dict", "(", ")", "monitors", "=", "dict", "(", ")", "for", "backend_id", ",", "backend_config", "in", "config", "[", "'backends'", "]", ".", "items", "(", ")", ":", "logg...
Creates the HAProxy server monitors from the given configuration object.
[ "Creates", "the", "HAProxy", "server", "monitors", "from", "the", "given", "configuration", "object", "." ]
[ "\"\"\"Creates the HAProxy server monitors from the given configuration object.\"\"\"" ]
[ { "param": "config", "type": null }, { "param": "loop", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "config", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "loop", "type": null, "docstring": null, "docstring_tokens":...
0f3817f8e38ca82b020a0496c3d5f6b8b7b7af02
NoelKocheril/Dorime-Bot
src/dorime-bot.py
[ "MIT" ]
Python
on_message
None
async def on_message(self, message: discord.Message) -> None: """ Describes how to handle messages that the bot sees :param discord.Message message: The incoming message :return None """ # If the message is coming from the ignore... if message.author == self.use...
Describes how to handle messages that the bot sees :param discord.Message message: The incoming message :return None
Describes how to handle messages that the bot sees :param discord.Message message: The incoming message :return None
[ "Describes", "how", "to", "handle", "messages", "that", "the", "bot", "sees", ":", "param", "discord", ".", "Message", "message", ":", "The", "incoming", "message", ":", "return", "None" ]
async def on_message(self, message: discord.Message) -> None: if message.author == self.user: return author: discord.User = message.author channel: discord.TextChannel = message.channel if DEBUG: print( f"channel.id ({channel.id}) == SPOTIFY_WATCHE...
[ "async", "def", "on_message", "(", "self", ",", "message", ":", "discord", ".", "Message", ")", "->", "None", ":", "if", "message", ".", "author", "==", "self", ".", "user", ":", "return", "author", ":", "discord", ".", "User", "=", "message", ".", "...
Describes how to handle messages that the bot sees :param discord.Message message: The incoming message :return None
[ "Describes", "how", "to", "handle", "messages", "that", "the", "bot", "sees", ":", "param", "discord", ".", "Message", "message", ":", "The", "incoming", "message", ":", "return", "None" ]
[ "\"\"\"\n Describes how to handle messages that the bot sees\n\n :param discord.Message message: The incoming message\n :return None\n \"\"\"", "# If the message is coming from the ignore...", "# If the message starts with $hello, reply with Hello", "# TODO: Add Track id to Spotify...
[ { "param": "self", "type": null }, { "param": "message", "type": "discord.Message" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "message", "type": "discord.Message", "docstring": null, "docs...
3846bbcf8e47f316113211108c1900df927970c5
kolyanu4/SmartIR
custom_components/smartir/climate.py
[ "MIT" ]
Python
async_setup_platform
<not_specific>
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the IR Climate platform.""" device_code = config.get(CONF_DEVICE_CODE) device_files_subdir = os.path.join('codes', 'climate') device_files_absdir = os.path.join(COMPONENT_ABS_DIR, device_files_subdir) i...
Set up the IR Climate platform.
Set up the IR Climate platform.
[ "Set", "up", "the", "IR", "Climate", "platform", "." ]
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): device_code = config.get(CONF_DEVICE_CODE) device_files_subdir = os.path.join('codes', 'climate') device_files_absdir = os.path.join(COMPONENT_ABS_DIR, device_files_subdir) if not os.path.isdir(device_files_absdir): ...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "device_code", "=", "config", ".", "get", "(", "CONF_DEVICE_CODE", ")", "device_files_subdir", "=", "os", ".", "path", ...
Set up the IR Climate platform.
[ "Set", "up", "the", "IR", "Climate", "platform", "." ]
[ "\"\"\"Set up the IR Climate platform.\"\"\"" ]
[ { "param": "hass", "type": null }, { "param": "config", "type": null }, { "param": "async_add_entities", "type": null }, { "param": "discovery_info", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hass", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config", "type": null, "docstring": null, "docstring_tokens":...
3846bbcf8e47f316113211108c1900df927970c5
kolyanu4/SmartIR
custom_components/smartir/climate.py
[ "MIT" ]
Python
async_added_to_hass
null
async def async_added_to_hass(self): """Run when entity about to be added.""" await super().async_added_to_hass() last_state = await self.async_get_last_state() if last_state: self._hvac_mode = last_state.state self._current_fan_mode = last_state.attributes['fan...
Run when entity about to be added.
Run when entity about to be added.
[ "Run", "when", "entity", "about", "to", "be", "added", "." ]
async def async_added_to_hass(self): await super().async_added_to_hass() last_state = await self.async_get_last_state() if last_state: self._hvac_mode = last_state.state self._current_fan_mode = last_state.attributes['fan_mode'] self._target_temperature = last...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "last_state", "=", "await", "self", ".", "async_get_last_state", "(", ")", "if", "last_state", ":", "self", ".", "_hvac_mode", "="...
Run when entity about to be added.
[ "Run", "when", "entity", "about", "to", "be", "added", "." ]
[ "\"\"\"Run when entity about to be added.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
be5e8c3fbc0ed95b86801790740eb834fa949dd9
clbarnes/solve_sudoku
solver.py
[ "MIT" ]
Python
create_template
<not_specific>
def create_template(sudoku_order): """ Create a template string for printing sudoku results. Parameters ---------- sudoku_order: int The number of cells in a row or column of a subgrid; the number of rows or columns of subgrids in the sudoku. Returns ------- str Templat...
Create a template string for printing sudoku results. Parameters ---------- sudoku_order: int The number of cells in a row or column of a subgrid; the number of rows or columns of subgrids in the sudoku. Returns ------- str Template string used internally by Sudoku.print()...
Create a template string for printing sudoku results. Parameters int The number of cells in a row or column of a subgrid; the number of rows or columns of subgrids in the sudoku. Returns str Template string used internally by Sudoku.print()
[ "Create", "a", "template", "string", "for", "printing", "sudoku", "results", ".", "Parameters", "int", "The", "number", "of", "cells", "in", "a", "row", "or", "column", "of", "a", "subgrid", ";", "the", "number", "of", "rows", "or", "columns", "of", "sub...
def create_template(sudoku_order): cell = '{0}{{}}{0}'.format(PAD) block_row = CELL_VSEP.join([cell] * sudoku_order) row = BLOCK_VSEP.join([block_row] * sudoku_order) row_len = len(row) - row.count('}') cell_hline = '\n{}\n'.format(CELL_HSEP * row_len) if CELL_HSEP else '\n' block_rows = cell_hl...
[ "def", "create_template", "(", "sudoku_order", ")", ":", "cell", "=", "'{0}{{}}{0}'", ".", "format", "(", "PAD", ")", "block_row", "=", "CELL_VSEP", ".", "join", "(", "[", "cell", "]", "*", "sudoku_order", ")", "row", "=", "BLOCK_VSEP", ".", "join", "(",...
Create a template string for printing sudoku results.
[ "Create", "a", "template", "string", "for", "printing", "sudoku", "results", "." ]
[ "\"\"\"\n Create a template string for printing sudoku results.\n\n Parameters\n ----------\n sudoku_order: int\n The number of cells in a row or column of a subgrid; the number of rows or columns of subgrids in the sudoku.\n\n Returns\n -------\n str\n Template string used intern...
[ { "param": "sudoku_order", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sudoku_order", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
be5e8c3fbc0ed95b86801790740eb834fa949dd9
clbarnes/solve_sudoku
solver.py
[ "MIT" ]
Python
validate_array
<not_specific>
def validate_array(array): """ Validate an array to ensure that it is sudoku-shaped and has no illegal numbers in it (does not check for clashes). Returns sudoku order. Parameters ---------- array : list of list Initial sudoku cells, where 0 is an empty cell. Returns ------- ...
Validate an array to ensure that it is sudoku-shaped and has no illegal numbers in it (does not check for clashes). Returns sudoku order. Parameters ---------- array : list of list Initial sudoku cells, where 0 is an empty cell. Returns ------- int Sudoku order.
Validate an array to ensure that it is sudoku-shaped and has no illegal numbers in it (does not check for clashes). Returns sudoku order. Parameters array : list of list Initial sudoku cells, where 0 is an empty cell. Returns int Sudoku order.
[ "Validate", "an", "array", "to", "ensure", "that", "it", "is", "sudoku", "-", "shaped", "and", "has", "no", "illegal", "numbers", "in", "it", "(", "does", "not", "check", "for", "clashes", ")", ".", "Returns", "sudoku", "order", ".", "Parameters", "array...
def validate_array(array): n_rows = len(array) assert not sqrt(n_rows) % 1, 'Sudoku width is not a square number' sudoku_order = int(sqrt(n_rows)) valid_numbers = set(range(sudoku_order ** 2 + 1)) for row in array: assert len(row) == n_rows, 'Sudoku is not square' assert valid_number...
[ "def", "validate_array", "(", "array", ")", ":", "n_rows", "=", "len", "(", "array", ")", "assert", "not", "sqrt", "(", "n_rows", ")", "%", "1", ",", "'Sudoku width is not a square number'", "sudoku_order", "=", "int", "(", "sqrt", "(", "n_rows", ")", ")",...
Validate an array to ensure that it is sudoku-shaped and has no illegal numbers in it (does not check for clashes).
[ "Validate", "an", "array", "to", "ensure", "that", "it", "is", "sudoku", "-", "shaped", "and", "has", "no", "illegal", "numbers", "in", "it", "(", "does", "not", "check", "for", "clashes", ")", "." ]
[ "\"\"\"\n Validate an array to ensure that it is sudoku-shaped and has no illegal numbers in it (does not check for clashes).\n\n Returns sudoku order.\n\n Parameters\n ----------\n array : list of list\n Initial sudoku cells, where 0 is an empty cell.\n\n Returns\n -------\n int\n ...
[ { "param": "array", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "array", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
be5e8c3fbc0ed95b86801790740eb834fa949dd9
clbarnes/solve_sudoku
solver.py
[ "MIT" ]
Python
load_str
<not_specific>
def load_str(arr_str): """ Load sudoku-like array and its order from CSV-like string Parameters ---------- arr_str : str CSV string containing initial sudoku Returns ------- tuple of (list of list, int) Initial sudoku array and sudoku order """ if '\t' in arr_st...
Load sudoku-like array and its order from CSV-like string Parameters ---------- arr_str : str CSV string containing initial sudoku Returns ------- tuple of (list of list, int) Initial sudoku array and sudoku order
Load sudoku-like array and its order from CSV-like string Parameters arr_str : str CSV string containing initial sudoku Returns tuple of (list of list, int) Initial sudoku array and sudoku order
[ "Load", "sudoku", "-", "like", "array", "and", "its", "order", "from", "CSV", "-", "like", "string", "Parameters", "arr_str", ":", "str", "CSV", "string", "containing", "initial", "sudoku", "Returns", "tuple", "of", "(", "list", "of", "list", "int", ")", ...
def load_str(arr_str): if '\t' in arr_str: split = lambda s: s.strip().split('\t') elif ',' in arr_str: split = lambda s: s.strip().split(',') else: split = lambda s: iter(s) array = [[int(item.strip()) if item else 0 for item in split(row)] for row in arr_str.split('\n')] su...
[ "def", "load_str", "(", "arr_str", ")", ":", "if", "'\\t'", "in", "arr_str", ":", "split", "=", "lambda", "s", ":", "s", ".", "strip", "(", ")", ".", "split", "(", "'\\t'", ")", "elif", "','", "in", "arr_str", ":", "split", "=", "lambda", "s", ":...
Load sudoku-like array and its order from CSV-like string Parameters
[ "Load", "sudoku", "-", "like", "array", "and", "its", "order", "from", "CSV", "-", "like", "string", "Parameters" ]
[ "\"\"\"\n Load sudoku-like array and its order from CSV-like string\n\n Parameters\n ----------\n arr_str : str\n CSV string containing initial sudoku\n\n Returns\n -------\n tuple of (list of list, int)\n Initial sudoku array and sudoku order\n \"\"\"" ]
[ { "param": "arr_str", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "arr_str", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
be5e8c3fbc0ed95b86801790740eb834fa949dd9
clbarnes/solve_sudoku
solver.py
[ "MIT" ]
Python
eliminate
<not_specific>
def eliminate(self, value): """ Eliminate a value from the cell's possibilities Parameters ---------- value : int Value to eliminate from possibilities Returns ------- int If there remains only one possibility, return it. Otherwis...
Eliminate a value from the cell's possibilities Parameters ---------- value : int Value to eliminate from possibilities Returns ------- int If there remains only one possibility, return it. Otherwise, 0.
Eliminate a value from the cell's possibilities Parameters value : int Value to eliminate from possibilities Returns int If there remains only one possibility, return it. Otherwise, 0.
[ "Eliminate", "a", "value", "from", "the", "cell", "'", "s", "possibilities", "Parameters", "value", ":", "int", "Value", "to", "eliminate", "from", "possibilities", "Returns", "int", "If", "there", "remains", "only", "one", "possibility", "return", "it", ".", ...
def eliminate(self, value): if len(self.possibilities) == 1 and self.possibilities[0] == value: raise ClashException('Tried to eliminate the only possible value from a cell') try: self.possibilities.remove(value) return self.value except ValueError: ...
[ "def", "eliminate", "(", "self", ",", "value", ")", ":", "if", "len", "(", "self", ".", "possibilities", ")", "==", "1", "and", "self", ".", "possibilities", "[", "0", "]", "==", "value", ":", "raise", "ClashException", "(", "'Tried to eliminate the only p...
Eliminate a value from the cell's possibilities Parameters
[ "Eliminate", "a", "value", "from", "the", "cell", "'", "s", "possibilities", "Parameters" ]
[ "\"\"\"\n Eliminate a value from the cell's possibilities\n\n Parameters\n ----------\n value : int\n Value to eliminate from possibilities\n\n Returns\n -------\n int\n If there remains only one possibility, return it. Otherwise, 0.\n \"...
[ { "param": "self", "type": null }, { "param": "value", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": null, "docstring": null, "docstring_tokens": ...
be5e8c3fbc0ed95b86801790740eb834fa949dd9
clbarnes/solve_sudoku
solver.py
[ "MIT" ]
Python
matches
<not_specific>
def matches(self, other): """ Return whether this cell shares a row, column or subgrid with the other. Assumes same sudoku order. Parameters ---------- other : Cell Returns ------- bool """ return any([self.row == other.row, self.col == o...
Return whether this cell shares a row, column or subgrid with the other. Assumes same sudoku order. Parameters ---------- other : Cell Returns ------- bool
Return whether this cell shares a row, column or subgrid with the other. Assumes same sudoku order. Parameters other : Cell Returns bool
[ "Return", "whether", "this", "cell", "shares", "a", "row", "column", "or", "subgrid", "with", "the", "other", ".", "Assumes", "same", "sudoku", "order", ".", "Parameters", "other", ":", "Cell", "Returns", "bool" ]
def matches(self, other): return any([self.row == other.row, self.col == other.col, self.subgrid == other.subgrid])
[ "def", "matches", "(", "self", ",", "other", ")", ":", "return", "any", "(", "[", "self", ".", "row", "==", "other", ".", "row", ",", "self", ".", "col", "==", "other", ".", "col", ",", "self", ".", "subgrid", "==", "other", ".", "subgrid", "]", ...
Return whether this cell shares a row, column or subgrid with the other.
[ "Return", "whether", "this", "cell", "shares", "a", "row", "column", "or", "subgrid", "with", "the", "other", "." ]
[ "\"\"\"\n Return whether this cell shares a row, column or subgrid with the other. Assumes same sudoku order.\n\n Parameters\n ----------\n other : Cell\n\n Returns\n -------\n bool\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "other", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "other", "type": null, "docstring": null, "docstring_tokens": ...
be5e8c3fbc0ed95b86801790740eb834fa949dd9
clbarnes/solve_sudoku
solver.py
[ "MIT" ]
Python
eliminate
<not_specific>
def eliminate(self, cell): """ Given a cell with a determined value, eliminate that value from all cells sharing a row, column or block Parameters ---------- cell : Cell Cell whose value is now determined """ value = cell.value if not value: ...
Given a cell with a determined value, eliminate that value from all cells sharing a row, column or block Parameters ---------- cell : Cell Cell whose value is now determined
Given a cell with a determined value, eliminate that value from all cells sharing a row, column or block Parameters cell : Cell Cell whose value is now determined
[ "Given", "a", "cell", "with", "a", "determined", "value", "eliminate", "that", "value", "from", "all", "cells", "sharing", "a", "row", "column", "or", "block", "Parameters", "cell", ":", "Cell", "Cell", "whose", "value", "is", "now", "determined" ]
def eliminate(self, cell): value = cell.value if not value: return for idx, other_cell in enumerate(self.cells): if cell == other_cell: continue if cell.matches(other_cell): newly_set = other_cell.eliminate(value) ...
[ "def", "eliminate", "(", "self", ",", "cell", ")", ":", "value", "=", "cell", ".", "value", "if", "not", "value", ":", "return", "for", "idx", ",", "other_cell", "in", "enumerate", "(", "self", ".", "cells", ")", ":", "if", "cell", "==", "other_cell"...
Given a cell with a determined value, eliminate that value from all cells sharing a row, column or block Parameters
[ "Given", "a", "cell", "with", "a", "determined", "value", "eliminate", "that", "value", "from", "all", "cells", "sharing", "a", "row", "column", "or", "block", "Parameters" ]
[ "\"\"\"\n Given a cell with a determined value, eliminate that value from all cells sharing a row, column or block\n\n Parameters\n ----------\n cell : Cell\n Cell whose value is now determined\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "cell", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cell", "type": null, "docstring": null, "docstring_tokens": [...
be5e8c3fbc0ed95b86801790740eb834fa949dd9
clbarnes/solve_sudoku
solver.py
[ "MIT" ]
Python
solve
<not_specific>
def solve(self, callback=None): """ Return a solved copy of this sudoku. Parameters ---------- callback : callable Function to be called every time the function recurses Returns ------- Sudoku Solved sudoku """ new...
Return a solved copy of this sudoku. Parameters ---------- callback : callable Function to be called every time the function recurses Returns ------- Sudoku Solved sudoku
Return a solved copy of this sudoku. Parameters callback : callable Function to be called every time the function recurses Returns Sudoku Solved sudoku
[ "Return", "a", "solved", "copy", "of", "this", "sudoku", ".", "Parameters", "callback", ":", "callable", "Function", "to", "be", "called", "every", "time", "the", "function", "recurses", "Returns", "Sudoku", "Solved", "sudoku" ]
def solve(self, callback=None): new_sudoku = copy.deepcopy(self) ret_val = new_sudoku._easy_step() if callback: callback(new_sudoku.progress) if ret_val is None: logger.info('Sudoku solved!') return new_sudoku cell_idx, possibilities = ret_val ...
[ "def", "solve", "(", "self", ",", "callback", "=", "None", ")", ":", "new_sudoku", "=", "copy", ".", "deepcopy", "(", "self", ")", "ret_val", "=", "new_sudoku", ".", "_easy_step", "(", ")", "if", "callback", ":", "callback", "(", "new_sudoku", ".", "pr...
Return a solved copy of this sudoku.
[ "Return", "a", "solved", "copy", "of", "this", "sudoku", "." ]
[ "\"\"\"\n Return a solved copy of this sudoku.\n\n Parameters\n ----------\n callback : callable\n Function to be called every time the function recurses\n\n Returns\n -------\n Sudoku\n Solved sudoku\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "callback", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback", "type": null, "docstring": null, "docstring_tokens...
90af5b71f60971ebe10b7da7aa31c75bb5ea87d7
Jim-Holmstroem/bayesian-optimization
poc.py
[ "BSD-3-Clause" ]
Python
a_LCB
<not_specific>
def a_LCB(gp_model, x_obs, y_obs, kappa=1.0): """ kappa could partially be estimated, see [Srinivas et al., 2010] """ def a_LCB_given(x): mu_x, sigma_x = gp_model.predict(x, return_std=True) return -(mu_x - kappa * sigma_x) # FIXME fix this properly, the minus is a "hack" (or show that...
kappa could partially be estimated, see [Srinivas et al., 2010]
kappa could partially be estimated, see [Srinivas et al., 2010]
[ "kappa", "could", "partially", "be", "estimated", "see", "[", "Srinivas", "et", "al", ".", "2010", "]" ]
def a_LCB(gp_model, x_obs, y_obs, kappa=1.0): def a_LCB_given(x): mu_x, sigma_x = gp_model.predict(x, return_std=True) return -(mu_x - kappa * sigma_x) return a_LCB_given
[ "def", "a_LCB", "(", "gp_model", ",", "x_obs", ",", "y_obs", ",", "kappa", "=", "1.0", ")", ":", "def", "a_LCB_given", "(", "x", ")", ":", "mu_x", ",", "sigma_x", "=", "gp_model", ".", "predict", "(", "x", ",", "return_std", "=", "True", ")", "retu...
kappa could partially be estimated, see [Srinivas et al., 2010]
[ "kappa", "could", "partially", "be", "estimated", "see", "[", "Srinivas", "et", "al", ".", "2010", "]" ]
[ "\"\"\"\n kappa could partially be estimated, see [Srinivas et al., 2010]\n \"\"\"", "# FIXME fix this properly, the minus is a \"hack\" (or show that it's not a hack)" ]
[ { "param": "gp_model", "type": null }, { "param": "x_obs", "type": null }, { "param": "y_obs", "type": null }, { "param": "kappa", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "gp_model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x_obs", "type": null, "docstring": null, "docstring_token...
d629d6ad38c2209f53e8198369afcf56d9a6f63b
actionAxolot/django_model_helpers
model_helpers.py
[ "MIT" ]
Python
cached_model_property
<not_specific>
def cached_model_property(model_method=None, readonly=True, cache_timeout=None): """ cached_model_property is a decorator for model functions that takes no arguments The function is converted into a property that support caching out of the box :param readonly: set readonly parameter False to make the p...
cached_model_property is a decorator for model functions that takes no arguments The function is converted into a property that support caching out of the box :param readonly: set readonly parameter False to make the property writeable :type readonly: bool :param cache_timeout: number of seconds b...
cached_model_property is a decorator for model functions that takes no arguments The function is converted into a property that support caching out of the box
[ "cached_model_property", "is", "a", "decorator", "for", "model", "functions", "that", "takes", "no", "arguments", "The", "function", "is", "converted", "into", "a", "property", "that", "support", "caching", "out", "of", "the", "box" ]
def cached_model_property(model_method=None, readonly=True, cache_timeout=None): def func(f): def _get_cache_key(obj): model_name = getattr(obj, "_meta").db_table method_name = f.__name__ return "%s.%s.%s" % (model_name, obj.pk, method_name) def get_x(obj): ...
[ "def", "cached_model_property", "(", "model_method", "=", "None", ",", "readonly", "=", "True", ",", "cache_timeout", "=", "None", ")", ":", "def", "func", "(", "f", ")", ":", "def", "_get_cache_key", "(", "obj", ")", ":", "\"\"\"\n :type obj: djang...
cached_model_property is a decorator for model functions that takes no arguments The function is converted into a property that support caching out of the box
[ "cached_model_property", "is", "a", "decorator", "for", "model", "functions", "that", "takes", "no", "arguments", "The", "function", "is", "converted", "into", "a", "property", "that", "support", "caching", "out", "of", "the", "box" ]
[ "\"\"\"\n cached_model_property is a decorator for model functions that takes no arguments\n The function is converted into a property that support caching out of the box\n\n :param readonly: set readonly parameter False to make the property writeable\n :type readonly: bool\n :param cache_timeout: nu...
[ { "param": "model_method", "type": null }, { "param": "readonly", "type": null }, { "param": "cache_timeout", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model_method", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "readonly", "type": null, "docstring": "set readonly paramet...
d629d6ad38c2209f53e8198369afcf56d9a6f63b
actionAxolot/django_model_helpers
model_helpers.py
[ "MIT" ]
Python
del_x
null
def del_x(obj): """ Remove that property from the cache :param obj: :return: None """ cache_key = _get_cache_key(obj) # Remove that key from the cache cache.delete(cache_key)
Remove that property from the cache :param obj: :return: None
Remove that property from the cache
[ "Remove", "that", "property", "from", "the", "cache" ]
def del_x(obj): cache_key = _get_cache_key(obj) cache.delete(cache_key)
[ "def", "del_x", "(", "obj", ")", ":", "cache_key", "=", "_get_cache_key", "(", "obj", ")", "cache", ".", "delete", "(", "cache_key", ")" ]
Remove that property from the cache
[ "Remove", "that", "property", "from", "the", "cache" ]
[ "\"\"\"\n Remove that property from the cache\n :param obj:\n :return: None\n \"\"\"", "# Remove that key from the cache" ]
[ { "param": "obj", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "obj", "type": null, "docstring": null, "docstring_tokens": [ "None" ], "default": null, "...
a0773634dc069e3407699f50891ab584af37540b
samims/recipe-app-api
app/user/tests/test_user_api.py
[ "MIT" ]
Python
post_update_user_profile
null
def post_update_user_profile(self): """Test update user profile for authenticated user""" payload = { 'name': 'test111', 'password': 'newpass#123' } res = self.client.patch(ME_URL, payload) self.user.refresh_from_db() self.assertTrue(self.user.chec...
Test update user profile for authenticated user
Test update user profile for authenticated user
[ "Test", "update", "user", "profile", "for", "authenticated", "user" ]
def post_update_user_profile(self): payload = { 'name': 'test111', 'password': 'newpass#123' } res = self.client.patch(ME_URL, payload) self.user.refresh_from_db() self.assertTrue(self.user.check_password(payload['password'])) self.assertEqual(res....
[ "def", "post_update_user_profile", "(", "self", ")", ":", "payload", "=", "{", "'name'", ":", "'test111'", ",", "'password'", ":", "'newpass#123'", "}", "res", "=", "self", ".", "client", ".", "patch", "(", "ME_URL", ",", "payload", ")", "self", ".", "us...
Test update user profile for authenticated user
[ "Test", "update", "user", "profile", "for", "authenticated", "user" ]
[ "\"\"\"Test update user profile for authenticated user\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8586e39f44539c976f22a0f82ce6aa03defb3c58
samims/recipe-app-api
app/recipe/tests/test_recipe_api.py
[ "MIT" ]
Python
sample_recipe
<not_specific>
def sample_recipe(user, **params): """Create a return a sample recipe""" default = {"title": "Sample recipe", "time_minutes": 10, "price": 5.0} default.update(params) return Recipe.objects.create(user=user, **default)
Create a return a sample recipe
Create a return a sample recipe
[ "Create", "a", "return", "a", "sample", "recipe" ]
def sample_recipe(user, **params): default = {"title": "Sample recipe", "time_minutes": 10, "price": 5.0} default.update(params) return Recipe.objects.create(user=user, **default)
[ "def", "sample_recipe", "(", "user", ",", "**", "params", ")", ":", "default", "=", "{", "\"title\"", ":", "\"Sample recipe\"", ",", "\"time_minutes\"", ":", "10", ",", "\"price\"", ":", "5.0", "}", "default", ".", "update", "(", "params", ")", "return", ...
Create a return a sample recipe
[ "Create", "a", "return", "a", "sample", "recipe" ]
[ "\"\"\"Create a return a sample recipe\"\"\"" ]
[ { "param": "user", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "user", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8ee5c94dec6bec698f8c86c496726f1f993094a7
carlosfranzreb/skipgram
skipgram/utils.py
[ "MIT" ]
Python
compute_freqs
null
def compute_freqs(count_file, dump_file, power=.75): """Compute the frequencies of the counts raised to the given power. count_file (str): file with the dictionary with words and their counts. dump_file (str): file where the result should be dumped. power (float): value to which the counts should be raised be...
Compute the frequencies of the counts raised to the given power. count_file (str): file with the dictionary with words and their counts. dump_file (str): file where the result should be dumped. power (float): value to which the counts should be raised before computing the frequencies. The default value is the...
Compute the frequencies of the counts raised to the given power. count_file (str): file with the dictionary with words and their counts. dump_file (str): file where the result should be dumped. power (float): value to which the counts should be raised before computing the frequencies. The default value is the recommend...
[ "Compute", "the", "frequencies", "of", "the", "counts", "raised", "to", "the", "given", "power", ".", "count_file", "(", "str", ")", ":", "file", "with", "the", "dictionary", "with", "words", "and", "their", "counts", ".", "dump_file", "(", "str", ")", "...
def compute_freqs(count_file, dump_file, power=.75): vocab = json.load(open(count_file, encoding='utf-8')) vocab = {word: cnt**power for word, cnt in vocab.items()} total = sum(vocab.values()) vocab = {word: cnt/total for word, cnt in vocab.items()} json.dump(vocab, open(dump_file, 'w', encoding='utf-8'))
[ "def", "compute_freqs", "(", "count_file", ",", "dump_file", ",", "power", "=", ".75", ")", ":", "vocab", "=", "json", ".", "load", "(", "open", "(", "count_file", ",", "encoding", "=", "'utf-8'", ")", ")", "vocab", "=", "{", "word", ":", "cnt", "**"...
Compute the frequencies of the counts raised to the given power.
[ "Compute", "the", "frequencies", "of", "the", "counts", "raised", "to", "the", "given", "power", "." ]
[ "\"\"\"Compute the frequencies of the counts raised to the given power. \n count_file (str): file with the dictionary with words and their counts.\n dump_file (str): file where the result should be dumped. \n power (float): value to which the counts should be raised before computing\n the frequencies. The defau...
[ { "param": "count_file", "type": null }, { "param": "dump_file", "type": null }, { "param": "power", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "count_file", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dump_file", "type": null, "docstring": null, "docstring...
bd945d8c1a6cdb727fcfea85cf3649ac938f602e
carlosfranzreb/skipgram
skipgram/train.py
[ "MIT" ]
Python
log_loss
null
def log_loss(self, epoch=-1): """ If epoch=-1: log avg. loss of the last 100 batches. Before resetting the cnt and current_loss, add them to the totals for the epoch. Else: epoch has ended - log its avg. loss, set all counters to zero and call save_embeddings(). """ self.epoch_loss -= self.current_l...
If epoch=-1: log avg. loss of the last 100 batches. Before resetting the cnt and current_loss, add them to the totals for the epoch. Else: epoch has ended - log its avg. loss, set all counters to zero and call save_embeddings().
If epoch=-1: log avg. loss of the last 100 batches. Before resetting the cnt and current_loss, add them to the totals for the epoch. Else: epoch has ended - log its avg. loss, set all counters to zero and call save_embeddings().
[ "If", "epoch", "=", "-", "1", ":", "log", "avg", ".", "loss", "of", "the", "last", "100", "batches", ".", "Before", "resetting", "the", "cnt", "and", "current_loss", "add", "them", "to", "the", "totals", "for", "the", "epoch", ".", "Else", ":", "epoc...
def log_loss(self, epoch=-1): self.epoch_loss -= self.current_loss self.epoch_cnt += self.cnt if epoch > 0: avg_loss = self.epoch_loss / self.epoch_cnt logging.info(f'Avg. loss of epoch {epoch}: {avg_loss}') self.epoch_loss = 0 self.epoch_cnt = 0 self.save_embeddings(epoch) ...
[ "def", "log_loss", "(", "self", ",", "epoch", "=", "-", "1", ")", ":", "self", ".", "epoch_loss", "-=", "self", ".", "current_loss", "self", ".", "epoch_cnt", "+=", "self", ".", "cnt", "if", "epoch", ">", "0", ":", "avg_loss", "=", "self", ".", "ep...
If epoch=-1: log avg.
[ "If", "epoch", "=", "-", "1", ":", "log", "avg", "." ]
[ "\"\"\" If epoch=-1: log avg. loss of the last 100 batches. Before resetting\n the cnt and current_loss, add them to the totals for the epoch.\n Else: epoch has ended - log its avg. loss, set all counters to zero\n and call save_embeddings(). \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "epoch", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "epoch", "type": null, "docstring": null, "docstring_tokens": ...
bd945d8c1a6cdb727fcfea85cf3649ac938f602e
carlosfranzreb/skipgram
skipgram/train.py
[ "MIT" ]
Python
save_embeddings
null
def save_embeddings(self, epoch): """ Save the embeddings of the model as a dict with the words as keys and the embeddings as values. The file should be named 'epoch_{epoch}', in the 'run_id' folder. """ folder = f'skipgram/embeddings/{self.run_id}' if not os.path.exists(folder): os.mkdir(fold...
Save the embeddings of the model as a dict with the words as keys and the embeddings as values. The file should be named 'epoch_{epoch}', in the 'run_id' folder.
Save the embeddings of the model as a dict with the words as keys and the embeddings as values. The file should be named 'epoch_{epoch}', in the 'run_id' folder.
[ "Save", "the", "embeddings", "of", "the", "model", "as", "a", "dict", "with", "the", "words", "as", "keys", "and", "the", "embeddings", "as", "values", ".", "The", "file", "should", "be", "named", "'", "epoch_", "{", "epoch", "}", "'", "in", "the", "...
def save_embeddings(self, epoch): folder = f'skipgram/embeddings/{self.run_id}' if not os.path.exists(folder): os.mkdir(folder) if not os.path.exists(f'{folder}/entries.json'): json.dump(self.dataset.vocab.entries, open( f'{folder}/entries.json', 'w', encoding='utf-8' )) torch....
[ "def", "save_embeddings", "(", "self", ",", "epoch", ")", ":", "folder", "=", "f'skipgram/embeddings/{self.run_id}'", "if", "not", "os", ".", "path", ".", "exists", "(", "folder", ")", ":", "os", ".", "mkdir", "(", "folder", ")", "if", "not", "os", ".", ...
Save the embeddings of the model as a dict with the words as keys and the embeddings as values.
[ "Save", "the", "embeddings", "of", "the", "model", "as", "a", "dict", "with", "the", "words", "as", "keys", "and", "the", "embeddings", "as", "values", "." ]
[ "\"\"\" Save the embeddings of the model as a dict with the words as keys and\n the embeddings as values. The file should be named\n 'epoch_{epoch}', in the 'run_id' folder. \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "epoch", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "epoch", "type": null, "docstring": null, "docstring_tokens": ...
bd945d8c1a6cdb727fcfea85cf3649ac938f602e
carlosfranzreb/skipgram
skipgram/train.py
[ "MIT" ]
Python
init_training
null
def init_training(run_id, vocab_file, data_file, neg_samples, window, n_dims, batch_size=32, n_epochs=5, lr=.002): """ Configure logging, log the parameters of this training procedure and initialize training. """ logging.info('Training embeddings with the following parameters:') logging.info(f'Vocab file: {...
Configure logging, log the parameters of this training procedure and initialize training.
Configure logging, log the parameters of this training procedure and initialize training.
[ "Configure", "logging", "log", "the", "parameters", "of", "this", "training", "procedure", "and", "initialize", "training", "." ]
def init_training(run_id, vocab_file, data_file, neg_samples, window, n_dims, batch_size=32, n_epochs=5, lr=.002): logging.info('Training embeddings with the following parameters:') logging.info(f'Vocab file: {vocab_file}') logging.info(f'Data file: {data_file}') logging.info(f'No. of negative samples: {neg...
[ "def", "init_training", "(", "run_id", ",", "vocab_file", ",", "data_file", ",", "neg_samples", ",", "window", ",", "n_dims", ",", "batch_size", "=", "32", ",", "n_epochs", "=", "5", ",", "lr", "=", ".002", ")", ":", "logging", ".", "info", "(", "'Trai...
Configure logging, log the parameters of this training procedure and initialize training.
[ "Configure", "logging", "log", "the", "parameters", "of", "this", "training", "procedure", "and", "initialize", "training", "." ]
[ "\"\"\" Configure logging, log the parameters of this training procedure and\n initialize training. \"\"\"" ]
[ { "param": "run_id", "type": null }, { "param": "vocab_file", "type": null }, { "param": "data_file", "type": null }, { "param": "neg_samples", "type": null }, { "param": "window", "type": null }, { "param": "n_dims", "type": null }, { "par...
{ "returns": [], "raises": [], "params": [ { "identifier": "run_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vocab_file", "type": null, "docstring": null, "docstring_to...
cdb71d1eca77a0375b5644cd5dc918d98d30c71e
MatthewDaffern/redditbot
Common.py
[ "Unlicense" ]
Python
verse_slice
<not_specific>
def verse_slice(input_string): print(input_string) """This is the regex pattern that I hit on during testing for grabbing verse sections. Note that finditer is used I have no idea why it works best, but it's the only solution.""" pattern = '\[.{0,15}:.{0,10}\]' match = re.finditer(pattern, input_...
This is the regex pattern that I hit on during testing for grabbing verse sections. Note that finditer is used I have no idea why it works best, but it's the only solution.
This is the regex pattern that I hit on during testing for grabbing verse sections. Note that finditer is used I have no idea why it works best, but it's the only solution.
[ "This", "is", "the", "regex", "pattern", "that", "I", "hit", "on", "during", "testing", "for", "grabbing", "verse", "sections", ".", "Note", "that", "finditer", "is", "used", "I", "have", "no", "idea", "why", "it", "works", "best", "but", "it", "'", "s...
def verse_slice(input_string): print(input_string) pattern = '\[.{0,15}:.{0,10}\]' match = re.finditer(pattern, input_string) print(match) return list(map(lambda x: x.group(0), list(match)))
[ "def", "verse_slice", "(", "input_string", ")", ":", "print", "(", "input_string", ")", "pattern", "=", "'\\[.{0,15}:.{0,10}\\]'", "match", "=", "re", ".", "finditer", "(", "pattern", ",", "input_string", ")", "print", "(", "match", ")", "return", "list", "(...
This is the regex pattern that I hit on during testing for grabbing verse sections.
[ "This", "is", "the", "regex", "pattern", "that", "I", "hit", "on", "during", "testing", "for", "grabbing", "verse", "sections", "." ]
[ "\"\"\"This is the regex pattern that I hit on during testing for grabbing verse sections. Note that finditer is used\n I have no idea why it works best, but it's the only solution.\"\"\"" ]
[ { "param": "input_string", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "input_string", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cdb71d1eca77a0375b5644cd5dc918d98d30c71e
MatthewDaffern/redditbot
Common.py
[ "Unlicense" ]
Python
versions_transformer
<not_specific>
def versions_transformer(query_input, versions_dict_input): """Grabs the version and casts it to a list""" processed_query = query_input.upper() for i in list(versions_dict_input.keys()): result = re.search(str(i), processed_query) if result is not None: version = versions_dict_i...
Grabs the version and casts it to a list
Grabs the version and casts it to a list
[ "Grabs", "the", "version", "and", "casts", "it", "to", "a", "list" ]
def versions_transformer(query_input, versions_dict_input): processed_query = query_input.upper() for i in list(versions_dict_input.keys()): result = re.search(str(i), processed_query) if result is not None: version = versions_dict_input[result.group(0)] reduced_query = p...
[ "def", "versions_transformer", "(", "query_input", ",", "versions_dict_input", ")", ":", "processed_query", "=", "query_input", ".", "upper", "(", ")", "for", "i", "in", "list", "(", "versions_dict_input", ".", "keys", "(", ")", ")", ":", "result", "=", "re"...
Grabs the version and casts it to a list
[ "Grabs", "the", "version", "and", "casts", "it", "to", "a", "list" ]
[ "\"\"\"Grabs the version and casts it to a list\"\"\"" ]
[ { "param": "query_input", "type": null }, { "param": "versions_dict_input", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "query_input", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "versions_dict_input", "type": null, "docstring": null, ...
cdb71d1eca77a0375b5644cd5dc918d98d30c71e
MatthewDaffern/redditbot
Common.py
[ "Unlicense" ]
Python
book_transformer
<not_specific>
def book_transformer(query_input, book_dict_input): """grabs the book and casts it to a list""" sample_version = versions_dict.versions_dict() query_input[1] = query_input[1].replace('[', '').replace(']', '').lstrip().rstrip().upper() for i in list(book_dict_input.keys()): result = re.search(i, ...
grabs the book and casts it to a list
grabs the book and casts it to a list
[ "grabs", "the", "book", "and", "casts", "it", "to", "a", "list" ]
def book_transformer(query_input, book_dict_input): sample_version = versions_dict.versions_dict() query_input[1] = query_input[1].replace('[', '').replace(']', '').lstrip().rstrip().upper() for i in list(book_dict_input.keys()): result = re.search(i, query_input[1]) if result is not None: ...
[ "def", "book_transformer", "(", "query_input", ",", "book_dict_input", ")", ":", "sample_version", "=", "versions_dict", ".", "versions_dict", "(", ")", "query_input", "[", "1", "]", "=", "query_input", "[", "1", "]", ".", "replace", "(", "'['", ",", "''", ...
grabs the book and casts it to a list
[ "grabs", "the", "book", "and", "casts", "it", "to", "a", "list" ]
[ "\"\"\"grabs the book and casts it to a list\"\"\"" ]
[ { "param": "query_input", "type": null }, { "param": "book_dict_input", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "query_input", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "book_dict_input", "type": null, "docstring": null, "do...
cdb71d1eca77a0375b5644cd5dc918d98d30c71e
MatthewDaffern/redditbot
Common.py
[ "Unlicense" ]
Python
error_code_handler
<not_specific>
def error_code_handler(json_input_object): """I pass everything as a response now, so I technically produce only valid responses. This will work later down the way so when the response is compiled, it's a formatted error message.""" json_input = json.loads(json_input_object.text) if 'statusCode' in j...
I pass everything as a response now, so I technically produce only valid responses. This will work later down the way so when the response is compiled, it's a formatted error message.
I pass everything as a response now, so I technically produce only valid responses. This will work later down the way so when the response is compiled, it's a formatted error message.
[ "I", "pass", "everything", "as", "a", "response", "now", "so", "I", "technically", "produce", "only", "valid", "responses", ".", "This", "will", "work", "later", "down", "the", "way", "so", "when", "the", "response", "is", "compiled", "it", "'", "s", "a"...
def error_code_handler(json_input_object): json_input = json.loads(json_input_object.text) if 'statusCode' in json_input.keys(): if not json_input['statusCode'] == '200': json_input['copyright'] = 'Malformed Request' json_input['reference'] = "***\nif you are seeing this, You hav...
[ "def", "error_code_handler", "(", "json_input_object", ")", ":", "json_input", "=", "json", ".", "loads", "(", "json_input_object", ".", "text", ")", "if", "'statusCode'", "in", "json_input", ".", "keys", "(", ")", ":", "if", "not", "json_input", "[", "'stat...
I pass everything as a response now, so I technically produce only valid responses.
[ "I", "pass", "everything", "as", "a", "response", "now", "so", "I", "technically", "produce", "only", "valid", "responses", "." ]
[ "\"\"\"I pass everything as a response now, so I technically produce only valid responses.\n This will work later down the way so when the response is compiled, it's a formatted error message.\"\"\"" ]
[ { "param": "json_input_object", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "json_input_object", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
38414a025a15bf5e8cb8e4c7feea3afb485ff3ea
MatthewDaffern/redditbot
scripture_bot.py
[ "Unlicense" ]
Python
log_to_cloud_watch_input
<not_specific>
def log_to_cloud_watch_input(comment_input): """Cloud Watch records my print statements, making logging easy. So, now I just log input and output.""" return print(str.join('', (str(comment_input), '\n', str(comment_input.body), '\n', str(datetime.dat...
Cloud Watch records my print statements, making logging easy. So, now I just log input and output.
Cloud Watch records my print statements, making logging easy. So, now I just log input and output.
[ "Cloud", "Watch", "records", "my", "print", "statements", "making", "logging", "easy", ".", "So", "now", "I", "just", "log", "input", "and", "output", "." ]
def log_to_cloud_watch_input(comment_input): return print(str.join('', (str(comment_input), '\n', str(comment_input.body), '\n', str(datetime.date.today()))))
[ "def", "log_to_cloud_watch_input", "(", "comment_input", ")", ":", "return", "print", "(", "str", ".", "join", "(", "''", ",", "(", "str", "(", "comment_input", ")", ",", "'\\n'", ",", "str", "(", "comment_input", ".", "body", ")", ",", "'\\n'", ",", "...
Cloud Watch records my print statements, making logging easy.
[ "Cloud", "Watch", "records", "my", "print", "statements", "making", "logging", "easy", "." ]
[ "\"\"\"Cloud Watch records my print statements, making logging easy. So, now I just log input and output.\"\"\"" ]
[ { "param": "comment_input", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "comment_input", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
38414a025a15bf5e8cb8e4c7feea3afb485ff3ea
MatthewDaffern/redditbot
scripture_bot.py
[ "Unlicense" ]
Python
fullname_creator
<not_specific>
def fullname_creator(comment_object): """You need to grab a full_name for an object, and for whatever reason splitting it on a _ is the best.""" initial_fullname = str(comment_object.fullname) initial_fullname_array = initial_fullname.split('_') final_fullname = str(initial_fullname_array[1]) return...
You need to grab a full_name for an object, and for whatever reason splitting it on a _ is the best.
You need to grab a full_name for an object, and for whatever reason splitting it on a _ is the best.
[ "You", "need", "to", "grab", "a", "full_name", "for", "an", "object", "and", "for", "whatever", "reason", "splitting", "it", "on", "a", "_", "is", "the", "best", "." ]
def fullname_creator(comment_object): initial_fullname = str(comment_object.fullname) initial_fullname_array = initial_fullname.split('_') final_fullname = str(initial_fullname_array[1]) return final_fullname
[ "def", "fullname_creator", "(", "comment_object", ")", ":", "initial_fullname", "=", "str", "(", "comment_object", ".", "fullname", ")", "initial_fullname_array", "=", "initial_fullname", ".", "split", "(", "'_'", ")", "final_fullname", "=", "str", "(", "initial_f...
You need to grab a full_name for an object, and for whatever reason splitting it on a _ is the best.
[ "You", "need", "to", "grab", "a", "full_name", "for", "an", "object", "and", "for", "whatever", "reason", "splitting", "it", "on", "a", "_", "is", "the", "best", "." ]
[ "\"\"\"You need to grab a full_name for an object, and for whatever reason splitting it on a _ is the best.\"\"\"" ]
[ { "param": "comment_object", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "comment_object", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
38414a025a15bf5e8cb8e4c7feea3afb485ff3ea
MatthewDaffern/redditbot
scripture_bot.py
[ "Unlicense" ]
Python
list_creator
<not_specific>
def list_creator(reddit_object_input): """Instead of iterating using a for loop, this creates a list of unprocessed comments. Quicker tbh.""" unread = set(reddit_object_input.inbox.unread(limit=None)) saved = set(reddit_object_input.redditor('scripture_bot').saved(limit=10)) resultant_list = list(filter...
Instead of iterating using a for loop, this creates a list of unprocessed comments. Quicker tbh.
Instead of iterating using a for loop, this creates a list of unprocessed comments. Quicker tbh.
[ "Instead", "of", "iterating", "using", "a", "for", "loop", "this", "creates", "a", "list", "of", "unprocessed", "comments", ".", "Quicker", "tbh", "." ]
def list_creator(reddit_object_input): unread = set(reddit_object_input.inbox.unread(limit=None)) saved = set(reddit_object_input.redditor('scripture_bot').saved(limit=10)) resultant_list = list(filter(reddit_comment_author_filter, [x for x in unread if x not in saved])) filter_out_accidental_comments =...
[ "def", "list_creator", "(", "reddit_object_input", ")", ":", "unread", "=", "set", "(", "reddit_object_input", ".", "inbox", ".", "unread", "(", "limit", "=", "None", ")", ")", "saved", "=", "set", "(", "reddit_object_input", ".", "redditor", "(", "'scriptur...
Instead of iterating using a for loop, this creates a list of unprocessed comments.
[ "Instead", "of", "iterating", "using", "a", "for", "loop", "this", "creates", "a", "list", "of", "unprocessed", "comments", "." ]
[ "\"\"\"Instead of iterating using a for loop, this creates a list of unprocessed comments. Quicker tbh.\"\"\"" ]
[ { "param": "reddit_object_input", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "reddit_object_input", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8bfc854c8acfb3104b85408145fca39d28fec8ca
UMCUGenetics/CoNVident
Scripts/CNV_vis.py
[ "MIT" ]
Python
vcf_calls
<not_specific>
def vcf_calls(): """ The vcf_calls function opens a vcf file and retrieves al the reqions called in the vcf file. :return regions: A list of coordinates specified in the vcf file. """ vcf_file = pysam.VariantFile(args.vcf) regions = [] for call in vcf_file: chr = call.chrom sta...
The vcf_calls function opens a vcf file and retrieves al the reqions called in the vcf file. :return regions: A list of coordinates specified in the vcf file.
The vcf_calls function opens a vcf file and retrieves al the reqions called in the vcf file.
[ "The", "vcf_calls", "function", "opens", "a", "vcf", "file", "and", "retrieves", "al", "the", "reqions", "called", "in", "the", "vcf", "file", "." ]
def vcf_calls(): vcf_file = pysam.VariantFile(args.vcf) regions = [] for call in vcf_file: chr = call.chrom start = str(call.start - args.capture_region) stop = str(call.stop + args.capture_region) region = [chr, start, stop] regions.append(region) return regions
[ "def", "vcf_calls", "(", ")", ":", "vcf_file", "=", "pysam", ".", "VariantFile", "(", "args", ".", "vcf", ")", "regions", "=", "[", "]", "for", "call", "in", "vcf_file", ":", "chr", "=", "call", ".", "chrom", "start", "=", "str", "(", "call", ".", ...
The vcf_calls function opens a vcf file and retrieves al the reqions called in the vcf file.
[ "The", "vcf_calls", "function", "opens", "a", "vcf", "file", "and", "retrieves", "al", "the", "reqions", "called", "in", "the", "vcf", "file", "." ]
[ "\"\"\" The vcf_calls function opens a vcf file and retrieves al the reqions called in the vcf file.\n\n :return regions: A list of coordinates specified in the vcf file.\n \"\"\"" ]
[]
{ "returns": [ { "docstring": "A list of coordinates specified in the vcf file.", "docstring_tokens": [ "A", "list", "of", "coordinates", "specified", "in", "the", "vcf", "file", "." ], "type": "regions" } ...
8bfc854c8acfb3104b85408145fca39d28fec8ca
UMCUGenetics/CoNVident
Scripts/CNV_vis.py
[ "MIT" ]
Python
fetch_reads
<not_specific>
def fetch_reads(regions): """ The fetch_reads function fetches the reads and matches them with their pairs from the regions specified in the regions list. :param regions: A list containing the chromosome and coordinates for every region. :return all_reads: A list containing the number of reads in the s...
The fetch_reads function fetches the reads and matches them with their pairs from the regions specified in the regions list. :param regions: A list containing the chromosome and coordinates for every region. :return all_reads: A list containing the number of reads in the specified region
The fetch_reads function fetches the reads and matches them with their pairs from the regions specified in the regions list.
[ "The", "fetch_reads", "function", "fetches", "the", "reads", "and", "matches", "them", "with", "their", "pairs", "from", "the", "regions", "specified", "in", "the", "regions", "list", "." ]
def fetch_reads(regions): bamfile = pysam.AlignmentFile(args.bam, 'rb') all_reads = [] for loc in regions: reads = bamfile.fetch(str(loc[0]), int(loc[1]), int(loc[2])) all_reads.append(list(reads)) bamfile.close() return all_reads
[ "def", "fetch_reads", "(", "regions", ")", ":", "bamfile", "=", "pysam", ".", "AlignmentFile", "(", "args", ".", "bam", ",", "'rb'", ")", "all_reads", "=", "[", "]", "for", "loc", "in", "regions", ":", "reads", "=", "bamfile", ".", "fetch", "(", "str...
The fetch_reads function fetches the reads and matches them with their pairs from the regions specified in the regions list.
[ "The", "fetch_reads", "function", "fetches", "the", "reads", "and", "matches", "them", "with", "their", "pairs", "from", "the", "regions", "specified", "in", "the", "regions", "list", "." ]
[ "\"\"\" The fetch_reads function fetches the reads and matches them with their pairs from the regions specified in the\n regions list.\n\n :param regions: A list containing the chromosome and coordinates for every region.\n :return all_reads: A list containing the number of reads in the specified region\n ...
[ { "param": "regions", "type": null } ]
{ "returns": [ { "docstring": "A list containing the number of reads in the specified region", "docstring_tokens": [ "A", "list", "containing", "the", "number", "of", "reads", "in", "the", "specified", "region" ...
8bfc854c8acfb3104b85408145fca39d28fec8ca
UMCUGenetics/CoNVident
Scripts/CNV_vis.py
[ "MIT" ]
Python
isfacaway
<not_specific>
def isfacaway(read): """ The isfacaway function returns True if the reads in a pair are faced away from each other and false if they are not. :param read: Pysam object containing data of a read. :return bool: A bool telling if a read pair face away from each other. """ if read.is_paired and not...
The isfacaway function returns True if the reads in a pair are faced away from each other and false if they are not. :param read: Pysam object containing data of a read. :return bool: A bool telling if a read pair face away from each other.
The isfacaway function returns True if the reads in a pair are faced away from each other and false if they are not.
[ "The", "isfacaway", "function", "returns", "True", "if", "the", "reads", "in", "a", "pair", "are", "faced", "away", "from", "each", "other", "and", "false", "if", "they", "are", "not", "." ]
def isfacaway(read): if read.is_paired and not read.mate_is_unmapped: if read.is_read1: if read.is_reverse and not read.mate_is_reverse: return True else: return False else: if not read.is_reverse and read.mate_is_reverse: ...
[ "def", "isfacaway", "(", "read", ")", ":", "if", "read", ".", "is_paired", "and", "not", "read", ".", "mate_is_unmapped", ":", "if", "read", ".", "is_read1", ":", "if", "read", ".", "is_reverse", "and", "not", "read", ".", "mate_is_reverse", ":", "return...
The isfacaway function returns True if the reads in a pair are faced away from each other and false if they are not.
[ "The", "isfacaway", "function", "returns", "True", "if", "the", "reads", "in", "a", "pair", "are", "faced", "away", "from", "each", "other", "and", "false", "if", "they", "are", "not", "." ]
[ "\"\"\" The isfacaway function returns True if the reads in a pair are faced away from each other and false if they are\n not.\n\n :param read: Pysam object containing data of a read.\n :return bool: A bool telling if a read pair face away from each other.\n \"\"\"" ]
[ { "param": "read", "type": null } ]
{ "returns": [ { "docstring": "A bool telling if a read pair face away from each other.", "docstring_tokens": [ "A", "bool", "telling", "if", "a", "read", "pair", "face", "away", "from", "each", "other", ...
8bfc854c8acfb3104b85408145fca39d28fec8ca
UMCUGenetics/CoNVident
Scripts/CNV_vis.py
[ "MIT" ]
Python
isvalidread
<not_specific>
def isvalidread(read): """ Function that returns True if read is valid to be used for the high insert size calculation. :param read: Pysam object containing data of a read. :return boool: A boolean returning true if read is valid. """ if read.is_paired and not read.is_unmapped and not read.mate_is_...
Function that returns True if read is valid to be used for the high insert size calculation. :param read: Pysam object containing data of a read. :return boool: A boolean returning true if read is valid.
Function that returns True if read is valid to be used for the high insert size calculation.
[ "Function", "that", "returns", "True", "if", "read", "is", "valid", "to", "be", "used", "for", "the", "high", "insert", "size", "calculation", "." ]
def isvalidread(read): if read.is_paired and not read.is_unmapped and not read.mate_is_unmapped and not read.is_duplicate: return True else: return False
[ "def", "isvalidread", "(", "read", ")", ":", "if", "read", ".", "is_paired", "and", "not", "read", ".", "is_unmapped", "and", "not", "read", ".", "mate_is_unmapped", "and", "not", "read", ".", "is_duplicate", ":", "return", "True", "else", ":", "return", ...
Function that returns True if read is valid to be used for the high insert size calculation.
[ "Function", "that", "returns", "True", "if", "read", "is", "valid", "to", "be", "used", "for", "the", "high", "insert", "size", "calculation", "." ]
[ "\"\"\" Function that returns True if read is valid to be used for the high insert size calculation.\n\n :param read: Pysam object containing data of a read.\n :return boool: A boolean returning true if read is valid.\n \"\"\"" ]
[ { "param": "read", "type": null } ]
{ "returns": [ { "docstring": "A boolean returning true if read is valid.", "docstring_tokens": [ "A", "boolean", "returning", "true", "if", "read", "is", "valid", "." ], "type": "boool" } ], "raises": [], "p...
8bfc854c8acfb3104b85408145fca39d28fec8ca
UMCUGenetics/CoNVident
Scripts/CNV_vis.py
[ "MIT" ]
Python
issameorientation
<not_specific>
def issameorientation(read): """ The issameorientation function returns a bool returning true if a pair of reads have the same orientation and false if they have an oposite orientation. :param read: Pysam object containing data of a read. :return bool: A boolean returning True if the reads of a pair ha...
The issameorientation function returns a bool returning true if a pair of reads have the same orientation and false if they have an oposite orientation. :param read: Pysam object containing data of a read. :return bool: A boolean returning True if the reads of a pair have the same orientation.
The issameorientation function returns a bool returning true if a pair of reads have the same orientation and false if they have an oposite orientation.
[ "The", "issameorientation", "function", "returns", "a", "bool", "returning", "true", "if", "a", "pair", "of", "reads", "have", "the", "same", "orientation", "and", "false", "if", "they", "have", "an", "oposite", "orientation", "." ]
def issameorientation(read): if read.is_paired and not read.mate_is_unmapped: if read.is_reverse == read.mate_is_reverse: return True else: return False
[ "def", "issameorientation", "(", "read", ")", ":", "if", "read", ".", "is_paired", "and", "not", "read", ".", "mate_is_unmapped", ":", "if", "read", ".", "is_reverse", "==", "read", ".", "mate_is_reverse", ":", "return", "True", "else", ":", "return", "Fal...
The issameorientation function returns a bool returning true if a pair of reads have the same orientation and false if they have an oposite orientation.
[ "The", "issameorientation", "function", "returns", "a", "bool", "returning", "true", "if", "a", "pair", "of", "reads", "have", "the", "same", "orientation", "and", "false", "if", "they", "have", "an", "oposite", "orientation", "." ]
[ "\"\"\" The issameorientation function returns a bool returning true if a pair of reads have the same orientation and\n false if they have an oposite orientation.\n\n :param read: Pysam object containing data of a read.\n :return bool: A boolean returning True if the reads of a pair have the same orientati...
[ { "param": "read", "type": null } ]
{ "returns": [ { "docstring": "A boolean returning True if the reads of a pair have the same orientation.", "docstring_tokens": [ "A", "boolean", "returning", "True", "if", "the", "reads", "of", "a", "pair", "have"...
8bfc854c8acfb3104b85408145fca39d28fec8ca
UMCUGenetics/CoNVident
Scripts/CNV_vis.py
[ "MIT" ]
Python
write_bedfile
null
def write_bedfile(regions, read_data): """ The write_bedfile function writes a file in BED format that can be loaded in igv and visualises the read data. :param regions: a list of coordinates specified in the vcf file. :param read_data: a 2d list containing the read data of every region. """ text =...
The write_bedfile function writes a file in BED format that can be loaded in igv and visualises the read data. :param regions: a list of coordinates specified in the vcf file. :param read_data: a 2d list containing the read data of every region.
The write_bedfile function writes a file in BED format that can be loaded in igv and visualises the read data.
[ "The", "write_bedfile", "function", "writes", "a", "file", "in", "BED", "format", "that", "can", "be", "loaded", "in", "igv", "and", "visualises", "the", "read", "data", "." ]
def write_bedfile(regions, read_data): text = 'track name=CNV_information description="Region_Summary." db=hg19 gffTags=on\n' for index in range(0, len(regions)): region = f"{regions[index][0]}\t{regions[index][1]}\t{regions[index][2]}" paired_reads = read_data[index][0] unmapped_mate = ...
[ "def", "write_bedfile", "(", "regions", ",", "read_data", ")", ":", "text", "=", "'track name=CNV_information description=\"Region_Summary.\" db=hg19 gffTags=on\\n'", "for", "index", "in", "range", "(", "0", ",", "len", "(", "regions", ")", ")", ":", "region", "=", ...
The write_bedfile function writes a file in BED format that can be loaded in igv and visualises the read data.
[ "The", "write_bedfile", "function", "writes", "a", "file", "in", "BED", "format", "that", "can", "be", "loaded", "in", "igv", "and", "visualises", "the", "read", "data", "." ]
[ "\"\"\" The write_bedfile function writes a file in BED format that can be loaded in igv and visualises the read data.\n\n :param regions: a list of coordinates specified in the vcf file.\n :param read_data: a 2d list containing the read data of every region.\n \"\"\"" ]
[ { "param": "regions", "type": null }, { "param": "read_data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "regions", "type": null, "docstring": "a list of coordinates specified in the vcf file.", "docstring_tokens": [ "a", "list", "of", "coordinates", "specified", "in", "the",...
8bfc854c8acfb3104b85408145fca39d28fec8ca
UMCUGenetics/CoNVident
Scripts/CNV_vis.py
[ "MIT" ]
Python
write_logfile
null
def write_logfile(): """ The write logfile function writes a log.txt file in the output folder and writes all the parameters down.""" current_path = os.getcwd() current_time = datetime.now().strftime("%H:%M:%S") current_day = date.today().strftime("%d/%m/%Y") text = f'Logfile created by: {current_...
The write logfile function writes a log.txt file in the output folder and writes all the parameters down.
The write logfile function writes a log.txt file in the output folder and writes all the parameters down.
[ "The", "write", "logfile", "function", "writes", "a", "log", ".", "txt", "file", "in", "the", "output", "folder", "and", "writes", "all", "the", "parameters", "down", "." ]
def write_logfile(): current_path = os.getcwd() current_time = datetime.now().strftime("%H:%M:%S") current_day = date.today().strftime("%d/%m/%Y") text = f'Logfile created by: {current_path}\nScript finished at: {current_time} {current_day}\n{"-"*80}\n' \ f'Parameters:\nBamfile: {args.bam}\nV...
[ "def", "write_logfile", "(", ")", ":", "current_path", "=", "os", ".", "getcwd", "(", ")", "current_time", "=", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "\"%H:%M:%S\"", ")", "current_day", "=", "date", ".", "today", "(", ")", ".", "strft...
The write logfile function writes a log.txt file in the output folder and writes all the parameters down.
[ "The", "write", "logfile", "function", "writes", "a", "log", ".", "txt", "file", "in", "the", "output", "folder", "and", "writes", "all", "the", "parameters", "down", "." ]
[ "\"\"\" The write logfile function writes a log.txt file in the output folder and writes all the parameters down.\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
b88f9fe8555e3e4cb1c1ba8b250d1442cecf5c6a
UMCUGenetics/CoNVident
Scripts/Start_job.py
[ "MIT" ]
Python
write_bedfile
null
def write_bedfile(chromosome): """ The write_bedfile function runs the Flag_placer.py script for the given chromosome with the given arguments. :param chromosome: Int or Str specifying the chromosome. """ if not os.path.exists(f"{args.output}/{args.name}_{chromosome}.bed"): os.system(f'python3 ...
The write_bedfile function runs the Flag_placer.py script for the given chromosome with the given arguments. :param chromosome: Int or Str specifying the chromosome.
The write_bedfile function runs the Flag_placer.py script for the given chromosome with the given arguments.
[ "The", "write_bedfile", "function", "runs", "the", "Flag_placer", ".", "py", "script", "for", "the", "given", "chromosome", "with", "the", "given", "arguments", "." ]
def write_bedfile(chromosome): if not os.path.exists(f"{args.output}/{args.name}_{chromosome}.bed"): os.system(f'python3 Flag_placer.py -b "{args.bam}"' f' -o "{args.output}"' f' -r "chr{chromosome}"' f' -t {args.threshold}' f' -mp {arg...
[ "def", "write_bedfile", "(", "chromosome", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "f\"{args.output}/{args.name}_{chromosome}.bed\"", ")", ":", "os", ".", "system", "(", "f'python3 Flag_placer.py -b \"{args.bam}\"'", "f' -o \"{args.output}\"'", "f'...
The write_bedfile function runs the Flag_placer.py script for the given chromosome with the given arguments.
[ "The", "write_bedfile", "function", "runs", "the", "Flag_placer", ".", "py", "script", "for", "the", "given", "chromosome", "with", "the", "given", "arguments", "." ]
[ "\"\"\" The write_bedfile function runs the Flag_placer.py script for the given chromosome with the given arguments.\n\n :param chromosome: Int or Str specifying the chromosome.\n \"\"\"" ]
[ { "param": "chromosome", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chromosome", "type": null, "docstring": "Int or Str specifying the chromosome.", "docstring_tokens": [ "Int", "or", "Str", "specifying", "the", "chromosome", "." ],...
b88f9fe8555e3e4cb1c1ba8b250d1442cecf5c6a
UMCUGenetics/CoNVident
Scripts/Start_job.py
[ "MIT" ]
Python
write_bedgraphfile
null
def write_bedgraphfile(chromosome): """ The write_bedgraphfile function runs the softclipp_graph.py script for the given chromosome with the given arguments :param chromosome: Int or Str specifying the chromosome. """ if not os.path.exists(f"{args.output}/{args.name}_{chromosome}.BedGraph"): ...
The write_bedgraphfile function runs the softclipp_graph.py script for the given chromosome with the given arguments :param chromosome: Int or Str specifying the chromosome.
The write_bedgraphfile function runs the softclipp_graph.py script for the given chromosome with the given arguments
[ "The", "write_bedgraphfile", "function", "runs", "the", "softclipp_graph", ".", "py", "script", "for", "the", "given", "chromosome", "with", "the", "given", "arguments" ]
def write_bedgraphfile(chromosome): if not os.path.exists(f"{args.output}/{args.name}_{chromosome}.BedGraph"): os.system(f'python3 softclip_graph.py -b "{args.bam}"' f' -o "{args.output}"' f' -r "chr{chromosome}"' f' -n "{args.name}_{chromosome}"')
[ "def", "write_bedgraphfile", "(", "chromosome", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "f\"{args.output}/{args.name}_{chromosome}.BedGraph\"", ")", ":", "os", ".", "system", "(", "f'python3 softclip_graph.py -b \"{args.bam}\"'", "f' -o \"{args.outpu...
The write_bedgraphfile function runs the softclipp_graph.py script for the given chromosome with the given arguments
[ "The", "write_bedgraphfile", "function", "runs", "the", "softclipp_graph", ".", "py", "script", "for", "the", "given", "chromosome", "with", "the", "given", "arguments" ]
[ "\"\"\" The write_bedgraphfile function runs the softclipp_graph.py script for the given chromosome with the given\n arguments\n\n :param chromosome: Int or Str specifying the chromosome.\n \"\"\"" ]
[ { "param": "chromosome", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chromosome", "type": null, "docstring": "Int or Str specifying the chromosome.", "docstring_tokens": [ "Int", "or", "Str", "specifying", "the", "chromosome", "." ],...
b88f9fe8555e3e4cb1c1ba8b250d1442cecf5c6a
UMCUGenetics/CoNVident
Scripts/Start_job.py
[ "MIT" ]
Python
merge_bedfiles
null
def merge_bedfiles(chromosomes, extension): """ The merge_bedfiles function combines all the bedfiles or BedGraph files into one large file. :param chromosomes: Int or Str specifying the chromosome. :param extension: Str representing the file extension. """ with open(f"{args.output}/{args.name}.{ex...
The merge_bedfiles function combines all the bedfiles or BedGraph files into one large file. :param chromosomes: Int or Str specifying the chromosome. :param extension: Str representing the file extension.
The merge_bedfiles function combines all the bedfiles or BedGraph files into one large file.
[ "The", "merge_bedfiles", "function", "combines", "all", "the", "bedfiles", "or", "BedGraph", "files", "into", "one", "large", "file", "." ]
def merge_bedfiles(chromosomes, extension): with open(f"{args.output}/{args.name}.{extension}", 'w') as output: output.write('track name=Flags description="Flags regions of interest." db=hg19 gffTags=on itemRGB="On"\n') for chromosome in chromosomes: bedfile_text = get_bed_text(chromosome, exten...
[ "def", "merge_bedfiles", "(", "chromosomes", ",", "extension", ")", ":", "with", "open", "(", "f\"{args.output}/{args.name}.{extension}\"", ",", "'w'", ")", "as", "output", ":", "output", ".", "write", "(", "'track name=Flags description=\"Flags regions of interest.\" db=...
The merge_bedfiles function combines all the bedfiles or BedGraph files into one large file.
[ "The", "merge_bedfiles", "function", "combines", "all", "the", "bedfiles", "or", "BedGraph", "files", "into", "one", "large", "file", "." ]
[ "\"\"\" The merge_bedfiles function combines all the bedfiles or BedGraph files into one large file.\n\n :param chromosomes: Int or Str specifying the chromosome.\n :param extension: Str representing the file extension.\n \"\"\"" ]
[ { "param": "chromosomes", "type": null }, { "param": "extension", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chromosomes", "type": null, "docstring": "Int or Str specifying the chromosome.", "docstring_tokens": [ "Int", "or", "Str", "specifying", "the", "chromosome", "." ]...
b88f9fe8555e3e4cb1c1ba8b250d1442cecf5c6a
UMCUGenetics/CoNVident
Scripts/Start_job.py
[ "MIT" ]
Python
bedfile_handle
null
def bedfile_handle(chromosomes, extension): """ The bedfile_handle function divides the chromosomes over the number of cores to multiprocess the Flag_placer.py script. :param chromosomes: A list of all chromosomes. :param extension: A string identifying the script that should be called. """ if ...
The bedfile_handle function divides the chromosomes over the number of cores to multiprocess the Flag_placer.py script. :param chromosomes: A list of all chromosomes. :param extension: A string identifying the script that should be called.
The bedfile_handle function divides the chromosomes over the number of cores to multiprocess the Flag_placer.py script.
[ "The", "bedfile_handle", "function", "divides", "the", "chromosomes", "over", "the", "number", "of", "cores", "to", "multiprocess", "the", "Flag_placer", ".", "py", "script", "." ]
def bedfile_handle(chromosomes, extension): if extension == 'flags': with Pool(args.cores) as p: p.map(write_bedfile, chromosomes) else: with Pool(args.cores) as p: p.map(write_bedgraphfile, chromosomes)
[ "def", "bedfile_handle", "(", "chromosomes", ",", "extension", ")", ":", "if", "extension", "==", "'flags'", ":", "with", "Pool", "(", "args", ".", "cores", ")", "as", "p", ":", "p", ".", "map", "(", "write_bedfile", ",", "chromosomes", ")", "else", ":...
The bedfile_handle function divides the chromosomes over the number of cores to multiprocess the Flag_placer.py script.
[ "The", "bedfile_handle", "function", "divides", "the", "chromosomes", "over", "the", "number", "of", "cores", "to", "multiprocess", "the", "Flag_placer", ".", "py", "script", "." ]
[ "\"\"\" The bedfile_handle function divides the chromosomes over the number of cores to multiprocess the Flag_placer.py\n script.\n\n :param chromosomes: A list of all chromosomes.\n :param extension: A string identifying the script that should be called.\n \"\"\"" ]
[ { "param": "chromosomes", "type": null }, { "param": "extension", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chromosomes", "type": null, "docstring": "A list of all chromosomes.", "docstring_tokens": [ "A", "list", "of", "all", "chromosomes", "." ], "default": null, "i...
5a37f56bf404833ff4c20ef7af56114575486dcf
UMCUGenetics/CoNVident
Scripts/softclip_graph.py
[ "MIT" ]
Python
fetch_reads
<not_specific>
def fetch_reads(): """ The fetch_reads function fetches the reads from the bam file :return reads: Pysam object containing read information """ bamfile = pysam.AlignmentFile(args.bam, 'rb') if args.region == 'all': reads = bamfile.fetch() else: if ':' in args.region and '-' in...
The fetch_reads function fetches the reads from the bam file :return reads: Pysam object containing read information
The fetch_reads function fetches the reads from the bam file
[ "The", "fetch_reads", "function", "fetches", "the", "reads", "from", "the", "bam", "file" ]
def fetch_reads(): bamfile = pysam.AlignmentFile(args.bam, 'rb') if args.region == 'all': reads = bamfile.fetch() else: if ':' in args.region and '-' in args.region: chromosome, start, end = re.split(':|-', args.region) chromosome = chromosome.replace('chr', '') ...
[ "def", "fetch_reads", "(", ")", ":", "bamfile", "=", "pysam", ".", "AlignmentFile", "(", "args", ".", "bam", ",", "'rb'", ")", "if", "args", ".", "region", "==", "'all'", ":", "reads", "=", "bamfile", ".", "fetch", "(", ")", "else", ":", "if", "':'...
The fetch_reads function fetches the reads from the bam file
[ "The", "fetch_reads", "function", "fetches", "the", "reads", "from", "the", "bam", "file" ]
[ "\"\"\" The fetch_reads function fetches the reads from the bam file\n\n :return reads: Pysam object containing read information\n \"\"\"" ]
[]
{ "returns": [ { "docstring": "Pysam object containing read information", "docstring_tokens": [ "Pysam", "object", "containing", "read", "information" ], "type": "reads" } ], "raises": [], "params": [], "outlier_params": [], "others": [...
5a37f56bf404833ff4c20ef7af56114575486dcf
UMCUGenetics/CoNVident
Scripts/softclip_graph.py
[ "MIT" ]
Python
remove_old
<not_specific>
def remove_old(handle, read_start): """ The remove old function removes the basepairs that do not have sofclips to save memory. :param softclip_data: A dictionary with positions and the number of "normal" bases and softclip bases. :param read_start: An integer representing the place where the read start. ...
The remove old function removes the basepairs that do not have sofclips to save memory. :param softclip_data: A dictionary with positions and the number of "normal" bases and softclip bases. :param read_start: An integer representing the place where the read start. :return sofclip_data: A dictionary with ...
The remove old function removes the basepairs that do not have sofclips to save memory.
[ "The", "remove", "old", "function", "removes", "the", "basepairs", "that", "do", "not", "have", "sofclips", "to", "save", "memory", "." ]
def remove_old(handle, read_start): remove = [] new_softclip_data = {} for position in handle: if position < (read_start-151): if handle[position][1] == 0: remove.append(position) else: new_softclip_data.update({position: handle[position]}) ...
[ "def", "remove_old", "(", "handle", ",", "read_start", ")", ":", "remove", "=", "[", "]", "new_softclip_data", "=", "{", "}", "for", "position", "in", "handle", ":", "if", "position", "<", "(", "read_start", "-", "151", ")", ":", "if", "handle", "[", ...
The remove old function removes the basepairs that do not have sofclips to save memory.
[ "The", "remove", "old", "function", "removes", "the", "basepairs", "that", "do", "not", "have", "sofclips", "to", "save", "memory", "." ]
[ "\"\"\" The remove old function removes the basepairs that do not have sofclips to save memory.\n\n :param softclip_data: A dictionary with positions and the number of \"normal\" bases and softclip bases.\n :param read_start: An integer representing the place where the read start.\n :return sofclip_data: A...
[ { "param": "handle", "type": null }, { "param": "read_start", "type": null } ]
{ "returns": [ { "docstring": "A dictionary with positions and the number of \"normal\" bases and softclip bases.", "docstring_tokens": [ "A", "dictionary", "with", "positions", "and", "the", "number", "of", "\"", "normal"...
5a37f56bf404833ff4c20ef7af56114575486dcf
UMCUGenetics/CoNVident
Scripts/softclip_graph.py
[ "MIT" ]
Python
update_softclipdata
<not_specific>
def update_softclipdata(region, softclipdata): """ The update_softclipdata function updates the softclipdata dictionary with new information. :param region: A region of a read defined by the cigar string. :param softclipdata: A dictionary with positions and the number of "normal" bases and softclip bases. ...
The update_softclipdata function updates the softclipdata dictionary with new information. :param region: A region of a read defined by the cigar string. :param softclipdata: A dictionary with positions and the number of "normal" bases and softclip bases. :return sofclipdata: A dictionary with positions a...
The update_softclipdata function updates the softclipdata dictionary with new information.
[ "The", "update_softclipdata", "function", "updates", "the", "softclipdata", "dictionary", "with", "new", "information", "." ]
def update_softclipdata(region, softclipdata): if region[2] == 'normal': index = 0 else: index = 1 for pos in range(region[0], region[1]): if pos in softclipdata: softclipdata[pos][index] += 1 else: posdata = [0, 0] posdata[index] += 1 ...
[ "def", "update_softclipdata", "(", "region", ",", "softclipdata", ")", ":", "if", "region", "[", "2", "]", "==", "'normal'", ":", "index", "=", "0", "else", ":", "index", "=", "1", "for", "pos", "in", "range", "(", "region", "[", "0", "]", ",", "re...
The update_softclipdata function updates the softclipdata dictionary with new information.
[ "The", "update_softclipdata", "function", "updates", "the", "softclipdata", "dictionary", "with", "new", "information", "." ]
[ "\"\"\" The update_softclipdata function updates the softclipdata dictionary with new information.\n\n :param region: A region of a read defined by the cigar string.\n :param softclipdata: A dictionary with positions and the number of \"normal\" bases and softclip bases.\n :return sofclipdata: A dictionary...
[ { "param": "region", "type": null }, { "param": "softclipdata", "type": null } ]
{ "returns": [ { "docstring": "A dictionary with positions and the number of \"normal\" bases and softclip bases.", "docstring_tokens": [ "A", "dictionary", "with", "positions", "and", "the", "number", "of", "\"", "normal"...
5a37f56bf404833ff4c20ef7af56114575486dcf
UMCUGenetics/CoNVident
Scripts/softclip_graph.py
[ "MIT" ]
Python
softclip_regions
<not_specific>
def softclip_regions(read_start, cigar): """ The softclip regions function iterates over the cigar string and returns the positions and if they are "normal" or a softclipped region. :param read_start: An integer representing the start of the read (including unmapped bases) :param cigar: a list containi...
The softclip regions function iterates over the cigar string and returns the positions and if they are "normal" or a softclipped region. :param read_start: An integer representing the start of the read (including unmapped bases) :param cigar: a list containing tuples representing the cigar string. :re...
The softclip regions function iterates over the cigar string and returns the positions and if they are "normal" or a softclipped region.
[ "The", "softclip", "regions", "function", "iterates", "over", "the", "cigar", "string", "and", "returns", "the", "positions", "and", "if", "they", "are", "\"", "normal", "\"", "or", "a", "softclipped", "region", "." ]
def softclip_regions(read_start, cigar): regions = [] cursor = read_start for element in cigar: if element[0] == 4: regions.append([cursor, cursor+element[1], 'softclip']) else: regions.append([cursor, cursor+element[1], 'normal']) cursor += element[1] ret...
[ "def", "softclip_regions", "(", "read_start", ",", "cigar", ")", ":", "regions", "=", "[", "]", "cursor", "=", "read_start", "for", "element", "in", "cigar", ":", "if", "element", "[", "0", "]", "==", "4", ":", "regions", ".", "append", "(", "[", "cu...
The softclip regions function iterates over the cigar string and returns the positions and if they are "normal" or a softclipped region.
[ "The", "softclip", "regions", "function", "iterates", "over", "the", "cigar", "string", "and", "returns", "the", "positions", "and", "if", "they", "are", "\"", "normal", "\"", "or", "a", "softclipped", "region", "." ]
[ "\"\"\" The softclip regions function iterates over the cigar string and returns the positions and if they are \"normal\"\n or a softclipped region.\n\n :param read_start: An integer representing the start of the read (including unmapped bases)\n :param cigar: a list containing tuples representing the ciga...
[ { "param": "read_start", "type": null }, { "param": "cigar", "type": null } ]
{ "returns": [ { "docstring": "a 2d list containing the regions of a read and specifying if they are \"normal\" or softclipped.", "docstring_tokens": [ "a", "2d", "list", "containing", "the", "regions", "of", "a", "read", ...
5a37f56bf404833ff4c20ef7af56114575486dcf
UMCUGenetics/CoNVident
Scripts/softclip_graph.py
[ "MIT" ]
Python
true_start
<not_specific>
def true_start(cigar, matchstart): """ The true_start function receives the cigar string and the starting position of the first match in a read. It returns the start position of the read including unmapped parts. :param cigar: a list containing tuples representing the cigar string. :param matchstart: a...
The true_start function receives the cigar string and the starting position of the first match in a read. It returns the start position of the read including unmapped parts. :param cigar: a list containing tuples representing the cigar string. :param matchstart: an integer representing the start of the fi...
The true_start function receives the cigar string and the starting position of the first match in a read. It returns the start position of the read including unmapped parts.
[ "The", "true_start", "function", "receives", "the", "cigar", "string", "and", "the", "starting", "position", "of", "the", "first", "match", "in", "a", "read", ".", "It", "returns", "the", "start", "position", "of", "the", "read", "including", "unmapped", "pa...
def true_start(cigar, matchstart): overshoot = 0 for element in cigar: if element[0] != 0: overshoot += element[1] else: break read_start = matchstart - overshoot return read_start
[ "def", "true_start", "(", "cigar", ",", "matchstart", ")", ":", "overshoot", "=", "0", "for", "element", "in", "cigar", ":", "if", "element", "[", "0", "]", "!=", "0", ":", "overshoot", "+=", "element", "[", "1", "]", "else", ":", "break", "read_star...
The true_start function receives the cigar string and the starting position of the first match in a read.
[ "The", "true_start", "function", "receives", "the", "cigar", "string", "and", "the", "starting", "position", "of", "the", "first", "match", "in", "a", "read", "." ]
[ "\"\"\" The true_start function receives the cigar string and the starting position of the first match in a read. It\n returns the start position of the read including unmapped parts.\n\n :param cigar: a list containing tuples representing the cigar string.\n :param matchstart: an integer representing the ...
[ { "param": "cigar", "type": null }, { "param": "matchstart", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cigar", "type": null, "docstring": "a list containing tuples representing the cigar string.", "docstring_tokens": [ "a", "list", "containing", "tuples", "representing", "the", ...
5a37f56bf404833ff4c20ef7af56114575486dcf
UMCUGenetics/CoNVident
Scripts/softclip_graph.py
[ "MIT" ]
Python
sort_flags
<not_specific>
def sort_flags(flags): """ The sort_flags function sorts the flags on starting position using insertionsort. :param flags: a 2d list containing all the flag information. :return flags: a 2d list containing all the flag information. """ for i in range(1, len(flags)): key = flags[i][1] ...
The sort_flags function sorts the flags on starting position using insertionsort. :param flags: a 2d list containing all the flag information. :return flags: a 2d list containing all the flag information.
The sort_flags function sorts the flags on starting position using insertionsort.
[ "The", "sort_flags", "function", "sorts", "the", "flags", "on", "starting", "position", "using", "insertionsort", "." ]
def sort_flags(flags): for i in range(1, len(flags)): key = flags[i][1] j = i - 1 while j >= 0 and key < flags[j][1] and flags[i][0] == flags[j][0]: temp = flags[j+1] flags[j+1] = flags[j] flags[j] = temp j -= 1 flags[j + 1][1] = key ...
[ "def", "sort_flags", "(", "flags", ")", ":", "for", "i", "in", "range", "(", "1", ",", "len", "(", "flags", ")", ")", ":", "key", "=", "flags", "[", "i", "]", "[", "1", "]", "j", "=", "i", "-", "1", "while", "j", ">=", "0", "and", "key", ...
The sort_flags function sorts the flags on starting position using insertionsort.
[ "The", "sort_flags", "function", "sorts", "the", "flags", "on", "starting", "position", "using", "insertionsort", "." ]
[ "\"\"\" The sort_flags function sorts the flags on starting position using insertionsort.\n\n :param flags: a 2d list containing all the flag information.\n :return flags: a 2d list containing all the flag information.\n \"\"\"" ]
[ { "param": "flags", "type": null } ]
{ "returns": [ { "docstring": "a 2d list containing all the flag information.", "docstring_tokens": [ "a", "2d", "list", "containing", "all", "the", "flag", "information", "." ], "type": "flags" } ], "raises": ...
5a37f56bf404833ff4c20ef7af56114575486dcf
UMCUGenetics/CoNVident
Scripts/softclip_graph.py
[ "MIT" ]
Python
write_bedgraph_file
null
def write_bedgraph_file(heatmapdata): """ The write_bedgraph_file function receives the heatmapdata and writes a BedGraph file. :param heatmapdata: A 2d list containing the coordinates and the percentage of sofclipped bases. """ with open(args.output + f'/{args.name}.BedGraph', 'w') as bedfile: ...
The write_bedgraph_file function receives the heatmapdata and writes a BedGraph file. :param heatmapdata: A 2d list containing the coordinates and the percentage of sofclipped bases.
The write_bedgraph_file function receives the heatmapdata and writes a BedGraph file.
[ "The", "write_bedgraph_file", "function", "receives", "the", "heatmapdata", "and", "writes", "a", "BedGraph", "file", "." ]
def write_bedgraph_file(heatmapdata): with open(args.output + f'/{args.name}.BedGraph', 'w') as bedfile: bedfile.write('track type=bedGraph name=Softclip_graph description="Softclip graph" color=220,20,60 ' 'graphType=bar alwaysZero=off\n') for datapoint in heatmapdata: wit...
[ "def", "write_bedgraph_file", "(", "heatmapdata", ")", ":", "with", "open", "(", "args", ".", "output", "+", "f'/{args.name}.BedGraph'", ",", "'w'", ")", "as", "bedfile", ":", "bedfile", ".", "write", "(", "'track type=bedGraph name=Softclip_graph description=\"Softcl...
The write_bedgraph_file function receives the heatmapdata and writes a BedGraph file.
[ "The", "write_bedgraph_file", "function", "receives", "the", "heatmapdata", "and", "writes", "a", "BedGraph", "file", "." ]
[ "\"\"\" The write_bedgraph_file function receives the heatmapdata and writes a BedGraph file.\n\n :param heatmapdata: A 2d list containing the coordinates and the percentage of sofclipped bases.\n \"\"\"" ]
[ { "param": "heatmapdata", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "heatmapdata", "type": null, "docstring": "A 2d list containing the coordinates and the percentage of sofclipped bases.", "docstring_tokens": [ "A", "2d", "list", "containing", "the", ...
5a37f56bf404833ff4c20ef7af56114575486dcf
UMCUGenetics/CoNVident
Scripts/softclip_graph.py
[ "MIT" ]
Python
write_logfile
null
def write_logfile(read_data): """ The write logfile function writes a log.txt file in the output folder and writes all the parameters down.""" current_path = os.getcwd() current_time = datetime.now().strftime("%H:%M:%S") current_day = date.today().strftime("%d/%m/%Y") text = f'Logfile created by: ...
The write logfile function writes a log.txt file in the output folder and writes all the parameters down.
The write logfile function writes a log.txt file in the output folder and writes all the parameters down.
[ "The", "write", "logfile", "function", "writes", "a", "log", ".", "txt", "file", "in", "the", "output", "folder", "and", "writes", "all", "the", "parameters", "down", "." ]
def write_logfile(read_data): current_path = os.getcwd() current_time = datetime.now().strftime("%H:%M:%S") current_day = date.today().strftime("%d/%m/%Y") text = f'Logfile created by: {current_path}/softclip_heatmap.py\nScript finished at: {current_time} {current_day}\n' \ f'{"-"*40}Read dat...
[ "def", "write_logfile", "(", "read_data", ")", ":", "current_path", "=", "os", ".", "getcwd", "(", ")", "current_time", "=", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "\"%H:%M:%S\"", ")", "current_day", "=", "date", ".", "today", "(", ")", ...
The write logfile function writes a log.txt file in the output folder and writes all the parameters down.
[ "The", "write", "logfile", "function", "writes", "a", "log", ".", "txt", "file", "in", "the", "output", "folder", "and", "writes", "all", "the", "parameters", "down", "." ]
[ "\"\"\" The write logfile function writes a log.txt file in the output folder and writes all the parameters down.\"\"\"" ]
[ { "param": "read_data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "read_data", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
66c4bb6bee3fdde4151bcc00d3dc9f3e08aa910c
UMCUGenetics/CoNVident
Scripts/Flag_placer.py
[ "MIT" ]
Python
place_flags
<not_specific>
def place_flags(reads): """ The place_flags function gets the coordinates of interesting regions and returns the coordinates of the flags with their information. :param reads: Pysam object containing read information :return all_flags: A 2d list containing the coordinates of the flags and additional in...
The place_flags function gets the coordinates of interesting regions and returns the coordinates of the flags with their information. :param reads: Pysam object containing read information :return all_flags: A 2d list containing the coordinates of the flags and additional information. :return read_dat...
The place_flags function gets the coordinates of interesting regions and returns the coordinates of the flags with their information.
[ "The", "place_flags", "function", "gets", "the", "coordinates", "of", "interesting", "regions", "and", "returns", "the", "coordinates", "of", "the", "flags", "with", "their", "information", "." ]
def place_flags(reads): all_flags = [] read_data = [0, 0, 0] isbuildingflags = [False, False, False, False] flags = [[None, None, None, {'type': 'same_orientation', 'count': 0, 'total': 0}], [None, None, None, {'type': 'high_insert_size', 'count': 0, 'total': 0, 'lengths': []}], ...
[ "def", "place_flags", "(", "reads", ")", ":", "all_flags", "=", "[", "]", "read_data", "=", "[", "0", ",", "0", ",", "0", "]", "isbuildingflags", "=", "[", "False", ",", "False", ",", "False", ",", "False", "]", "flags", "=", "[", "[", "None", ",...
The place_flags function gets the coordinates of interesting regions and returns the coordinates of the flags with their information.
[ "The", "place_flags", "function", "gets", "the", "coordinates", "of", "interesting", "regions", "and", "returns", "the", "coordinates", "of", "the", "flags", "with", "their", "information", "." ]
[ "\"\"\" The place_flags function gets the coordinates of interesting regions and returns the coordinates of the flags\n with their information.\n\n :param reads: Pysam object containing read information\n :return all_flags: A 2d list containing the coordinates of the flags and additional information.\n ...
[ { "param": "reads", "type": null } ]
{ "returns": [ { "docstring": "A 2d list containing the coordinates of the flags and additional information.", "docstring_tokens": [ "A", "2d", "list", "containing", "the", "coordinates", "of", "the", "flags", "and", ...
66c4bb6bee3fdde4151bcc00d3dc9f3e08aa910c
UMCUGenetics/CoNVident
Scripts/Flag_placer.py
[ "MIT" ]
Python
flag_sameorientation
<not_specific>
def flag_sameorientation(read, flags, isbuildingflags, all_flags, chromosome, start): """ The flag_sameorientation function checks if the current read should be added to a same_orientation flag or start creating a same_orientation flag. :param read: pysam object containing data of a read. :param flags:...
The flag_sameorientation function checks if the current read should be added to a same_orientation flag or start creating a same_orientation flag. :param read: pysam object containing data of a read. :param flags: a 2d list containing all the flag information. :param isbuildingflags: a list indicating...
The flag_sameorientation function checks if the current read should be added to a same_orientation flag or start creating a same_orientation flag.
[ "The", "flag_sameorientation", "function", "checks", "if", "the", "current", "read", "should", "be", "added", "to", "a", "same_orientation", "flag", "or", "start", "creating", "a", "same_orientation", "flag", "." ]
def flag_sameorientation(read, flags, isbuildingflags, all_flags, chromosome, start): if issameorientation(read): flags, isbuildingflags = generate_flag(read, flags, isbuildingflags, 0) elif isbuildingflags[0] and start > flags[0][2]: percentage = round(flags[0][3]['count'] / flags[0][3]['total'...
[ "def", "flag_sameorientation", "(", "read", ",", "flags", ",", "isbuildingflags", ",", "all_flags", ",", "chromosome", ",", "start", ")", ":", "if", "issameorientation", "(", "read", ")", ":", "flags", ",", "isbuildingflags", "=", "generate_flag", "(", "read",...
The flag_sameorientation function checks if the current read should be added to a same_orientation flag or start creating a same_orientation flag.
[ "The", "flag_sameorientation", "function", "checks", "if", "the", "current", "read", "should", "be", "added", "to", "a", "same_orientation", "flag", "or", "start", "creating", "a", "same_orientation", "flag", "." ]
[ "\"\"\" The flag_sameorientation function checks if the current read should be added to a same_orientation flag or\n start creating a same_orientation flag.\n\n :param read: pysam object containing data of a read.\n :param flags: a 2d list containing all the flag information.\n :param isbuildingflags: a...
[ { "param": "read", "type": null }, { "param": "flags", "type": null }, { "param": "isbuildingflags", "type": null }, { "param": "all_flags", "type": null }, { "param": "chromosome", "type": null }, { "param": "start", "type": null } ]
{ "returns": [ { "docstring": "a 2d list containing all the flag information.", "docstring_tokens": [ "a", "2d", "list", "containing", "all", "the", "flag", "information", "." ], "type": "flags" }, { "doc...
66c4bb6bee3fdde4151bcc00d3dc9f3e08aa910c
UMCUGenetics/CoNVident
Scripts/Flag_placer.py
[ "MIT" ]
Python
flag_high_isize
<not_specific>
def flag_high_isize(read, flags, isbuildingflags, all_flags, chromosome, start): """ The flag_high_isize function checks if the current read should be added to a high_insert_size flag or start creating a high_isize_flag. :param read: pysam object containing data of a read. :param flags: a 2d list conta...
The flag_high_isize function checks if the current read should be added to a high_insert_size flag or start creating a high_isize_flag. :param read: pysam object containing data of a read. :param flags: a 2d list containing all the flag information. :param isbuildingflags: a list indicating which flag...
The flag_high_isize function checks if the current read should be added to a high_insert_size flag or start creating a high_isize_flag.
[ "The", "flag_high_isize", "function", "checks", "if", "the", "current", "read", "should", "be", "added", "to", "a", "high_insert_size", "flag", "or", "start", "creating", "a", "high_isize_flag", "." ]
def flag_high_isize(read, flags, isbuildingflags, all_flags, chromosome, start): insert_size = abs(read.isize) if args.high_insert_size < insert_size < args.ultra_high_insert_size: flags, isbuildingflags = generate_flag(read, flags, isbuildingflags, 1) flags[1][3]['lengths'].append(insert_size) ...
[ "def", "flag_high_isize", "(", "read", ",", "flags", ",", "isbuildingflags", ",", "all_flags", ",", "chromosome", ",", "start", ")", ":", "insert_size", "=", "abs", "(", "read", ".", "isize", ")", "if", "args", ".", "high_insert_size", "<", "insert_size", ...
The flag_high_isize function checks if the current read should be added to a high_insert_size flag or start creating a high_isize_flag.
[ "The", "flag_high_isize", "function", "checks", "if", "the", "current", "read", "should", "be", "added", "to", "a", "high_insert_size", "flag", "or", "start", "creating", "a", "high_isize_flag", "." ]
[ "\"\"\" The flag_high_isize function checks if the current read should be added to a high_insert_size flag or start\n creating a high_isize_flag.\n\n :param read: pysam object containing data of a read.\n :param flags: a 2d list containing all the flag information.\n :param isbuildingflags: a list indic...
[ { "param": "read", "type": null }, { "param": "flags", "type": null }, { "param": "isbuildingflags", "type": null }, { "param": "all_flags", "type": null }, { "param": "chromosome", "type": null }, { "param": "start", "type": null } ]
{ "returns": [ { "docstring": "a 2d list containing all the flag information.", "docstring_tokens": [ "a", "2d", "list", "containing", "all", "the", "flag", "information", "." ], "type": "flags" }, { "doc...
66c4bb6bee3fdde4151bcc00d3dc9f3e08aa910c
UMCUGenetics/CoNVident
Scripts/Flag_placer.py
[ "MIT" ]
Python
flag_ultra_high_isize
<not_specific>
def flag_ultra_high_isize(read, flags, isbuildingflags, all_flags, chromosome, start): """ The flag_ultra_high_isize function checks if the current read should be added to a Ultra_high_insert_size flag or start creating an ultra_high_isize_flag. :param read: pysam object containing data of a read. :par...
The flag_ultra_high_isize function checks if the current read should be added to a Ultra_high_insert_size flag or start creating an ultra_high_isize_flag. :param read: pysam object containing data of a read. :param flags: a 2d list containing all the flag information. :param isbuildingflags: a list in...
The flag_ultra_high_isize function checks if the current read should be added to a Ultra_high_insert_size flag or start creating an ultra_high_isize_flag.
[ "The", "flag_ultra_high_isize", "function", "checks", "if", "the", "current", "read", "should", "be", "added", "to", "a", "Ultra_high_insert_size", "flag", "or", "start", "creating", "an", "ultra_high_isize_flag", "." ]
def flag_ultra_high_isize(read, flags, isbuildingflags, all_flags, chromosome, start): insert_size = abs(read.isize) if insert_size > args.ultra_high_insert_size: flags, isbuildingflags = generate_flag(read, flags, isbuildingflags, 3) flags[3][3]['lengths'].append(insert_size) elif isbuildin...
[ "def", "flag_ultra_high_isize", "(", "read", ",", "flags", ",", "isbuildingflags", ",", "all_flags", ",", "chromosome", ",", "start", ")", ":", "insert_size", "=", "abs", "(", "read", ".", "isize", ")", "if", "insert_size", ">", "args", ".", "ultra_high_inse...
The flag_ultra_high_isize function checks if the current read should be added to a Ultra_high_insert_size flag or start creating an ultra_high_isize_flag.
[ "The", "flag_ultra_high_isize", "function", "checks", "if", "the", "current", "read", "should", "be", "added", "to", "a", "Ultra_high_insert_size", "flag", "or", "start", "creating", "an", "ultra_high_isize_flag", "." ]
[ "\"\"\" The flag_ultra_high_isize function checks if the current read should be added to a Ultra_high_insert_size flag\n or start creating an ultra_high_isize_flag.\n\n :param read: pysam object containing data of a read.\n :param flags: a 2d list containing all the flag information.\n :param isbuilding...
[ { "param": "read", "type": null }, { "param": "flags", "type": null }, { "param": "isbuildingflags", "type": null }, { "param": "all_flags", "type": null }, { "param": "chromosome", "type": null }, { "param": "start", "type": null } ]
{ "returns": [ { "docstring": "a 2d list containing all the flag information.", "docstring_tokens": [ "a", "2d", "list", "containing", "all", "the", "flag", "information", "." ], "type": "flags" }, { "doc...
66c4bb6bee3fdde4151bcc00d3dc9f3e08aa910c
UMCUGenetics/CoNVident
Scripts/Flag_placer.py
[ "MIT" ]
Python
flag_unmapped_mate
<not_specific>
def flag_unmapped_mate(read, flags, isbuildingflags, all_flags, chromosome, start): """ The flag_unmapped_mate function checks if the current read should be added to the unmapped_mate flag or start creating a unmapped_mate flag. :param read: pysam object containing data of a read. :param flags: a 2d li...
The flag_unmapped_mate function checks if the current read should be added to the unmapped_mate flag or start creating a unmapped_mate flag. :param read: pysam object containing data of a read. :param flags: a 2d list containing all the flag information. :param isbuildingflags: a list indicating which...
The flag_unmapped_mate function checks if the current read should be added to the unmapped_mate flag or start creating a unmapped_mate flag.
[ "The", "flag_unmapped_mate", "function", "checks", "if", "the", "current", "read", "should", "be", "added", "to", "the", "unmapped_mate", "flag", "or", "start", "creating", "a", "unmapped_mate", "flag", "." ]
def flag_unmapped_mate(read, flags, isbuildingflags, all_flags, chromosome, start): if read.mate_is_unmapped: flags, isbuildingflags = generate_flag(read, flags, isbuildingflags, 2) elif isbuildingflags[2] and start > flags[2][2]: percentage = round(flags[2][3]['count'] / flags[2][3]['total'], 2...
[ "def", "flag_unmapped_mate", "(", "read", ",", "flags", ",", "isbuildingflags", ",", "all_flags", ",", "chromosome", ",", "start", ")", ":", "if", "read", ".", "mate_is_unmapped", ":", "flags", ",", "isbuildingflags", "=", "generate_flag", "(", "read", ",", ...
The flag_unmapped_mate function checks if the current read should be added to the unmapped_mate flag or start creating a unmapped_mate flag.
[ "The", "flag_unmapped_mate", "function", "checks", "if", "the", "current", "read", "should", "be", "added", "to", "the", "unmapped_mate", "flag", "or", "start", "creating", "a", "unmapped_mate", "flag", "." ]
[ "\"\"\" The flag_unmapped_mate function checks if the current read should be added to the unmapped_mate flag or start\n creating a unmapped_mate flag.\n\n :param read: pysam object containing data of a read.\n :param flags: a 2d list containing all the flag information.\n :param isbuildingflags: a list ...
[ { "param": "read", "type": null }, { "param": "flags", "type": null }, { "param": "isbuildingflags", "type": null }, { "param": "all_flags", "type": null }, { "param": "chromosome", "type": null }, { "param": "start", "type": null } ]
{ "returns": [ { "docstring": "a 2d list containing all the flag information.", "docstring_tokens": [ "a", "2d", "list", "containing", "all", "the", "flag", "information", "." ], "type": "flags" }, { "doc...
66c4bb6bee3fdde4151bcc00d3dc9f3e08aa910c
UMCUGenetics/CoNVident
Scripts/Flag_placer.py
[ "MIT" ]
Python
update_total
<not_specific>
def update_total(flags, isbuildingflags): """ The update_total function iterates over all the flag types and increments the total number of reads it has encountered by 1. :param flags: a 2d list containing all the flag information. :param isbuildingflags: a list indicating which flags are currently bei...
The update_total function iterates over all the flag types and increments the total number of reads it has encountered by 1. :param flags: a 2d list containing all the flag information. :param isbuildingflags: a list indicating which flags are currently being built. return flags: a 2d list containing ...
The update_total function iterates over all the flag types and increments the total number of reads it has encountered by 1.
[ "The", "update_total", "function", "iterates", "over", "all", "the", "flag", "types", "and", "increments", "the", "total", "number", "of", "reads", "it", "has", "encountered", "by", "1", "." ]
def update_total(flags, isbuildingflags): for index in range(0, len(flags)): if isbuildingflags[index]: flags[index][3]['total'] += 1 return flags
[ "def", "update_total", "(", "flags", ",", "isbuildingflags", ")", ":", "for", "index", "in", "range", "(", "0", ",", "len", "(", "flags", ")", ")", ":", "if", "isbuildingflags", "[", "index", "]", ":", "flags", "[", "index", "]", "[", "3", "]", "["...
The update_total function iterates over all the flag types and increments the total number of reads it has encountered by 1.
[ "The", "update_total", "function", "iterates", "over", "all", "the", "flag", "types", "and", "increments", "the", "total", "number", "of", "reads", "it", "has", "encountered", "by", "1", "." ]
[ "\"\"\" The update_total function iterates over all the flag types and increments the total number of reads it has\n encountered by 1.\n\n :param flags: a 2d list containing all the flag information.\n :param isbuildingflags: a list indicating which flags are currently being built.\n return flags: a 2d ...
[ { "param": "flags", "type": null }, { "param": "isbuildingflags", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "flags", "type": null, "docstring": "a 2d list containing all the flag information.", "docstring_tokens": [ "a", "2d", "list", "containing", "all", "the", "flag", ...
66c4bb6bee3fdde4151bcc00d3dc9f3e08aa910c
UMCUGenetics/CoNVident
Scripts/Flag_placer.py
[ "MIT" ]
Python
generate_flag
<not_specific>
def generate_flag(read, flags, isbuildingflags, flagindex): """ The generate_flag function receives a read and decides if it should be included in the current working flag or not. Or it starts the creation of a new flag. :param read: pysam object containing data of a read. :param flags: a 2d list conta...
The generate_flag function receives a read and decides if it should be included in the current working flag or not. Or it starts the creation of a new flag. :param read: pysam object containing data of a read. :param flags: a 2d list containing all the flag information. :param isbuildingflags; a list ...
The generate_flag function receives a read and decides if it should be included in the current working flag or not. Or it starts the creation of a new flag. :param read: pysam object containing data of a read. :param flags: a 2d list containing all the flag information.
[ "The", "generate_flag", "function", "receives", "a", "read", "and", "decides", "if", "it", "should", "be", "included", "in", "the", "current", "working", "flag", "or", "not", ".", "Or", "it", "starts", "the", "creation", "of", "a", "new", "flag", ".", ":...
def generate_flag(read, flags, isbuildingflags, flagindex): start, end = true_position(read) if not isbuildingflags[flagindex]: flags[flagindex][0] = read.reference_name flags[flagindex][1] = start flags[flagindex][2] = end isbuildingflags[flagindex] = True if isbuildingflags...
[ "def", "generate_flag", "(", "read", ",", "flags", ",", "isbuildingflags", ",", "flagindex", ")", ":", "start", ",", "end", "=", "true_position", "(", "read", ")", "if", "not", "isbuildingflags", "[", "flagindex", "]", ":", "flags", "[", "flagindex", "]", ...
The generate_flag function receives a read and decides if it should be included in the current working flag or not.
[ "The", "generate_flag", "function", "receives", "a", "read", "and", "decides", "if", "it", "should", "be", "included", "in", "the", "current", "working", "flag", "or", "not", "." ]
[ "\"\"\" The generate_flag function receives a read and decides if it should be included in the current working flag or\n not. Or it starts the creation of a new flag.\n\n :param read: pysam object containing data of a read.\n :param flags: a 2d list containing all the flag information.\n :param isbuildi...
[ { "param": "read", "type": null }, { "param": "flags", "type": null }, { "param": "isbuildingflags", "type": null }, { "param": "flagindex", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "read", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flags", "type": null, "docstring": null, "docstring_tokens": ...
66c4bb6bee3fdde4151bcc00d3dc9f3e08aa910c
UMCUGenetics/CoNVident
Scripts/Flag_placer.py
[ "MIT" ]
Python
true_position
<not_specific>
def true_position(read): """ The true_position function receives a read and determines the start of the read as presented in igv by including unmapped basepairs. :param read: pysam object containing data of a read. :return start: an integer indicating the true start of a read. :return end: an integ...
The true_position function receives a read and determines the start of the read as presented in igv by including unmapped basepairs. :param read: pysam object containing data of a read. :return start: an integer indicating the true start of a read. :return end: an integer idicating the true end of a r...
The true_position function receives a read and determines the start of the read as presented in igv by including unmapped basepairs.
[ "The", "true_position", "function", "receives", "a", "read", "and", "determines", "the", "start", "of", "the", "read", "as", "presented", "in", "igv", "by", "including", "unmapped", "basepairs", "." ]
def true_position(read): cigar = read.cigar start = read.positions[0] - calculate_overshoot(cigar) end = read.positions[-1] + calculate_overshoot(cigar[::-1]) return start, end
[ "def", "true_position", "(", "read", ")", ":", "cigar", "=", "read", ".", "cigar", "start", "=", "read", ".", "positions", "[", "0", "]", "-", "calculate_overshoot", "(", "cigar", ")", "end", "=", "read", ".", "positions", "[", "-", "1", "]", "+", ...
The true_position function receives a read and determines the start of the read as presented in igv by including unmapped basepairs.
[ "The", "true_position", "function", "receives", "a", "read", "and", "determines", "the", "start", "of", "the", "read", "as", "presented", "in", "igv", "by", "including", "unmapped", "basepairs", "." ]
[ "\"\"\" The true_position function receives a read and determines the start of the read as presented in igv by including\n unmapped basepairs.\n\n :param read: pysam object containing data of a read.\n :return start: an integer indicating the true start of a read.\n :return end: an integer idicating the...
[ { "param": "read", "type": null } ]
{ "returns": [ { "docstring": "an integer indicating the true start of a read.", "docstring_tokens": [ "an", "integer", "indicating", "the", "true", "start", "of", "a", "read", "." ], "type": "start" }, ...
66c4bb6bee3fdde4151bcc00d3dc9f3e08aa910c
UMCUGenetics/CoNVident
Scripts/Flag_placer.py
[ "MIT" ]
Python
calculate_overshoot
<not_specific>
def calculate_overshoot(cigar): """ The calculate overshoot function calculates the number of basepairs that have not been mapped but are part of the read. :param cigar: a list containing tuples representing the cigar string. :return overshoot: an integer indicating the number of basepairs in the read ...
The calculate overshoot function calculates the number of basepairs that have not been mapped but are part of the read. :param cigar: a list containing tuples representing the cigar string. :return overshoot: an integer indicating the number of basepairs in the read before it is mapped.
The calculate overshoot function calculates the number of basepairs that have not been mapped but are part of the read.
[ "The", "calculate", "overshoot", "function", "calculates", "the", "number", "of", "basepairs", "that", "have", "not", "been", "mapped", "but", "are", "part", "of", "the", "read", "." ]
def calculate_overshoot(cigar): overshoot = 0 for element in cigar: if element[0]: overshoot += element[1] else: break return overshoot
[ "def", "calculate_overshoot", "(", "cigar", ")", ":", "overshoot", "=", "0", "for", "element", "in", "cigar", ":", "if", "element", "[", "0", "]", ":", "overshoot", "+=", "element", "[", "1", "]", "else", ":", "break", "return", "overshoot" ]
The calculate overshoot function calculates the number of basepairs that have not been mapped but are part of the read.
[ "The", "calculate", "overshoot", "function", "calculates", "the", "number", "of", "basepairs", "that", "have", "not", "been", "mapped", "but", "are", "part", "of", "the", "read", "." ]
[ "\"\"\" The calculate overshoot function calculates the number of basepairs that have not been mapped but are part of\n the read.\n\n :param cigar: a list containing tuples representing the cigar string.\n :return overshoot: an integer indicating the number of basepairs in the read before it is mapped.\n ...
[ { "param": "cigar", "type": null } ]
{ "returns": [ { "docstring": "an integer indicating the number of basepairs in the read before it is mapped.", "docstring_tokens": [ "an", "integer", "indicating", "the", "number", "of", "basepairs", "in", "the", "read", ...
66c4bb6bee3fdde4151bcc00d3dc9f3e08aa910c
UMCUGenetics/CoNVident
Scripts/Flag_placer.py
[ "MIT" ]
Python
issameorientation
<not_specific>
def issameorientation(read): """ The issameorientation function returns a bool returning true if a pair of reads have the same orientation and the mate is on the same chromosome. It will return false if this is not the case :param read: Pysam object containing data of a read. :return bool: A boolean re...
The issameorientation function returns a bool returning true if a pair of reads have the same orientation and the mate is on the same chromosome. It will return false if this is not the case :param read: Pysam object containing data of a read. :return bool: A boolean returning True if the reads of a pair ...
The issameorientation function returns a bool returning true if a pair of reads have the same orientation and the mate is on the same chromosome. It will return false if this is not the case
[ "The", "issameorientation", "function", "returns", "a", "bool", "returning", "true", "if", "a", "pair", "of", "reads", "have", "the", "same", "orientation", "and", "the", "mate", "is", "on", "the", "same", "chromosome", ".", "It", "will", "return", "false", ...
def issameorientation(read): if (read.is_paired and not read.mate_is_unmapped and read.is_reverse == read.mate_is_reverse and read.reference_name == read.next_reference_name): return True return False
[ "def", "issameorientation", "(", "read", ")", ":", "if", "(", "read", ".", "is_paired", "and", "not", "read", ".", "mate_is_unmapped", "and", "read", ".", "is_reverse", "==", "read", ".", "mate_is_reverse", "and", "read", ".", "reference_name", "==", "read",...
The issameorientation function returns a bool returning true if a pair of reads have the same orientation and the mate is on the same chromosome.
[ "The", "issameorientation", "function", "returns", "a", "bool", "returning", "true", "if", "a", "pair", "of", "reads", "have", "the", "same", "orientation", "and", "the", "mate", "is", "on", "the", "same", "chromosome", "." ]
[ "\"\"\" The issameorientation function returns a bool returning true if a pair of reads have the same orientation and\n the mate is on the same chromosome. It will return false if this is not the case\n\n :param read: Pysam object containing data of a read.\n :return bool: A boolean returning True if the r...
[ { "param": "read", "type": null } ]
{ "returns": [ { "docstring": "A boolean returning True if the reads of a pair have the same orientation.", "docstring_tokens": [ "A", "boolean", "returning", "True", "if", "the", "reads", "of", "a", "pair", "have"...
66c4bb6bee3fdde4151bcc00d3dc9f3e08aa910c
UMCUGenetics/CoNVident
Scripts/Flag_placer.py
[ "MIT" ]
Python
write_bedfile
null
def write_bedfile(flags): """ The write_bedfile function writes a file in BED format that can be loaded in igv and visualises the read data. :param flags: a 2d list containing all the flag information. """ with open(args.output + f'/{args.name}.bed', 'w') as bedfile: bedfile.write('track name=F...
The write_bedfile function writes a file in BED format that can be loaded in igv and visualises the read data. :param flags: a 2d list containing all the flag information.
The write_bedfile function writes a file in BED format that can be loaded in igv and visualises the read data.
[ "The", "write_bedfile", "function", "writes", "a", "file", "in", "BED", "format", "that", "can", "be", "loaded", "in", "igv", "and", "visualises", "the", "read", "data", "." ]
def write_bedfile(flags): with open(args.output + f'/{args.name}.bed', 'w') as bedfile: bedfile.write('track name=Flags description="Flags regions of interest." db=hg19 gffTags=on itemRGB="On"\n') for flag in flags: percentage = round(flag[3]['count'] / flag[3]['total'], 2) region = f"{f...
[ "def", "write_bedfile", "(", "flags", ")", ":", "with", "open", "(", "args", ".", "output", "+", "f'/{args.name}.bed'", ",", "'w'", ")", "as", "bedfile", ":", "bedfile", ".", "write", "(", "'track name=Flags description=\"Flags regions of interest.\" db=hg19 gffTags=o...
The write_bedfile function writes a file in BED format that can be loaded in igv and visualises the read data.
[ "The", "write_bedfile", "function", "writes", "a", "file", "in", "BED", "format", "that", "can", "be", "loaded", "in", "igv", "and", "visualises", "the", "read", "data", "." ]
[ "\"\"\" The write_bedfile function writes a file in BED format that can be loaded in igv and visualises the read data.\n\n :param flags: a 2d list containing all the flag information.\n \"\"\"" ]
[ { "param": "flags", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "flags", "type": null, "docstring": "a 2d list containing all the flag information.", "docstring_tokens": [ "a", "2d", "list", "containing", "all", "the", "flag", ...
66c4bb6bee3fdde4151bcc00d3dc9f3e08aa910c
UMCUGenetics/CoNVident
Scripts/Flag_placer.py
[ "MIT" ]
Python
write_logfile
null
def write_logfile(read_data): """ The write logfile function writes a log.txt file in the output folder and writes all the parameters down.""" current_path = os.getcwd() current_time = datetime.now().strftime("%H:%M:%S") current_day = date.today().strftime("%d/%m/%Y") text = f'Logfile created by: ...
The write logfile function writes a log.txt file in the output folder and writes all the parameters down.
The write logfile function writes a log.txt file in the output folder and writes all the parameters down.
[ "The", "write", "logfile", "function", "writes", "a", "log", ".", "txt", "file", "in", "the", "output", "folder", "and", "writes", "all", "the", "parameters", "down", "." ]
def write_logfile(read_data): current_path = os.getcwd() current_time = datetime.now().strftime("%H:%M:%S") current_day = date.today().strftime("%d/%m/%Y") text = f'Logfile created by: {current_path}/Flag_placer.py\nScript finished at: {current_time} {current_day}\n' \ f'{"-"*40}Read data{"-"...
[ "def", "write_logfile", "(", "read_data", ")", ":", "current_path", "=", "os", ".", "getcwd", "(", ")", "current_time", "=", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "\"%H:%M:%S\"", ")", "current_day", "=", "date", ".", "today", "(", ")", ...
The write logfile function writes a log.txt file in the output folder and writes all the parameters down.
[ "The", "write", "logfile", "function", "writes", "a", "log", ".", "txt", "file", "in", "the", "output", "folder", "and", "writes", "all", "the", "parameters", "down", "." ]
[ "\"\"\" The write logfile function writes a log.txt file in the output folder and writes all the parameters down.\"\"\"" ]
[ { "param": "read_data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "read_data", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }