repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
threeML/astromodels | astromodels/core/model.py | Model.get_extended_source_fluxes | def get_extended_source_fluxes(self, id, j2000_ra, j2000_dec, energies):
"""
Get the flux of the id-th extended sources at the given position at the given energies
:param id: id of the source
:param j2000_ra: R.A. where the flux is desired
:param j2000_dec: Dec. where the flux i... | python | def get_extended_source_fluxes(self, id, j2000_ra, j2000_dec, energies):
"""
Get the flux of the id-th extended sources at the given position at the given energies
:param id: id of the source
:param j2000_ra: R.A. where the flux is desired
:param j2000_dec: Dec. where the flux i... | [
"def",
"get_extended_source_fluxes",
"(",
"self",
",",
"id",
",",
"j2000_ra",
",",
"j2000_dec",
",",
"energies",
")",
":",
"return",
"self",
".",
"_extended_sources",
".",
"values",
"(",
")",
"[",
"id",
"]",
"(",
"j2000_ra",
",",
"j2000_dec",
",",
"energie... | Get the flux of the id-th extended sources at the given position at the given energies
:param id: id of the source
:param j2000_ra: R.A. where the flux is desired
:param j2000_dec: Dec. where the flux is desired
:param energies: energies at which the flux is desired
:return: flu... | [
"Get",
"the",
"flux",
"of",
"the",
"id",
"-",
"th",
"extended",
"sources",
"at",
"the",
"given",
"position",
"at",
"the",
"given",
"energies"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L996-L1007 | train |
threeML/astromodels | astromodels/utils/long_path_formatter.py | long_path_formatter | def long_path_formatter(line, max_width=pd.get_option('max_colwidth')):
"""
If a path is longer than max_width, it substitute it with the first and last element,
joined by "...". For example 'this.is.a.long.path.which.we.want.to.shorten' becomes
'this...shorten'
:param line:
:param max_width:
... | python | def long_path_formatter(line, max_width=pd.get_option('max_colwidth')):
"""
If a path is longer than max_width, it substitute it with the first and last element,
joined by "...". For example 'this.is.a.long.path.which.we.want.to.shorten' becomes
'this...shorten'
:param line:
:param max_width:
... | [
"def",
"long_path_formatter",
"(",
"line",
",",
"max_width",
"=",
"pd",
".",
"get_option",
"(",
"'max_colwidth'",
")",
")",
":",
"if",
"len",
"(",
"line",
")",
">",
"max_width",
":",
"tokens",
"=",
"line",
".",
"split",
"(",
"\".\"",
")",
"trial1",
"="... | If a path is longer than max_width, it substitute it with the first and last element,
joined by "...". For example 'this.is.a.long.path.which.we.want.to.shorten' becomes
'this...shorten'
:param line:
:param max_width:
:return: | [
"If",
"a",
"path",
"is",
"longer",
"than",
"max_width",
"it",
"substitute",
"it",
"with",
"the",
"first",
"and",
"last",
"element",
"joined",
"by",
"...",
".",
"For",
"example",
"this",
".",
"is",
".",
"a",
".",
"long",
".",
"path",
".",
"which",
"."... | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/long_path_formatter.py#L4-L30 | train |
threeML/astromodels | astromodels/sources/point_source.py | PointSource.has_free_parameters | def has_free_parameters(self):
"""
Returns True or False whether there is any parameter in this source
:return:
"""
for component in self._components.values():
for par in component.shape.parameters.values():
if par.free:
return... | python | def has_free_parameters(self):
"""
Returns True or False whether there is any parameter in this source
:return:
"""
for component in self._components.values():
for par in component.shape.parameters.values():
if par.free:
return... | [
"def",
"has_free_parameters",
"(",
"self",
")",
":",
"for",
"component",
"in",
"self",
".",
"_components",
".",
"values",
"(",
")",
":",
"for",
"par",
"in",
"component",
".",
"shape",
".",
"parameters",
".",
"values",
"(",
")",
":",
"if",
"par",
".",
... | Returns True or False whether there is any parameter in this source
:return: | [
"Returns",
"True",
"or",
"False",
"whether",
"there",
"is",
"any",
"parameter",
"in",
"this",
"source"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/sources/point_source.py#L214-L235 | train |
threeML/astromodels | astromodels/sources/point_source.py | PointSource._repr__base | def _repr__base(self, rich_output=False):
"""
Representation of the object
:param rich_output: if True, generates HTML, otherwise text
:return: the representation
"""
# Make a dictionary which will then be transformed in a list
repr_dict = collections.OrderedDi... | python | def _repr__base(self, rich_output=False):
"""
Representation of the object
:param rich_output: if True, generates HTML, otherwise text
:return: the representation
"""
# Make a dictionary which will then be transformed in a list
repr_dict = collections.OrderedDi... | [
"def",
"_repr__base",
"(",
"self",
",",
"rich_output",
"=",
"False",
")",
":",
"repr_dict",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"key",
"=",
"'%s (point source)'",
"%",
"self",
".",
"name",
"repr_dict",
"[",
"key",
"]",
"=",
"collections",
"."... | Representation of the object
:param rich_output: if True, generates HTML, otherwise text
:return: the representation | [
"Representation",
"of",
"the",
"object"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/sources/point_source.py#L287-L309 | train |
threeML/astromodels | astromodels/functions/function.py | get_function | def get_function(function_name, composite_function_expression=None):
"""
Returns the function "name", which must be among the known functions or a composite function.
:param function_name: the name of the function (use 'composite' if the function is a composite function)
:param composite_function_expre... | python | def get_function(function_name, composite_function_expression=None):
"""
Returns the function "name", which must be among the known functions or a composite function.
:param function_name: the name of the function (use 'composite' if the function is a composite function)
:param composite_function_expre... | [
"def",
"get_function",
"(",
"function_name",
",",
"composite_function_expression",
"=",
"None",
")",
":",
"if",
"composite_function_expression",
"is",
"not",
"None",
":",
"return",
"_parse_function_expression",
"(",
"composite_function_expression",
")",
"else",
":",
"if... | Returns the function "name", which must be among the known functions or a composite function.
:param function_name: the name of the function (use 'composite' if the function is a composite function)
:param composite_function_expression: composite function specification such as
((((powerlaw{1} + (sin{2} * 3... | [
"Returns",
"the",
"function",
"name",
"which",
"must",
"be",
"among",
"the",
"known",
"functions",
"or",
"a",
"composite",
"function",
"."
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/function.py#L1566-L1609 | train |
threeML/astromodels | astromodels/functions/function.py | get_function_class | def get_function_class(function_name):
"""
Return the type for the requested function
:param function_name: the function to return
:return: the type for that function (i.e., this is a class, not an instance)
"""
if function_name in _known_functions:
return _known_functions[function_na... | python | def get_function_class(function_name):
"""
Return the type for the requested function
:param function_name: the function to return
:return: the type for that function (i.e., this is a class, not an instance)
"""
if function_name in _known_functions:
return _known_functions[function_na... | [
"def",
"get_function_class",
"(",
"function_name",
")",
":",
"if",
"function_name",
"in",
"_known_functions",
":",
"return",
"_known_functions",
"[",
"function_name",
"]",
"else",
":",
"raise",
"UnknownFunction",
"(",
"\"Function %s is not known. Known functions are: %s\"",... | Return the type for the requested function
:param function_name: the function to return
:return: the type for that function (i.e., this is a class, not an instance) | [
"Return",
"the",
"type",
"for",
"the",
"requested",
"function"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/function.py#L1612-L1627 | train |
threeML/astromodels | astromodels/functions/function.py | FunctionMeta.check_calling_sequence | def check_calling_sequence(name, function_name, function, possible_variables):
"""
Check the calling sequence for the function looking for the variables specified.
One or more of the variables can be in the calling sequence. Note that the
order of the variables will be enforced.
... | python | def check_calling_sequence(name, function_name, function, possible_variables):
"""
Check the calling sequence for the function looking for the variables specified.
One or more of the variables can be in the calling sequence. Note that the
order of the variables will be enforced.
... | [
"def",
"check_calling_sequence",
"(",
"name",
",",
"function_name",
",",
"function",
",",
"possible_variables",
")",
":",
"try",
":",
"calling_sequence",
"=",
"inspect",
".",
"getargspec",
"(",
"function",
".",
"input_object",
")",
".",
"args",
"except",
"Attrib... | Check the calling sequence for the function looking for the variables specified.
One or more of the variables can be in the calling sequence. Note that the
order of the variables will be enforced.
It will also enforce that the first parameter in the calling sequence is called 'self'.
:p... | [
"Check",
"the",
"calling",
"sequence",
"for",
"the",
"function",
"looking",
"for",
"the",
"variables",
"specified",
".",
"One",
"or",
"more",
"of",
"the",
"variables",
"can",
"be",
"in",
"the",
"calling",
"sequence",
".",
"Note",
"that",
"the",
"order",
"o... | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/function.py#L339-L385 | train |
threeML/astromodels | astromodels/functions/function.py | Function.free_parameters | def free_parameters(self):
"""
Returns a dictionary of free parameters for this function
:return: dictionary of free parameters
"""
free_parameters = collections.OrderedDict([(k,v) for k, v in self.parameters.iteritems() if v.free])
return free_parameters | python | def free_parameters(self):
"""
Returns a dictionary of free parameters for this function
:return: dictionary of free parameters
"""
free_parameters = collections.OrderedDict([(k,v) for k, v in self.parameters.iteritems() if v.free])
return free_parameters | [
"def",
"free_parameters",
"(",
"self",
")",
":",
"free_parameters",
"=",
"collections",
".",
"OrderedDict",
"(",
"[",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"parameters",
".",
"iteritems",
"(",
")",
"if",
"v",
".",
"free",
... | Returns a dictionary of free parameters for this function
:return: dictionary of free parameters | [
"Returns",
"a",
"dictionary",
"of",
"free",
"parameters",
"for",
"this",
"function"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/function.py#L518-L527 | train |
threeML/astromodels | astromodels/utils/data_files.py | _get_data_file_path | def _get_data_file_path(data_file):
"""
Returns the absolute path to the required data files.
:param data_file: relative path to the data file, relative to the astromodels/data path.
So to get the path to data/dark_matter/gammamc_dif.dat you need to use data_file="dark_matter/gammamc_dif.dat"
:retu... | python | def _get_data_file_path(data_file):
"""
Returns the absolute path to the required data files.
:param data_file: relative path to the data file, relative to the astromodels/data path.
So to get the path to data/dark_matter/gammamc_dif.dat you need to use data_file="dark_matter/gammamc_dif.dat"
:retu... | [
"def",
"_get_data_file_path",
"(",
"data_file",
")",
":",
"try",
":",
"file_path",
"=",
"pkg_resources",
".",
"resource_filename",
"(",
"\"astromodels\"",
",",
"'data/%s'",
"%",
"data_file",
")",
"except",
"KeyError",
":",
"raise",
"IOError",
"(",
"\"Could not rea... | Returns the absolute path to the required data files.
:param data_file: relative path to the data file, relative to the astromodels/data path.
So to get the path to data/dark_matter/gammamc_dif.dat you need to use data_file="dark_matter/gammamc_dif.dat"
:return: absolute path of the data file | [
"Returns",
"the",
"absolute",
"path",
"to",
"the",
"required",
"data",
"files",
"."
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/data_files.py#L5-L25 | train |
threeML/astromodels | astromodels/functions/dark_matter/dm_models.py | DMFitFunction._setup | def _setup(self):
tablepath = _get_data_file_path("dark_matter/gammamc_dif.dat")
self._data = np.loadtxt(tablepath)
"""
Mapping between the channel codes and the rows in the gammamc file
1 : 8, # ee
2 : 6, # mumu
3 : 3, # tautau
4 :... | python | def _setup(self):
tablepath = _get_data_file_path("dark_matter/gammamc_dif.dat")
self._data = np.loadtxt(tablepath)
"""
Mapping between the channel codes and the rows in the gammamc file
1 : 8, # ee
2 : 6, # mumu
3 : 3, # tautau
4 :... | [
"def",
"_setup",
"(",
"self",
")",
":",
"tablepath",
"=",
"_get_data_file_path",
"(",
"\"dark_matter/gammamc_dif.dat\"",
")",
"self",
".",
"_data",
"=",
"np",
".",
"loadtxt",
"(",
"tablepath",
")",
"channel_index_mapping",
"=",
"{",
"1",
":",
"8",
",",
"2",
... | Mapping between the channel codes and the rows in the gammamc file
1 : 8, # ee
2 : 6, # mumu
3 : 3, # tautau
4 : 1, # bb
5 : 2, # tt
6 : 7, # gg
7 : 4, # ww
8 : 5, # zz
9 : 0, # cc
10 : 10, # uu
... | [
"Mapping",
"between",
"the",
"channel",
"codes",
"and",
"the",
"rows",
"in",
"the",
"gammamc",
"file"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/dark_matter/dm_models.py#L48-L108 | train |
threeML/astromodels | astromodels/functions/dark_matter/dm_models.py | DMSpectra._setup | def _setup(self):
# Get and open the two data files
tablepath_h = _get_data_file_path("dark_matter/dmSpecTab.npy")
self._data_h = np.load(tablepath_h)
tablepath_f = _get_data_file_path("dark_matter/gammamc_dif.dat")
self._data_f = np.loadtxt(tablepath_f)
"""
... | python | def _setup(self):
# Get and open the two data files
tablepath_h = _get_data_file_path("dark_matter/dmSpecTab.npy")
self._data_h = np.load(tablepath_h)
tablepath_f = _get_data_file_path("dark_matter/gammamc_dif.dat")
self._data_f = np.loadtxt(tablepath_f)
"""
... | [
"def",
"_setup",
"(",
"self",
")",
":",
"tablepath_h",
"=",
"_get_data_file_path",
"(",
"\"dark_matter/dmSpecTab.npy\"",
")",
"self",
".",
"_data_h",
"=",
"np",
".",
"load",
"(",
"tablepath_h",
")",
"tablepath_f",
"=",
"_get_data_file_path",
"(",
"\"dark_matter/ga... | Mapping between the channel codes and the rows in the gammamc file
dmSpecTab.npy created to match this mapping too
1 : 8, # ee
2 : 6, # mumu
3 : 3, # tautau
4 : 1, # bb
5 : 2, # tt
6 : 7, # gg
7 : 4, # ww
8 : 5,... | [
"Mapping",
"between",
"the",
"channel",
"codes",
"and",
"the",
"rows",
"in",
"the",
"gammamc",
"file",
"dmSpecTab",
".",
"npy",
"created",
"to",
"match",
"this",
"mapping",
"too"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/dark_matter/dm_models.py#L209-L291 | train |
threeML/astromodels | astromodels/utils/valid_variable.py | is_valid_variable_name | def is_valid_variable_name(string_to_check):
"""
Returns whether the provided name is a valid variable name in Python
:param string_to_check: the string to be checked
:return: True or False
"""
try:
parse('{} = None'.format(string_to_check))
return True
except (SyntaxErro... | python | def is_valid_variable_name(string_to_check):
"""
Returns whether the provided name is a valid variable name in Python
:param string_to_check: the string to be checked
:return: True or False
"""
try:
parse('{} = None'.format(string_to_check))
return True
except (SyntaxErro... | [
"def",
"is_valid_variable_name",
"(",
"string_to_check",
")",
":",
"try",
":",
"parse",
"(",
"'{} = None'",
".",
"format",
"(",
"string_to_check",
")",
")",
"return",
"True",
"except",
"(",
"SyntaxError",
",",
"ValueError",
",",
"TypeError",
")",
":",
"return"... | Returns whether the provided name is a valid variable name in Python
:param string_to_check: the string to be checked
:return: True or False | [
"Returns",
"whether",
"the",
"provided",
"name",
"is",
"a",
"valid",
"variable",
"name",
"in",
"Python"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/valid_variable.py#L4-L19 | train |
threeML/astromodels | astromodels/core/units.py | _check_unit | def _check_unit(new_unit, old_unit):
"""
Check that the new unit is compatible with the old unit for the quantity described by variable_name
:param new_unit: instance of astropy.units.Unit
:param old_unit: instance of astropy.units.Unit
:return: nothin
"""
try:
new_unit.physical_t... | python | def _check_unit(new_unit, old_unit):
"""
Check that the new unit is compatible with the old unit for the quantity described by variable_name
:param new_unit: instance of astropy.units.Unit
:param old_unit: instance of astropy.units.Unit
:return: nothin
"""
try:
new_unit.physical_t... | [
"def",
"_check_unit",
"(",
"new_unit",
",",
"old_unit",
")",
":",
"try",
":",
"new_unit",
".",
"physical_type",
"except",
"AttributeError",
":",
"raise",
"UnitMismatch",
"(",
"\"The provided unit (%s) has no physical type. Was expecting a unit for %s\"",
"%",
"(",
"new_un... | Check that the new unit is compatible with the old unit for the quantity described by variable_name
:param new_unit: instance of astropy.units.Unit
:param old_unit: instance of astropy.units.Unit
:return: nothin | [
"Check",
"that",
"the",
"new",
"unit",
"is",
"compatible",
"with",
"the",
"old",
"unit",
"for",
"the",
"quantity",
"described",
"by",
"variable_name"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/units.py#L29-L50 | train |
threeML/astromodels | astromodels/functions/functions.py | Log_parabola.peak_energy | def peak_energy(self):
"""
Returns the peak energy in the nuFnu spectrum
:return: peak energy in keV
"""
# Eq. 6 in Massaro et al. 2004
# (http://adsabs.harvard.edu/abs/2004A%26A...413..489M)
return self.piv.value * pow(10, ((2 + self.alpha.value) * np.log(10))... | python | def peak_energy(self):
"""
Returns the peak energy in the nuFnu spectrum
:return: peak energy in keV
"""
# Eq. 6 in Massaro et al. 2004
# (http://adsabs.harvard.edu/abs/2004A%26A...413..489M)
return self.piv.value * pow(10, ((2 + self.alpha.value) * np.log(10))... | [
"def",
"peak_energy",
"(",
"self",
")",
":",
"return",
"self",
".",
"piv",
".",
"value",
"*",
"pow",
"(",
"10",
",",
"(",
"(",
"2",
"+",
"self",
".",
"alpha",
".",
"value",
")",
"*",
"np",
".",
"log",
"(",
"10",
")",
")",
"/",
"(",
"2",
"*"... | Returns the peak energy in the nuFnu spectrum
:return: peak energy in keV | [
"Returns",
"the",
"peak",
"energy",
"in",
"the",
"nuFnu",
"spectrum"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/functions.py#L1562-L1572 | train |
threeML/astromodels | astromodels/core/parameter.py | ParameterBase.in_unit_of | def in_unit_of(self, unit, as_quantity=False):
"""
Return the current value transformed to the new units
:param unit: either an astropy.Unit instance, or a string which can be converted to an astropy.Unit
instance, like "1 / (erg cm**2 s)"
:param as_quantity: if True, the me... | python | def in_unit_of(self, unit, as_quantity=False):
"""
Return the current value transformed to the new units
:param unit: either an astropy.Unit instance, or a string which can be converted to an astropy.Unit
instance, like "1 / (erg cm**2 s)"
:param as_quantity: if True, the me... | [
"def",
"in_unit_of",
"(",
"self",
",",
"unit",
",",
"as_quantity",
"=",
"False",
")",
":",
"new_unit",
"=",
"u",
".",
"Unit",
"(",
"unit",
")",
"new_quantity",
"=",
"self",
".",
"as_quantity",
".",
"to",
"(",
"new_unit",
")",
"if",
"as_quantity",
":",
... | Return the current value transformed to the new units
:param unit: either an astropy.Unit instance, or a string which can be converted to an astropy.Unit
instance, like "1 / (erg cm**2 s)"
:param as_quantity: if True, the method return an astropy.Quantity, if False just a floating point num... | [
"Return",
"the",
"current",
"value",
"transformed",
"to",
"the",
"new",
"units"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L325-L346 | train |
threeML/astromodels | astromodels/core/parameter.py | ParameterBase._get_value | def _get_value(self):
"""Return current parameter value"""
# This is going to be true (possibly) only for derived classes. It is here to make the code cleaner
# and also to avoid infinite recursion
if self._aux_variable:
return self._aux_variable['law'](self._aux_variable[... | python | def _get_value(self):
"""Return current parameter value"""
# This is going to be true (possibly) only for derived classes. It is here to make the code cleaner
# and also to avoid infinite recursion
if self._aux_variable:
return self._aux_variable['law'](self._aux_variable[... | [
"def",
"_get_value",
"(",
"self",
")",
":",
"if",
"self",
".",
"_aux_variable",
":",
"return",
"self",
".",
"_aux_variable",
"[",
"'law'",
"]",
"(",
"self",
".",
"_aux_variable",
"[",
"'variable'",
"]",
".",
"value",
")",
"if",
"self",
".",
"_transformat... | Return current parameter value | [
"Return",
"current",
"parameter",
"value"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L394-L415 | train |
threeML/astromodels | astromodels/core/parameter.py | ParameterBase._set_value | def _set_value(self, new_value):
"""Sets the current value of the parameter, ensuring that it is within the allowed range."""
if self.min_value is not None and new_value < self.min_value:
raise SettingOutOfBounds(
"Trying to set parameter {0} = {1}, which is less than the m... | python | def _set_value(self, new_value):
"""Sets the current value of the parameter, ensuring that it is within the allowed range."""
if self.min_value is not None and new_value < self.min_value:
raise SettingOutOfBounds(
"Trying to set parameter {0} = {1}, which is less than the m... | [
"def",
"_set_value",
"(",
"self",
",",
"new_value",
")",
":",
"if",
"self",
".",
"min_value",
"is",
"not",
"None",
"and",
"new_value",
"<",
"self",
".",
"min_value",
":",
"raise",
"SettingOutOfBounds",
"(",
"\"Trying to set parameter {0} = {1}, which is less than th... | Sets the current value of the parameter, ensuring that it is within the allowed range. | [
"Sets",
"the",
"current",
"value",
"of",
"the",
"parameter",
"ensuring",
"that",
"it",
"is",
"within",
"the",
"allowed",
"range",
"."
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L420-L471 | train |
threeML/astromodels | astromodels/core/parameter.py | ParameterBase._set_internal_value | def _set_internal_value(self, new_internal_value):
"""
This is supposed to be only used by fitting engines
:param new_internal_value: new value in internal representation
:return: none
"""
if new_internal_value != self._internal_value:
self._internal_value ... | python | def _set_internal_value(self, new_internal_value):
"""
This is supposed to be only used by fitting engines
:param new_internal_value: new value in internal representation
:return: none
"""
if new_internal_value != self._internal_value:
self._internal_value ... | [
"def",
"_set_internal_value",
"(",
"self",
",",
"new_internal_value",
")",
":",
"if",
"new_internal_value",
"!=",
"self",
".",
"_internal_value",
":",
"self",
".",
"_internal_value",
"=",
"new_internal_value",
"for",
"callback",
"in",
"self",
".",
"_callbacks",
":... | This is supposed to be only used by fitting engines
:param new_internal_value: new value in internal representation
:return: none | [
"This",
"is",
"supposed",
"to",
"be",
"only",
"used",
"by",
"fitting",
"engines"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L491-L507 | train |
threeML/astromodels | astromodels/core/parameter.py | ParameterBase._set_min_value | def _set_min_value(self, min_value):
"""Sets current minimum allowed value"""
# Check that the min value can be transformed if a transformation is present
if self._transformation is not None:
if min_value is not None:
try:
_ = self._transforma... | python | def _set_min_value(self, min_value):
"""Sets current minimum allowed value"""
# Check that the min value can be transformed if a transformation is present
if self._transformation is not None:
if min_value is not None:
try:
_ = self._transforma... | [
"def",
"_set_min_value",
"(",
"self",
",",
"min_value",
")",
":",
"if",
"self",
".",
"_transformation",
"is",
"not",
"None",
":",
"if",
"min_value",
"is",
"not",
"None",
":",
"try",
":",
"_",
"=",
"self",
".",
"_transformation",
".",
"forward",
"(",
"m... | Sets current minimum allowed value | [
"Sets",
"current",
"minimum",
"allowed",
"value"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L518-L550 | train |
threeML/astromodels | astromodels/core/parameter.py | ParameterBase._set_max_value | def _set_max_value(self, max_value):
"""Sets current maximum allowed value"""
self._external_max_value = max_value
# Check that the current value of the parameter is still within the boundaries. If not, issue a warning
if self._external_max_value is not None and self.value > self._ext... | python | def _set_max_value(self, max_value):
"""Sets current maximum allowed value"""
self._external_max_value = max_value
# Check that the current value of the parameter is still within the boundaries. If not, issue a warning
if self._external_max_value is not None and self.value > self._ext... | [
"def",
"_set_max_value",
"(",
"self",
",",
"max_value",
")",
":",
"self",
".",
"_external_max_value",
"=",
"max_value",
"if",
"self",
".",
"_external_max_value",
"is",
"not",
"None",
"and",
"self",
".",
"value",
">",
"self",
".",
"_external_max_value",
":",
... | Sets current maximum allowed value | [
"Sets",
"current",
"maximum",
"allowed",
"value"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L600-L612 | train |
threeML/astromodels | astromodels/core/parameter.py | ParameterBase._set_bounds | def _set_bounds(self, bounds):
"""Sets the boundaries for this parameter to min_value and max_value"""
# Use the properties so that the checks and the handling of units are made automatically
min_value, max_value = bounds
# Remove old boundaries to avoid problems with the new one, if ... | python | def _set_bounds(self, bounds):
"""Sets the boundaries for this parameter to min_value and max_value"""
# Use the properties so that the checks and the handling of units are made automatically
min_value, max_value = bounds
# Remove old boundaries to avoid problems with the new one, if ... | [
"def",
"_set_bounds",
"(",
"self",
",",
"bounds",
")",
":",
"min_value",
",",
"max_value",
"=",
"bounds",
"self",
".",
"min_value",
"=",
"None",
"self",
".",
"max_value",
"=",
"None",
"self",
".",
"min_value",
"=",
"min_value",
"self",
".",
"max_value",
... | Sets the boundaries for this parameter to min_value and max_value | [
"Sets",
"the",
"boundaries",
"for",
"this",
"parameter",
"to",
"min_value",
"and",
"max_value"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L653-L667 | train |
threeML/astromodels | astromodels/core/parameter.py | Parameter._set_prior | def _set_prior(self, prior):
"""Set prior for this parameter. The prior must be a function accepting the current value of the parameter
as input and giving the probability density as output."""
if prior is None:
# Removing prior
self._prior = None
else:
... | python | def _set_prior(self, prior):
"""Set prior for this parameter. The prior must be a function accepting the current value of the parameter
as input and giving the probability density as output."""
if prior is None:
# Removing prior
self._prior = None
else:
... | [
"def",
"_set_prior",
"(",
"self",
",",
"prior",
")",
":",
"if",
"prior",
"is",
"None",
":",
"self",
".",
"_prior",
"=",
"None",
"else",
":",
"try",
":",
"_",
"=",
"prior",
"(",
"self",
".",
"value",
")",
"except",
":",
"raise",
"NotCallableOrErrorInC... | Set prior for this parameter. The prior must be a function accepting the current value of the parameter
as input and giving the probability density as output. | [
"Set",
"prior",
"for",
"this",
"parameter",
".",
"The",
"prior",
"must",
"be",
"a",
"function",
"accepting",
"the",
"current",
"value",
"of",
"the",
"parameter",
"as",
"input",
"and",
"giving",
"the",
"probability",
"density",
"as",
"output",
"."
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L916-L946 | train |
threeML/astromodels | astromodels/core/parameter.py | Parameter.set_uninformative_prior | def set_uninformative_prior(self, prior_class):
"""
Sets the prior for the parameter to a uniform prior between the current minimum and maximum, or a
log-uniform prior between the current minimum and maximum.
NOTE: if the current minimum and maximum are not defined, the default bounds f... | python | def set_uninformative_prior(self, prior_class):
"""
Sets the prior for the parameter to a uniform prior between the current minimum and maximum, or a
log-uniform prior between the current minimum and maximum.
NOTE: if the current minimum and maximum are not defined, the default bounds f... | [
"def",
"set_uninformative_prior",
"(",
"self",
",",
"prior_class",
")",
":",
"prior_instance",
"=",
"prior_class",
"(",
")",
"if",
"self",
".",
"min_value",
"is",
"None",
":",
"raise",
"ParameterMustHaveBounds",
"(",
"\"Parameter %s does not have a defined minimum. Set ... | Sets the prior for the parameter to a uniform prior between the current minimum and maximum, or a
log-uniform prior between the current minimum and maximum.
NOTE: if the current minimum and maximum are not defined, the default bounds for the prior class will be used.
:param prior_class : the c... | [
"Sets",
"the",
"prior",
"for",
"the",
"parameter",
"to",
"a",
"uniform",
"prior",
"between",
"the",
"current",
"minimum",
"and",
"maximum",
"or",
"a",
"log",
"-",
"uniform",
"prior",
"between",
"the",
"current",
"minimum",
"and",
"maximum",
"."
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L962-L1011 | train |
threeML/astromodels | astromodels/core/parameter.py | Parameter.remove_auxiliary_variable | def remove_auxiliary_variable(self):
"""
Remove an existing auxiliary variable
:return:
"""
if not self.has_auxiliary_variable():
# do nothing, but print a warning
warnings.warn("Cannot remove a non-existing auxiliary variable", RuntimeWarning)
... | python | def remove_auxiliary_variable(self):
"""
Remove an existing auxiliary variable
:return:
"""
if not self.has_auxiliary_variable():
# do nothing, but print a warning
warnings.warn("Cannot remove a non-existing auxiliary variable", RuntimeWarning)
... | [
"def",
"remove_auxiliary_variable",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"has_auxiliary_variable",
"(",
")",
":",
"warnings",
".",
"warn",
"(",
"\"Cannot remove a non-existing auxiliary variable\"",
",",
"RuntimeWarning",
")",
"else",
":",
"self",
".",
... | Remove an existing auxiliary variable
:return: | [
"Remove",
"an",
"existing",
"auxiliary",
"variable"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L1077-L1102 | train |
threeML/astromodels | astromodels/core/tree.py | OldNode._get_child_from_path | def _get_child_from_path(self, path):
"""
Return a children below this level, starting from a path of the kind "this_level.something.something.name"
:param path: the key
:return: the child
"""
keys = path.split(".")
this_child = self
for key in keys:
... | python | def _get_child_from_path(self, path):
"""
Return a children below this level, starting from a path of the kind "this_level.something.something.name"
:param path: the key
:return: the child
"""
keys = path.split(".")
this_child = self
for key in keys:
... | [
"def",
"_get_child_from_path",
"(",
"self",
",",
"path",
")",
":",
"keys",
"=",
"path",
".",
"split",
"(",
"\".\"",
")",
"this_child",
"=",
"self",
"for",
"key",
"in",
"keys",
":",
"try",
":",
"this_child",
"=",
"this_child",
".",
"_get_child",
"(",
"k... | Return a children below this level, starting from a path of the kind "this_level.something.something.name"
:param path: the key
:return: the child | [
"Return",
"a",
"children",
"below",
"this",
"level",
"starting",
"from",
"a",
"path",
"of",
"the",
"kind",
"this_level",
".",
"something",
".",
"something",
".",
"name"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/tree.py#L210-L232 | train |
threeML/astromodels | astromodels/core/tree.py | OldNode._find_instances | def _find_instances(self, cls):
"""
Find all the instances of cls below this node.
:return: a dictionary of instances of cls
"""
instances = collections.OrderedDict()
for child_name, child in self._children.iteritems():
if isinstance(child, cls):
... | python | def _find_instances(self, cls):
"""
Find all the instances of cls below this node.
:return: a dictionary of instances of cls
"""
instances = collections.OrderedDict()
for child_name, child in self._children.iteritems():
if isinstance(child, cls):
... | [
"def",
"_find_instances",
"(",
"self",
",",
"cls",
")",
":",
"instances",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"for",
"child_name",
",",
"child",
"in",
"self",
".",
"_children",
".",
"iteritems",
"(",
")",
":",
"if",
"isinstance",
"(",
"chil... | Find all the instances of cls below this node.
:return: a dictionary of instances of cls | [
"Find",
"all",
"the",
"instances",
"of",
"cls",
"below",
"this",
"node",
"."
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/tree.py#L299-L329 | train |
threeML/astromodels | setup.py | find_library | def find_library(library_root, additional_places=None):
"""
Returns the name of the library without extension
:param library_root: root of the library to search, for example "cfitsio_" will match libcfitsio_1.2.3.4.so
:return: the name of the library found (NOTE: this is *not* the path), and a director... | python | def find_library(library_root, additional_places=None):
"""
Returns the name of the library without extension
:param library_root: root of the library to search, for example "cfitsio_" will match libcfitsio_1.2.3.4.so
:return: the name of the library found (NOTE: this is *not* the path), and a director... | [
"def",
"find_library",
"(",
"library_root",
",",
"additional_places",
"=",
"None",
")",
":",
"first_guess",
"=",
"ctypes",
".",
"util",
".",
"find_library",
"(",
"library_root",
")",
"if",
"first_guess",
"is",
"not",
"None",
":",
"if",
"sys",
".",
"platform"... | Returns the name of the library without extension
:param library_root: root of the library to search, for example "cfitsio_" will match libcfitsio_1.2.3.4.so
:return: the name of the library found (NOTE: this is *not* the path), and a directory path if the library is not
in the system paths (and None other... | [
"Returns",
"the",
"name",
"of",
"the",
"library",
"without",
"extension"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/setup.py#L54-L172 | train |
threeML/astromodels | astromodels/utils/table.py | dict_to_table | def dict_to_table(dictionary, list_of_keys=None):
"""
Return a table representing the dictionary.
:param dictionary: the dictionary to represent
:param list_of_keys: optionally, only the keys in this list will be inserted in the table
:return: a Table instance
"""
# assert len(dictionary.v... | python | def dict_to_table(dictionary, list_of_keys=None):
"""
Return a table representing the dictionary.
:param dictionary: the dictionary to represent
:param list_of_keys: optionally, only the keys in this list will be inserted in the table
:return: a Table instance
"""
# assert len(dictionary.v... | [
"def",
"dict_to_table",
"(",
"dictionary",
",",
"list_of_keys",
"=",
"None",
")",
":",
"table",
"=",
"Table",
"(",
")",
"if",
"len",
"(",
"dictionary",
")",
">",
"0",
":",
"table",
"[",
"'name'",
"]",
"=",
"dictionary",
".",
"keys",
"(",
")",
"protot... | Return a table representing the dictionary.
:param dictionary: the dictionary to represent
:param list_of_keys: optionally, only the keys in this list will be inserted in the table
:return: a Table instance | [
"Return",
"a",
"table",
"representing",
"the",
"dictionary",
"."
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/table.py#L6-L49 | train |
threeML/astromodels | astromodels/utils/table.py | Table._base_repr_ | def _base_repr_(self, html=False, show_name=True, **kwargs):
"""
Override the method in the astropy.Table class
to avoid displaying the description, and the format
of the columns
"""
table_id = 'table{id}'.format(id=id(self))
data_lines, outs = self.formatter._p... | python | def _base_repr_(self, html=False, show_name=True, **kwargs):
"""
Override the method in the astropy.Table class
to avoid displaying the description, and the format
of the columns
"""
table_id = 'table{id}'.format(id=id(self))
data_lines, outs = self.formatter._p... | [
"def",
"_base_repr_",
"(",
"self",
",",
"html",
"=",
"False",
",",
"show_name",
"=",
"True",
",",
"**",
"kwargs",
")",
":",
"table_id",
"=",
"'table{id}'",
".",
"format",
"(",
"id",
"=",
"id",
"(",
"self",
")",
")",
"data_lines",
",",
"outs",
"=",
... | Override the method in the astropy.Table class
to avoid displaying the description, and the format
of the columns | [
"Override",
"the",
"method",
"in",
"the",
"astropy",
".",
"Table",
"class",
"to",
"avoid",
"displaying",
"the",
"description",
"and",
"the",
"format",
"of",
"the",
"columns"
] | 9aac365a372f77603039533df9a6b694c1e360d5 | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/table.py#L60-L78 | train |
eamigo86/graphene-django-extras | graphene_django_extras/views.py | ExtraGraphQLView.fetch_cache_key | def fetch_cache_key(request):
""" Returns a hashed cache key. """
m = hashlib.md5()
m.update(request.body)
return m.hexdigest() | python | def fetch_cache_key(request):
""" Returns a hashed cache key. """
m = hashlib.md5()
m.update(request.body)
return m.hexdigest() | [
"def",
"fetch_cache_key",
"(",
"request",
")",
":",
"m",
"=",
"hashlib",
".",
"md5",
"(",
")",
"m",
".",
"update",
"(",
"request",
".",
"body",
")",
"return",
"m",
".",
"hexdigest",
"(",
")"
] | Returns a hashed cache key. | [
"Returns",
"a",
"hashed",
"cache",
"key",
"."
] | b27fd6b5128f6b6a500a8b7a497d76be72d6a232 | https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/views.py#L42-L47 | train |
eamigo86/graphene-django-extras | graphene_django_extras/views.py | ExtraGraphQLView.dispatch | def dispatch(self, request, *args, **kwargs):
""" Fetches queried data from graphql and returns cached & hashed key. """
if not graphql_api_settings.CACHE_ACTIVE:
return self.super_call(request, *args, **kwargs)
cache = caches["default"]
operation_ast = self.get_operation_as... | python | def dispatch(self, request, *args, **kwargs):
""" Fetches queried data from graphql and returns cached & hashed key. """
if not graphql_api_settings.CACHE_ACTIVE:
return self.super_call(request, *args, **kwargs)
cache = caches["default"]
operation_ast = self.get_operation_as... | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"graphql_api_settings",
".",
"CACHE_ACTIVE",
":",
"return",
"self",
".",
"super_call",
"(",
"request",
",",
"*",
"args",
",",
"**",
"kwargs",
... | Fetches queried data from graphql and returns cached & hashed key. | [
"Fetches",
"queried",
"data",
"from",
"graphql",
"and",
"returns",
"cached",
"&",
"hashed",
"key",
"."
] | b27fd6b5128f6b6a500a8b7a497d76be72d6a232 | https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/views.py#L54-L74 | train |
eamigo86/graphene-django-extras | graphene_django_extras/directives/date.py | _parse | def _parse(partial_dt):
"""
parse a partial datetime object to a complete datetime object
"""
dt = None
try:
if isinstance(partial_dt, datetime):
dt = partial_dt
if isinstance(partial_dt, date):
dt = _combine_date_time(partial_dt, time(0, 0, 0))
if isi... | python | def _parse(partial_dt):
"""
parse a partial datetime object to a complete datetime object
"""
dt = None
try:
if isinstance(partial_dt, datetime):
dt = partial_dt
if isinstance(partial_dt, date):
dt = _combine_date_time(partial_dt, time(0, 0, 0))
if isi... | [
"def",
"_parse",
"(",
"partial_dt",
")",
":",
"dt",
"=",
"None",
"try",
":",
"if",
"isinstance",
"(",
"partial_dt",
",",
"datetime",
")",
":",
"dt",
"=",
"partial_dt",
"if",
"isinstance",
"(",
"partial_dt",
",",
"date",
")",
":",
"dt",
"=",
"_combine_d... | parse a partial datetime object to a complete datetime object | [
"parse",
"a",
"partial",
"datetime",
"object",
"to",
"a",
"complete",
"datetime",
"object"
] | b27fd6b5128f6b6a500a8b7a497d76be72d6a232 | https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/directives/date.py#L73-L94 | train |
eamigo86/graphene-django-extras | graphene_django_extras/utils.py | clean_dict | def clean_dict(d):
"""
Remove all empty fields in a nested dict
"""
if not isinstance(d, (dict, list)):
return d
if isinstance(d, list):
return [v for v in (clean_dict(v) for v in d) if v]
return OrderedDict(
[(k, v) for k, v in ((k, clean_dict(v)) for k, v in list(d... | python | def clean_dict(d):
"""
Remove all empty fields in a nested dict
"""
if not isinstance(d, (dict, list)):
return d
if isinstance(d, list):
return [v for v in (clean_dict(v) for v in d) if v]
return OrderedDict(
[(k, v) for k, v in ((k, clean_dict(v)) for k, v in list(d... | [
"def",
"clean_dict",
"(",
"d",
")",
":",
"if",
"not",
"isinstance",
"(",
"d",
",",
"(",
"dict",
",",
"list",
")",
")",
":",
"return",
"d",
"if",
"isinstance",
"(",
"d",
",",
"list",
")",
":",
"return",
"[",
"v",
"for",
"v",
"in",
"(",
"clean_di... | Remove all empty fields in a nested dict | [
"Remove",
"all",
"empty",
"fields",
"in",
"a",
"nested",
"dict"
] | b27fd6b5128f6b6a500a8b7a497d76be72d6a232 | https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/utils.py#L168-L179 | train |
eamigo86/graphene-django-extras | graphene_django_extras/utils.py | _get_queryset | def _get_queryset(klass):
"""
Returns a QuerySet from a Model, Manager, or QuerySet. Created to make
get_object_or_404 and get_list_or_404 more DRY.
Raises a ValueError if klass is not a Model, Manager, or QuerySet.
"""
if isinstance(klass, QuerySet):
return klass
elif isinstance(kl... | python | def _get_queryset(klass):
"""
Returns a QuerySet from a Model, Manager, or QuerySet. Created to make
get_object_or_404 and get_list_or_404 more DRY.
Raises a ValueError if klass is not a Model, Manager, or QuerySet.
"""
if isinstance(klass, QuerySet):
return klass
elif isinstance(kl... | [
"def",
"_get_queryset",
"(",
"klass",
")",
":",
"if",
"isinstance",
"(",
"klass",
",",
"QuerySet",
")",
":",
"return",
"klass",
"elif",
"isinstance",
"(",
"klass",
",",
"Manager",
")",
":",
"manager",
"=",
"klass",
"elif",
"isinstance",
"(",
"klass",
","... | Returns a QuerySet from a Model, Manager, or QuerySet. Created to make
get_object_or_404 and get_list_or_404 more DRY.
Raises a ValueError if klass is not a Model, Manager, or QuerySet. | [
"Returns",
"a",
"QuerySet",
"from",
"a",
"Model",
"Manager",
"or",
"QuerySet",
".",
"Created",
"to",
"make",
"get_object_or_404",
"and",
"get_list_or_404",
"more",
"DRY",
"."
] | b27fd6b5128f6b6a500a8b7a497d76be72d6a232 | https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/utils.py#L224-L246 | train |
Proteus-tech/tormor | tormor/schema.py | find_schema_paths | def find_schema_paths(schema_files_path=DEFAULT_SCHEMA_FILES_PATH):
"""Searches the locations in the `SCHEMA_FILES_PATH` to
try to find where the schema SQL files are located.
"""
paths = []
for path in schema_files_path:
if os.path.isdir(path):
paths.append(path)
if paths:
... | python | def find_schema_paths(schema_files_path=DEFAULT_SCHEMA_FILES_PATH):
"""Searches the locations in the `SCHEMA_FILES_PATH` to
try to find where the schema SQL files are located.
"""
paths = []
for path in schema_files_path:
if os.path.isdir(path):
paths.append(path)
if paths:
... | [
"def",
"find_schema_paths",
"(",
"schema_files_path",
"=",
"DEFAULT_SCHEMA_FILES_PATH",
")",
":",
"paths",
"=",
"[",
"]",
"for",
"path",
"in",
"schema_files_path",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"paths",
".",
"append",
"... | Searches the locations in the `SCHEMA_FILES_PATH` to
try to find where the schema SQL files are located. | [
"Searches",
"the",
"locations",
"in",
"the",
"SCHEMA_FILES_PATH",
"to",
"try",
"to",
"find",
"where",
"the",
"schema",
"SQL",
"files",
"are",
"located",
"."
] | 3083b0cd2b9a4d21b20dfd5c27678b23660548d7 | https://github.com/Proteus-tech/tormor/blob/3083b0cd2b9a4d21b20dfd5c27678b23660548d7/tormor/schema.py#L41-L51 | train |
plivo/sharq-server | runner.py | run | def run():
"""Exposes a CLI to configure the SharQ Server and runs the server."""
# create a arg parser and configure it.
parser = argparse.ArgumentParser(description='SharQ Server.')
parser.add_argument('-c', '--config', action='store', required=True,
help='Absolute path of the ... | python | def run():
"""Exposes a CLI to configure the SharQ Server and runs the server."""
# create a arg parser and configure it.
parser = argparse.ArgumentParser(description='SharQ Server.')
parser.add_argument('-c', '--config', action='store', required=True,
help='Absolute path of the ... | [
"def",
"run",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'SharQ Server.'",
")",
"parser",
".",
"add_argument",
"(",
"'-c'",
",",
"'--config'",
",",
"action",
"=",
"'store'",
",",
"required",
"=",
"True",
",",... | Exposes a CLI to configure the SharQ Server and runs the server. | [
"Exposes",
"a",
"CLI",
"to",
"configure",
"the",
"SharQ",
"Server",
"and",
"runs",
"the",
"server",
"."
] | 9f4c50eb5ee28d1084591febc4a3a34d7ffd0556 | https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/runner.py#L38-L97 | train |
plivo/sharq-server | sharq_server/server.py | setup_server | def setup_server(config_path):
"""Configure SharQ server, start the requeue loop
and return the server."""
# configure the SharQ server
server = SharQServer(config_path)
# start the requeue loop
gevent.spawn(server.requeue)
return server | python | def setup_server(config_path):
"""Configure SharQ server, start the requeue loop
and return the server."""
# configure the SharQ server
server = SharQServer(config_path)
# start the requeue loop
gevent.spawn(server.requeue)
return server | [
"def",
"setup_server",
"(",
"config_path",
")",
":",
"server",
"=",
"SharQServer",
"(",
"config_path",
")",
"gevent",
".",
"spawn",
"(",
"server",
".",
"requeue",
")",
"return",
"server"
] | Configure SharQ server, start the requeue loop
and return the server. | [
"Configure",
"SharQ",
"server",
"start",
"the",
"requeue",
"loop",
"and",
"return",
"the",
"server",
"."
] | 9f4c50eb5ee28d1084591febc4a3a34d7ffd0556 | https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L204-L212 | train |
plivo/sharq-server | sharq_server/server.py | SharQServer.requeue | def requeue(self):
"""Loop endlessly and requeue expired jobs."""
job_requeue_interval = float(
self.config.get('sharq', 'job_requeue_interval'))
while True:
self.sq.requeue()
gevent.sleep(job_requeue_interval / 1000.00) | python | def requeue(self):
"""Loop endlessly and requeue expired jobs."""
job_requeue_interval = float(
self.config.get('sharq', 'job_requeue_interval'))
while True:
self.sq.requeue()
gevent.sleep(job_requeue_interval / 1000.00) | [
"def",
"requeue",
"(",
"self",
")",
":",
"job_requeue_interval",
"=",
"float",
"(",
"self",
".",
"config",
".",
"get",
"(",
"'sharq'",
",",
"'job_requeue_interval'",
")",
")",
"while",
"True",
":",
"self",
".",
"sq",
".",
"requeue",
"(",
")",
"gevent",
... | Loop endlessly and requeue expired jobs. | [
"Loop",
"endlessly",
"and",
"requeue",
"expired",
"jobs",
"."
] | 9f4c50eb5ee28d1084591febc4a3a34d7ffd0556 | https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L57-L63 | train |
plivo/sharq-server | sharq_server/server.py | SharQServer._view_enqueue | def _view_enqueue(self, queue_type, queue_id):
"""Enqueues a job into SharQ."""
response = {
'status': 'failure'
}
try:
request_data = json.loads(request.data)
except Exception, e:
response['message'] = e.message
return jsonify(**re... | python | def _view_enqueue(self, queue_type, queue_id):
"""Enqueues a job into SharQ."""
response = {
'status': 'failure'
}
try:
request_data = json.loads(request.data)
except Exception, e:
response['message'] = e.message
return jsonify(**re... | [
"def",
"_view_enqueue",
"(",
"self",
",",
"queue_type",
",",
"queue_id",
")",
":",
"response",
"=",
"{",
"'status'",
":",
"'failure'",
"}",
"try",
":",
"request_data",
"=",
"json",
".",
"loads",
"(",
"request",
".",
"data",
")",
"except",
"Exception",
",... | Enqueues a job into SharQ. | [
"Enqueues",
"a",
"job",
"into",
"SharQ",
"."
] | 9f4c50eb5ee28d1084591febc4a3a34d7ffd0556 | https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L69-L91 | train |
plivo/sharq-server | sharq_server/server.py | SharQServer._view_dequeue | def _view_dequeue(self, queue_type):
"""Dequeues a job from SharQ."""
response = {
'status': 'failure'
}
request_data = {
'queue_type': queue_type
}
try:
response = self.sq.dequeue(**request_data)
if response['status'] == '... | python | def _view_dequeue(self, queue_type):
"""Dequeues a job from SharQ."""
response = {
'status': 'failure'
}
request_data = {
'queue_type': queue_type
}
try:
response = self.sq.dequeue(**request_data)
if response['status'] == '... | [
"def",
"_view_dequeue",
"(",
"self",
",",
"queue_type",
")",
":",
"response",
"=",
"{",
"'status'",
":",
"'failure'",
"}",
"request_data",
"=",
"{",
"'queue_type'",
":",
"queue_type",
"}",
"try",
":",
"response",
"=",
"self",
".",
"sq",
".",
"dequeue",
"... | Dequeues a job from SharQ. | [
"Dequeues",
"a",
"job",
"from",
"SharQ",
"."
] | 9f4c50eb5ee28d1084591febc4a3a34d7ffd0556 | https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L93-L110 | train |
plivo/sharq-server | sharq_server/server.py | SharQServer._view_finish | def _view_finish(self, queue_type, queue_id, job_id):
"""Marks a job as finished in SharQ."""
response = {
'status': 'failure'
}
request_data = {
'queue_type': queue_type,
'queue_id': queue_id,
'job_id': job_id
}
try:
... | python | def _view_finish(self, queue_type, queue_id, job_id):
"""Marks a job as finished in SharQ."""
response = {
'status': 'failure'
}
request_data = {
'queue_type': queue_type,
'queue_id': queue_id,
'job_id': job_id
}
try:
... | [
"def",
"_view_finish",
"(",
"self",
",",
"queue_type",
",",
"queue_id",
",",
"job_id",
")",
":",
"response",
"=",
"{",
"'status'",
":",
"'failure'",
"}",
"request_data",
"=",
"{",
"'queue_type'",
":",
"queue_type",
",",
"'queue_id'",
":",
"queue_id",
",",
... | Marks a job as finished in SharQ. | [
"Marks",
"a",
"job",
"as",
"finished",
"in",
"SharQ",
"."
] | 9f4c50eb5ee28d1084591febc4a3a34d7ffd0556 | https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L112-L131 | train |
plivo/sharq-server | sharq_server/server.py | SharQServer._view_interval | def _view_interval(self, queue_type, queue_id):
"""Updates the queue interval in SharQ."""
response = {
'status': 'failure'
}
try:
request_data = json.loads(request.data)
interval = request_data['interval']
except Exception, e:
resp... | python | def _view_interval(self, queue_type, queue_id):
"""Updates the queue interval in SharQ."""
response = {
'status': 'failure'
}
try:
request_data = json.loads(request.data)
interval = request_data['interval']
except Exception, e:
resp... | [
"def",
"_view_interval",
"(",
"self",
",",
"queue_type",
",",
"queue_id",
")",
":",
"response",
"=",
"{",
"'status'",
":",
"'failure'",
"}",
"try",
":",
"request_data",
"=",
"json",
".",
"loads",
"(",
"request",
".",
"data",
")",
"interval",
"=",
"reques... | Updates the queue interval in SharQ. | [
"Updates",
"the",
"queue",
"interval",
"in",
"SharQ",
"."
] | 9f4c50eb5ee28d1084591febc4a3a34d7ffd0556 | https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L133-L159 | train |
plivo/sharq-server | sharq_server/server.py | SharQServer._view_metrics | def _view_metrics(self, queue_type, queue_id):
"""Gets SharQ metrics based on the params."""
response = {
'status': 'failure'
}
request_data = {}
if queue_type:
request_data['queue_type'] = queue_type
if queue_id:
request_data['queue_id... | python | def _view_metrics(self, queue_type, queue_id):
"""Gets SharQ metrics based on the params."""
response = {
'status': 'failure'
}
request_data = {}
if queue_type:
request_data['queue_type'] = queue_type
if queue_id:
request_data['queue_id... | [
"def",
"_view_metrics",
"(",
"self",
",",
"queue_type",
",",
"queue_id",
")",
":",
"response",
"=",
"{",
"'status'",
":",
"'failure'",
"}",
"request_data",
"=",
"{",
"}",
"if",
"queue_type",
":",
"request_data",
"[",
"'queue_type'",
"]",
"=",
"queue_type",
... | Gets SharQ metrics based on the params. | [
"Gets",
"SharQ",
"metrics",
"based",
"on",
"the",
"params",
"."
] | 9f4c50eb5ee28d1084591febc4a3a34d7ffd0556 | https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L161-L178 | train |
plivo/sharq-server | sharq_server/server.py | SharQServer._view_clear_queue | def _view_clear_queue(self, queue_type, queue_id):
"""remove queueu from SharQ based on the queue_type and queue_id."""
response = {
'status': 'failure'
}
try:
request_data = json.loads(request.data)
except Exception, e:
response['message'] = e... | python | def _view_clear_queue(self, queue_type, queue_id):
"""remove queueu from SharQ based on the queue_type and queue_id."""
response = {
'status': 'failure'
}
try:
request_data = json.loads(request.data)
except Exception, e:
response['message'] = e... | [
"def",
"_view_clear_queue",
"(",
"self",
",",
"queue_type",
",",
"queue_id",
")",
":",
"response",
"=",
"{",
"'status'",
":",
"'failure'",
"}",
"try",
":",
"request_data",
"=",
"json",
".",
"loads",
"(",
"request",
".",
"data",
")",
"except",
"Exception",
... | remove queueu from SharQ based on the queue_type and queue_id. | [
"remove",
"queueu",
"from",
"SharQ",
"based",
"on",
"the",
"queue_type",
"and",
"queue_id",
"."
] | 9f4c50eb5ee28d1084591febc4a3a34d7ffd0556 | https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L180-L201 | train |
depop/python-automock | automock/base.py | start_patching | def start_patching(name=None):
# type: (Optional[str]) -> None
"""
Initiate mocking of the functions listed in `_factory_map`.
For this to work reliably all mocked helper functions should be imported
and used like this:
import dp_paypal.client as paypal
res = paypal.do_paypal_expre... | python | def start_patching(name=None):
# type: (Optional[str]) -> None
"""
Initiate mocking of the functions listed in `_factory_map`.
For this to work reliably all mocked helper functions should be imported
and used like this:
import dp_paypal.client as paypal
res = paypal.do_paypal_expre... | [
"def",
"start_patching",
"(",
"name",
"=",
"None",
")",
":",
"global",
"_factory_map",
",",
"_patchers",
",",
"_mocks",
"if",
"_patchers",
"and",
"name",
"is",
"None",
":",
"warnings",
".",
"warn",
"(",
"'start_patching() called again, already patched'",
")",
"_... | Initiate mocking of the functions listed in `_factory_map`.
For this to work reliably all mocked helper functions should be imported
and used like this:
import dp_paypal.client as paypal
res = paypal.do_paypal_express_checkout(...)
(i.e. don't use `from dp_paypal.client import x` import s... | [
"Initiate",
"mocking",
"of",
"the",
"functions",
"listed",
"in",
"_factory_map",
"."
] | 8a02acecd9265c8f9a00d7b8e097cae87cdf28bd | https://github.com/depop/python-automock/blob/8a02acecd9265c8f9a00d7b8e097cae87cdf28bd/automock/base.py#L88-L121 | train |
depop/python-automock | automock/base.py | stop_patching | def stop_patching(name=None):
# type: (Optional[str]) -> None
"""
Finish the mocking initiated by `start_patching`
Kwargs:
name (Optional[str]): if given, only unpatch the specified path, else all
defined default mocks
"""
global _patchers, _mocks
if not _patchers:
... | python | def stop_patching(name=None):
# type: (Optional[str]) -> None
"""
Finish the mocking initiated by `start_patching`
Kwargs:
name (Optional[str]): if given, only unpatch the specified path, else all
defined default mocks
"""
global _patchers, _mocks
if not _patchers:
... | [
"def",
"stop_patching",
"(",
"name",
"=",
"None",
")",
":",
"global",
"_patchers",
",",
"_mocks",
"if",
"not",
"_patchers",
":",
"warnings",
".",
"warn",
"(",
"'stop_patching() called again, already stopped'",
")",
"if",
"name",
"is",
"not",
"None",
":",
"item... | Finish the mocking initiated by `start_patching`
Kwargs:
name (Optional[str]): if given, only unpatch the specified path, else all
defined default mocks | [
"Finish",
"the",
"mocking",
"initiated",
"by",
"start_patching"
] | 8a02acecd9265c8f9a00d7b8e097cae87cdf28bd | https://github.com/depop/python-automock/blob/8a02acecd9265c8f9a00d7b8e097cae87cdf28bd/automock/base.py#L124-L145 | train |
matousc89/padasip | padasip/preprocess/standardize_back.py | standardize_back | def standardize_back(xs, offset, scale):
"""
This is function for de-standarization of input series.
**Args:**
* `xs` : standardized input (1 dimensional array)
* `offset` : offset to add (float).
* `scale` : scale (float).
**Returns:**
* `x` : original (destandardised) ser... | python | def standardize_back(xs, offset, scale):
"""
This is function for de-standarization of input series.
**Args:**
* `xs` : standardized input (1 dimensional array)
* `offset` : offset to add (float).
* `scale` : scale (float).
**Returns:**
* `x` : original (destandardised) ser... | [
"def",
"standardize_back",
"(",
"xs",
",",
"offset",
",",
"scale",
")",
":",
"try",
":",
"offset",
"=",
"float",
"(",
"offset",
")",
"except",
":",
"raise",
"ValueError",
"(",
"'The argument offset is not None or float.'",
")",
"try",
":",
"scale",
"=",
"flo... | This is function for de-standarization of input series.
**Args:**
* `xs` : standardized input (1 dimensional array)
* `offset` : offset to add (float).
* `scale` : scale (float).
**Returns:**
* `x` : original (destandardised) series | [
"This",
"is",
"function",
"for",
"de",
"-",
"standarization",
"of",
"input",
"series",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/standardize_back.py#L33-L62 | train |
matousc89/padasip | padasip/preprocess/standardize.py | standardize | def standardize(x, offset=None, scale=None):
"""
This is function for standarization of input series.
**Args:**
* `x` : series (1 dimensional array)
**Kwargs:**
* `offset` : offset to remove (float). If not given, \
the mean value of `x` is used.
* `scale` : scale (float). If... | python | def standardize(x, offset=None, scale=None):
"""
This is function for standarization of input series.
**Args:**
* `x` : series (1 dimensional array)
**Kwargs:**
* `offset` : offset to remove (float). If not given, \
the mean value of `x` is used.
* `scale` : scale (float). If... | [
"def",
"standardize",
"(",
"x",
",",
"offset",
"=",
"None",
",",
"scale",
"=",
"None",
")",
":",
"if",
"offset",
"==",
"None",
":",
"offset",
"=",
"np",
".",
"array",
"(",
"x",
")",
".",
"mean",
"(",
")",
"else",
":",
"try",
":",
"offset",
"=",... | This is function for standarization of input series.
**Args:**
* `x` : series (1 dimensional array)
**Kwargs:**
* `offset` : offset to remove (float). If not given, \
the mean value of `x` is used.
* `scale` : scale (float). If not given, \
the standard deviation of `x` is used.... | [
"This",
"is",
"function",
"for",
"standarization",
"of",
"input",
"series",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/standardize.py#L62-L100 | train |
matousc89/padasip | padasip/preprocess/input_from_history.py | input_from_history | def input_from_history(a, n, bias=False):
"""
This is function for creation of input matrix.
**Args:**
* `a` : series (1 dimensional array)
* `n` : size of input matrix row (int). It means how many samples \
of previous history you want to use \
as the filter input. It also repres... | python | def input_from_history(a, n, bias=False):
"""
This is function for creation of input matrix.
**Args:**
* `a` : series (1 dimensional array)
* `n` : size of input matrix row (int). It means how many samples \
of previous history you want to use \
as the filter input. It also repres... | [
"def",
"input_from_history",
"(",
"a",
",",
"n",
",",
"bias",
"=",
"False",
")",
":",
"if",
"not",
"type",
"(",
"n",
")",
"==",
"int",
":",
"raise",
"ValueError",
"(",
"'The argument n must be int.'",
")",
"if",
"not",
"n",
">",
"0",
":",
"raise",
"V... | This is function for creation of input matrix.
**Args:**
* `a` : series (1 dimensional array)
* `n` : size of input matrix row (int). It means how many samples \
of previous history you want to use \
as the filter input. It also represents the filter length.
**Kwargs:**
* `bias`... | [
"This",
"is",
"function",
"for",
"creation",
"of",
"input",
"matrix",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/input_from_history.py#L34-L72 | train |
matousc89/padasip | padasip/filters/base_filter.py | AdaptiveFilter.init_weights | def init_weights(self, w, n=-1):
"""
This function initialises the adaptive weights of the filter.
**Args:**
* `w` : initial weights of filter. Possible values are:
* array with initial weights (1 dimensional array) of filter size
* "random" : ... | python | def init_weights(self, w, n=-1):
"""
This function initialises the adaptive weights of the filter.
**Args:**
* `w` : initial weights of filter. Possible values are:
* array with initial weights (1 dimensional array) of filter size
* "random" : ... | [
"def",
"init_weights",
"(",
"self",
",",
"w",
",",
"n",
"=",
"-",
"1",
")",
":",
"if",
"n",
"==",
"-",
"1",
":",
"n",
"=",
"self",
".",
"n",
"if",
"type",
"(",
"w",
")",
"==",
"str",
":",
"if",
"w",
"==",
"\"random\"",
":",
"w",
"=",
"np"... | This function initialises the adaptive weights of the filter.
**Args:**
* `w` : initial weights of filter. Possible values are:
* array with initial weights (1 dimensional array) of filter size
* "random" : create random weights
* "zer... | [
"This",
"function",
"initialises",
"the",
"adaptive",
"weights",
"of",
"the",
"filter",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/base_filter.py#L16-L56 | train |
matousc89/padasip | padasip/filters/base_filter.py | AdaptiveFilter.predict | def predict(self, x):
"""
This function calculates the new output value `y` from input array `x`.
**Args:**
* `x` : input vector (1 dimension array) in length of filter.
**Returns:**
* `y` : output value (float) calculated from input array.
"""
y = np... | python | def predict(self, x):
"""
This function calculates the new output value `y` from input array `x`.
**Args:**
* `x` : input vector (1 dimension array) in length of filter.
**Returns:**
* `y` : output value (float) calculated from input array.
"""
y = np... | [
"def",
"predict",
"(",
"self",
",",
"x",
")",
":",
"y",
"=",
"np",
".",
"dot",
"(",
"self",
".",
"w",
",",
"x",
")",
"return",
"y"
] | This function calculates the new output value `y` from input array `x`.
**Args:**
* `x` : input vector (1 dimension array) in length of filter.
**Returns:**
* `y` : output value (float) calculated from input array. | [
"This",
"function",
"calculates",
"the",
"new",
"output",
"value",
"y",
"from",
"input",
"array",
"x",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/base_filter.py#L58-L72 | train |
matousc89/padasip | padasip/filters/base_filter.py | AdaptiveFilter.explore_learning | def explore_learning(self, d, x, mu_start=0, mu_end=1., steps=100,
ntrain=0.5, epochs=1, criteria="MSE", target_w=False):
"""
Test what learning rate is the best.
**Args:**
* `d` : desired value (1 dimensional array)
* `x` : input matrix (2-dimensional array). Rows... | python | def explore_learning(self, d, x, mu_start=0, mu_end=1., steps=100,
ntrain=0.5, epochs=1, criteria="MSE", target_w=False):
"""
Test what learning rate is the best.
**Args:**
* `d` : desired value (1 dimensional array)
* `x` : input matrix (2-dimensional array). Rows... | [
"def",
"explore_learning",
"(",
"self",
",",
"d",
",",
"x",
",",
"mu_start",
"=",
"0",
",",
"mu_end",
"=",
"1.",
",",
"steps",
"=",
"100",
",",
"ntrain",
"=",
"0.5",
",",
"epochs",
"=",
"1",
",",
"criteria",
"=",
"\"MSE\"",
",",
"target_w",
"=",
... | Test what learning rate is the best.
**Args:**
* `d` : desired value (1 dimensional array)
* `x` : input matrix (2-dimensional array). Rows are samples,
columns are input arrays.
**Kwargs:**
* `mu_start` : starting learning rate (float)
... | [
"Test",
"what",
"learning",
"rate",
"is",
"the",
"best",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/base_filter.py#L112-L168 | train |
matousc89/padasip | padasip/filters/base_filter.py | AdaptiveFilter.check_float_param | def check_float_param(self, param, low, high, name):
"""
Check if the value of the given parameter is in the given range
and a float.
Designed for testing parameters like `mu` and `eps`.
To pass this function the variable `param` must be able to be converted
into a float ... | python | def check_float_param(self, param, low, high, name):
"""
Check if the value of the given parameter is in the given range
and a float.
Designed for testing parameters like `mu` and `eps`.
To pass this function the variable `param` must be able to be converted
into a float ... | [
"def",
"check_float_param",
"(",
"self",
",",
"param",
",",
"low",
",",
"high",
",",
"name",
")",
":",
"try",
":",
"param",
"=",
"float",
"(",
"param",
")",
"except",
":",
"raise",
"ValueError",
"(",
"'Parameter {} is not float or similar'",
".",
"format",
... | Check if the value of the given parameter is in the given range
and a float.
Designed for testing parameters like `mu` and `eps`.
To pass this function the variable `param` must be able to be converted
into a float with a value between `low` and `high`.
**Args:**
* `par... | [
"Check",
"if",
"the",
"value",
"of",
"the",
"given",
"parameter",
"is",
"in",
"the",
"given",
"range",
"and",
"a",
"float",
".",
"Designed",
"for",
"testing",
"parameters",
"like",
"mu",
"and",
"eps",
".",
"To",
"pass",
"this",
"function",
"the",
"variab... | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/base_filter.py#L170-L203 | train |
matousc89/padasip | padasip/filters/base_filter.py | AdaptiveFilter.check_int_param | def check_int_param(self, param, low, high, name):
"""
Check if the value of the given parameter is in the given range
and an int.
Designed for testing parameters like `mu` and `eps`.
To pass this function the variable `param` must be able to be converted
into a float wit... | python | def check_int_param(self, param, low, high, name):
"""
Check if the value of the given parameter is in the given range
and an int.
Designed for testing parameters like `mu` and `eps`.
To pass this function the variable `param` must be able to be converted
into a float wit... | [
"def",
"check_int_param",
"(",
"self",
",",
"param",
",",
"low",
",",
"high",
",",
"name",
")",
":",
"try",
":",
"param",
"=",
"int",
"(",
"param",
")",
"except",
":",
"raise",
"ValueError",
"(",
"'Parameter {} is not int or similar'",
".",
"format",
"(",
... | Check if the value of the given parameter is in the given range
and an int.
Designed for testing parameters like `mu` and `eps`.
To pass this function the variable `param` must be able to be converted
into a float with a value between `low` and `high`.
**Args:**
* `para... | [
"Check",
"if",
"the",
"value",
"of",
"the",
"given",
"parameter",
"is",
"in",
"the",
"given",
"range",
"and",
"an",
"int",
".",
"Designed",
"for",
"testing",
"parameters",
"like",
"mu",
"and",
"eps",
".",
"To",
"pass",
"this",
"function",
"the",
"variabl... | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/base_filter.py#L226-L259 | train |
matousc89/padasip | padasip/misc/error_evaluation.py | MAE | def MAE(x1, x2=-1):
"""
Mean absolute error - this function accepts two series of data or directly
one series with error.
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this sho... | python | def MAE(x1, x2=-1):
"""
Mean absolute error - this function accepts two series of data or directly
one series with error.
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this sho... | [
"def",
"MAE",
"(",
"x1",
",",
"x2",
"=",
"-",
"1",
")",
":",
"e",
"=",
"get_valid_error",
"(",
"x1",
",",
"x2",
")",
"return",
"np",
".",
"sum",
"(",
"np",
".",
"abs",
"(",
"e",
")",
")",
"/",
"float",
"(",
"len",
"(",
"e",
")",
")"
] | Mean absolute error - this function accepts two series of data or directly
one series with error.
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this should be the second series
**... | [
"Mean",
"absolute",
"error",
"-",
"this",
"function",
"accepts",
"two",
"series",
"of",
"data",
"or",
"directly",
"one",
"series",
"with",
"error",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/misc/error_evaluation.py#L152-L173 | train |
matousc89/padasip | padasip/misc/error_evaluation.py | MSE | def MSE(x1, x2=-1):
"""
Mean squared error - this function accepts two series of data or directly
one series with error.
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this shou... | python | def MSE(x1, x2=-1):
"""
Mean squared error - this function accepts two series of data or directly
one series with error.
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this shou... | [
"def",
"MSE",
"(",
"x1",
",",
"x2",
"=",
"-",
"1",
")",
":",
"e",
"=",
"get_valid_error",
"(",
"x1",
",",
"x2",
")",
"return",
"np",
".",
"dot",
"(",
"e",
",",
"e",
")",
"/",
"float",
"(",
"len",
"(",
"e",
")",
")"
] | Mean squared error - this function accepts two series of data or directly
one series with error.
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this should be the second series
**R... | [
"Mean",
"squared",
"error",
"-",
"this",
"function",
"accepts",
"two",
"series",
"of",
"data",
"or",
"directly",
"one",
"series",
"with",
"error",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/misc/error_evaluation.py#L175-L196 | train |
matousc89/padasip | padasip/misc/error_evaluation.py | RMSE | def RMSE(x1, x2=-1):
"""
Root-mean-square error - this function accepts two series of data
or directly one series with error.
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this... | python | def RMSE(x1, x2=-1):
"""
Root-mean-square error - this function accepts two series of data
or directly one series with error.
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this... | [
"def",
"RMSE",
"(",
"x1",
",",
"x2",
"=",
"-",
"1",
")",
":",
"e",
"=",
"get_valid_error",
"(",
"x1",
",",
"x2",
")",
"return",
"np",
".",
"sqrt",
"(",
"np",
".",
"dot",
"(",
"e",
",",
"e",
")",
"/",
"float",
"(",
"len",
"(",
"e",
")",
")... | Root-mean-square error - this function accepts two series of data
or directly one series with error.
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this should be the second series
... | [
"Root",
"-",
"mean",
"-",
"square",
"error",
"-",
"this",
"function",
"accepts",
"two",
"series",
"of",
"data",
"or",
"directly",
"one",
"series",
"with",
"error",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/misc/error_evaluation.py#L198-L219 | train |
matousc89/padasip | padasip/detection/elbnd.py | ELBND | def ELBND(w, e, function="max"):
"""
This function estimates Error and Learning Based Novelty Detection measure
from given data.
**Args:**
* `w` : history of adaptive parameters of an adaptive model (2d array),
every row represents parameters in given time index.
* `e` : error of adapti... | python | def ELBND(w, e, function="max"):
"""
This function estimates Error and Learning Based Novelty Detection measure
from given data.
**Args:**
* `w` : history of adaptive parameters of an adaptive model (2d array),
every row represents parameters in given time index.
* `e` : error of adapti... | [
"def",
"ELBND",
"(",
"w",
",",
"e",
",",
"function",
"=",
"\"max\"",
")",
":",
"if",
"not",
"function",
"in",
"[",
"\"max\"",
",",
"\"sum\"",
"]",
":",
"raise",
"ValueError",
"(",
"'Unknown output function'",
")",
"N",
"=",
"w",
".",
"shape",
"[",
"0... | This function estimates Error and Learning Based Novelty Detection measure
from given data.
**Args:**
* `w` : history of adaptive parameters of an adaptive model (2d array),
every row represents parameters in given time index.
* `e` : error of adaptive model (1d array)
**Kwargs:**
* `... | [
"This",
"function",
"estimates",
"Error",
"and",
"Learning",
"Based",
"Novelty",
"Detection",
"measure",
"from",
"given",
"data",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/detection/elbnd.py#L93-L138 | train |
matousc89/padasip | padasip/preprocess/lda.py | LDA_base | def LDA_base(x, labels):
"""
Base function used for Linear Discriminant Analysis.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
sample with corresponding index
**Returns:**
* ... | python | def LDA_base(x, labels):
"""
Base function used for Linear Discriminant Analysis.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
sample with corresponding index
**Returns:**
* ... | [
"def",
"LDA_base",
"(",
"x",
",",
"labels",
")",
":",
"classes",
"=",
"np",
".",
"array",
"(",
"tuple",
"(",
"set",
"(",
"labels",
")",
")",
")",
"cols",
"=",
"x",
".",
"shape",
"[",
"1",
"]",
"means",
"=",
"np",
".",
"zeros",
"(",
"(",
"len"... | Base function used for Linear Discriminant Analysis.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
sample with corresponding index
**Returns:**
* `eigenvalues`, `eigenvectors` : eigen... | [
"Base",
"function",
"used",
"for",
"Linear",
"Discriminant",
"Analysis",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/lda.py#L104-L144 | train |
matousc89/padasip | padasip/preprocess/lda.py | LDA | def LDA(x, labels, n=False):
"""
Linear Discriminant Analysis function.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
sample with corresponding index
**Kwargs:**
* `n` : number of... | python | def LDA(x, labels, n=False):
"""
Linear Discriminant Analysis function.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
sample with corresponding index
**Kwargs:**
* `n` : number of... | [
"def",
"LDA",
"(",
"x",
",",
"labels",
",",
"n",
"=",
"False",
")",
":",
"if",
"not",
"n",
":",
"n",
"=",
"x",
".",
"shape",
"[",
"1",
"]",
"-",
"1",
"try",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
"except",
":",
"raise",
"ValueE... | Linear Discriminant Analysis function.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
sample with corresponding index
**Kwargs:**
* `n` : number of features returned (integer) - how many c... | [
"Linear",
"Discriminant",
"Analysis",
"function",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/lda.py#L146-L181 | train |
matousc89/padasip | padasip/preprocess/lda.py | LDA_discriminants | def LDA_discriminants(x, labels):
"""
Linear Discriminant Analysis helper for determination how many columns of
data should be reduced.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
s... | python | def LDA_discriminants(x, labels):
"""
Linear Discriminant Analysis helper for determination how many columns of
data should be reduced.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
s... | [
"def",
"LDA_discriminants",
"(",
"x",
",",
"labels",
")",
":",
"try",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
"except",
":",
"raise",
"ValueError",
"(",
"'Impossible to convert x to a numpy array.'",
")",
"eigen_values",
",",
"eigen_vectors",
"=",
... | Linear Discriminant Analysis helper for determination how many columns of
data should be reduced.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
sample with corresponding index
**Returns:... | [
"Linear",
"Discriminant",
"Analysis",
"helper",
"for",
"determination",
"how",
"many",
"columns",
"of",
"data",
"should",
"be",
"reduced",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/lda.py#L184-L208 | train |
matousc89/padasip | padasip/filters/ocnlms.py | FilterOCNLMS.read_memory | def read_memory(self):
"""
This function read mean value of target`d`
and input vector `x` from history
"""
if self.mem_empty == True:
if self.mem_idx == 0:
m_x = np.zeros(self.n)
m_d = 0
else:
m_x = np.mean(... | python | def read_memory(self):
"""
This function read mean value of target`d`
and input vector `x` from history
"""
if self.mem_empty == True:
if self.mem_idx == 0:
m_x = np.zeros(self.n)
m_d = 0
else:
m_x = np.mean(... | [
"def",
"read_memory",
"(",
"self",
")",
":",
"if",
"self",
".",
"mem_empty",
"==",
"True",
":",
"if",
"self",
".",
"mem_idx",
"==",
"0",
":",
"m_x",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"n",
")",
"m_d",
"=",
"0",
"else",
":",
"m_x",
"=",
... | This function read mean value of target`d`
and input vector `x` from history | [
"This",
"function",
"read",
"mean",
"value",
"of",
"target",
"d",
"and",
"input",
"vector",
"x",
"from",
"history"
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/ocnlms.py#L86-L105 | train |
matousc89/padasip | padasip/detection/le.py | learning_entropy | def learning_entropy(w, m=10, order=1, alpha=False):
"""
This function estimates Learning Entropy.
**Args:**
* `w` : history of adaptive parameters of an adaptive model (2d array),
every row represents parameters in given time index.
**Kwargs:**
* `m` : window size (1d array) - how man... | python | def learning_entropy(w, m=10, order=1, alpha=False):
"""
This function estimates Learning Entropy.
**Args:**
* `w` : history of adaptive parameters of an adaptive model (2d array),
every row represents parameters in given time index.
**Kwargs:**
* `m` : window size (1d array) - how man... | [
"def",
"learning_entropy",
"(",
"w",
",",
"m",
"=",
"10",
",",
"order",
"=",
"1",
",",
"alpha",
"=",
"False",
")",
":",
"w",
"=",
"np",
".",
"array",
"(",
"w",
")",
"N",
"=",
"w",
".",
"shape",
"[",
"0",
"]",
"n",
"=",
"w",
".",
"shape",
... | This function estimates Learning Entropy.
**Args:**
* `w` : history of adaptive parameters of an adaptive model (2d array),
every row represents parameters in given time index.
**Kwargs:**
* `m` : window size (1d array) - how many last samples are used for
evaluation of every sample.
... | [
"This",
"function",
"estimates",
"Learning",
"Entropy",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/detection/le.py#L145-L200 | train |
matousc89/padasip | padasip/ann/mlp.py | Layer.activation | def activation(self, x, f="sigmoid", der=False):
"""
This function process values of layer outputs with activation function.
**Args:**
* `x` : array to process (1-dimensional array)
**Kwargs:**
* `f` : activation function
* `der` : normal output, or its deri... | python | def activation(self, x, f="sigmoid", der=False):
"""
This function process values of layer outputs with activation function.
**Args:**
* `x` : array to process (1-dimensional array)
**Kwargs:**
* `f` : activation function
* `der` : normal output, or its deri... | [
"def",
"activation",
"(",
"self",
",",
"x",
",",
"f",
"=",
"\"sigmoid\"",
",",
"der",
"=",
"False",
")",
":",
"if",
"f",
"==",
"\"sigmoid\"",
":",
"if",
"der",
":",
"return",
"x",
"*",
"(",
"1",
"-",
"x",
")",
"return",
"1.",
"/",
"(",
"1",
"... | This function process values of layer outputs with activation function.
**Args:**
* `x` : array to process (1-dimensional array)
**Kwargs:**
* `f` : activation function
* `der` : normal output, or its derivation (bool)
**Returns:**
* values processed with ... | [
"This",
"function",
"process",
"values",
"of",
"layer",
"outputs",
"with",
"activation",
"function",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/ann/mlp.py#L126-L152 | train |
matousc89/padasip | padasip/ann/mlp.py | NetworkMLP.train | def train(self, x, d, epochs=10, shuffle=False):
"""
Function for batch training of MLP.
**Args:**
* `x` : input array (2-dimensional array).
Every row represents one input vector (features).
* `d` : input array (n-dimensional array).
Every row represen... | python | def train(self, x, d, epochs=10, shuffle=False):
"""
Function for batch training of MLP.
**Args:**
* `x` : input array (2-dimensional array).
Every row represents one input vector (features).
* `d` : input array (n-dimensional array).
Every row represen... | [
"def",
"train",
"(",
"self",
",",
"x",
",",
"d",
",",
"epochs",
"=",
"10",
",",
"shuffle",
"=",
"False",
")",
":",
"N",
"=",
"len",
"(",
"x",
")",
"if",
"not",
"len",
"(",
"d",
")",
"==",
"N",
":",
"raise",
"ValueError",
"(",
"'The length of ve... | Function for batch training of MLP.
**Args:**
* `x` : input array (2-dimensional array).
Every row represents one input vector (features).
* `d` : input array (n-dimensional array).
Every row represents target for one input vector.
Target can be one or more... | [
"Function",
"for",
"batch",
"training",
"of",
"MLP",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/ann/mlp.py#L267-L334 | train |
matousc89/padasip | padasip/ann/mlp.py | NetworkMLP.run | def run(self, x):
"""
Function for batch usage of already trained and tested MLP.
**Args:**
* `x` : input array (2-dimensional array).
Every row represents one input vector (features).
**Returns:**
* `y`: output vector (n-dimensional array). Every ... | python | def run(self, x):
"""
Function for batch usage of already trained and tested MLP.
**Args:**
* `x` : input array (2-dimensional array).
Every row represents one input vector (features).
**Returns:**
* `y`: output vector (n-dimensional array). Every ... | [
"def",
"run",
"(",
"self",
",",
"x",
")",
":",
"try",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
"except",
":",
"raise",
"ValueError",
"(",
"'Impossible to convert x to a numpy array'",
")",
"N",
"=",
"len",
"(",
"x",
")",
"if",
"self",
".",
... | Function for batch usage of already trained and tested MLP.
**Args:**
* `x` : input array (2-dimensional array).
Every row represents one input vector (features).
**Returns:**
* `y`: output vector (n-dimensional array). Every row represents
output (out... | [
"Function",
"for",
"batch",
"usage",
"of",
"already",
"trained",
"and",
"tested",
"MLP",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/ann/mlp.py#L336-L365 | train |
matousc89/padasip | padasip/preprocess/pca.py | PCA_components | def PCA_components(x):
"""
Principal Component Analysis helper to check out eigenvalues of components.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
**Returns:**
* `components`: sorted array of principal components eigenvalues
"""
# validat... | python | def PCA_components(x):
"""
Principal Component Analysis helper to check out eigenvalues of components.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
**Returns:**
* `components`: sorted array of principal components eigenvalues
"""
# validat... | [
"def",
"PCA_components",
"(",
"x",
")",
":",
"try",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
"except",
":",
"raise",
"ValueError",
"(",
"'Impossible to convert x to a numpy array.'",
")",
"eigen_values",
",",
"eigen_vectors",
"=",
"np",
".",
"linalg... | Principal Component Analysis helper to check out eigenvalues of components.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
**Returns:**
* `components`: sorted array of principal components eigenvalues | [
"Principal",
"Component",
"Analysis",
"helper",
"to",
"check",
"out",
"eigenvalues",
"of",
"components",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/pca.py#L68-L91 | train |
matousc89/padasip | padasip/preprocess/pca.py | PCA | def PCA(x, n=False):
"""
Principal component analysis function.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
**Kwargs:**
* `n` : number of features returned (integer) - how many columns
should the output keep
**Returns:**
* `new_x` : matrix ... | python | def PCA(x, n=False):
"""
Principal component analysis function.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
**Kwargs:**
* `n` : number of features returned (integer) - how many columns
should the output keep
**Returns:**
* `new_x` : matrix ... | [
"def",
"PCA",
"(",
"x",
",",
"n",
"=",
"False",
")",
":",
"if",
"not",
"n",
":",
"n",
"=",
"x",
".",
"shape",
"[",
"1",
"]",
"-",
"1",
"try",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
"except",
":",
"raise",
"ValueError",
"(",
"'I... | Principal component analysis function.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
**Kwargs:**
* `n` : number of features returned (integer) - how many columns
should the output keep
**Returns:**
* `new_x` : matrix with reduced size (lower number o... | [
"Principal",
"component",
"analysis",
"function",
"."
] | c969eadd7fa181a84da0554d737fc13c6450d16f | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/pca.py#L94-L127 | train |
widdowquinn/pyani | pyani/pyani_graphics.py | clean_axis | def clean_axis(axis):
"""Remove ticks, tick labels, and frame from axis"""
axis.get_xaxis().set_ticks([])
axis.get_yaxis().set_ticks([])
for spine in list(axis.spines.values()):
spine.set_visible(False) | python | def clean_axis(axis):
"""Remove ticks, tick labels, and frame from axis"""
axis.get_xaxis().set_ticks([])
axis.get_yaxis().set_ticks([])
for spine in list(axis.spines.values()):
spine.set_visible(False) | [
"def",
"clean_axis",
"(",
"axis",
")",
":",
"axis",
".",
"get_xaxis",
"(",
")",
".",
"set_ticks",
"(",
"[",
"]",
")",
"axis",
".",
"get_yaxis",
"(",
")",
".",
"set_ticks",
"(",
"[",
"]",
")",
"for",
"spine",
"in",
"list",
"(",
"axis",
".",
"spine... | Remove ticks, tick labels, and frame from axis | [
"Remove",
"ticks",
"tick",
"labels",
"and",
"frame",
"from",
"axis"
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L63-L68 | train |
widdowquinn/pyani | pyani/pyani_graphics.py | get_seaborn_colorbar | def get_seaborn_colorbar(dfr, classes):
"""Return a colorbar representing classes, for a Seaborn plot.
The aim is to get a pd.Series for the passed dataframe columns,
in the form:
0 colour for class in col 0
1 colour for class in col 1
... colour for class in col ...
n colour for ... | python | def get_seaborn_colorbar(dfr, classes):
"""Return a colorbar representing classes, for a Seaborn plot.
The aim is to get a pd.Series for the passed dataframe columns,
in the form:
0 colour for class in col 0
1 colour for class in col 1
... colour for class in col ...
n colour for ... | [
"def",
"get_seaborn_colorbar",
"(",
"dfr",
",",
"classes",
")",
":",
"levels",
"=",
"sorted",
"(",
"list",
"(",
"set",
"(",
"classes",
".",
"values",
"(",
")",
")",
")",
")",
"paldict",
"=",
"{",
"lvl",
":",
"pal",
"for",
"(",
"lvl",
",",
"pal",
... | Return a colorbar representing classes, for a Seaborn plot.
The aim is to get a pd.Series for the passed dataframe columns,
in the form:
0 colour for class in col 0
1 colour for class in col 1
... colour for class in col ...
n colour for class in col n | [
"Return",
"a",
"colorbar",
"representing",
"classes",
"for",
"a",
"Seaborn",
"plot",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L72-L98 | train |
widdowquinn/pyani | pyani/pyani_graphics.py | get_safe_seaborn_labels | def get_safe_seaborn_labels(dfr, labels):
"""Returns labels guaranteed to correspond to the dataframe."""
if labels is not None:
return [labels.get(i, i) for i in dfr.index]
return [i for i in dfr.index] | python | def get_safe_seaborn_labels(dfr, labels):
"""Returns labels guaranteed to correspond to the dataframe."""
if labels is not None:
return [labels.get(i, i) for i in dfr.index]
return [i for i in dfr.index] | [
"def",
"get_safe_seaborn_labels",
"(",
"dfr",
",",
"labels",
")",
":",
"if",
"labels",
"is",
"not",
"None",
":",
"return",
"[",
"labels",
".",
"get",
"(",
"i",
",",
"i",
")",
"for",
"i",
"in",
"dfr",
".",
"index",
"]",
"return",
"[",
"i",
"for",
... | Returns labels guaranteed to correspond to the dataframe. | [
"Returns",
"labels",
"guaranteed",
"to",
"correspond",
"to",
"the",
"dataframe",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L102-L106 | train |
widdowquinn/pyani | pyani/pyani_graphics.py | get_seaborn_clustermap | def get_seaborn_clustermap(dfr, params, title=None, annot=True):
"""Returns a Seaborn clustermap."""
fig = sns.clustermap(
dfr,
cmap=params.cmap,
vmin=params.vmin,
vmax=params.vmax,
col_colors=params.colorbar,
row_colors=params.colorbar,
figsize=(params.fi... | python | def get_seaborn_clustermap(dfr, params, title=None, annot=True):
"""Returns a Seaborn clustermap."""
fig = sns.clustermap(
dfr,
cmap=params.cmap,
vmin=params.vmin,
vmax=params.vmax,
col_colors=params.colorbar,
row_colors=params.colorbar,
figsize=(params.fi... | [
"def",
"get_seaborn_clustermap",
"(",
"dfr",
",",
"params",
",",
"title",
"=",
"None",
",",
"annot",
"=",
"True",
")",
":",
"fig",
"=",
"sns",
".",
"clustermap",
"(",
"dfr",
",",
"cmap",
"=",
"params",
".",
"cmap",
",",
"vmin",
"=",
"params",
".",
... | Returns a Seaborn clustermap. | [
"Returns",
"a",
"Seaborn",
"clustermap",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L110-L134 | train |
widdowquinn/pyani | pyani/pyani_graphics.py | heatmap_seaborn | def heatmap_seaborn(dfr, outfilename=None, title=None, params=None):
"""Returns seaborn heatmap with cluster dendrograms.
- dfr - pandas DataFrame with relevant data
- outfilename - path to output file (indicates output format)
"""
# Decide on figure layout size: a minimum size is required for
... | python | def heatmap_seaborn(dfr, outfilename=None, title=None, params=None):
"""Returns seaborn heatmap with cluster dendrograms.
- dfr - pandas DataFrame with relevant data
- outfilename - path to output file (indicates output format)
"""
# Decide on figure layout size: a minimum size is required for
... | [
"def",
"heatmap_seaborn",
"(",
"dfr",
",",
"outfilename",
"=",
"None",
",",
"title",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"maxfigsize",
"=",
"120",
"calcfigsize",
"=",
"dfr",
".",
"shape",
"[",
"0",
"]",
"*",
"1.1",
"figsize",
"=",
"min... | Returns seaborn heatmap with cluster dendrograms.
- dfr - pandas DataFrame with relevant data
- outfilename - path to output file (indicates output format) | [
"Returns",
"seaborn",
"heatmap",
"with",
"cluster",
"dendrograms",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L138-L175 | train |
widdowquinn/pyani | pyani/pyani_graphics.py | add_mpl_dendrogram | def add_mpl_dendrogram(dfr, fig, heatmap_gs, orientation="col"):
"""Return a dendrogram and corresponding gridspec, attached to the fig
Modifies the fig in-place. Orientation is either 'row' or 'col' and
determines location and orientation of the rendered dendrogram.
"""
# Row or column axes?
i... | python | def add_mpl_dendrogram(dfr, fig, heatmap_gs, orientation="col"):
"""Return a dendrogram and corresponding gridspec, attached to the fig
Modifies the fig in-place. Orientation is either 'row' or 'col' and
determines location and orientation of the rendered dendrogram.
"""
# Row or column axes?
i... | [
"def",
"add_mpl_dendrogram",
"(",
"dfr",
",",
"fig",
",",
"heatmap_gs",
",",
"orientation",
"=",
"\"col\"",
")",
":",
"if",
"orientation",
"==",
"\"row\"",
":",
"dists",
"=",
"distance",
".",
"squareform",
"(",
"distance",
".",
"pdist",
"(",
"dfr",
")",
... | Return a dendrogram and corresponding gridspec, attached to the fig
Modifies the fig in-place. Orientation is either 'row' or 'col' and
determines location and orientation of the rendered dendrogram. | [
"Return",
"a",
"dendrogram",
"and",
"corresponding",
"gridspec",
"attached",
"to",
"the",
"fig"
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L179-L215 | train |
widdowquinn/pyani | pyani/pyani_graphics.py | get_mpl_heatmap_axes | def get_mpl_heatmap_axes(dfr, fig, heatmap_gs):
"""Return axis for Matplotlib heatmap."""
# Create heatmap axis
heatmap_axes = fig.add_subplot(heatmap_gs[1, 1])
heatmap_axes.set_xticks(np.linspace(0, dfr.shape[0] - 1, dfr.shape[0]))
heatmap_axes.set_yticks(np.linspace(0, dfr.shape[0] - 1, dfr.shape[... | python | def get_mpl_heatmap_axes(dfr, fig, heatmap_gs):
"""Return axis for Matplotlib heatmap."""
# Create heatmap axis
heatmap_axes = fig.add_subplot(heatmap_gs[1, 1])
heatmap_axes.set_xticks(np.linspace(0, dfr.shape[0] - 1, dfr.shape[0]))
heatmap_axes.set_yticks(np.linspace(0, dfr.shape[0] - 1, dfr.shape[... | [
"def",
"get_mpl_heatmap_axes",
"(",
"dfr",
",",
"fig",
",",
"heatmap_gs",
")",
":",
"heatmap_axes",
"=",
"fig",
".",
"add_subplot",
"(",
"heatmap_gs",
"[",
"1",
",",
"1",
"]",
")",
"heatmap_axes",
".",
"set_xticks",
"(",
"np",
".",
"linspace",
"(",
"0",
... | Return axis for Matplotlib heatmap. | [
"Return",
"axis",
"for",
"Matplotlib",
"heatmap",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L219-L228 | train |
widdowquinn/pyani | pyani/pyani_graphics.py | add_mpl_colorbar | def add_mpl_colorbar(dfr, fig, dend, params, orientation="row"):
"""Add class colorbars to Matplotlib heatmap."""
for name in dfr.index[dend["dendrogram"]["leaves"]]:
if name not in params.classes:
params.classes[name] = name
# Assign a numerical value to each class, for mpl
classdi... | python | def add_mpl_colorbar(dfr, fig, dend, params, orientation="row"):
"""Add class colorbars to Matplotlib heatmap."""
for name in dfr.index[dend["dendrogram"]["leaves"]]:
if name not in params.classes:
params.classes[name] = name
# Assign a numerical value to each class, for mpl
classdi... | [
"def",
"add_mpl_colorbar",
"(",
"dfr",
",",
"fig",
",",
"dend",
",",
"params",
",",
"orientation",
"=",
"\"row\"",
")",
":",
"for",
"name",
"in",
"dfr",
".",
"index",
"[",
"dend",
"[",
"\"dendrogram\"",
"]",
"[",
"\"leaves\"",
"]",
"]",
":",
"if",
"n... | Add class colorbars to Matplotlib heatmap. | [
"Add",
"class",
"colorbars",
"to",
"Matplotlib",
"heatmap",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L231-L269 | train |
widdowquinn/pyani | pyani/pyani_graphics.py | add_mpl_labels | def add_mpl_labels(heatmap_axes, rowlabels, collabels, params):
"""Add labels to Matplotlib heatmap axes, in-place."""
if params.labels:
# If a label mapping is missing, use the key text as fall back
rowlabels = [params.labels.get(lab, lab) for lab in rowlabels]
collabels = [params.label... | python | def add_mpl_labels(heatmap_axes, rowlabels, collabels, params):
"""Add labels to Matplotlib heatmap axes, in-place."""
if params.labels:
# If a label mapping is missing, use the key text as fall back
rowlabels = [params.labels.get(lab, lab) for lab in rowlabels]
collabels = [params.label... | [
"def",
"add_mpl_labels",
"(",
"heatmap_axes",
",",
"rowlabels",
",",
"collabels",
",",
"params",
")",
":",
"if",
"params",
".",
"labels",
":",
"rowlabels",
"=",
"[",
"params",
".",
"labels",
".",
"get",
"(",
"lab",
",",
"lab",
")",
"for",
"lab",
"in",
... | Add labels to Matplotlib heatmap axes, in-place. | [
"Add",
"labels",
"to",
"Matplotlib",
"heatmap",
"axes",
"in",
"-",
"place",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L273-L285 | train |
widdowquinn/pyani | pyani/pyani_graphics.py | add_mpl_colorscale | def add_mpl_colorscale(fig, heatmap_gs, ax_map, params, title=None):
"""Add colour scale to heatmap."""
# Set tick intervals
cbticks = [params.vmin + e * params.vdiff for e in (0, 0.25, 0.5, 0.75, 1)]
if params.vmax > 10:
exponent = int(floor(log10(params.vmax))) - 1
cbticks = [int(round... | python | def add_mpl_colorscale(fig, heatmap_gs, ax_map, params, title=None):
"""Add colour scale to heatmap."""
# Set tick intervals
cbticks = [params.vmin + e * params.vdiff for e in (0, 0.25, 0.5, 0.75, 1)]
if params.vmax > 10:
exponent = int(floor(log10(params.vmax))) - 1
cbticks = [int(round... | [
"def",
"add_mpl_colorscale",
"(",
"fig",
",",
"heatmap_gs",
",",
"ax_map",
",",
"params",
",",
"title",
"=",
"None",
")",
":",
"cbticks",
"=",
"[",
"params",
".",
"vmin",
"+",
"e",
"*",
"params",
".",
"vdiff",
"for",
"e",
"in",
"(",
"0",
",",
"0.25... | Add colour scale to heatmap. | [
"Add",
"colour",
"scale",
"to",
"heatmap",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L289-L308 | train |
widdowquinn/pyani | pyani/pyani_graphics.py | heatmap_mpl | def heatmap_mpl(dfr, outfilename=None, title=None, params=None):
"""Returns matplotlib heatmap with cluster dendrograms.
- dfr - pandas DataFrame with relevant data
- outfilename - path to output file (indicates output format)
- params - a list of parameters for plotting: [colormap, vmin, vmax]
- l... | python | def heatmap_mpl(dfr, outfilename=None, title=None, params=None):
"""Returns matplotlib heatmap with cluster dendrograms.
- dfr - pandas DataFrame with relevant data
- outfilename - path to output file (indicates output format)
- params - a list of parameters for plotting: [colormap, vmin, vmax]
- l... | [
"def",
"heatmap_mpl",
"(",
"dfr",
",",
"outfilename",
"=",
"None",
",",
"title",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"figsize",
"=",
"max",
"(",
"8",
",",
"dfr",
".",
"shape",
"[",
"0",
"]",
"*",
"0.175",
")",
"fig",
"=",
"plt",
... | Returns matplotlib heatmap with cluster dendrograms.
- dfr - pandas DataFrame with relevant data
- outfilename - path to output file (indicates output format)
- params - a list of parameters for plotting: [colormap, vmin, vmax]
- labels - dictionary of alternative labels, keyed by default sequence
... | [
"Returns",
"matplotlib",
"heatmap",
"with",
"cluster",
"dendrograms",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L312-L375 | train |
widdowquinn/pyani | pyani/run_multiprocessing.py | run_dependency_graph | def run_dependency_graph(jobgraph, workers=None, logger=None):
"""Creates and runs pools of jobs based on the passed jobgraph.
- jobgraph - list of jobs, which may have dependencies.
- verbose - flag for multiprocessing verbosity
- logger - a logger module logger (optional)
The strategy here is to... | python | def run_dependency_graph(jobgraph, workers=None, logger=None):
"""Creates and runs pools of jobs based on the passed jobgraph.
- jobgraph - list of jobs, which may have dependencies.
- verbose - flag for multiprocessing verbosity
- logger - a logger module logger (optional)
The strategy here is to... | [
"def",
"run_dependency_graph",
"(",
"jobgraph",
",",
"workers",
"=",
"None",
",",
"logger",
"=",
"None",
")",
":",
"cmdsets",
"=",
"[",
"]",
"for",
"job",
"in",
"jobgraph",
":",
"cmdsets",
"=",
"populate_cmdsets",
"(",
"job",
",",
"cmdsets",
",",
"depth"... | Creates and runs pools of jobs based on the passed jobgraph.
- jobgraph - list of jobs, which may have dependencies.
- verbose - flag for multiprocessing verbosity
- logger - a logger module logger (optional)
The strategy here is to loop over each job in the list of jobs (jobgraph),
and create/pop... | [
"Creates",
"and",
"runs",
"pools",
"of",
"jobs",
"based",
"on",
"the",
"passed",
"jobgraph",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_multiprocessing.py#L22-L48 | train |
widdowquinn/pyani | pyani/run_multiprocessing.py | populate_cmdsets | def populate_cmdsets(job, cmdsets, depth):
"""Creates a list of sets containing jobs at different depths of the
dependency tree.
This is a recursive function (is there something quicker in the itertools
module?) that descends each 'root' job in turn, populating each
"""
if len(cmdsets) < depth:... | python | def populate_cmdsets(job, cmdsets, depth):
"""Creates a list of sets containing jobs at different depths of the
dependency tree.
This is a recursive function (is there something quicker in the itertools
module?) that descends each 'root' job in turn, populating each
"""
if len(cmdsets) < depth:... | [
"def",
"populate_cmdsets",
"(",
"job",
",",
"cmdsets",
",",
"depth",
")",
":",
"if",
"len",
"(",
"cmdsets",
")",
"<",
"depth",
":",
"cmdsets",
".",
"append",
"(",
"set",
"(",
")",
")",
"cmdsets",
"[",
"depth",
"-",
"1",
"]",
".",
"add",
"(",
"job... | Creates a list of sets containing jobs at different depths of the
dependency tree.
This is a recursive function (is there something quicker in the itertools
module?) that descends each 'root' job in turn, populating each | [
"Creates",
"a",
"list",
"of",
"sets",
"containing",
"jobs",
"at",
"different",
"depths",
"of",
"the",
"dependency",
"tree",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_multiprocessing.py#L51-L65 | train |
widdowquinn/pyani | pyani/run_multiprocessing.py | multiprocessing_run | def multiprocessing_run(cmdlines, workers=None):
"""Distributes passed command-line jobs using multiprocessing.
- cmdlines - an iterable of command line strings
Returns the sum of exit codes from each job that was run. If
all goes well, this should be 0. Anything else and the calling
function shou... | python | def multiprocessing_run(cmdlines, workers=None):
"""Distributes passed command-line jobs using multiprocessing.
- cmdlines - an iterable of command line strings
Returns the sum of exit codes from each job that was run. If
all goes well, this should be 0. Anything else and the calling
function shou... | [
"def",
"multiprocessing_run",
"(",
"cmdlines",
",",
"workers",
"=",
"None",
")",
":",
"pool",
"=",
"multiprocessing",
".",
"Pool",
"(",
"processes",
"=",
"workers",
")",
"results",
"=",
"[",
"pool",
".",
"apply_async",
"(",
"subprocess",
".",
"run",
",",
... | Distributes passed command-line jobs using multiprocessing.
- cmdlines - an iterable of command line strings
Returns the sum of exit codes from each job that was run. If
all goes well, this should be 0. Anything else and the calling
function should act accordingly. | [
"Distributes",
"passed",
"command",
"-",
"line",
"jobs",
"using",
"multiprocessing",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_multiprocessing.py#L69-L89 | train |
widdowquinn/pyani | pyani/pyani_files.py | get_input_files | def get_input_files(dirname, *ext):
"""Returns files in passed directory, filtered by extension.
- dirname - path to input directory
- *ext - list of arguments describing permitted file extensions
"""
filelist = [f for f in os.listdir(dirname) if
os.path.splitext(f)[-1] in ext]
... | python | def get_input_files(dirname, *ext):
"""Returns files in passed directory, filtered by extension.
- dirname - path to input directory
- *ext - list of arguments describing permitted file extensions
"""
filelist = [f for f in os.listdir(dirname) if
os.path.splitext(f)[-1] in ext]
... | [
"def",
"get_input_files",
"(",
"dirname",
",",
"*",
"ext",
")",
":",
"filelist",
"=",
"[",
"f",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"dirname",
")",
"if",
"os",
".",
"path",
".",
"splitext",
"(",
"f",
")",
"[",
"-",
"1",
"]",
"in",
"ext... | Returns files in passed directory, filtered by extension.
- dirname - path to input directory
- *ext - list of arguments describing permitted file extensions | [
"Returns",
"files",
"in",
"passed",
"directory",
"filtered",
"by",
"extension",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_files.py#L27-L35 | train |
widdowquinn/pyani | pyani/pyani_files.py | get_sequence_lengths | def get_sequence_lengths(fastafilenames):
"""Returns dictionary of sequence lengths, keyed by organism.
Biopython's SeqIO module is used to parse all sequences in the FASTA
file corresponding to each organism, and the total base count in each
is obtained.
NOTE: ambiguity symbols are not discounted... | python | def get_sequence_lengths(fastafilenames):
"""Returns dictionary of sequence lengths, keyed by organism.
Biopython's SeqIO module is used to parse all sequences in the FASTA
file corresponding to each organism, and the total base count in each
is obtained.
NOTE: ambiguity symbols are not discounted... | [
"def",
"get_sequence_lengths",
"(",
"fastafilenames",
")",
":",
"tot_lengths",
"=",
"{",
"}",
"for",
"fn",
"in",
"fastafilenames",
":",
"tot_lengths",
"[",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"split",
"(",
"fn",
")",
"[",
"... | Returns dictionary of sequence lengths, keyed by organism.
Biopython's SeqIO module is used to parse all sequences in the FASTA
file corresponding to each organism, and the total base count in each
is obtained.
NOTE: ambiguity symbols are not discounted. | [
"Returns",
"dictionary",
"of",
"sequence",
"lengths",
"keyed",
"by",
"organism",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_files.py#L39-L52 | train |
widdowquinn/pyani | bin/average_nucleotide_identity.py | last_exception | def last_exception():
""" Returns last exception as a string, or use in logging.
"""
exc_type, exc_value, exc_traceback = sys.exc_info()
return "".join(traceback.format_exception(exc_type, exc_value, exc_traceback)) | python | def last_exception():
""" Returns last exception as a string, or use in logging.
"""
exc_type, exc_value, exc_traceback = sys.exc_info()
return "".join(traceback.format_exception(exc_type, exc_value, exc_traceback)) | [
"def",
"last_exception",
"(",
")",
":",
"exc_type",
",",
"exc_value",
",",
"exc_traceback",
"=",
"sys",
".",
"exc_info",
"(",
")",
"return",
"\"\"",
".",
"join",
"(",
"traceback",
".",
"format_exception",
"(",
"exc_type",
",",
"exc_value",
",",
"exc_tracebac... | Returns last exception as a string, or use in logging. | [
"Returns",
"last",
"exception",
"as",
"a",
"string",
"or",
"use",
"in",
"logging",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L439-L443 | train |
widdowquinn/pyani | bin/average_nucleotide_identity.py | make_outdir | def make_outdir():
"""Make the output directory, if required.
This is a little involved. If the output directory already exists,
we take the safe option by default, and stop with an error. We can,
however, choose to force the program to go on, in which case we can
either clobber the existing dire... | python | def make_outdir():
"""Make the output directory, if required.
This is a little involved. If the output directory already exists,
we take the safe option by default, and stop with an error. We can,
however, choose to force the program to go on, in which case we can
either clobber the existing dire... | [
"def",
"make_outdir",
"(",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"args",
".",
"outdirname",
")",
":",
"if",
"not",
"args",
".",
"force",
":",
"logger",
".",
"error",
"(",
"\"Output directory %s would overwrite existing \"",
"+",
"\"files (ex... | Make the output directory, if required.
This is a little involved. If the output directory already exists,
we take the safe option by default, and stop with an error. We can,
however, choose to force the program to go on, in which case we can
either clobber the existing directory, or not. The option... | [
"Make",
"the",
"output",
"directory",
"if",
"required",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L447-L490 | train |
widdowquinn/pyani | bin/average_nucleotide_identity.py | compress_delete_outdir | def compress_delete_outdir(outdir):
"""Compress the contents of the passed directory to .tar.gz and delete."""
# Compress output in .tar.gz file and remove raw output
tarfn = outdir + ".tar.gz"
logger.info("\tCompressing output from %s to %s", outdir, tarfn)
with tarfile.open(tarfn, "w:gz") as fh:
... | python | def compress_delete_outdir(outdir):
"""Compress the contents of the passed directory to .tar.gz and delete."""
# Compress output in .tar.gz file and remove raw output
tarfn = outdir + ".tar.gz"
logger.info("\tCompressing output from %s to %s", outdir, tarfn)
with tarfile.open(tarfn, "w:gz") as fh:
... | [
"def",
"compress_delete_outdir",
"(",
"outdir",
")",
":",
"tarfn",
"=",
"outdir",
"+",
"\".tar.gz\"",
"logger",
".",
"info",
"(",
"\"\\tCompressing output from %s to %s\"",
",",
"outdir",
",",
"tarfn",
")",
"with",
"tarfile",
".",
"open",
"(",
"tarfn",
",",
"\... | Compress the contents of the passed directory to .tar.gz and delete. | [
"Compress",
"the",
"contents",
"of",
"the",
"passed",
"directory",
"to",
".",
"tar",
".",
"gz",
"and",
"delete",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L494-L502 | train |
widdowquinn/pyani | bin/average_nucleotide_identity.py | calculate_anim | def calculate_anim(infiles, org_lengths):
"""Returns ANIm result dataframes for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Finds ANI by the ANIm method, as described in Richter et al (2009)
Proc Natl Acad S... | python | def calculate_anim(infiles, org_lengths):
"""Returns ANIm result dataframes for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Finds ANI by the ANIm method, as described in Richter et al (2009)
Proc Natl Acad S... | [
"def",
"calculate_anim",
"(",
"infiles",
",",
"org_lengths",
")",
":",
"logger",
".",
"info",
"(",
"\"Running ANIm\"",
")",
"logger",
".",
"info",
"(",
"\"Generating NUCmer command-lines\"",
")",
"deltadir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"args",
... | Returns ANIm result dataframes for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Finds ANI by the ANIm method, as described in Richter et al (2009)
Proc Natl Acad Sci USA 106: 19126-19131 doi:10.1073/pnas.09064121... | [
"Returns",
"ANIm",
"result",
"dataframes",
"for",
"files",
"in",
"input",
"directory",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L506-L599 | train |
widdowquinn/pyani | bin/average_nucleotide_identity.py | calculate_tetra | def calculate_tetra(infiles):
"""Calculate TETRA for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Calculates TETRA correlation scores, as described in:
Richter M, Rossello-Mora R (2009) Shifting the genomic ... | python | def calculate_tetra(infiles):
"""Calculate TETRA for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Calculates TETRA correlation scores, as described in:
Richter M, Rossello-Mora R (2009) Shifting the genomic ... | [
"def",
"calculate_tetra",
"(",
"infiles",
")",
":",
"logger",
".",
"info",
"(",
"\"Running TETRA.\"",
")",
"logger",
".",
"info",
"(",
"\"Calculating TETRA Z-scores for each sequence.\"",
")",
"tetra_zscores",
"=",
"{",
"}",
"for",
"filename",
"in",
"infiles",
":"... | Calculate TETRA for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Calculates TETRA correlation scores, as described in:
Richter M, Rossello-Mora R (2009) Shifting the genomic gold standard for
the prokaryotic... | [
"Calculate",
"TETRA",
"for",
"files",
"in",
"input",
"directory",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L603-L632 | train |
widdowquinn/pyani | bin/average_nucleotide_identity.py | unified_anib | def unified_anib(infiles, org_lengths):
"""Calculate ANIb for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Calculates ANI by the ANIb method, as described in Goris et al. (2007)
Int J Syst Evol Micr 57: 81-91... | python | def unified_anib(infiles, org_lengths):
"""Calculate ANIb for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Calculates ANI by the ANIb method, as described in Goris et al. (2007)
Int J Syst Evol Micr 57: 81-91... | [
"def",
"unified_anib",
"(",
"infiles",
",",
"org_lengths",
")",
":",
"logger",
".",
"info",
"(",
"\"Running %s\"",
",",
"args",
".",
"method",
")",
"blastdir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"args",
".",
"outdirname",
",",
"ALIGNDIR",
"[",
"... | Calculate ANIb for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Calculates ANI by the ANIb method, as described in Goris et al. (2007)
Int J Syst Evol Micr 57: 81-91. doi:10.1099/ijs.0.64483-0. There are
some... | [
"Calculate",
"ANIb",
"for",
"files",
"in",
"input",
"directory",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L636-L752 | train |
widdowquinn/pyani | bin/average_nucleotide_identity.py | subsample_input | def subsample_input(infiles):
"""Returns a random subsample of the input files.
- infiles: a list of input files for analysis
"""
logger.info("--subsample: %s", args.subsample)
try:
samplesize = float(args.subsample)
except TypeError: # Not a number
logger.error(
"-... | python | def subsample_input(infiles):
"""Returns a random subsample of the input files.
- infiles: a list of input files for analysis
"""
logger.info("--subsample: %s", args.subsample)
try:
samplesize = float(args.subsample)
except TypeError: # Not a number
logger.error(
"-... | [
"def",
"subsample_input",
"(",
"infiles",
")",
":",
"logger",
".",
"info",
"(",
"\"--subsample: %s\"",
",",
"args",
".",
"subsample",
")",
"try",
":",
"samplesize",
"=",
"float",
"(",
"args",
".",
"subsample",
")",
"except",
"TypeError",
":",
"logger",
"."... | Returns a random subsample of the input files.
- infiles: a list of input files for analysis | [
"Returns",
"a",
"random",
"subsample",
"of",
"the",
"input",
"files",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L813-L842 | train |
widdowquinn/pyani | pyani/pyani_jobs.py | Job.wait | def wait(self, interval=SGE_WAIT):
"""Wait until the job finishes, and poll SGE on its status."""
finished = False
while not finished:
time.sleep(interval)
interval = min(2 * interval, 60)
finished = os.system("qstat -j %s > /dev/null" % (self.name)) | python | def wait(self, interval=SGE_WAIT):
"""Wait until the job finishes, and poll SGE on its status."""
finished = False
while not finished:
time.sleep(interval)
interval = min(2 * interval, 60)
finished = os.system("qstat -j %s > /dev/null" % (self.name)) | [
"def",
"wait",
"(",
"self",
",",
"interval",
"=",
"SGE_WAIT",
")",
":",
"finished",
"=",
"False",
"while",
"not",
"finished",
":",
"time",
".",
"sleep",
"(",
"interval",
")",
"interval",
"=",
"min",
"(",
"2",
"*",
"interval",
",",
"60",
")",
"finishe... | Wait until the job finishes, and poll SGE on its status. | [
"Wait",
"until",
"the",
"job",
"finishes",
"and",
"poll",
"SGE",
"on",
"its",
"status",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_jobs.py#L77-L83 | train |
widdowquinn/pyani | pyani/anim.py | generate_nucmer_jobs | def generate_nucmer_jobs(
filenames,
outdir=".",
nucmer_exe=pyani_config.NUCMER_DEFAULT,
filter_exe=pyani_config.FILTER_DEFAULT,
maxmatch=False,
jobprefix="ANINUCmer",
):
"""Return a list of Jobs describing NUCmer command-lines for ANIm
- filenames - a list of paths to input FASTA files... | python | def generate_nucmer_jobs(
filenames,
outdir=".",
nucmer_exe=pyani_config.NUCMER_DEFAULT,
filter_exe=pyani_config.FILTER_DEFAULT,
maxmatch=False,
jobprefix="ANINUCmer",
):
"""Return a list of Jobs describing NUCmer command-lines for ANIm
- filenames - a list of paths to input FASTA files... | [
"def",
"generate_nucmer_jobs",
"(",
"filenames",
",",
"outdir",
"=",
"\".\"",
",",
"nucmer_exe",
"=",
"pyani_config",
".",
"NUCMER_DEFAULT",
",",
"filter_exe",
"=",
"pyani_config",
".",
"FILTER_DEFAULT",
",",
"maxmatch",
"=",
"False",
",",
"jobprefix",
"=",
"\"A... | Return a list of Jobs describing NUCmer command-lines for ANIm
- filenames - a list of paths to input FASTA files
- outdir - path to output directory
- nucmer_exe - location of the nucmer binary
- maxmatch - Boolean flag indicating to use NUCmer's -maxmatch option
Loop over all FASTA files, genera... | [
"Return",
"a",
"list",
"of",
"Jobs",
"describing",
"NUCmer",
"command",
"-",
"lines",
"for",
"ANIm"
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anim.py#L33-L61 | train |
widdowquinn/pyani | pyani/anim.py | generate_nucmer_commands | def generate_nucmer_commands(
filenames,
outdir=".",
nucmer_exe=pyani_config.NUCMER_DEFAULT,
filter_exe=pyani_config.FILTER_DEFAULT,
maxmatch=False,
):
"""Return a tuple of lists of NUCmer command-lines for ANIm
The first element is a list of NUCmer commands, the second a list
of delta_... | python | def generate_nucmer_commands(
filenames,
outdir=".",
nucmer_exe=pyani_config.NUCMER_DEFAULT,
filter_exe=pyani_config.FILTER_DEFAULT,
maxmatch=False,
):
"""Return a tuple of lists of NUCmer command-lines for ANIm
The first element is a list of NUCmer commands, the second a list
of delta_... | [
"def",
"generate_nucmer_commands",
"(",
"filenames",
",",
"outdir",
"=",
"\".\"",
",",
"nucmer_exe",
"=",
"pyani_config",
".",
"NUCMER_DEFAULT",
",",
"filter_exe",
"=",
"pyani_config",
".",
"FILTER_DEFAULT",
",",
"maxmatch",
"=",
"False",
",",
")",
":",
"nucmer_... | Return a tuple of lists of NUCmer command-lines for ANIm
The first element is a list of NUCmer commands, the second a list
of delta_filter_wrapper.py commands. These are ordered such that
commands are paired. The NUCmer commands should be run before
the delta-filter commands.
- filenames - a list ... | [
"Return",
"a",
"tuple",
"of",
"lists",
"of",
"NUCmer",
"command",
"-",
"lines",
"for",
"ANIm"
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anim.py#L66-L96 | train |
widdowquinn/pyani | pyani/anim.py | construct_nucmer_cmdline | def construct_nucmer_cmdline(
fname1,
fname2,
outdir=".",
nucmer_exe=pyani_config.NUCMER_DEFAULT,
filter_exe=pyani_config.FILTER_DEFAULT,
maxmatch=False,
):
"""Returns a tuple of NUCmer and delta-filter commands
The split into a tuple was made necessary by changes to SGE/OGE. The
de... | python | def construct_nucmer_cmdline(
fname1,
fname2,
outdir=".",
nucmer_exe=pyani_config.NUCMER_DEFAULT,
filter_exe=pyani_config.FILTER_DEFAULT,
maxmatch=False,
):
"""Returns a tuple of NUCmer and delta-filter commands
The split into a tuple was made necessary by changes to SGE/OGE. The
de... | [
"def",
"construct_nucmer_cmdline",
"(",
"fname1",
",",
"fname2",
",",
"outdir",
"=",
"\".\"",
",",
"nucmer_exe",
"=",
"pyani_config",
".",
"NUCMER_DEFAULT",
",",
"filter_exe",
"=",
"pyani_config",
".",
"FILTER_DEFAULT",
",",
"maxmatch",
"=",
"False",
",",
")",
... | Returns a tuple of NUCmer and delta-filter commands
The split into a tuple was made necessary by changes to SGE/OGE. The
delta-filter command must now be run as a dependency of the NUCmer
command, and be wrapped in a Python script to capture STDOUT.
NOTE: This command-line writes output data to a subd... | [
"Returns",
"a",
"tuple",
"of",
"NUCmer",
"and",
"delta",
"-",
"filter",
"commands"
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anim.py#L101-L143 | train |
widdowquinn/pyani | pyani/anim.py | process_deltadir | def process_deltadir(delta_dir, org_lengths, logger=None):
"""Returns a tuple of ANIm results for .deltas in passed directory.
- delta_dir - path to the directory containing .delta files
- org_lengths - dictionary of total sequence lengths, keyed by sequence
Returns the following pandas dataframes in ... | python | def process_deltadir(delta_dir, org_lengths, logger=None):
"""Returns a tuple of ANIm results for .deltas in passed directory.
- delta_dir - path to the directory containing .delta files
- org_lengths - dictionary of total sequence lengths, keyed by sequence
Returns the following pandas dataframes in ... | [
"def",
"process_deltadir",
"(",
"delta_dir",
",",
"org_lengths",
",",
"logger",
"=",
"None",
")",
":",
"deltafiles",
"=",
"pyani_files",
".",
"get_input_files",
"(",
"delta_dir",
",",
"\".filter\"",
")",
"results",
"=",
"ANIResults",
"(",
"list",
"(",
"org_len... | Returns a tuple of ANIm results for .deltas in passed directory.
- delta_dir - path to the directory containing .delta files
- org_lengths - dictionary of total sequence lengths, keyed by sequence
Returns the following pandas dataframes in an ANIResults object;
query sequences are rows, subject sequen... | [
"Returns",
"a",
"tuple",
"of",
"ANIm",
"results",
"for",
".",
"deltas",
"in",
"passed",
"directory",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anim.py#L169-L244 | train |
widdowquinn/pyani | bin/genbank_get_genomes_by_taxon.py | set_ncbi_email | def set_ncbi_email():
"""Set contact email for NCBI."""
Entrez.email = args.email
logger.info("Set NCBI contact email to %s", args.email)
Entrez.tool = "genbank_get_genomes_by_taxon.py" | python | def set_ncbi_email():
"""Set contact email for NCBI."""
Entrez.email = args.email
logger.info("Set NCBI contact email to %s", args.email)
Entrez.tool = "genbank_get_genomes_by_taxon.py" | [
"def",
"set_ncbi_email",
"(",
")",
":",
"Entrez",
".",
"email",
"=",
"args",
".",
"email",
"logger",
".",
"info",
"(",
"\"Set NCBI contact email to %s\"",
",",
"args",
".",
"email",
")",
"Entrez",
".",
"tool",
"=",
"\"genbank_get_genomes_by_taxon.py\""
] | Set contact email for NCBI. | [
"Set",
"contact",
"email",
"for",
"NCBI",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L139-L143 | train |
widdowquinn/pyani | bin/genbank_get_genomes_by_taxon.py | entrez_retry | def entrez_retry(func, *fnargs, **fnkwargs):
"""Retries the passed function up to the number of times specified
by args.retries
"""
tries, success = 0, False
while not success and tries < args.retries:
try:
output = func(*fnargs, **fnkwargs)
success = True
exc... | python | def entrez_retry(func, *fnargs, **fnkwargs):
"""Retries the passed function up to the number of times specified
by args.retries
"""
tries, success = 0, False
while not success and tries < args.retries:
try:
output = func(*fnargs, **fnkwargs)
success = True
exc... | [
"def",
"entrez_retry",
"(",
"func",
",",
"*",
"fnargs",
",",
"**",
"fnkwargs",
")",
":",
"tries",
",",
"success",
"=",
"0",
",",
"False",
"while",
"not",
"success",
"and",
"tries",
"<",
"args",
".",
"retries",
":",
"try",
":",
"output",
"=",
"func",
... | Retries the passed function up to the number of times specified
by args.retries | [
"Retries",
"the",
"passed",
"function",
"up",
"to",
"the",
"number",
"of",
"times",
"specified",
"by",
"args",
".",
"retries"
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L187-L204 | train |
widdowquinn/pyani | bin/genbank_get_genomes_by_taxon.py | entrez_batch_webhistory | def entrez_batch_webhistory(record, expected, batchsize, *fnargs, **fnkwargs):
"""Recovers the Entrez data from a prior NCBI webhistory search, in
batches of defined size, using Efetch. Returns all results as a list.
- record: Entrez webhistory record
- expected: number of expected search returns
-... | python | def entrez_batch_webhistory(record, expected, batchsize, *fnargs, **fnkwargs):
"""Recovers the Entrez data from a prior NCBI webhistory search, in
batches of defined size, using Efetch. Returns all results as a list.
- record: Entrez webhistory record
- expected: number of expected search returns
-... | [
"def",
"entrez_batch_webhistory",
"(",
"record",
",",
"expected",
",",
"batchsize",
",",
"*",
"fnargs",
",",
"**",
"fnkwargs",
")",
":",
"results",
"=",
"[",
"]",
"for",
"start",
"in",
"range",
"(",
"0",
",",
"expected",
",",
"batchsize",
")",
":",
"ba... | Recovers the Entrez data from a prior NCBI webhistory search, in
batches of defined size, using Efetch. Returns all results as a list.
- record: Entrez webhistory record
- expected: number of expected search returns
- batchsize: how many search returns to retrieve in a batch
- *fnargs: arguments to... | [
"Recovers",
"the",
"Entrez",
"data",
"from",
"a",
"prior",
"NCBI",
"webhistory",
"search",
"in",
"batches",
"of",
"defined",
"size",
"using",
"Efetch",
".",
"Returns",
"all",
"results",
"as",
"a",
"list",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L208-L230 | train |
widdowquinn/pyani | bin/genbank_get_genomes_by_taxon.py | get_asm_uids | def get_asm_uids(taxon_uid):
"""Returns a set of NCBI UIDs associated with the passed taxon.
This query at NCBI returns all assemblies for the taxon subtree
rooted at the passed taxon_uid.
"""
query = "txid%s[Organism:exp]" % taxon_uid
logger.info("Entrez ESearch with query: %s", query)
# ... | python | def get_asm_uids(taxon_uid):
"""Returns a set of NCBI UIDs associated with the passed taxon.
This query at NCBI returns all assemblies for the taxon subtree
rooted at the passed taxon_uid.
"""
query = "txid%s[Organism:exp]" % taxon_uid
logger.info("Entrez ESearch with query: %s", query)
# ... | [
"def",
"get_asm_uids",
"(",
"taxon_uid",
")",
":",
"query",
"=",
"\"txid%s[Organism:exp]\"",
"%",
"taxon_uid",
"logger",
".",
"info",
"(",
"\"Entrez ESearch with query: %s\"",
",",
"query",
")",
"handle",
"=",
"entrez_retry",
"(",
"Entrez",
".",
"esearch",
",",
... | Returns a set of NCBI UIDs associated with the passed taxon.
This query at NCBI returns all assemblies for the taxon subtree
rooted at the passed taxon_uid. | [
"Returns",
"a",
"set",
"of",
"NCBI",
"UIDs",
"associated",
"with",
"the",
"passed",
"taxon",
"."
] | 2b24ec971401e04024bba896e4011984fe3f53f0 | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L234-L259 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.