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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
pkgw/pwkit
pwkit/environments/casa/tasks.py
importevla
def importevla(asdm, ms): """Convert an EVLA low-level SDM dataset to Measurement Set format. asdm (str) The path to the input ASDM dataset. ms (str) The path to the output MS dataset. This implementation automatically infers the value of the "tbuff" parameter. Example:: fr...
python
def importevla(asdm, ms): """Convert an EVLA low-level SDM dataset to Measurement Set format. asdm (str) The path to the input ASDM dataset. ms (str) The path to the output MS dataset. This implementation automatically infers the value of the "tbuff" parameter. Example:: fr...
[ "def", "importevla", "(", "asdm", ",", "ms", ")", ":", "from", ".", "scripting", "import", "CasapyScript", "# Here's the best way I can figure to find the recommended value of tbuff", "#(= 1.5 * integration time). Obviously you might have different", "# integration times in the dataset...
Convert an EVLA low-level SDM dataset to Measurement Set format. asdm (str) The path to the input ASDM dataset. ms (str) The path to the output MS dataset. This implementation automatically infers the value of the "tbuff" parameter. Example:: from pwkit.environments.casa import...
[ "Convert", "an", "EVLA", "low", "-", "level", "SDM", "dataset", "to", "Measurement", "Set", "format", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L2314-L2368
train
62,400
pkgw/pwkit
pwkit/environments/casa/tasks.py
listobs
def listobs(vis): """Textually describe the contents of a measurement set. vis (str) The path to the dataset. Returns A generator of lines of human-readable output Errors can only be detected by looking at the output. Example:: from pwkit.environments.casa import tasks for li...
python
def listobs(vis): """Textually describe the contents of a measurement set. vis (str) The path to the dataset. Returns A generator of lines of human-readable output Errors can only be detected by looking at the output. Example:: from pwkit.environments.casa import tasks for li...
[ "def", "listobs", "(", "vis", ")", ":", "def", "inner_list", "(", "sink", ")", ":", "try", ":", "ms", "=", "util", ".", "tools", ".", "ms", "(", ")", "ms", ".", "open", "(", "vis", ")", "ms", ".", "summary", "(", "verbose", "=", "True", ")", ...
Textually describe the contents of a measurement set. vis (str) The path to the dataset. Returns A generator of lines of human-readable output Errors can only be detected by looking at the output. Example:: from pwkit.environments.casa import tasks for line in tasks.listobs('myda...
[ "Textually", "describe", "the", "contents", "of", "a", "measurement", "set", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L2392-L2422
train
62,401
pkgw/pwkit
pwkit/environments/casa/tasks.py
mjd2date
def mjd2date(mjd, precision=3): """Convert an MJD to a data string in the format used by CASA. mjd (numeric) An MJD value in the UTC timescale. precision (integer, default 3) The number of digits of decimal precision in the seconds portion of the returned string Returns A string...
python
def mjd2date(mjd, precision=3): """Convert an MJD to a data string in the format used by CASA. mjd (numeric) An MJD value in the UTC timescale. precision (integer, default 3) The number of digits of decimal precision in the seconds portion of the returned string Returns A string...
[ "def", "mjd2date", "(", "mjd", ",", "precision", "=", "3", ")", ":", "from", "astropy", ".", "time", "import", "Time", "dt", "=", "Time", "(", "mjd", ",", "format", "=", "'mjd'", ",", "scale", "=", "'utc'", ")", ".", "to_datetime", "(", ")", "fracs...
Convert an MJD to a data string in the format used by CASA. mjd (numeric) An MJD value in the UTC timescale. precision (integer, default 3) The number of digits of decimal precision in the seconds portion of the returned string Returns A string representing the input argument in CAS...
[ "Convert", "an", "MJD", "to", "a", "data", "string", "in", "the", "format", "used", "by", "CASA", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L3208-L3232
train
62,402
pkgw/pwkit
pwkit/environments/casa/tasks.py
plotants
def plotants(vis, figfile): """Plot the physical layout of the antennas described in the MS. vis (str) Path to the input dataset figfile (str) Path to the output image file. The output image format will be inferred from the extension of *figfile*. Example:: from pwkit.environmen...
python
def plotants(vis, figfile): """Plot the physical layout of the antennas described in the MS. vis (str) Path to the input dataset figfile (str) Path to the output image file. The output image format will be inferred from the extension of *figfile*. Example:: from pwkit.environmen...
[ "def", "plotants", "(", "vis", ",", "figfile", ")", ":", "from", ".", "scripting", "import", "CasapyScript", "script", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'cscript_plotants.py'", ")", ...
Plot the physical layout of the antennas described in the MS. vis (str) Path to the input dataset figfile (str) Path to the output image file. The output image format will be inferred from the extension of *figfile*. Example:: from pwkit.environments.casa import tasks tasks.pl...
[ "Plot", "the", "physical", "layout", "of", "the", "antennas", "described", "in", "the", "MS", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L3378-L3398
train
62,403
pkgw/pwkit
pwkit/latex.py
latexify
def latexify(obj, **kwargs): """Render an object in LaTeX appropriately. """ if hasattr(obj, '__pk_latex__'): return obj.__pk_latex__(**kwargs) if isinstance(obj, text_type): from .unicode_to_latex import unicode_to_latex return unicode_to_latex(obj) if isinstance(obj, boo...
python
def latexify(obj, **kwargs): """Render an object in LaTeX appropriately. """ if hasattr(obj, '__pk_latex__'): return obj.__pk_latex__(**kwargs) if isinstance(obj, text_type): from .unicode_to_latex import unicode_to_latex return unicode_to_latex(obj) if isinstance(obj, boo...
[ "def", "latexify", "(", "obj", ",", "*", "*", "kwargs", ")", ":", "if", "hasattr", "(", "obj", ",", "'__pk_latex__'", ")", ":", "return", "obj", ".", "__pk_latex__", "(", "*", "*", "kwargs", ")", "if", "isinstance", "(", "obj", ",", "text_type", ")",...
Render an object in LaTeX appropriately.
[ "Render", "an", "object", "in", "LaTeX", "appropriately", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/latex.py#L145-L174
train
62,404
pkgw/pwkit
pwkit/latex.py
latexify_n2col
def latexify_n2col(x, nplaces=None, **kwargs): """Render a number into LaTeX in a 2-column format, where the columns split immediately to the left of the decimal point. This gives nice alignment of numbers in a table. """ if nplaces is not None: t = '%.*f' % (nplaces, x) else: t...
python
def latexify_n2col(x, nplaces=None, **kwargs): """Render a number into LaTeX in a 2-column format, where the columns split immediately to the left of the decimal point. This gives nice alignment of numbers in a table. """ if nplaces is not None: t = '%.*f' % (nplaces, x) else: t...
[ "def", "latexify_n2col", "(", "x", ",", "nplaces", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "nplaces", "is", "not", "None", ":", "t", "=", "'%.*f'", "%", "(", "nplaces", ",", "x", ")", "else", ":", "t", "=", "'%f'", "%", "x", "if",...
Render a number into LaTeX in a 2-column format, where the columns split immediately to the left of the decimal point. This gives nice alignment of numbers in a table.
[ "Render", "a", "number", "into", "LaTeX", "in", "a", "2", "-", "column", "format", "where", "the", "columns", "split", "immediately", "to", "the", "left", "of", "the", "decimal", "point", ".", "This", "gives", "nice", "alignment", "of", "numbers", "in", ...
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/latex.py#L177-L192
train
62,405
pkgw/pwkit
pwkit/latex.py
latexify_u3col
def latexify_u3col(obj, **kwargs): """Convert an object to special LaTeX for uncertainty tables. This conversion is meant for uncertain values in a table. The return value should span three columns. The first column ends just before the decimal point in the main number value, if it has one. It has no s...
python
def latexify_u3col(obj, **kwargs): """Convert an object to special LaTeX for uncertainty tables. This conversion is meant for uncertain values in a table. The return value should span three columns. The first column ends just before the decimal point in the main number value, if it has one. It has no s...
[ "def", "latexify_u3col", "(", "obj", ",", "*", "*", "kwargs", ")", ":", "if", "hasattr", "(", "obj", ",", "'__pk_latex_u3col__'", ")", ":", "return", "obj", ".", "__pk_latex_u3col__", "(", "*", "*", "kwargs", ")", "# TODO: there are reasonable ways to format man...
Convert an object to special LaTeX for uncertainty tables. This conversion is meant for uncertain values in a table. The return value should span three columns. The first column ends just before the decimal point in the main number value, if it has one. It has no separation from the second column. The ...
[ "Convert", "an", "object", "to", "special", "LaTeX", "for", "uncertainty", "tables", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/latex.py#L195-L213
train
62,406
pkgw/pwkit
pwkit/latex.py
latexify_l3col
def latexify_l3col(obj, **kwargs): """Convert an object to special LaTeX for limit tables. This conversion is meant for limit values in a table. The return value should span three columns. The first column is the limit indicator: <, >, ~, etc. The second column is the whole part of the value, up until ...
python
def latexify_l3col(obj, **kwargs): """Convert an object to special LaTeX for limit tables. This conversion is meant for limit values in a table. The return value should span three columns. The first column is the limit indicator: <, >, ~, etc. The second column is the whole part of the value, up until ...
[ "def", "latexify_l3col", "(", "obj", ",", "*", "*", "kwargs", ")", ":", "if", "hasattr", "(", "obj", ",", "'__pk_latex_l3col__'", ")", ":", "return", "obj", ".", "__pk_latex_l3col__", "(", "*", "*", "kwargs", ")", "if", "isinstance", "(", "obj", ",", "...
Convert an object to special LaTeX for limit tables. This conversion is meant for limit values in a table. The return value should span three columns. The first column is the limit indicator: <, >, ~, etc. The second column is the whole part of the value, up until just before the decimal point. The thi...
[ "Convert", "an", "object", "to", "special", "LaTeX", "for", "limit", "tables", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/latex.py#L216-L241
train
62,407
pkgw/pwkit
pwkit/tabfile.py
read
def read (path, tabwidth=8, **kwargs): """Read a typed tabular text file into a stream of Holders. Arguments: path The path of the file to read. tabwidth=8 The tab width to assume. Please don't monkey with it. mode='rt' The file open mode (passed to io.open()). noexistok=Fals...
python
def read (path, tabwidth=8, **kwargs): """Read a typed tabular text file into a stream of Holders. Arguments: path The path of the file to read. tabwidth=8 The tab width to assume. Please don't monkey with it. mode='rt' The file open mode (passed to io.open()). noexistok=Fals...
[ "def", "read", "(", "path", ",", "tabwidth", "=", "8", ",", "*", "*", "kwargs", ")", ":", "datamode", "=", "False", "fixedcols", "=", "{", "}", "for", "text", "in", "_trimmedlines", "(", "path", ",", "*", "*", "kwargs", ")", ":", "text", "=", "te...
Read a typed tabular text file into a stream of Holders. Arguments: path The path of the file to read. tabwidth=8 The tab width to assume. Please don't monkey with it. mode='rt' The file open mode (passed to io.open()). noexistok=False If True and the file is missing, treat...
[ "Read", "a", "typed", "tabular", "text", "file", "into", "a", "stream", "of", "Holders", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/tabfile.py#L45-L123
train
62,408
pkgw/pwkit
pwkit/tabfile.py
write
def write (stream, items, fieldnames, tabwidth=8): """Write a typed tabular text file to the specified stream. Arguments: stream The destination stream. items An iterable of items to write. Two passes have to be made over the items (to discover the needed column widths), so thi...
python
def write (stream, items, fieldnames, tabwidth=8): """Write a typed tabular text file to the specified stream. Arguments: stream The destination stream. items An iterable of items to write. Two passes have to be made over the items (to discover the needed column widths), so thi...
[ "def", "write", "(", "stream", ",", "items", ",", "fieldnames", ",", "tabwidth", "=", "8", ")", ":", "if", "isinstance", "(", "fieldnames", ",", "six", ".", "string_types", ")", ":", "fieldnames", "=", "fieldnames", ".", "split", "(", ")", "maxlens", "...
Write a typed tabular text file to the specified stream. Arguments: stream The destination stream. items An iterable of items to write. Two passes have to be made over the items (to discover the needed column widths), so this will be saved into a list. fieldnames Either a...
[ "Write", "a", "typed", "tabular", "text", "file", "to", "the", "specified", "stream", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/tabfile.py#L140-L227
train
62,409
pkgw/pwkit
pwkit/tabfile.py
vizread
def vizread (descpath, descsection, tabpath, tabwidth=8, **kwargs): """Read a headerless tabular text file into a stream of Holders. Arguments: descpath The path of the table description ini file. descsection The section in the description file to use. tabpath The path to the act...
python
def vizread (descpath, descsection, tabpath, tabwidth=8, **kwargs): """Read a headerless tabular text file into a stream of Holders. Arguments: descpath The path of the table description ini file. descsection The section in the description file to use. tabpath The path to the act...
[ "def", "vizread", "(", "descpath", ",", "descsection", ",", "tabpath", ",", "tabwidth", "=", "8", ",", "*", "*", "kwargs", ")", ":", "from", ".", "inifile", "import", "read", "as", "iniread", "cols", "=", "[", "]", "for", "i", "in", "iniread", "(", ...
Read a headerless tabular text file into a stream of Holders. Arguments: descpath The path of the table description ini file. descsection The section in the description file to use. tabpath The path to the actual table data. tabwidth=8 The tab width to assume. Please don't ...
[ "Read", "a", "headerless", "tabular", "text", "file", "into", "a", "stream", "of", "Holders", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/tabfile.py#L230-L297
train
62,410
pkgw/pwkit
pwkit/lsqmdl.py
_broadcast_shapes
def _broadcast_shapes(s1, s2): """Given array shapes `s1` and `s2`, compute the shape of the array that would result from broadcasting them together.""" n1 = len(s1) n2 = len(s2) n = max(n1, n2) res = [1] * n for i in range(n): if i >= n1: c1 = 1 else: ...
python
def _broadcast_shapes(s1, s2): """Given array shapes `s1` and `s2`, compute the shape of the array that would result from broadcasting them together.""" n1 = len(s1) n2 = len(s2) n = max(n1, n2) res = [1] * n for i in range(n): if i >= n1: c1 = 1 else: ...
[ "def", "_broadcast_shapes", "(", "s1", ",", "s2", ")", ":", "n1", "=", "len", "(", "s1", ")", "n2", "=", "len", "(", "s2", ")", "n", "=", "max", "(", "n1", ",", "n2", ")", "res", "=", "[", "1", "]", "*", "n", "for", "i", "in", "range", "(...
Given array shapes `s1` and `s2`, compute the shape of the array that would result from broadcasting them together.
[ "Given", "array", "shapes", "s1", "and", "s2", "compute", "the", "shape", "of", "the", "array", "that", "would", "result", "from", "broadcasting", "them", "together", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L757-L786
train
62,411
pkgw/pwkit
pwkit/lsqmdl.py
ModelBase.set_data
def set_data(self, data, invsigma=None): """Set the data to be modeled. Returns *self*. """ self.data = np.array(data, dtype=np.float, ndmin=1) if invsigma is None: self.invsigma = np.ones(self.data.shape) else: i = np.array(invsigma, dtype=np.f...
python
def set_data(self, data, invsigma=None): """Set the data to be modeled. Returns *self*. """ self.data = np.array(data, dtype=np.float, ndmin=1) if invsigma is None: self.invsigma = np.ones(self.data.shape) else: i = np.array(invsigma, dtype=np.f...
[ "def", "set_data", "(", "self", ",", "data", ",", "invsigma", "=", "None", ")", ":", "self", ".", "data", "=", "np", ".", "array", "(", "data", ",", "dtype", "=", "np", ".", "float", ",", "ndmin", "=", "1", ")", "if", "invsigma", "is", "None", ...
Set the data to be modeled. Returns *self*.
[ "Set", "the", "data", "to", "be", "modeled", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L126-L143
train
62,412
pkgw/pwkit
pwkit/lsqmdl.py
ModelBase.print_soln
def print_soln(self): """Print information about the model solution.""" lmax = reduce(max,(len(x) for x in self.pnames), len('r chi sq')) if self.puncerts is None: for pn, val in zip(self.pnames, self.params): print('%s: %14g' % (pn.rjust(lmax), val)) else: ...
python
def print_soln(self): """Print information about the model solution.""" lmax = reduce(max,(len(x) for x in self.pnames), len('r chi sq')) if self.puncerts is None: for pn, val in zip(self.pnames, self.params): print('%s: %14g' % (pn.rjust(lmax), val)) else: ...
[ "def", "print_soln", "(", "self", ")", ":", "lmax", "=", "reduce", "(", "max", ",", "(", "len", "(", "x", ")", "for", "x", "in", "self", ".", "pnames", ")", ",", "len", "(", "'r chi sq'", ")", ")", "if", "self", ".", "puncerts", "is", "None", "...
Print information about the model solution.
[ "Print", "information", "about", "the", "model", "solution", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L146-L164
train
62,413
pkgw/pwkit
pwkit/lsqmdl.py
ModelBase.show_corr
def show_corr(self): "Show the parameter correlation matrix with `pwkit.ndshow_gtk3`." from .ndshow_gtk3 import view d = np.diag(self.covar) ** -0.5 corr = self.covar * d[np.newaxis,:] * d[:,np.newaxis] view(corr, title='Correlation Matrix')
python
def show_corr(self): "Show the parameter correlation matrix with `pwkit.ndshow_gtk3`." from .ndshow_gtk3 import view d = np.diag(self.covar) ** -0.5 corr = self.covar * d[np.newaxis,:] * d[:,np.newaxis] view(corr, title='Correlation Matrix')
[ "def", "show_corr", "(", "self", ")", ":", "from", ".", "ndshow_gtk3", "import", "view", "d", "=", "np", ".", "diag", "(", "self", ".", "covar", ")", "**", "-", "0.5", "corr", "=", "self", ".", "covar", "*", "d", "[", "np", ".", "newaxis", ",", ...
Show the parameter correlation matrix with `pwkit.ndshow_gtk3`.
[ "Show", "the", "parameter", "correlation", "matrix", "with", "pwkit", ".", "ndshow_gtk3", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L246-L251
train
62,414
pkgw/pwkit
pwkit/lsqmdl.py
Model.set_func
def set_func(self, func, pnames, args=()): """Set the model function to use an efficient but tedious calling convention. The function should obey the following convention:: def func(param_vec, *args): modeled_data = { do something using param_vec } return mo...
python
def set_func(self, func, pnames, args=()): """Set the model function to use an efficient but tedious calling convention. The function should obey the following convention:: def func(param_vec, *args): modeled_data = { do something using param_vec } return mo...
[ "def", "set_func", "(", "self", ",", "func", ",", "pnames", ",", "args", "=", "(", ")", ")", ":", "from", ".", "lmmin", "import", "Problem", "self", ".", "func", "=", "func", "self", ".", "_args", "=", "args", "self", ".", "pnames", "=", "list", ...
Set the model function to use an efficient but tedious calling convention. The function should obey the following convention:: def func(param_vec, *args): modeled_data = { do something using param_vec } return modeled_data This function creates the :class:`...
[ "Set", "the", "model", "function", "to", "use", "an", "efficient", "but", "tedious", "calling", "convention", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L297-L318
train
62,415
pkgw/pwkit
pwkit/lsqmdl.py
Model.set_simple_func
def set_simple_func(self, func, args=()): """Set the model function to use a simple but somewhat inefficient calling convention. The function should obey the following convention:: def func(param0, param1, ..., paramN, *args): modeled_data = { do something using the...
python
def set_simple_func(self, func, args=()): """Set the model function to use a simple but somewhat inefficient calling convention. The function should obey the following convention:: def func(param0, param1, ..., paramN, *args): modeled_data = { do something using the...
[ "def", "set_simple_func", "(", "self", ",", "func", ",", "args", "=", "(", ")", ")", ":", "code", "=", "get_function_code", "(", "func", ")", "npar", "=", "code", ".", "co_argcount", "-", "len", "(", "args", ")", "pnames", "=", "code", ".", "co_varna...
Set the model function to use a simple but somewhat inefficient calling convention. The function should obey the following convention:: def func(param0, param1, ..., paramN, *args): modeled_data = { do something using the parameters } return modeled_data ...
[ "Set", "the", "model", "function", "to", "use", "a", "simple", "but", "somewhat", "inefficient", "calling", "convention", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L321-L341
train
62,416
pkgw/pwkit
pwkit/lsqmdl.py
Model.make_frozen_func
def make_frozen_func(self, params): """Returns a model function frozen to the specified parameter values. Any remaining arguments are left free and must be provided when the function is called. For this model, the returned function is the application of :func:`functools.partial...
python
def make_frozen_func(self, params): """Returns a model function frozen to the specified parameter values. Any remaining arguments are left free and must be provided when the function is called. For this model, the returned function is the application of :func:`functools.partial...
[ "def", "make_frozen_func", "(", "self", ",", "params", ")", ":", "params", "=", "np", ".", "array", "(", "params", ",", "dtype", "=", "np", ".", "float", ",", "ndmin", "=", "1", ")", "from", "functools", "import", "partial", "return", "partial", "(", ...
Returns a model function frozen to the specified parameter values. Any remaining arguments are left free and must be provided when the function is called. For this model, the returned function is the application of :func:`functools.partial` to the :attr:`func` property of this object.
[ "Returns", "a", "model", "function", "frozen", "to", "the", "specified", "parameter", "values", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L344-L356
train
62,417
pkgw/pwkit
pwkit/lsqmdl.py
Model.solve
def solve(self, guess): """Solve for the parameters, using an initial guess. This uses the Levenberg-Marquardt optimizer described in :mod:`pwkit.lmmin`. Returns *self*. """ guess = np.array(guess, dtype=np.float, ndmin=1) f = self.func args = self._arg...
python
def solve(self, guess): """Solve for the parameters, using an initial guess. This uses the Levenberg-Marquardt optimizer described in :mod:`pwkit.lmmin`. Returns *self*. """ guess = np.array(guess, dtype=np.float, ndmin=1) f = self.func args = self._arg...
[ "def", "solve", "(", "self", ",", "guess", ")", ":", "guess", "=", "np", ".", "array", "(", "guess", ",", "dtype", "=", "np", ".", "float", ",", "ndmin", "=", "1", ")", "f", "=", "self", ".", "func", "args", "=", "self", ".", "_args", "def", ...
Solve for the parameters, using an initial guess. This uses the Levenberg-Marquardt optimizer described in :mod:`pwkit.lmmin`. Returns *self*.
[ "Solve", "for", "the", "parameters", "using", "an", "initial", "guess", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L359-L394
train
62,418
pkgw/pwkit
pwkit/lsqmdl.py
PolynomialModel.as_nonlinear
def as_nonlinear(self, params=None): """Return a `Model` equivalent to this object. The nonlinear solver is less efficient, but lets you freeze parameters, compute uncertainties, etc. If the `params` argument is provided, solve() will be called on the returned object with those paramete...
python
def as_nonlinear(self, params=None): """Return a `Model` equivalent to this object. The nonlinear solver is less efficient, but lets you freeze parameters, compute uncertainties, etc. If the `params` argument is provided, solve() will be called on the returned object with those paramete...
[ "def", "as_nonlinear", "(", "self", ",", "params", "=", "None", ")", ":", "if", "params", "is", "None", ":", "params", "=", "self", ".", "params", "nlm", "=", "Model", "(", "None", ",", "self", ".", "data", ",", "self", ".", "invsigma", ")", "nlm",...
Return a `Model` equivalent to this object. The nonlinear solver is less efficient, but lets you freeze parameters, compute uncertainties, etc. If the `params` argument is provided, solve() will be called on the returned object with those parameters. If it is `None` and this object has ...
[ "Return", "a", "Model", "equivalent", "to", "this", "object", ".", "The", "nonlinear", "solver", "is", "less", "efficient", "but", "lets", "you", "freeze", "parameters", "compute", "uncertainties", "etc", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L444-L464
train
62,419
bibanon/BASC-py4chan
basc_py4chan/thread.py
Thread.files
def files(self): """Returns the URLs of all files attached to posts in the thread.""" if self.topic.has_file: yield self.topic.file.file_url for reply in self.replies: if reply.has_file: yield reply.file.file_url
python
def files(self): """Returns the URLs of all files attached to posts in the thread.""" if self.topic.has_file: yield self.topic.file.file_url for reply in self.replies: if reply.has_file: yield reply.file.file_url
[ "def", "files", "(", "self", ")", ":", "if", "self", ".", "topic", ".", "has_file", ":", "yield", "self", ".", "topic", ".", "file", ".", "file_url", "for", "reply", "in", "self", ".", "replies", ":", "if", "reply", ".", "has_file", ":", "yield", "...
Returns the URLs of all files attached to posts in the thread.
[ "Returns", "the", "URLs", "of", "all", "files", "attached", "to", "posts", "in", "the", "thread", "." ]
88e4866d73853e1025e549fbbe9744e750522359
https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/thread.py#L105-L111
train
62,420
bibanon/BASC-py4chan
basc_py4chan/thread.py
Thread.thumbs
def thumbs(self): """Returns the URLs of all thumbnails in the thread.""" if self.topic.has_file: yield self.topic.file.thumbnail_url for reply in self.replies: if reply.has_file: yield reply.file.thumbnail_url
python
def thumbs(self): """Returns the URLs of all thumbnails in the thread.""" if self.topic.has_file: yield self.topic.file.thumbnail_url for reply in self.replies: if reply.has_file: yield reply.file.thumbnail_url
[ "def", "thumbs", "(", "self", ")", ":", "if", "self", ".", "topic", ".", "has_file", ":", "yield", "self", ".", "topic", ".", "file", ".", "thumbnail_url", "for", "reply", "in", "self", ".", "replies", ":", "if", "reply", ".", "has_file", ":", "yield...
Returns the URLs of all thumbnails in the thread.
[ "Returns", "the", "URLs", "of", "all", "thumbnails", "in", "the", "thread", "." ]
88e4866d73853e1025e549fbbe9744e750522359
https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/thread.py#L113-L119
train
62,421
bibanon/BASC-py4chan
basc_py4chan/thread.py
Thread.filenames
def filenames(self): """Returns the filenames of all files attached to posts in the thread.""" if self.topic.has_file: yield self.topic.file.filename for reply in self.replies: if reply.has_file: yield reply.file.filename
python
def filenames(self): """Returns the filenames of all files attached to posts in the thread.""" if self.topic.has_file: yield self.topic.file.filename for reply in self.replies: if reply.has_file: yield reply.file.filename
[ "def", "filenames", "(", "self", ")", ":", "if", "self", ".", "topic", ".", "has_file", ":", "yield", "self", ".", "topic", ".", "file", ".", "filename", "for", "reply", "in", "self", ".", "replies", ":", "if", "reply", ".", "has_file", ":", "yield",...
Returns the filenames of all files attached to posts in the thread.
[ "Returns", "the", "filenames", "of", "all", "files", "attached", "to", "posts", "in", "the", "thread", "." ]
88e4866d73853e1025e549fbbe9744e750522359
https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/thread.py#L121-L127
train
62,422
bibanon/BASC-py4chan
basc_py4chan/thread.py
Thread.thumbnames
def thumbnames(self): """Returns the filenames of all thumbnails in the thread.""" if self.topic.has_file: yield self.topic.file.thumbnail_fname for reply in self.replies: if reply.has_file: yield reply.file.thumbnail_fname
python
def thumbnames(self): """Returns the filenames of all thumbnails in the thread.""" if self.topic.has_file: yield self.topic.file.thumbnail_fname for reply in self.replies: if reply.has_file: yield reply.file.thumbnail_fname
[ "def", "thumbnames", "(", "self", ")", ":", "if", "self", ".", "topic", ".", "has_file", ":", "yield", "self", ".", "topic", ".", "file", ".", "thumbnail_fname", "for", "reply", "in", "self", ".", "replies", ":", "if", "reply", ".", "has_file", ":", ...
Returns the filenames of all thumbnails in the thread.
[ "Returns", "the", "filenames", "of", "all", "thumbnails", "in", "the", "thread", "." ]
88e4866d73853e1025e549fbbe9744e750522359
https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/thread.py#L129-L135
train
62,423
bibanon/BASC-py4chan
basc_py4chan/thread.py
Thread.update
def update(self, force=False): """Fetch new posts from the server. Arguments: force (bool): Force a thread update, even if thread has 404'd. Returns: int: How many new posts have been fetched. """ # The thread has already 404'ed, this function shouldn't...
python
def update(self, force=False): """Fetch new posts from the server. Arguments: force (bool): Force a thread update, even if thread has 404'd. Returns: int: How many new posts have been fetched. """ # The thread has already 404'ed, this function shouldn't...
[ "def", "update", "(", "self", ",", "force", "=", "False", ")", ":", "# The thread has already 404'ed, this function shouldn't do anything anymore.", "if", "self", ".", "is_404", "and", "not", "force", ":", "return", "0", "if", "self", ".", "_last_modified", ":", "...
Fetch new posts from the server. Arguments: force (bool): Force a thread update, even if thread has 404'd. Returns: int: How many new posts have been fetched.
[ "Fetch", "new", "posts", "from", "the", "server", "." ]
88e4866d73853e1025e549fbbe9744e750522359
https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/thread.py#L145-L214
train
62,424
pkgw/pwkit
pwkit/radio_cal_models.py
cas_a
def cas_a (freq_mhz, year): """Return the flux of Cas A given a frequency and the year of observation. Based on the formula given in Baars et al., 1977. Parameters: freq - Observation frequency in MHz. year - Year of observation. May be floating-point. Returns: s, flux in Jy. """ # T...
python
def cas_a (freq_mhz, year): """Return the flux of Cas A given a frequency and the year of observation. Based on the formula given in Baars et al., 1977. Parameters: freq - Observation frequency in MHz. year - Year of observation. May be floating-point. Returns: s, flux in Jy. """ # T...
[ "def", "cas_a", "(", "freq_mhz", ",", "year", ")", ":", "# The snu rule is right out of Baars et al. The dnu is corrected", "# for the frequency being measured in MHz, not GHz.", "snu", "=", "10.", "**", "(", "5.745", "-", "0.770", "*", "np", ".", "log10", "(", "freq_mh...
Return the flux of Cas A given a frequency and the year of observation. Based on the formula given in Baars et al., 1977. Parameters: freq - Observation frequency in MHz. year - Year of observation. May be floating-point. Returns: s, flux in Jy.
[ "Return", "the", "flux", "of", "Cas", "A", "given", "a", "frequency", "and", "the", "year", "of", "observation", ".", "Based", "on", "the", "formula", "given", "in", "Baars", "et", "al", ".", "1977", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/radio_cal_models.py#L44-L62
train
62,425
pkgw/pwkit
pwkit/radio_cal_models.py
init_cas_a
def init_cas_a (year): """Insert an entry for Cas A into the table of models. Need to specify the year of the observations to account for the time variation of Cas A's emission. """ year = float (year) models['CasA'] = lambda f: cas_a (f, year)
python
def init_cas_a (year): """Insert an entry for Cas A into the table of models. Need to specify the year of the observations to account for the time variation of Cas A's emission. """ year = float (year) models['CasA'] = lambda f: cas_a (f, year)
[ "def", "init_cas_a", "(", "year", ")", ":", "year", "=", "float", "(", "year", ")", "models", "[", "'CasA'", "]", "=", "lambda", "f", ":", "cas_a", "(", "f", ",", "year", ")" ]
Insert an entry for Cas A into the table of models. Need to specify the year of the observations to account for the time variation of Cas A's emission.
[ "Insert", "an", "entry", "for", "Cas", "A", "into", "the", "table", "of", "models", ".", "Need", "to", "specify", "the", "year", "of", "the", "observations", "to", "account", "for", "the", "time", "variation", "of", "Cas", "A", "s", "emission", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/radio_cal_models.py#L65-L72
train
62,426
pkgw/pwkit
pwkit/radio_cal_models.py
add_from_vla_obs
def add_from_vla_obs (src, Lband, Cband): """Add an entry into the models table for a source based on L-band and C-band flux densities. """ if src in models: raise PKError ('already have a model for ' + src) fL = np.log10 (1425) fC = np.log10 (4860) lL = np.log10 (Lband) lC = ...
python
def add_from_vla_obs (src, Lband, Cband): """Add an entry into the models table for a source based on L-band and C-band flux densities. """ if src in models: raise PKError ('already have a model for ' + src) fL = np.log10 (1425) fC = np.log10 (4860) lL = np.log10 (Lband) lC = ...
[ "def", "add_from_vla_obs", "(", "src", ",", "Lband", ",", "Cband", ")", ":", "if", "src", "in", "models", ":", "raise", "PKError", "(", "'already have a model for '", "+", "src", ")", "fL", "=", "np", ".", "log10", "(", "1425", ")", "fC", "=", "np", ...
Add an entry into the models table for a source based on L-band and C-band flux densities.
[ "Add", "an", "entry", "into", "the", "models", "table", "for", "a", "source", "based", "on", "L", "-", "band", "and", "C", "-", "band", "flux", "densities", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/radio_cal_models.py#L164-L188
train
62,427
pkgw/pwkit
pwkit/ellipses.py
databiv
def databiv (xy, coordouter=False, **kwargs): """Compute the main parameters of a bivariate distribution from data. The parameters are returned in the same format as used in the rest of this module. * xy: a 2D data array of shape (2, nsamp) or (nsamp, 2) * coordouter: if True, the coordinate axis i...
python
def databiv (xy, coordouter=False, **kwargs): """Compute the main parameters of a bivariate distribution from data. The parameters are returned in the same format as used in the rest of this module. * xy: a 2D data array of shape (2, nsamp) or (nsamp, 2) * coordouter: if True, the coordinate axis i...
[ "def", "databiv", "(", "xy", ",", "coordouter", "=", "False", ",", "*", "*", "kwargs", ")", ":", "xy", "=", "np", ".", "asarray", "(", "xy", ")", "if", "xy", ".", "ndim", "!=", "2", ":", "raise", "ValueError", "(", "'\"xy\" must be a 2D array'", ")",...
Compute the main parameters of a bivariate distribution from data. The parameters are returned in the same format as used in the rest of this module. * xy: a 2D data array of shape (2, nsamp) or (nsamp, 2) * coordouter: if True, the coordinate axis is the outer axis; i.e. the shape is (2, nsamp)....
[ "Compute", "the", "main", "parameters", "of", "a", "bivariate", "distribution", "from", "data", ".", "The", "parameters", "are", "returned", "in", "the", "same", "format", "as", "used", "in", "the", "rest", "of", "this", "module", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/ellipses.py#L183-L216
train
62,428
pkgw/pwkit
pwkit/ellipses.py
bivrandom
def bivrandom (x0, y0, sx, sy, cxy, size=None): """Compute random values distributed according to the specified bivariate distribution. Inputs: * x0: the center of the x distribution (i.e. its intended mean) * y0: the center of the y distribution * sx: standard deviation (not variance) of x va...
python
def bivrandom (x0, y0, sx, sy, cxy, size=None): """Compute random values distributed according to the specified bivariate distribution. Inputs: * x0: the center of the x distribution (i.e. its intended mean) * y0: the center of the y distribution * sx: standard deviation (not variance) of x va...
[ "def", "bivrandom", "(", "x0", ",", "y0", ",", "sx", ",", "sy", ",", "cxy", ",", "size", "=", "None", ")", ":", "from", "numpy", ".", "random", "import", "multivariate_normal", "as", "mvn", "p0", "=", "np", ".", "asarray", "(", "[", "x0", ",", "y...
Compute random values distributed according to the specified bivariate distribution. Inputs: * x0: the center of the x distribution (i.e. its intended mean) * y0: the center of the y distribution * sx: standard deviation (not variance) of x var * sy: standard deviation (not variance) of y var ...
[ "Compute", "random", "values", "distributed", "according", "to", "the", "specified", "bivariate", "distribution", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/ellipses.py#L219-L243
train
62,429
pkgw/pwkit
pwkit/ellipses.py
bivconvolve
def bivconvolve (sx_a, sy_a, cxy_a, sx_b, sy_b, cxy_b): """Given two independent bivariate distributions, compute a bivariate distribution corresponding to their convolution. I'm sure this is worked out in a ton of places, but I got the equations from Pineau+ (2011A&A...527A.126P). Returns: (sx_c,...
python
def bivconvolve (sx_a, sy_a, cxy_a, sx_b, sy_b, cxy_b): """Given two independent bivariate distributions, compute a bivariate distribution corresponding to their convolution. I'm sure this is worked out in a ton of places, but I got the equations from Pineau+ (2011A&A...527A.126P). Returns: (sx_c,...
[ "def", "bivconvolve", "(", "sx_a", ",", "sy_a", ",", "cxy_a", ",", "sx_b", ",", "sy_b", ",", "cxy_b", ")", ":", "_bivcheck", "(", "sx_a", ",", "sy_a", ",", "cxy_a", ")", "_bivcheck", "(", "sx_b", ",", "sy_b", ",", "cxy_b", ")", "sx_c", "=", "np", ...
Given two independent bivariate distributions, compute a bivariate distribution corresponding to their convolution. I'm sure this is worked out in a ton of places, but I got the equations from Pineau+ (2011A&A...527A.126P). Returns: (sx_c, sy_c, cxy_c), the parameters of the convolved distribution...
[ "Given", "two", "independent", "bivariate", "distributions", "compute", "a", "bivariate", "distribution", "corresponding", "to", "their", "convolution", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/ellipses.py#L246-L264
train
62,430
pkgw/pwkit
pwkit/ellipses.py
ellplot
def ellplot (mjr, mnr, pa): """Utility for debugging.""" _ellcheck (mjr, mnr, pa) import omega as om th = np.linspace (0, 2 * np.pi, 200) x, y = ellpoint (mjr, mnr, pa, th) return om.quickXY (x, y, 'mjr=%f mnr=%f pa=%f' % (mjr, mnr, pa * 180 / np.pi))
python
def ellplot (mjr, mnr, pa): """Utility for debugging.""" _ellcheck (mjr, mnr, pa) import omega as om th = np.linspace (0, 2 * np.pi, 200) x, y = ellpoint (mjr, mnr, pa, th) return om.quickXY (x, y, 'mjr=%f mnr=%f pa=%f' % (mjr, mnr, pa * 180 / np.pi))
[ "def", "ellplot", "(", "mjr", ",", "mnr", ",", "pa", ")", ":", "_ellcheck", "(", "mjr", ",", "mnr", ",", "pa", ")", "import", "omega", "as", "om", "th", "=", "np", ".", "linspace", "(", "0", ",", "2", "*", "np", ".", "pi", ",", "200", ")", ...
Utility for debugging.
[ "Utility", "for", "debugging", "." ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/ellipses.py#L445-L453
train
62,431
pkgw/pwkit
pwkit/ellipses.py
abcd2
def abcd2 (x0, y0, a, b, c, x, y): """Given an 2D Gaussian expressed as the ABC polynomial coefficients, compute a "squared distance parameter" such that z = exp (-0.5 * d2) Inputs: * x0: position of Gaussian center on x axis * y0: position of Gaussian center on y axis * a: such that z...
python
def abcd2 (x0, y0, a, b, c, x, y): """Given an 2D Gaussian expressed as the ABC polynomial coefficients, compute a "squared distance parameter" such that z = exp (-0.5 * d2) Inputs: * x0: position of Gaussian center on x axis * y0: position of Gaussian center on y axis * a: such that z...
[ "def", "abcd2", "(", "x0", ",", "y0", ",", "a", ",", "b", ",", "c", ",", "x", ",", "y", ")", ":", "_abccheck", "(", "a", ",", "b", ",", "c", ")", "dx", ",", "dy", "=", "x", "-", "x0", ",", "y", "-", "y0", "return", "-", "2", "*", "(",...
Given an 2D Gaussian expressed as the ABC polynomial coefficients, compute a "squared distance parameter" such that z = exp (-0.5 * d2) Inputs: * x0: position of Gaussian center on x axis * y0: position of Gaussian center on y axis * a: such that z = exp (ax² + bxy + cy²) * b: see abov...
[ "Given", "an", "2D", "Gaussian", "expressed", "as", "the", "ABC", "polynomial", "coefficients", "compute", "a", "squared", "distance", "parameter", "such", "that" ]
d40957a1c3d2ea34e7ceac2267ee9635135f2793
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/ellipses.py#L500-L523
train
62,432
jakevdp/lpproj
lpproj/lpproj.py
eigh_robust
def eigh_robust(a, b=None, eigvals=None, eigvals_only=False, overwrite_a=False, overwrite_b=False, turbo=True, check_finite=True): """Robustly solve the Hermitian generalized eigenvalue problem This function robustly solves the Hermetian generalized eigenvalue problem ``A v ...
python
def eigh_robust(a, b=None, eigvals=None, eigvals_only=False, overwrite_a=False, overwrite_b=False, turbo=True, check_finite=True): """Robustly solve the Hermitian generalized eigenvalue problem This function robustly solves the Hermetian generalized eigenvalue problem ``A v ...
[ "def", "eigh_robust", "(", "a", ",", "b", "=", "None", ",", "eigvals", "=", "None", ",", "eigvals_only", "=", "False", ",", "overwrite_a", "=", "False", ",", "overwrite_b", "=", "False", ",", "turbo", "=", "True", ",", "check_finite", "=", "True", ")",...
Robustly solve the Hermitian generalized eigenvalue problem This function robustly solves the Hermetian generalized eigenvalue problem ``A v = lambda B v`` in the case that B is not strictly positive definite. When B is strictly positive-definite, the result is equivalent to scipy.linalg.eigh() within ...
[ "Robustly", "solve", "the", "Hermitian", "generalized", "eigenvalue", "problem" ]
9c9042b0c2d16c153b53dcc0a759c7fe8c272176
https://github.com/jakevdp/lpproj/blob/9c9042b0c2d16c153b53dcc0a759c7fe8c272176/lpproj/lpproj.py#L105-L173
train
62,433
jakevdp/lpproj
lpproj/lpproj.py
LocalityPreservingProjection._compute_projection
def _compute_projection(self, X, W): """Compute the LPP projection matrix Parameters ---------- X : array_like, (n_samples, n_features) The input data W : array_like or sparse matrix, (n_samples, n_samples) The precomputed adjacency matrix Return...
python
def _compute_projection(self, X, W): """Compute the LPP projection matrix Parameters ---------- X : array_like, (n_samples, n_features) The input data W : array_like or sparse matrix, (n_samples, n_samples) The precomputed adjacency matrix Return...
[ "def", "_compute_projection", "(", "self", ",", "X", ",", "W", ")", ":", "# TODO: check W input; handle sparse case", "X", "=", "check_array", "(", "X", ")", "D", "=", "np", ".", "diag", "(", "W", ".", "sum", "(", "1", ")", ")", "L", "=", "D", "-", ...
Compute the LPP projection matrix Parameters ---------- X : array_like, (n_samples, n_features) The input data W : array_like or sparse matrix, (n_samples, n_samples) The precomputed adjacency matrix Returns ------- P : ndarray, (n_featur...
[ "Compute", "the", "LPP", "projection", "matrix" ]
9c9042b0c2d16c153b53dcc0a759c7fe8c272176
https://github.com/jakevdp/lpproj/blob/9c9042b0c2d16c153b53dcc0a759c7fe8c272176/lpproj/lpproj.py#L57-L80
train
62,434
andrenarchy/krypy
krypy/utils.py
find_common_dtype
def find_common_dtype(*args): '''Returns common dtype of numpy and scipy objects. Recognizes ndarray, spmatrix and LinearOperator. All other objects are ignored (most notably None).''' dtypes = [] for arg in args: if type(arg) is numpy.ndarray or \ isspmatrix(arg) or \ ...
python
def find_common_dtype(*args): '''Returns common dtype of numpy and scipy objects. Recognizes ndarray, spmatrix and LinearOperator. All other objects are ignored (most notably None).''' dtypes = [] for arg in args: if type(arg) is numpy.ndarray or \ isspmatrix(arg) or \ ...
[ "def", "find_common_dtype", "(", "*", "args", ")", ":", "dtypes", "=", "[", "]", "for", "arg", "in", "args", ":", "if", "type", "(", "arg", ")", "is", "numpy", ".", "ndarray", "or", "isspmatrix", "(", "arg", ")", "or", "isinstance", "(", "arg", ","...
Returns common dtype of numpy and scipy objects. Recognizes ndarray, spmatrix and LinearOperator. All other objects are ignored (most notably None).
[ "Returns", "common", "dtype", "of", "numpy", "and", "scipy", "objects", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L75-L90
train
62,435
andrenarchy/krypy
krypy/utils.py
inner
def inner(X, Y, ip_B=None): '''Euclidean and non-Euclidean inner product. numpy.vdot only works for vectors and numpy.dot does not use the conjugate transpose. :param X: numpy array with ``shape==(N,m)`` :param Y: numpy array with ``shape==(N,n)`` :param ip_B: (optional) May be one of the foll...
python
def inner(X, Y, ip_B=None): '''Euclidean and non-Euclidean inner product. numpy.vdot only works for vectors and numpy.dot does not use the conjugate transpose. :param X: numpy array with ``shape==(N,m)`` :param Y: numpy array with ``shape==(N,n)`` :param ip_B: (optional) May be one of the foll...
[ "def", "inner", "(", "X", ",", "Y", ",", "ip_B", "=", "None", ")", ":", "if", "ip_B", "is", "None", "or", "isinstance", "(", "ip_B", ",", "IdentityLinearOperator", ")", ":", "return", "numpy", ".", "dot", "(", "X", ".", "T", ".", "conj", "(", ")"...
Euclidean and non-Euclidean inner product. numpy.vdot only works for vectors and numpy.dot does not use the conjugate transpose. :param X: numpy array with ``shape==(N,m)`` :param Y: numpy array with ``shape==(N,n)`` :param ip_B: (optional) May be one of the following * ``None``: Euclidea...
[ "Euclidean", "and", "non", "-", "Euclidean", "inner", "product", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L128-L161
train
62,436
andrenarchy/krypy
krypy/utils.py
norm_squared
def norm_squared(x, Mx=None, inner_product=ip_euclid): '''Compute the norm^2 w.r.t. to a given scalar product.''' assert(len(x.shape) == 2) if Mx is None: rho = inner_product(x, x) else: assert(len(Mx.shape) == 2) rho = inner_product(x, Mx) if rho.shape == (1, 1): if...
python
def norm_squared(x, Mx=None, inner_product=ip_euclid): '''Compute the norm^2 w.r.t. to a given scalar product.''' assert(len(x.shape) == 2) if Mx is None: rho = inner_product(x, x) else: assert(len(Mx.shape) == 2) rho = inner_product(x, Mx) if rho.shape == (1, 1): if...
[ "def", "norm_squared", "(", "x", ",", "Mx", "=", "None", ",", "inner_product", "=", "ip_euclid", ")", ":", "assert", "(", "len", "(", "x", ".", "shape", ")", "==", "2", ")", "if", "Mx", "is", "None", ":", "rho", "=", "inner_product", "(", "x", ",...
Compute the norm^2 w.r.t. to a given scalar product.
[ "Compute", "the", "norm^2", "w", ".", "r", ".", "t", ".", "to", "a", "given", "scalar", "product", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L164-L178
train
62,437
andrenarchy/krypy
krypy/utils.py
get_linearoperator
def get_linearoperator(shape, A, timer=None): """Enhances aslinearoperator if A is None.""" ret = None import scipy.sparse.linalg as scipylinalg if isinstance(A, LinearOperator): ret = A elif A is None: ret = IdentityLinearOperator(shape) elif isinstance(A, numpy.ndarray) or issp...
python
def get_linearoperator(shape, A, timer=None): """Enhances aslinearoperator if A is None.""" ret = None import scipy.sparse.linalg as scipylinalg if isinstance(A, LinearOperator): ret = A elif A is None: ret = IdentityLinearOperator(shape) elif isinstance(A, numpy.ndarray) or issp...
[ "def", "get_linearoperator", "(", "shape", ",", "A", ",", "timer", "=", "None", ")", ":", "ret", "=", "None", "import", "scipy", ".", "sparse", ".", "linalg", "as", "scipylinalg", "if", "isinstance", "(", "A", ",", "LinearOperator", ")", ":", "ret", "=...
Enhances aslinearoperator if A is None.
[ "Enhances", "aslinearoperator", "if", "A", "is", "None", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L207-L236
train
62,438
andrenarchy/krypy
krypy/utils.py
orthonormality
def orthonormality(V, ip_B=None): """Measure orthonormality of given basis. :param V: a matrix :math:`V=[v_1,\ldots,v_n]` with ``shape==(N,n)``. :param ip_B: (optional) the inner product to use, see :py:meth:`inner`. :return: :math:`\\| I_n - \\langle V,V \\rangle \\|_2`. """ return norm(numpy...
python
def orthonormality(V, ip_B=None): """Measure orthonormality of given basis. :param V: a matrix :math:`V=[v_1,\ldots,v_n]` with ``shape==(N,n)``. :param ip_B: (optional) the inner product to use, see :py:meth:`inner`. :return: :math:`\\| I_n - \\langle V,V \\rangle \\|_2`. """ return norm(numpy...
[ "def", "orthonormality", "(", "V", ",", "ip_B", "=", "None", ")", ":", "return", "norm", "(", "numpy", ".", "eye", "(", "V", ".", "shape", "[", "1", "]", ")", "-", "inner", "(", "V", ",", "V", ",", "ip_B", "=", "ip_B", ")", ")" ]
Measure orthonormality of given basis. :param V: a matrix :math:`V=[v_1,\ldots,v_n]` with ``shape==(N,n)``. :param ip_B: (optional) the inner product to use, see :py:meth:`inner`. :return: :math:`\\| I_n - \\langle V,V \\rangle \\|_2`.
[ "Measure", "orthonormality", "of", "given", "basis", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L260-L268
train
62,439
andrenarchy/krypy
krypy/utils.py
arnoldi_res
def arnoldi_res(A, V, H, ip_B=None): """Measure Arnoldi residual. :param A: a linear operator that can be used with scipy's aslinearoperator with ``shape==(N,N)``. :param V: Arnoldi basis matrix with ``shape==(N,n)``. :param H: Hessenberg matrix: either :math:`\\underline{H}_{n-1}` with ``s...
python
def arnoldi_res(A, V, H, ip_B=None): """Measure Arnoldi residual. :param A: a linear operator that can be used with scipy's aslinearoperator with ``shape==(N,N)``. :param V: Arnoldi basis matrix with ``shape==(N,n)``. :param H: Hessenberg matrix: either :math:`\\underline{H}_{n-1}` with ``s...
[ "def", "arnoldi_res", "(", "A", ",", "V", ",", "H", ",", "ip_B", "=", "None", ")", ":", "N", "=", "V", ".", "shape", "[", "0", "]", "invariant", "=", "H", ".", "shape", "[", "0", "]", "==", "H", ".", "shape", "[", "1", "]", "A", "=", "get...
Measure Arnoldi residual. :param A: a linear operator that can be used with scipy's aslinearoperator with ``shape==(N,N)``. :param V: Arnoldi basis matrix with ``shape==(N,n)``. :param H: Hessenberg matrix: either :math:`\\underline{H}_{n-1}` with ``shape==(n,n-1)`` or :math:`H_n` with ``shape=...
[ "Measure", "Arnoldi", "residual", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L271-L292
train
62,440
andrenarchy/krypy
krypy/utils.py
qr
def qr(X, ip_B=None, reorthos=1): """QR factorization with customizable inner product. :param X: array with ``shape==(N,k)`` :param ip_B: (optional) inner product, see :py:meth:`inner`. :param reorthos: (optional) numer of reorthogonalizations. Defaults to 1 (i.e. 2 runs of modified Gram-Schmidt)...
python
def qr(X, ip_B=None, reorthos=1): """QR factorization with customizable inner product. :param X: array with ``shape==(N,k)`` :param ip_B: (optional) inner product, see :py:meth:`inner`. :param reorthos: (optional) numer of reorthogonalizations. Defaults to 1 (i.e. 2 runs of modified Gram-Schmidt)...
[ "def", "qr", "(", "X", ",", "ip_B", "=", "None", ",", "reorthos", "=", "1", ")", ":", "if", "ip_B", "is", "None", "and", "X", ".", "shape", "[", "1", "]", ">", "0", ":", "return", "scipy", ".", "linalg", ".", "qr", "(", "X", ",", "mode", "=...
QR factorization with customizable inner product. :param X: array with ``shape==(N,k)`` :param ip_B: (optional) inner product, see :py:meth:`inner`. :param reorthos: (optional) numer of reorthogonalizations. Defaults to 1 (i.e. 2 runs of modified Gram-Schmidt) which should be enough in most cas...
[ "QR", "factorization", "with", "customizable", "inner", "product", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L648-L675
train
62,441
andrenarchy/krypy
krypy/utils.py
angles
def angles(F, G, ip_B=None, compute_vectors=False): """Principal angles between two subspaces. This algorithm is based on algorithm 6.2 in `Knyazev, Argentati. Principal angles between subspaces in an A-based scalar product: algorithms and perturbation estimates. 2002.` This algorithm can also handle s...
python
def angles(F, G, ip_B=None, compute_vectors=False): """Principal angles between two subspaces. This algorithm is based on algorithm 6.2 in `Knyazev, Argentati. Principal angles between subspaces in an A-based scalar product: algorithms and perturbation estimates. 2002.` This algorithm can also handle s...
[ "def", "angles", "(", "F", ",", "G", ",", "ip_B", "=", "None", ",", "compute_vectors", "=", "False", ")", ":", "# make sure that F.shape[1]>=G.shape[1]", "reverse", "=", "False", "if", "F", ".", "shape", "[", "1", "]", "<", "G", ".", "shape", "[", "1",...
Principal angles between two subspaces. This algorithm is based on algorithm 6.2 in `Knyazev, Argentati. Principal angles between subspaces in an A-based scalar product: algorithms and perturbation estimates. 2002.` This algorithm can also handle small angles (in contrast to the naive cosine-based svd ...
[ "Principal", "angles", "between", "two", "subspaces", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L678-L772
train
62,442
andrenarchy/krypy
krypy/utils.py
gap
def gap(lamda, sigma, mode='individual'): """Compute spectral gap. Useful for eigenvalue/eigenvector bounds. Computes the gap :math:`\delta\geq 0` between two sets of real numbers ``lamda`` and ``sigma``. The gap can be computed in several ways and may not exist, see the ``mode`` parameter. :p...
python
def gap(lamda, sigma, mode='individual'): """Compute spectral gap. Useful for eigenvalue/eigenvector bounds. Computes the gap :math:`\delta\geq 0` between two sets of real numbers ``lamda`` and ``sigma``. The gap can be computed in several ways and may not exist, see the ``mode`` parameter. :p...
[ "def", "gap", "(", "lamda", ",", "sigma", ",", "mode", "=", "'individual'", ")", ":", "# sanitize input", "if", "numpy", ".", "isscalar", "(", "lamda", ")", ":", "lamda", "=", "[", "lamda", "]", "lamda", "=", "numpy", ".", "array", "(", "lamda", ")",...
Compute spectral gap. Useful for eigenvalue/eigenvector bounds. Computes the gap :math:`\delta\geq 0` between two sets of real numbers ``lamda`` and ``sigma``. The gap can be computed in several ways and may not exist, see the ``mode`` parameter. :param lamda: a non-empty set :math:`\Lambda=...
[ "Compute", "spectral", "gap", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1603-L1656
train
62,443
andrenarchy/krypy
krypy/utils.py
bound_perturbed_gmres
def bound_perturbed_gmres(pseudo, p, epsilon, deltas): '''Compute GMRES perturbation bound based on pseudospectrum Computes the GMRES bound from [SifEM13]_. ''' if not numpy.all(numpy.array(deltas) > epsilon): raise ArgumentError('all deltas have to be greater than epsilon') bound = [] ...
python
def bound_perturbed_gmres(pseudo, p, epsilon, deltas): '''Compute GMRES perturbation bound based on pseudospectrum Computes the GMRES bound from [SifEM13]_. ''' if not numpy.all(numpy.array(deltas) > epsilon): raise ArgumentError('all deltas have to be greater than epsilon') bound = [] ...
[ "def", "bound_perturbed_gmres", "(", "pseudo", ",", "p", ",", "epsilon", ",", "deltas", ")", ":", "if", "not", "numpy", ".", "all", "(", "numpy", ".", "array", "(", "deltas", ")", ">", "epsilon", ")", ":", "raise", "ArgumentError", "(", "'all deltas have...
Compute GMRES perturbation bound based on pseudospectrum Computes the GMRES bound from [SifEM13]_.
[ "Compute", "GMRES", "perturbation", "bound", "based", "on", "pseudospectrum" ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1946-L1969
train
62,444
andrenarchy/krypy
krypy/utils.py
get_residual_norms
def get_residual_norms(H, self_adjoint=False): '''Compute relative residual norms from Hessenberg matrix. It is assumed that the initial guess is chosen as zero.''' H = H.copy() n_, n = H.shape y = numpy.eye(n_, 1, dtype=H.dtype) resnorms = [1.] for i in range(n_-1): G = Givens(H[i:...
python
def get_residual_norms(H, self_adjoint=False): '''Compute relative residual norms from Hessenberg matrix. It is assumed that the initial guess is chosen as zero.''' H = H.copy() n_, n = H.shape y = numpy.eye(n_, 1, dtype=H.dtype) resnorms = [1.] for i in range(n_-1): G = Givens(H[i:...
[ "def", "get_residual_norms", "(", "H", ",", "self_adjoint", "=", "False", ")", ":", "H", "=", "H", ".", "copy", "(", ")", "n_", ",", "n", "=", "H", ".", "shape", "y", "=", "numpy", ".", "eye", "(", "n_", ",", "1", ",", "dtype", "=", "H", ".",...
Compute relative residual norms from Hessenberg matrix. It is assumed that the initial guess is chosen as zero.
[ "Compute", "relative", "residual", "norms", "from", "Hessenberg", "matrix", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L2037-L2055
train
62,445
andrenarchy/krypy
krypy/utils.py
House.apply
def apply(self, x): """Apply Householder transformation to vector x. Applies the Householder transformation efficiently to the given vector. """ # make sure that x is a (N,*) matrix if len(x.shape) != 2: raise ArgumentError('x is not a matrix of shape (N,*)') ...
python
def apply(self, x): """Apply Householder transformation to vector x. Applies the Householder transformation efficiently to the given vector. """ # make sure that x is a (N,*) matrix if len(x.shape) != 2: raise ArgumentError('x is not a matrix of shape (N,*)') ...
[ "def", "apply", "(", "self", ",", "x", ")", ":", "# make sure that x is a (N,*) matrix", "if", "len", "(", "x", ".", "shape", ")", "!=", "2", ":", "raise", "ArgumentError", "(", "'x is not a matrix of shape (N,*)'", ")", "if", "self", ".", "beta", "==", "0",...
Apply Householder transformation to vector x. Applies the Householder transformation efficiently to the given vector.
[ "Apply", "Householder", "transformation", "to", "vector", "x", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L342-L352
train
62,446
andrenarchy/krypy
krypy/utils.py
House.matrix
def matrix(self): """Build matrix representation of Householder transformation. Builds the matrix representation :math:`H = I - \\beta vv^*`. **Use with care!** This routine may be helpful for testing purposes but should not be used in production codes for high dimensions since...
python
def matrix(self): """Build matrix representation of Householder transformation. Builds the matrix representation :math:`H = I - \\beta vv^*`. **Use with care!** This routine may be helpful for testing purposes but should not be used in production codes for high dimensions since...
[ "def", "matrix", "(", "self", ")", ":", "n", "=", "self", ".", "v", ".", "shape", "[", "0", "]", "return", "numpy", ".", "eye", "(", "n", ",", "n", ")", "-", "self", ".", "beta", "*", "numpy", ".", "dot", "(", "self", ".", "v", ",", "self",...
Build matrix representation of Householder transformation. Builds the matrix representation :math:`H = I - \\beta vv^*`. **Use with care!** This routine may be helpful for testing purposes but should not be used in production codes for high dimensions since the resulting matrix...
[ "Build", "matrix", "representation", "of", "Householder", "transformation", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L354-L365
train
62,447
andrenarchy/krypy
krypy/utils.py
Projection._apply
def _apply(self, a, return_Ya=False): r'''Single application of the projection. :param a: array with ``a.shape==(N,m)``. :param return_inner: (optional) should the inner product :math:`\langle Y,a\rangle` be returned? :return: * :math:`P_{\mathcal{X},\mathcal{Y}^\pe...
python
def _apply(self, a, return_Ya=False): r'''Single application of the projection. :param a: array with ``a.shape==(N,m)``. :param return_inner: (optional) should the inner product :math:`\langle Y,a\rangle` be returned? :return: * :math:`P_{\mathcal{X},\mathcal{Y}^\pe...
[ "def", "_apply", "(", "self", ",", "a", ",", "return_Ya", "=", "False", ")", ":", "# is projection the zero operator?", "if", "self", ".", "V", ".", "shape", "[", "1", "]", "==", "0", ":", "Pa", "=", "numpy", ".", "zeros", "(", "a", ".", "shape", "...
r'''Single application of the projection. :param a: array with ``a.shape==(N,m)``. :param return_inner: (optional) should the inner product :math:`\langle Y,a\rangle` be returned? :return: * :math:`P_{\mathcal{X},\mathcal{Y}^\perp} a = X \langle Y,X\rangle^{-1} ...
[ "r", "Single", "application", "of", "the", "projection", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L490-L520
train
62,448
andrenarchy/krypy
krypy/utils.py
Projection._apply_adj
def _apply_adj(self, a): # is projection the zero operator? if self.V.shape[1] == 0: return numpy.zeros(a.shape) '''Single application of the adjoint projection.''' c = inner(self.V, a, ip_B=self.ip_B) if self.Q is not None and self.R is not None: c = self...
python
def _apply_adj(self, a): # is projection the zero operator? if self.V.shape[1] == 0: return numpy.zeros(a.shape) '''Single application of the adjoint projection.''' c = inner(self.V, a, ip_B=self.ip_B) if self.Q is not None and self.R is not None: c = self...
[ "def", "_apply_adj", "(", "self", ",", "a", ")", ":", "# is projection the zero operator?", "if", "self", ".", "V", ".", "shape", "[", "1", "]", "==", "0", ":", "return", "numpy", ".", "zeros", "(", "a", ".", "shape", ")", "c", "=", "inner", "(", "...
Single application of the adjoint projection.
[ "Single", "application", "of", "the", "adjoint", "projection", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L522-L531
train
62,449
andrenarchy/krypy
krypy/utils.py
Projection.apply
def apply(self, a, return_Ya=False): r"""Apply the projection to an array. The computation is carried out without explicitly forming the matrix corresponding to the projection (which would be an array with ``shape==(N,N)``). See also :py:meth:`_apply`. """ # is ...
python
def apply(self, a, return_Ya=False): r"""Apply the projection to an array. The computation is carried out without explicitly forming the matrix corresponding to the projection (which would be an array with ``shape==(N,N)``). See also :py:meth:`_apply`. """ # is ...
[ "def", "apply", "(", "self", ",", "a", ",", "return_Ya", "=", "False", ")", ":", "# is projection the zero operator?", "if", "self", ".", "V", ".", "shape", "[", "1", "]", "==", "0", ":", "Pa", "=", "numpy", ".", "zeros", "(", "a", ".", "shape", ")...
r"""Apply the projection to an array. The computation is carried out without explicitly forming the matrix corresponding to the projection (which would be an array with ``shape==(N,N)``). See also :py:meth:`_apply`.
[ "r", "Apply", "the", "projection", "to", "an", "array", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L533-L558
train
62,450
andrenarchy/krypy
krypy/utils.py
Projection.apply_complement
def apply_complement(self, a, return_Ya=False): """Apply the complementary projection to an array. :param z: array with ``shape==(N,m)``. :return: :math:`P_{\\mathcal{Y}^\\perp,\\mathcal{X}}z = z - P_{\\mathcal{X},\\mathcal{Y}^\\perp} z`. """ # is projection the zer...
python
def apply_complement(self, a, return_Ya=False): """Apply the complementary projection to an array. :param z: array with ``shape==(N,m)``. :return: :math:`P_{\\mathcal{Y}^\\perp,\\mathcal{X}}z = z - P_{\\mathcal{X},\\mathcal{Y}^\\perp} z`. """ # is projection the zer...
[ "def", "apply_complement", "(", "self", ",", "a", ",", "return_Ya", "=", "False", ")", ":", "# is projection the zero operator? --> complement is identity", "if", "self", ".", "V", ".", "shape", "[", "1", "]", "==", "0", ":", "if", "return_Ya", ":", "return", ...
Apply the complementary projection to an array. :param z: array with ``shape==(N,m)``. :return: :math:`P_{\\mathcal{Y}^\\perp,\\mathcal{X}}z = z - P_{\\mathcal{X},\\mathcal{Y}^\\perp} z`.
[ "Apply", "the", "complementary", "projection", "to", "an", "array", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L571-L594
train
62,451
andrenarchy/krypy
krypy/utils.py
Timings.get
def get(self, key): '''Return timings for `key`. Returns 0 if not present.''' if key in self and len(self[key]) > 0: return min(self[key]) else: return 0
python
def get(self, key): '''Return timings for `key`. Returns 0 if not present.''' if key in self and len(self[key]) > 0: return min(self[key]) else: return 0
[ "def", "get", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", "and", "len", "(", "self", "[", "key", "]", ")", ">", "0", ":", "return", "min", "(", "self", "[", "key", "]", ")", "else", ":", "return", "0" ]
Return timings for `key`. Returns 0 if not present.
[ "Return", "timings", "for", "key", ".", "Returns", "0", "if", "not", "present", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1304-L1309
train
62,452
andrenarchy/krypy
krypy/utils.py
Timings.get_ops
def get_ops(self, ops): '''Return timings for dictionary ops holding the operation names as keys and the number of applications as values.''' time = 0. for op, count in ops.items(): time += self.get(op) * count return time
python
def get_ops(self, ops): '''Return timings for dictionary ops holding the operation names as keys and the number of applications as values.''' time = 0. for op, count in ops.items(): time += self.get(op) * count return time
[ "def", "get_ops", "(", "self", ",", "ops", ")", ":", "time", "=", "0.", "for", "op", ",", "count", "in", "ops", ".", "items", "(", ")", ":", "time", "+=", "self", ".", "get", "(", "op", ")", "*", "count", "return", "time" ]
Return timings for dictionary ops holding the operation names as keys and the number of applications as values.
[ "Return", "timings", "for", "dictionary", "ops", "holding", "the", "operation", "names", "as", "keys", "and", "the", "number", "of", "applications", "as", "values", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1311-L1317
train
62,453
andrenarchy/krypy
krypy/utils.py
Intervals.min_pos
def min_pos(self): '''Returns minimal positive value or None.''' if self.__len__() == 0: return ArgumentError('empty set has no minimum positive value.') if self.contains(0): return None positive = [interval for interval in self.intervals if in...
python
def min_pos(self): '''Returns minimal positive value or None.''' if self.__len__() == 0: return ArgumentError('empty set has no minimum positive value.') if self.contains(0): return None positive = [interval for interval in self.intervals if in...
[ "def", "min_pos", "(", "self", ")", ":", "if", "self", ".", "__len__", "(", ")", "==", "0", ":", "return", "ArgumentError", "(", "'empty set has no minimum positive value.'", ")", "if", "self", ".", "contains", "(", "0", ")", ":", "return", "None", "positi...
Returns minimal positive value or None.
[ "Returns", "minimal", "positive", "value", "or", "None", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1751-L1761
train
62,454
andrenarchy/krypy
krypy/utils.py
Intervals.max_neg
def max_neg(self): '''Returns maximum negative value or None.''' if self.__len__() == 0: return ArgumentError('empty set has no maximum negative value.') if self.contains(0): return None negative = [interval for interval in self.intervals if in...
python
def max_neg(self): '''Returns maximum negative value or None.''' if self.__len__() == 0: return ArgumentError('empty set has no maximum negative value.') if self.contains(0): return None negative = [interval for interval in self.intervals if in...
[ "def", "max_neg", "(", "self", ")", ":", "if", "self", ".", "__len__", "(", ")", "==", "0", ":", "return", "ArgumentError", "(", "'empty set has no maximum negative value.'", ")", "if", "self", ".", "contains", "(", "0", ")", ":", "return", "None", "negati...
Returns maximum negative value or None.
[ "Returns", "maximum", "negative", "value", "or", "None", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1763-L1773
train
62,455
andrenarchy/krypy
krypy/utils.py
Intervals.min_abs
def min_abs(self): '''Returns minimum absolute value.''' if self.__len__() == 0: return ArgumentError('empty set has no minimum absolute value.') if self.contains(0): return 0 return numpy.min([numpy.abs(val) for val in [self.max_neg(), s...
python
def min_abs(self): '''Returns minimum absolute value.''' if self.__len__() == 0: return ArgumentError('empty set has no minimum absolute value.') if self.contains(0): return 0 return numpy.min([numpy.abs(val) for val in [self.max_neg(), s...
[ "def", "min_abs", "(", "self", ")", ":", "if", "self", ".", "__len__", "(", ")", "==", "0", ":", "return", "ArgumentError", "(", "'empty set has no minimum absolute value.'", ")", "if", "self", ".", "contains", "(", "0", ")", ":", "return", "0", "return", ...
Returns minimum absolute value.
[ "Returns", "minimum", "absolute", "value", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1775-L1783
train
62,456
andrenarchy/krypy
krypy/utils.py
Intervals.max_abs
def max_abs(self): '''Returns maximum absolute value.''' if self.__len__() == 0: return ArgumentError('empty set has no maximum absolute value.') return numpy.max(numpy.abs([self.max(), self.min()]))
python
def max_abs(self): '''Returns maximum absolute value.''' if self.__len__() == 0: return ArgumentError('empty set has no maximum absolute value.') return numpy.max(numpy.abs([self.max(), self.min()]))
[ "def", "max_abs", "(", "self", ")", ":", "if", "self", ".", "__len__", "(", ")", "==", "0", ":", "return", "ArgumentError", "(", "'empty set has no maximum absolute value.'", ")", "return", "numpy", ".", "max", "(", "numpy", ".", "abs", "(", "[", "self", ...
Returns maximum absolute value.
[ "Returns", "maximum", "absolute", "value", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1785-L1789
train
62,457
andrenarchy/krypy
krypy/utils.py
BoundMinres.get_step
def get_step(self, tol): '''Return step at which bound falls below tolerance. ''' return 2 * numpy.log(tol/2.)/numpy.log(self.base)
python
def get_step(self, tol): '''Return step at which bound falls below tolerance. ''' return 2 * numpy.log(tol/2.)/numpy.log(self.base)
[ "def", "get_step", "(", "self", ",", "tol", ")", ":", "return", "2", "*", "numpy", ".", "log", "(", "tol", "/", "2.", ")", "/", "numpy", ".", "log", "(", "self", ".", "base", ")" ]
Return step at which bound falls below tolerance.
[ "Return", "step", "at", "which", "bound", "falls", "below", "tolerance", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1941-L1943
train
62,458
andrenarchy/krypy
krypy/utils.py
NormalizedRootsPolynomial.minmax_candidates
def minmax_candidates(self): '''Get points where derivative is zero. Useful for computing the extrema of the polynomial over an interval if the polynomial has real roots. In this case, the maximum is attained for one of the interval endpoints or a point from the result of this f...
python
def minmax_candidates(self): '''Get points where derivative is zero. Useful for computing the extrema of the polynomial over an interval if the polynomial has real roots. In this case, the maximum is attained for one of the interval endpoints or a point from the result of this f...
[ "def", "minmax_candidates", "(", "self", ")", ":", "from", "numpy", ".", "polynomial", "import", "Polynomial", "as", "P", "p", "=", "P", ".", "fromroots", "(", "self", ".", "roots", ")", "return", "p", ".", "deriv", "(", "1", ")", ".", "roots", "(", ...
Get points where derivative is zero. Useful for computing the extrema of the polynomial over an interval if the polynomial has real roots. In this case, the maximum is attained for one of the interval endpoints or a point from the result of this function that is contained in the interva...
[ "Get", "points", "where", "derivative", "is", "zero", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L1991-L2001
train
62,459
dslackw/alarm
alarm/main.py
ALARM.errors
def errors(self): """ Check for usage errors """ try: self.now = datetime.datetime.now() if len(self.alarm_day) < 2 or len(self.alarm_day) > 2: print("error: day: usage 'DD' such us '0%s' not '%s'" % ( self.alarm_day, self.alarm...
python
def errors(self): """ Check for usage errors """ try: self.now = datetime.datetime.now() if len(self.alarm_day) < 2 or len(self.alarm_day) > 2: print("error: day: usage 'DD' such us '0%s' not '%s'" % ( self.alarm_day, self.alarm...
[ "def", "errors", "(", "self", ")", ":", "try", ":", "self", ".", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "if", "len", "(", "self", ".", "alarm_day", ")", "<", "2", "or", "len", "(", "self", ".", "alarm_day", ")", ">", "2"...
Check for usage errors
[ "Check", "for", "usage", "errors" ]
6c6a6eea372057094862d5c1b7d4d7b38b453bfc
https://github.com/dslackw/alarm/blob/6c6a6eea372057094862d5c1b7d4d7b38b453bfc/alarm/main.py#L140-L175
train
62,460
andrenarchy/krypy
krypy/recycling/factories.py
RitzFactory._get_best_subset
def _get_best_subset(self, ritz): '''Return candidate set with smallest goal functional.''' # (c,\omega(c)) for all considered subsets c overall_evaluations = {} def evaluate(_subset, _evaluations): try: _evaluations[_subset] = \ self.sub...
python
def _get_best_subset(self, ritz): '''Return candidate set with smallest goal functional.''' # (c,\omega(c)) for all considered subsets c overall_evaluations = {} def evaluate(_subset, _evaluations): try: _evaluations[_subset] = \ self.sub...
[ "def", "_get_best_subset", "(", "self", ",", "ritz", ")", ":", "# (c,\\omega(c)) for all considered subsets c", "overall_evaluations", "=", "{", "}", "def", "evaluate", "(", "_subset", ",", "_evaluations", ")", ":", "try", ":", "_evaluations", "[", "_subset", "]",...
Return candidate set with smallest goal functional.
[ "Return", "candidate", "set", "with", "smallest", "goal", "functional", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/recycling/factories.py#L53-L136
train
62,461
click-contrib/click-default-group
click_default_group.py
DefaultGroup.set_default_command
def set_default_command(self, command): """Sets a command function as the default command.""" cmd_name = command.name self.add_command(command) self.default_cmd_name = cmd_name
python
def set_default_command(self, command): """Sets a command function as the default command.""" cmd_name = command.name self.add_command(command) self.default_cmd_name = cmd_name
[ "def", "set_default_command", "(", "self", ",", "command", ")", ":", "cmd_name", "=", "command", ".", "name", "self", ".", "add_command", "(", "command", ")", "self", ".", "default_cmd_name", "=", "cmd_name" ]
Sets a command function as the default command.
[ "Sets", "a", "command", "function", "as", "the", "default", "command", "." ]
70427e5dabc04c86c3fb74b2c950fec857d6a213
https://github.com/click-contrib/click-default-group/blob/70427e5dabc04c86c3fb74b2c950fec857d6a213/click_default_group.py#L74-L78
train
62,462
andrenarchy/krypy
krypy/linsys.py
LinearSystem.get_residual
def get_residual(self, z, compute_norm=False): r'''Compute residual. For a given :math:`z\in\mathbb{C}^N`, the residual .. math:: r = M M_l ( b - A z ) is computed. If ``compute_norm == True``, then also the absolute residual norm .. math:: \| M ...
python
def get_residual(self, z, compute_norm=False): r'''Compute residual. For a given :math:`z\in\mathbb{C}^N`, the residual .. math:: r = M M_l ( b - A z ) is computed. If ``compute_norm == True``, then also the absolute residual norm .. math:: \| M ...
[ "def", "get_residual", "(", "self", ",", "z", ",", "compute_norm", "=", "False", ")", ":", "if", "z", "is", "None", ":", "if", "compute_norm", ":", "return", "self", ".", "MMlb", ",", "self", ".", "Mlb", ",", "self", ".", "MMlb_norm", "return", "self...
r'''Compute residual. For a given :math:`z\in\mathbb{C}^N`, the residual .. math:: r = M M_l ( b - A z ) is computed. If ``compute_norm == True``, then also the absolute residual norm .. math:: \| M M_l (b-Az)\|_{M^{-1}} is computed. :p...
[ "r", "Compute", "residual", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/linsys.py#L123-L154
train
62,463
andrenarchy/krypy
krypy/linsys.py
LinearSystem.get_ip_Minv_B
def get_ip_Minv_B(self): '''Returns the inner product that is implicitly used with the positive definite preconditioner ``M``.''' if not isinstance(self.M, utils.IdentityLinearOperator): if isinstance(self.Minv, utils.IdentityLinearOperator): raise utils.ArgumentError...
python
def get_ip_Minv_B(self): '''Returns the inner product that is implicitly used with the positive definite preconditioner ``M``.''' if not isinstance(self.M, utils.IdentityLinearOperator): if isinstance(self.Minv, utils.IdentityLinearOperator): raise utils.ArgumentError...
[ "def", "get_ip_Minv_B", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "M", ",", "utils", ".", "IdentityLinearOperator", ")", ":", "if", "isinstance", "(", "self", ".", "Minv", ",", "utils", ".", "IdentityLinearOperator", ")", ":", "...
Returns the inner product that is implicitly used with the positive definite preconditioner ``M``.
[ "Returns", "the", "inner", "product", "that", "is", "implicitly", "used", "with", "the", "positive", "definite", "preconditioner", "M", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/linsys.py#L156-L168
train
62,464
andrenarchy/krypy
krypy/linsys.py
_KrylovSolver._get_xk
def _get_xk(self, yk): '''Compute approximate solution from initial guess and approximate solution of the preconditioned linear system.''' if yk is not None: return self.x0 + self.linear_system.Mr * yk return self.x0
python
def _get_xk(self, yk): '''Compute approximate solution from initial guess and approximate solution of the preconditioned linear system.''' if yk is not None: return self.x0 + self.linear_system.Mr * yk return self.x0
[ "def", "_get_xk", "(", "self", ",", "yk", ")", ":", "if", "yk", "is", "not", "None", ":", "return", "self", ".", "x0", "+", "self", ".", "linear_system", ".", "Mr", "*", "yk", "return", "self", ".", "x0" ]
Compute approximate solution from initial guess and approximate solution of the preconditioned linear system.
[ "Compute", "approximate", "solution", "from", "initial", "guess", "and", "approximate", "solution", "of", "the", "preconditioned", "linear", "system", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/linsys.py#L392-L397
train
62,465
andrenarchy/krypy
krypy/linsys.py
_KrylovSolver._finalize_iteration
def _finalize_iteration(self, yk, resnorm): '''Compute solution, error norm and residual norm if required. :return: the residual norm or ``None``. ''' self.xk = None # compute error norm if asked for if self.linear_system.exact_solution is not None: self.xk =...
python
def _finalize_iteration(self, yk, resnorm): '''Compute solution, error norm and residual norm if required. :return: the residual norm or ``None``. ''' self.xk = None # compute error norm if asked for if self.linear_system.exact_solution is not None: self.xk =...
[ "def", "_finalize_iteration", "(", "self", ",", "yk", ",", "resnorm", ")", ":", "self", ".", "xk", "=", "None", "# compute error norm if asked for", "if", "self", ".", "linear_system", ".", "exact_solution", "is", "not", "None", ":", "self", ".", "xk", "=", ...
Compute solution, error norm and residual norm if required. :return: the residual norm or ``None``.
[ "Compute", "solution", "error", "norm", "and", "residual", "norm", "if", "required", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/linsys.py#L399-L451
train
62,466
andrenarchy/krypy
krypy/linsys.py
Gmres.operations
def operations(nsteps): '''Returns the number of operations needed for nsteps of GMRES''' return {'A': 1 + nsteps, 'M': 2 + nsteps, 'Ml': 2 + nsteps, 'Mr': 1 + nsteps, 'ip_B': 2 + nsteps + nsteps*(nsteps+1)/2, 'axpy': 4 + 2*...
python
def operations(nsteps): '''Returns the number of operations needed for nsteps of GMRES''' return {'A': 1 + nsteps, 'M': 2 + nsteps, 'Ml': 2 + nsteps, 'Mr': 1 + nsteps, 'ip_B': 2 + nsteps + nsteps*(nsteps+1)/2, 'axpy': 4 + 2*...
[ "def", "operations", "(", "nsteps", ")", ":", "return", "{", "'A'", ":", "1", "+", "nsteps", ",", "'M'", ":", "2", "+", "nsteps", ",", "'Ml'", ":", "2", "+", "nsteps", ",", "'Mr'", ":", "1", "+", "nsteps", ",", "'ip_B'", ":", "2", "+", "nsteps"...
Returns the number of operations needed for nsteps of GMRES
[ "Returns", "the", "number", "of", "operations", "needed", "for", "nsteps", "of", "GMRES" ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/linsys.py#L897-L905
train
62,467
andrenarchy/krypy
krypy/recycling/linsys.py
_RecyclingSolver.solve
def solve(self, linear_system, vector_factory=None, *args, **kwargs): '''Solve the given linear system with recycling. The provided `vector_factory` determines which vectors are used for deflation. :param linear_system: the :py:class:`~krypy.linsys.LinearSys...
python
def solve(self, linear_system, vector_factory=None, *args, **kwargs): '''Solve the given linear system with recycling. The provided `vector_factory` determines which vectors are used for deflation. :param linear_system: the :py:class:`~krypy.linsys.LinearSys...
[ "def", "solve", "(", "self", ",", "linear_system", ",", "vector_factory", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# replace linear_system with equivalent TimedLinearSystem on demand", "if", "not", "isinstance", "(", "linear_system", ",", ...
Solve the given linear system with recycling. The provided `vector_factory` determines which vectors are used for deflation. :param linear_system: the :py:class:`~krypy.linsys.LinearSystem` that is about to be solved. :param vector_factory: (optional) see description in const...
[ "Solve", "the", "given", "linear", "system", "with", "recycling", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/recycling/linsys.py#L52-L111
train
62,468
getdnsapi/getdns-python-bindings
examples/checkdanecert.py
compute_hash
def compute_hash(func, string): """compute hash of string using given hash function""" h = func() h.update(string) return h.hexdigest()
python
def compute_hash(func, string): """compute hash of string using given hash function""" h = func() h.update(string) return h.hexdigest()
[ "def", "compute_hash", "(", "func", ",", "string", ")", ":", "h", "=", "func", "(", ")", "h", ".", "update", "(", "string", ")", "return", "h", ".", "hexdigest", "(", ")" ]
compute hash of string using given hash function
[ "compute", "hash", "of", "string", "using", "given", "hash", "function" ]
6a094f7fcc148afaaa822152f9037ca9fa4ada6c
https://github.com/getdnsapi/getdns-python-bindings/blob/6a094f7fcc148afaaa822152f9037ca9fa4ada6c/examples/checkdanecert.py#L25-L29
train
62,469
reincubate/deviceidentifier-py
deviceidentifier/util/local.py
get_local_serial
def get_local_serial(): ''' Retrieves the serial number from the executing host. For example, 'C02NT43PFY14' ''' return [x for x in [subprocess.Popen("system_profiler SPHardwareDataType |grep -v tray |awk '/Serial/ {print $4}'", shell=True, stdout=subprocess.PIPE).communicate()[0].strip()] if x]
python
def get_local_serial(): ''' Retrieves the serial number from the executing host. For example, 'C02NT43PFY14' ''' return [x for x in [subprocess.Popen("system_profiler SPHardwareDataType |grep -v tray |awk '/Serial/ {print $4}'", shell=True, stdout=subprocess.PIPE).communicate()[0].strip()] if x]
[ "def", "get_local_serial", "(", ")", ":", "return", "[", "x", "for", "x", "in", "[", "subprocess", ".", "Popen", "(", "\"system_profiler SPHardwareDataType |grep -v tray |awk '/Serial/ {print $4}'\"", ",", "shell", "=", "True", ",", "stdout", "=", "subprocess", ".",...
Retrieves the serial number from the executing host. For example, 'C02NT43PFY14'
[ "Retrieves", "the", "serial", "number", "from", "the", "executing", "host", ".", "For", "example", "C02NT43PFY14" ]
e6ddf73c6ab3b26a703bca8619fc999dfeaeb5d2
https://github.com/reincubate/deviceidentifier-py/blob/e6ddf73c6ab3b26a703bca8619fc999dfeaeb5d2/deviceidentifier/util/local.py#L4-L8
train
62,470
andrenarchy/krypy
krypy/recycling/evaluators.py
RitzApriori._estimate_eval_intervals
def _estimate_eval_intervals(ritz, indices, indices_remaining, eps_min=0, eps_max=0, eps_res=None): '''Estimate evals based on eval inclusion theorem + heuristic. :returns: Intervals object with inclusion...
python
def _estimate_eval_intervals(ritz, indices, indices_remaining, eps_min=0, eps_max=0, eps_res=None): '''Estimate evals based on eval inclusion theorem + heuristic. :returns: Intervals object with inclusion...
[ "def", "_estimate_eval_intervals", "(", "ritz", ",", "indices", ",", "indices_remaining", ",", "eps_min", "=", "0", ",", "eps_max", "=", "0", ",", "eps_res", "=", "None", ")", ":", "if", "len", "(", "indices", ")", "==", "0", ":", "return", "utils", "....
Estimate evals based on eval inclusion theorem + heuristic. :returns: Intervals object with inclusion intervals for eigenvalues
[ "Estimate", "evals", "based", "on", "eval", "inclusion", "theorem", "+", "heuristic", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/recycling/evaluators.py#L76-L135
train
62,471
andrenarchy/krypy
krypy/deflation.py
ObliqueProjection.correct
def correct(self, z): '''Correct the given approximate solution ``z`` with respect to the linear system ``linear_system`` and the deflation space defined by ``U``.''' c = self.linear_system.Ml*( self.linear_system.b - self.linear_system.A*z) c = utils.inner(self.W, c,...
python
def correct(self, z): '''Correct the given approximate solution ``z`` with respect to the linear system ``linear_system`` and the deflation space defined by ``U``.''' c = self.linear_system.Ml*( self.linear_system.b - self.linear_system.A*z) c = utils.inner(self.W, c,...
[ "def", "correct", "(", "self", ",", "z", ")", ":", "c", "=", "self", ".", "linear_system", ".", "Ml", "*", "(", "self", ".", "linear_system", ".", "b", "-", "self", ".", "linear_system", ".", "A", "*", "z", ")", "c", "=", "utils", ".", "inner", ...
Correct the given approximate solution ``z`` with respect to the linear system ``linear_system`` and the deflation space defined by ``U``.
[ "Correct", "the", "given", "approximate", "solution", "z", "with", "respect", "to", "the", "linear", "system", "linear_system", "and", "the", "deflation", "space", "defined", "by", "U", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L52-L63
train
62,472
andrenarchy/krypy
krypy/deflation.py
_DeflationMixin._apply_projection
def _apply_projection(self, Av): '''Apply the projection and store inner product. :param v: the vector resulting from an application of :math:`M_lAM_r` to the current Arnoldi vector. (CG needs special treatment, here). ''' PAv, UAv = self.projection.apply_complement(Av, return...
python
def _apply_projection(self, Av): '''Apply the projection and store inner product. :param v: the vector resulting from an application of :math:`M_lAM_r` to the current Arnoldi vector. (CG needs special treatment, here). ''' PAv, UAv = self.projection.apply_complement(Av, return...
[ "def", "_apply_projection", "(", "self", ",", "Av", ")", ":", "PAv", ",", "UAv", "=", "self", ".", "projection", ".", "apply_complement", "(", "Av", ",", "return_Ya", "=", "True", ")", "self", ".", "C", "=", "numpy", ".", "c_", "[", "self", ".", "C...
Apply the projection and store inner product. :param v: the vector resulting from an application of :math:`M_lAM_r` to the current Arnoldi vector. (CG needs special treatment, here).
[ "Apply", "the", "projection", "and", "store", "inner", "product", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L129-L137
train
62,473
andrenarchy/krypy
krypy/deflation.py
_DeflationMixin._get_initial_residual
def _get_initial_residual(self, x0): '''Return the projected initial residual. Returns :math:`MPM_l(b-Ax_0)`. ''' if x0 is None: Mlr = self.linear_system.Mlb else: r = self.linear_system.b - self.linear_system.A*x0 Mlr = self.linear_system.Ml*...
python
def _get_initial_residual(self, x0): '''Return the projected initial residual. Returns :math:`MPM_l(b-Ax_0)`. ''' if x0 is None: Mlr = self.linear_system.Mlb else: r = self.linear_system.b - self.linear_system.A*x0 Mlr = self.linear_system.Ml*...
[ "def", "_get_initial_residual", "(", "self", ",", "x0", ")", ":", "if", "x0", "is", "None", ":", "Mlr", "=", "self", ".", "linear_system", ".", "Mlb", "else", ":", "r", "=", "self", ".", "linear_system", ".", "b", "-", "self", ".", "linear_system", "...
Return the projected initial residual. Returns :math:`MPM_l(b-Ax_0)`.
[ "Return", "the", "projected", "initial", "residual", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L139-L153
train
62,474
andrenarchy/krypy
krypy/deflation.py
_DeflationMixin.estimate_time
def estimate_time(self, nsteps, ndefl, deflweight=1.0): '''Estimate time needed to run nsteps iterations with deflation Uses timings from :py:attr:`linear_system` if it is an instance of :py:class:`~krypy.linsys.TimedLinearSystem`. Otherwise, an :py:class:`~krypy.utils.OtherError` ...
python
def estimate_time(self, nsteps, ndefl, deflweight=1.0): '''Estimate time needed to run nsteps iterations with deflation Uses timings from :py:attr:`linear_system` if it is an instance of :py:class:`~krypy.linsys.TimedLinearSystem`. Otherwise, an :py:class:`~krypy.utils.OtherError` ...
[ "def", "estimate_time", "(", "self", ",", "nsteps", ",", "ndefl", ",", "deflweight", "=", "1.0", ")", ":", "# get ops for nsteps of this solver", "solver_ops", "=", "self", ".", "operations", "(", "nsteps", ")", "# define ops for deflation setup + application with ndefl...
Estimate time needed to run nsteps iterations with deflation Uses timings from :py:attr:`linear_system` if it is an instance of :py:class:`~krypy.linsys.TimedLinearSystem`. Otherwise, an :py:class:`~krypy.utils.OtherError` is raised. :param nsteps: number of iterations. ...
[ "Estimate", "time", "needed", "to", "run", "nsteps", "iterations", "with", "deflation" ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L182-L220
train
62,475
andrenarchy/krypy
krypy/deflation.py
Ritz.get_vectors
def get_vectors(self, indices=None): '''Compute Ritz vectors.''' H_ = self._deflated_solver.H (n_, n) = H_.shape coeffs = self.coeffs if indices is None else self.coeffs[:, indices] return numpy.c_[self._deflated_solver.V[:, :n], self._deflated_solver.proj...
python
def get_vectors(self, indices=None): '''Compute Ritz vectors.''' H_ = self._deflated_solver.H (n_, n) = H_.shape coeffs = self.coeffs if indices is None else self.coeffs[:, indices] return numpy.c_[self._deflated_solver.V[:, :n], self._deflated_solver.proj...
[ "def", "get_vectors", "(", "self", ",", "indices", "=", "None", ")", ":", "H_", "=", "self", ".", "_deflated_solver", ".", "H", "(", "n_", ",", "n", ")", "=", "H_", ".", "shape", "coeffs", "=", "self", ".", "coeffs", "if", "indices", "is", "None", ...
Compute Ritz vectors.
[ "Compute", "Ritz", "vectors", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L808-L814
train
62,476
andrenarchy/krypy
krypy/deflation.py
Ritz.get_explicit_residual
def get_explicit_residual(self, indices=None): '''Explicitly computes the Ritz residual.''' ritz_vecs = self.get_vectors(indices) return self._deflated_solver.linear_system.MlAMr * ritz_vecs \ - ritz_vecs * self.values
python
def get_explicit_residual(self, indices=None): '''Explicitly computes the Ritz residual.''' ritz_vecs = self.get_vectors(indices) return self._deflated_solver.linear_system.MlAMr * ritz_vecs \ - ritz_vecs * self.values
[ "def", "get_explicit_residual", "(", "self", ",", "indices", "=", "None", ")", ":", "ritz_vecs", "=", "self", ".", "get_vectors", "(", "indices", ")", "return", "self", ".", "_deflated_solver", ".", "linear_system", ".", "MlAMr", "*", "ritz_vecs", "-", "ritz...
Explicitly computes the Ritz residual.
[ "Explicitly", "computes", "the", "Ritz", "residual", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L816-L820
train
62,477
andrenarchy/krypy
krypy/deflation.py
Ritz.get_explicit_resnorms
def get_explicit_resnorms(self, indices=None): '''Explicitly computes the Ritz residual norms.''' res = self.get_explicit_residual(indices) # apply preconditioner linear_system = self._deflated_solver.linear_system Mres = linear_system.M * res # compute norms re...
python
def get_explicit_resnorms(self, indices=None): '''Explicitly computes the Ritz residual norms.''' res = self.get_explicit_residual(indices) # apply preconditioner linear_system = self._deflated_solver.linear_system Mres = linear_system.M * res # compute norms re...
[ "def", "get_explicit_resnorms", "(", "self", ",", "indices", "=", "None", ")", ":", "res", "=", "self", ".", "get_explicit_residual", "(", "indices", ")", "# apply preconditioner", "linear_system", "=", "self", ".", "_deflated_solver", ".", "linear_system", "Mres"...
Explicitly computes the Ritz residual norms.
[ "Explicitly", "computes", "the", "Ritz", "residual", "norms", "." ]
4883ec9a61d64ea56489e15c35cc40f0633ab2f1
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/deflation.py#L822-L835
train
62,478
wrobstory/bearcart
bearcart/bearcart.py
Chart.transform_data
def transform_data(self, data): '''Transform Pandas Timeseries into JSON format Parameters ---------- data: DataFrame or Series Pandas DataFrame or Series must have datetime index Returns ------- JSON to object.json_data Example ----...
python
def transform_data(self, data): '''Transform Pandas Timeseries into JSON format Parameters ---------- data: DataFrame or Series Pandas DataFrame or Series must have datetime index Returns ------- JSON to object.json_data Example ----...
[ "def", "transform_data", "(", "self", ",", "data", ")", ":", "def", "type_check", "(", "value", ")", ":", "'''Type check values for JSON serialization. Native Python JSON\n serialization will not recognize some Numpy data types properly,\n so they must be explictly ...
Transform Pandas Timeseries into JSON format Parameters ---------- data: DataFrame or Series Pandas DataFrame or Series must have datetime index Returns ------- JSON to object.json_data Example ------- >>>vis.transform_data(df) ...
[ "Transform", "Pandas", "Timeseries", "into", "JSON", "format" ]
8a65684830f4f0d63b455120ae329c3ebb479572
https://github.com/wrobstory/bearcart/blob/8a65684830f4f0d63b455120ae329c3ebb479572/bearcart/bearcart.py#L147-L193
train
62,479
wrobstory/bearcart
bearcart/bearcart.py
Chart._build_graph
def _build_graph(self): '''Build Rickshaw graph syntax with all data''' # Set palette colors if necessary if not self.colors: self.palette = self.env.get_template('palette.js') self.template_vars.update({'palette': self.palette.render()}) self.colors = {x['na...
python
def _build_graph(self): '''Build Rickshaw graph syntax with all data''' # Set palette colors if necessary if not self.colors: self.palette = self.env.get_template('palette.js') self.template_vars.update({'palette': self.palette.render()}) self.colors = {x['na...
[ "def", "_build_graph", "(", "self", ")", ":", "# Set palette colors if necessary", "if", "not", "self", ".", "colors", ":", "self", ".", "palette", "=", "self", ".", "env", ".", "get_template", "(", "'palette.js'", ")", "self", ".", "template_vars", ".", "up...
Build Rickshaw graph syntax with all data
[ "Build", "Rickshaw", "graph", "syntax", "with", "all", "data" ]
8a65684830f4f0d63b455120ae329c3ebb479572
https://github.com/wrobstory/bearcart/blob/8a65684830f4f0d63b455120ae329c3ebb479572/bearcart/bearcart.py#L195-L218
train
62,480
wrobstory/bearcart
bearcart/bearcart.py
Chart.create_chart
def create_chart(self, html_path='index.html', data_path='data.json', js_path='rickshaw.min.js', css_path='rickshaw.min.css', html_prefix=''): '''Save bearcart output to HTML and JSON. Parameters ---------- html_path: string, default 'index.html...
python
def create_chart(self, html_path='index.html', data_path='data.json', js_path='rickshaw.min.js', css_path='rickshaw.min.css', html_prefix=''): '''Save bearcart output to HTML and JSON. Parameters ---------- html_path: string, default 'index.html...
[ "def", "create_chart", "(", "self", ",", "html_path", "=", "'index.html'", ",", "data_path", "=", "'data.json'", ",", "js_path", "=", "'rickshaw.min.js'", ",", "css_path", "=", "'rickshaw.min.css'", ",", "html_prefix", "=", "''", ")", ":", "self", ".", "templa...
Save bearcart output to HTML and JSON. Parameters ---------- html_path: string, default 'index.html' Path for html output data_path: string, default 'data.json' Path for data JSON output js_path: string, default 'rickshaw.min.js' If passed, th...
[ "Save", "bearcart", "output", "to", "HTML", "and", "JSON", "." ]
8a65684830f4f0d63b455120ae329c3ebb479572
https://github.com/wrobstory/bearcart/blob/8a65684830f4f0d63b455120ae329c3ebb479572/bearcart/bearcart.py#L220-L279
train
62,481
raymontag/kppy
kppy/groups.py
v1Group.set_expire
def set_expire(self, y = 2999, mon = 12, d = 28, h = 23, min_ = 59, s = 59): """This method is used to change the expire date of a group - y is the year between 1 and 9999 inclusive - mon is the month between 1 and 12 - d is a day in the given month ...
python
def set_expire(self, y = 2999, mon = 12, d = 28, h = 23, min_ = 59, s = 59): """This method is used to change the expire date of a group - y is the year between 1 and 9999 inclusive - mon is the month between 1 and 12 - d is a day in the given month ...
[ "def", "set_expire", "(", "self", ",", "y", "=", "2999", ",", "mon", "=", "12", ",", "d", "=", "28", ",", "h", "=", "23", ",", "min_", "=", "59", ",", "s", "=", "59", ")", ":", "if", "type", "(", "y", ")", "is", "not", "int", "or", "type"...
This method is used to change the expire date of a group - y is the year between 1 and 9999 inclusive - mon is the month between 1 and 12 - d is a day in the given month - h is a hour between 0 and 23 - min_ is a minute between 0 and 59 - s is a s...
[ "This", "method", "is", "used", "to", "change", "the", "expire", "date", "of", "a", "group" ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/groups.py#L79-L108
train
62,482
raymontag/kppy
kppy/groups.py
v1Group.create_entry
def create_entry(self, title='', image=1, url='', username='', password='', comment='', y=2999, mon=12, d=28, h=23, min_=59, s=59): """This method creates an entry in this group. Compare to StdEntry for information about the arguments. One of the following arguments is ne...
python
def create_entry(self, title='', image=1, url='', username='', password='', comment='', y=2999, mon=12, d=28, h=23, min_=59, s=59): """This method creates an entry in this group. Compare to StdEntry for information about the arguments. One of the following arguments is ne...
[ "def", "create_entry", "(", "self", ",", "title", "=", "''", ",", "image", "=", "1", ",", "url", "=", "''", ",", "username", "=", "''", ",", "password", "=", "''", ",", "comment", "=", "''", ",", "y", "=", "2999", ",", "mon", "=", "12", ",", ...
This method creates an entry in this group. Compare to StdEntry for information about the arguments. One of the following arguments is needed: - title - url - username - password - comment
[ "This", "method", "creates", "an", "entry", "in", "this", "group", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/groups.py#L125-L142
train
62,483
raymontag/kppy
kppy/entries.py
v1Entry.set_title
def set_title(self, title = None): """This method is used to change an entry title. A new title string is needed. """ if title is None or type(title) is not str: raise KPError("Need a new title.") else: self.title = title self.last_mod = dat...
python
def set_title(self, title = None): """This method is used to change an entry title. A new title string is needed. """ if title is None or type(title) is not str: raise KPError("Need a new title.") else: self.title = title self.last_mod = dat...
[ "def", "set_title", "(", "self", ",", "title", "=", "None", ")", ":", "if", "title", "is", "None", "or", "type", "(", "title", ")", "is", "not", "str", ":", "raise", "KPError", "(", "\"Need a new title.\"", ")", "else", ":", "self", ".", "title", "="...
This method is used to change an entry title. A new title string is needed.
[ "This", "method", "is", "used", "to", "change", "an", "entry", "title", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/entries.py#L55-L67
train
62,484
raymontag/kppy
kppy/entries.py
v1Entry.set_image
def set_image(self, image = None): """This method is used to set the image number. image must be an unsigned int. """ if image is None or type(image) is not int: raise KPError("Need a new image number") else: self.image = image self....
python
def set_image(self, image = None): """This method is used to set the image number. image must be an unsigned int. """ if image is None or type(image) is not int: raise KPError("Need a new image number") else: self.image = image self....
[ "def", "set_image", "(", "self", ",", "image", "=", "None", ")", ":", "if", "image", "is", "None", "or", "type", "(", "image", ")", "is", "not", "int", ":", "raise", "KPError", "(", "\"Need a new image number\"", ")", "else", ":", "self", ".", "image",...
This method is used to set the image number. image must be an unsigned int.
[ "This", "method", "is", "used", "to", "set", "the", "image", "number", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/entries.py#L69-L81
train
62,485
raymontag/kppy
kppy/entries.py
v1Entry.set_url
def set_url(self, url = None): """This method is used to set the url. url must be a string. """ if url is None or type(url) is not str: raise KPError("Need a new image number") else: self.url = url self.last_mod = datetime.no...
python
def set_url(self, url = None): """This method is used to set the url. url must be a string. """ if url is None or type(url) is not str: raise KPError("Need a new image number") else: self.url = url self.last_mod = datetime.no...
[ "def", "set_url", "(", "self", ",", "url", "=", "None", ")", ":", "if", "url", "is", "None", "or", "type", "(", "url", ")", "is", "not", "str", ":", "raise", "KPError", "(", "\"Need a new image number\"", ")", "else", ":", "self", ".", "url", "=", ...
This method is used to set the url. url must be a string.
[ "This", "method", "is", "used", "to", "set", "the", "url", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/entries.py#L83-L95
train
62,486
raymontag/kppy
kppy/entries.py
v1Entry.set_username
def set_username(self, username = None): """This method is used to set the username. username must be a string. """ if username is None or type(username) is not str: raise KPError("Need a new image number") else: self.username = username ...
python
def set_username(self, username = None): """This method is used to set the username. username must be a string. """ if username is None or type(username) is not str: raise KPError("Need a new image number") else: self.username = username ...
[ "def", "set_username", "(", "self", ",", "username", "=", "None", ")", ":", "if", "username", "is", "None", "or", "type", "(", "username", ")", "is", "not", "str", ":", "raise", "KPError", "(", "\"Need a new image number\"", ")", "else", ":", "self", "."...
This method is used to set the username. username must be a string.
[ "This", "method", "is", "used", "to", "set", "the", "username", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/entries.py#L97-L109
train
62,487
raymontag/kppy
kppy/entries.py
v1Entry.set_password
def set_password(self, password = None): """This method is used to set the password. password must be a string. """ if password is None or type(password) is not str: raise KPError("Need a new image number") else: self.password = password ...
python
def set_password(self, password = None): """This method is used to set the password. password must be a string. """ if password is None or type(password) is not str: raise KPError("Need a new image number") else: self.password = password ...
[ "def", "set_password", "(", "self", ",", "password", "=", "None", ")", ":", "if", "password", "is", "None", "or", "type", "(", "password", ")", "is", "not", "str", ":", "raise", "KPError", "(", "\"Need a new image number\"", ")", "else", ":", "self", "."...
This method is used to set the password. password must be a string.
[ "This", "method", "is", "used", "to", "set", "the", "password", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/entries.py#L111-L123
train
62,488
raymontag/kppy
kppy/entries.py
v1Entry.set_comment
def set_comment(self, comment = None): """This method is used to the the comment. comment must be a string. """ if comment is None or type(comment) is not str: raise KPError("Need a new image number") else: self.comment = comment sel...
python
def set_comment(self, comment = None): """This method is used to the the comment. comment must be a string. """ if comment is None or type(comment) is not str: raise KPError("Need a new image number") else: self.comment = comment sel...
[ "def", "set_comment", "(", "self", ",", "comment", "=", "None", ")", ":", "if", "comment", "is", "None", "or", "type", "(", "comment", ")", "is", "not", "str", ":", "raise", "KPError", "(", "\"Need a new image number\"", ")", "else", ":", "self", ".", ...
This method is used to the the comment. comment must be a string.
[ "This", "method", "is", "used", "to", "the", "the", "comment", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/entries.py#L125-L137
train
62,489
raymontag/kppy
kppy/database.py
KPDBv1.read_buf
def read_buf(self): """Read database file""" with open(self.filepath, 'rb') as handler: try: buf = handler.read() # There should be a header at least if len(buf) < 124: raise KPError('Unexpected file size. ...
python
def read_buf(self): """Read database file""" with open(self.filepath, 'rb') as handler: try: buf = handler.read() # There should be a header at least if len(buf) < 124: raise KPError('Unexpected file size. ...
[ "def", "read_buf", "(", "self", ")", ":", "with", "open", "(", "self", ".", "filepath", ",", "'rb'", ")", "as", "handler", ":", "try", ":", "buf", "=", "handler", ".", "read", "(", ")", "# There should be a header at least", "if", "len", "(", "buf", ")...
Read database file
[ "Read", "database", "file" ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L295-L309
train
62,490
raymontag/kppy
kppy/database.py
KPDBv1.close
def close(self): """This method closes the database correctly.""" if self.filepath is not None: if path.isfile(self.filepath+'.lock'): remove(self.filepath+'.lock') self.filepath = None self.read_only = False self.lock() ...
python
def close(self): """This method closes the database correctly.""" if self.filepath is not None: if path.isfile(self.filepath+'.lock'): remove(self.filepath+'.lock') self.filepath = None self.read_only = False self.lock() ...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "filepath", "is", "not", "None", ":", "if", "path", ".", "isfile", "(", "self", ".", "filepath", "+", "'.lock'", ")", ":", "remove", "(", "self", ".", "filepath", "+", "'.lock'", ")", "self"...
This method closes the database correctly.
[ "This", "method", "closes", "the", "database", "correctly", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L448-L459
train
62,491
raymontag/kppy
kppy/database.py
KPDBv1.lock
def lock(self): """This method locks the database.""" self.password = None self.keyfile = None self.groups[:] = [] self.entries[:] = [] self._group_order[:] = [] self._entry_order[:] = [] self.root_group = v1Group() self._num_groups = 1 ...
python
def lock(self): """This method locks the database.""" self.password = None self.keyfile = None self.groups[:] = [] self.entries[:] = [] self._group_order[:] = [] self._entry_order[:] = [] self.root_group = v1Group() self._num_groups = 1 ...
[ "def", "lock", "(", "self", ")", ":", "self", ".", "password", "=", "None", "self", ".", "keyfile", "=", "None", "self", ".", "groups", "[", ":", "]", "=", "[", "]", "self", ".", "entries", "[", ":", "]", "=", "[", "]", "self", ".", "_group_ord...
This method locks the database.
[ "This", "method", "locks", "the", "database", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L461-L473
train
62,492
raymontag/kppy
kppy/database.py
KPDBv1.unlock
def unlock(self, password = None, keyfile = None, buf = None): """Unlock the database. masterkey is needed. """ if ((password is None or password == "") and (keyfile is None or keyfile == "")): raise KPError("A password/keyfile is needed") elif...
python
def unlock(self, password = None, keyfile = None, buf = None): """Unlock the database. masterkey is needed. """ if ((password is None or password == "") and (keyfile is None or keyfile == "")): raise KPError("A password/keyfile is needed") elif...
[ "def", "unlock", "(", "self", ",", "password", "=", "None", ",", "keyfile", "=", "None", ",", "buf", "=", "None", ")", ":", "if", "(", "(", "password", "is", "None", "or", "password", "==", "\"\"", ")", "and", "(", "keyfile", "is", "None", "or", ...
Unlock the database. masterkey is needed.
[ "Unlock", "the", "database", ".", "masterkey", "is", "needed", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L475-L494
train
62,493
raymontag/kppy
kppy/database.py
KPDBv1.remove_group
def remove_group(self, group = None): """This method removes a group. The group needed to remove the group. group must be a v1Group. """ if group is None: raise KPError("Need group to remove a group") elif type(group) is not v1Group: ra...
python
def remove_group(self, group = None): """This method removes a group. The group needed to remove the group. group must be a v1Group. """ if group is None: raise KPError("Need group to remove a group") elif type(group) is not v1Group: ra...
[ "def", "remove_group", "(", "self", ",", "group", "=", "None", ")", ":", "if", "group", "is", "None", ":", "raise", "KPError", "(", "\"Need group to remove a group\"", ")", "elif", "type", "(", "group", ")", "is", "not", "v1Group", ":", "raise", "KPError",...
This method removes a group. The group needed to remove the group. group must be a v1Group.
[ "This", "method", "removes", "a", "group", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L547-L579
train
62,494
raymontag/kppy
kppy/database.py
KPDBv1.move_group
def move_group(self, group = None, parent = None): """Append group to a new parent. group and parent must be v1Group-instances. """ if group is None or type(group) is not v1Group: raise KPError("A valid group must be given.") elif parent is not None and type(parent...
python
def move_group(self, group = None, parent = None): """Append group to a new parent. group and parent must be v1Group-instances. """ if group is None or type(group) is not v1Group: raise KPError("A valid group must be given.") elif parent is not None and type(parent...
[ "def", "move_group", "(", "self", ",", "group", "=", "None", ",", "parent", "=", "None", ")", ":", "if", "group", "is", "None", "or", "type", "(", "group", ")", "is", "not", "v1Group", ":", "raise", "KPError", "(", "\"A valid group must be given.\"", ")"...
Append group to a new parent. group and parent must be v1Group-instances.
[ "Append", "group", "to", "a", "new", "parent", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L581-L619
train
62,495
raymontag/kppy
kppy/database.py
KPDBv1.move_group_in_parent
def move_group_in_parent(self, group = None, index = None): """Move group to another position in group's parent. index must be a valid index of group.parent.groups """ if group is None or index is None: raise KPError("group and index must be set") e...
python
def move_group_in_parent(self, group = None, index = None): """Move group to another position in group's parent. index must be a valid index of group.parent.groups """ if group is None or index is None: raise KPError("group and index must be set") e...
[ "def", "move_group_in_parent", "(", "self", ",", "group", "=", "None", ",", "index", "=", "None", ")", ":", "if", "group", "is", "None", "or", "index", "is", "None", ":", "raise", "KPError", "(", "\"group and index must be set\"", ")", "elif", "type", "(",...
Move group to another position in group's parent. index must be a valid index of group.parent.groups
[ "Move", "group", "to", "another", "position", "in", "group", "s", "parent", ".", "index", "must", "be", "a", "valid", "index", "of", "group", ".", "parent", ".", "groups" ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L621-L652
train
62,496
raymontag/kppy
kppy/database.py
KPDBv1._move_group_helper
def _move_group_helper(self, group): """A helper to move the chidren of a group.""" for i in group.children: self.groups.remove(i) i.level = group.level + 1 self.groups.insert(self.groups.index(group) + 1, i) if i.children: self._move_grou...
python
def _move_group_helper(self, group): """A helper to move the chidren of a group.""" for i in group.children: self.groups.remove(i) i.level = group.level + 1 self.groups.insert(self.groups.index(group) + 1, i) if i.children: self._move_grou...
[ "def", "_move_group_helper", "(", "self", ",", "group", ")", ":", "for", "i", "in", "group", ".", "children", ":", "self", ".", "groups", ".", "remove", "(", "i", ")", "i", ".", "level", "=", "group", ".", "level", "+", "1", "self", ".", "groups", ...
A helper to move the chidren of a group.
[ "A", "helper", "to", "move", "the", "chidren", "of", "a", "group", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L654-L662
train
62,497
raymontag/kppy
kppy/database.py
KPDBv1.create_entry
def create_entry(self, group = None, title = "", image = 1, url = "", username = "", password = "", comment = "", y = 2999, mon = 12, d = 28, h = 23, min_ = 59, s = 59): """This method creates a new entry. The group which should hol...
python
def create_entry(self, group = None, title = "", image = 1, url = "", username = "", password = "", comment = "", y = 2999, mon = 12, d = 28, h = 23, min_ = 59, s = 59): """This method creates a new entry. The group which should hol...
[ "def", "create_entry", "(", "self", ",", "group", "=", "None", ",", "title", "=", "\"\"", ",", "image", "=", "1", ",", "url", "=", "\"\"", ",", "username", "=", "\"\"", ",", "password", "=", "\"\"", ",", "comment", "=", "\"\"", ",", "y", "=", "29...
This method creates a new entry. The group which should hold the entry is needed. image must be an unsigned int >0, group a v1Group. It is possible to give an expire date in the following way: - y is the year between 1 and 9999 inclusive - mon is the mo...
[ "This", "method", "creates", "a", "new", "entry", ".", "The", "group", "which", "should", "hold", "the", "entry", "is", "needed", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L664-L723
train
62,498
raymontag/kppy
kppy/database.py
KPDBv1.remove_entry
def remove_entry(self, entry = None): """This method can remove entries. The v1Entry-object entry is needed. """ if entry is None or type(entry) is not v1Entry: raise KPError("Need an entry.") elif entry in self.entries: entry.gr...
python
def remove_entry(self, entry = None): """This method can remove entries. The v1Entry-object entry is needed. """ if entry is None or type(entry) is not v1Entry: raise KPError("Need an entry.") elif entry in self.entries: entry.gr...
[ "def", "remove_entry", "(", "self", ",", "entry", "=", "None", ")", ":", "if", "entry", "is", "None", "or", "type", "(", "entry", ")", "is", "not", "v1Entry", ":", "raise", "KPError", "(", "\"Need an entry.\"", ")", "elif", "entry", "in", "self", ".", ...
This method can remove entries. The v1Entry-object entry is needed.
[ "This", "method", "can", "remove", "entries", ".", "The", "v1Entry", "-", "object", "entry", "is", "needed", "." ]
a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L725-L740
train
62,499