id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
237,900
astropy/regions
ah_bootstrap.py
_Bootstrapper._check_submodule
def _check_submodule(self): """ Check if the given path is a git submodule. See the docstrings for ``_check_submodule_using_git`` and ``_check_submodule_no_git`` for further details. """ if (self.path is None or (os.path.exists(self.path) and not os.path...
python
def _check_submodule(self): """ Check if the given path is a git submodule. See the docstrings for ``_check_submodule_using_git`` and ``_check_submodule_no_git`` for further details. """ if (self.path is None or (os.path.exists(self.path) and not os.path...
[ "def", "_check_submodule", "(", "self", ")", ":", "if", "(", "self", ".", "path", "is", "None", "or", "(", "os", ".", "path", ".", "exists", "(", "self", ".", "path", ")", "and", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "path", ...
Check if the given path is a git submodule. See the docstrings for ``_check_submodule_using_git`` and ``_check_submodule_no_git`` for further details.
[ "Check", "if", "the", "given", "path", "is", "a", "git", "submodule", "." ]
452d962c417e4ff20d1268f99535c6ff89c83437
https://github.com/astropy/regions/blob/452d962c417e4ff20d1268f99535c6ff89c83437/ah_bootstrap.py#L607-L622
237,901
EconForge/dolo
dolo/numeric/tensor.py
sdot
def sdot( U, V ): ''' Computes the tensorproduct reducing last dimensoin of U with first dimension of V. For matrices, it is equal to regular matrix product. ''' nu = U.ndim #nv = V.ndim return np.tensordot( U, V, axes=(nu-1,0) )
python
def sdot( U, V ): ''' Computes the tensorproduct reducing last dimensoin of U with first dimension of V. For matrices, it is equal to regular matrix product. ''' nu = U.ndim #nv = V.ndim return np.tensordot( U, V, axes=(nu-1,0) )
[ "def", "sdot", "(", "U", ",", "V", ")", ":", "nu", "=", "U", ".", "ndim", "#nv = V.ndim", "return", "np", ".", "tensordot", "(", "U", ",", "V", ",", "axes", "=", "(", "nu", "-", "1", ",", "0", ")", ")" ]
Computes the tensorproduct reducing last dimensoin of U with first dimension of V. For matrices, it is equal to regular matrix product.
[ "Computes", "the", "tensorproduct", "reducing", "last", "dimensoin", "of", "U", "with", "first", "dimension", "of", "V", ".", "For", "matrices", "it", "is", "equal", "to", "regular", "matrix", "product", "." ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/numeric/tensor.py#L44-L51
237,902
EconForge/dolo
dolo/numeric/interpolation/smolyak.py
SmolyakBasic.set_values
def set_values(self,x): """ Updates self.theta parameter. No returns values""" x = numpy.atleast_2d(x) x = x.real # ahem C_inv = self.__C_inv__ theta = numpy.dot( x, C_inv ) self.theta = theta return theta
python
def set_values(self,x): """ Updates self.theta parameter. No returns values""" x = numpy.atleast_2d(x) x = x.real # ahem C_inv = self.__C_inv__ theta = numpy.dot( x, C_inv ) self.theta = theta return theta
[ "def", "set_values", "(", "self", ",", "x", ")", ":", "x", "=", "numpy", ".", "atleast_2d", "(", "x", ")", "x", "=", "x", ".", "real", "# ahem", "C_inv", "=", "self", ".", "__C_inv__", "theta", "=", "numpy", ".", "dot", "(", "x", ",", "C_inv", ...
Updates self.theta parameter. No returns values
[ "Updates", "self", ".", "theta", "parameter", ".", "No", "returns", "values" ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/numeric/interpolation/smolyak.py#L256-L267
237,903
EconForge/dolo
dolo/numeric/discretization/discretization.py
tauchen
def tauchen(N, mu, rho, sigma, m=2): """ Approximate an AR1 process by a finite markov chain using Tauchen's method. :param N: scalar, number of nodes for Z :param mu: scalar, unconditional mean of process :param rho: scalar :param sigma: scalar, std. dev. of epsilons :param m: max +- std. ...
python
def tauchen(N, mu, rho, sigma, m=2): """ Approximate an AR1 process by a finite markov chain using Tauchen's method. :param N: scalar, number of nodes for Z :param mu: scalar, unconditional mean of process :param rho: scalar :param sigma: scalar, std. dev. of epsilons :param m: max +- std. ...
[ "def", "tauchen", "(", "N", ",", "mu", ",", "rho", ",", "sigma", ",", "m", "=", "2", ")", ":", "Z", "=", "np", ".", "zeros", "(", "(", "N", ",", "1", ")", ")", "Zprob", "=", "np", ".", "zeros", "(", "(", "N", ",", "N", ")", ")", "a", ...
Approximate an AR1 process by a finite markov chain using Tauchen's method. :param N: scalar, number of nodes for Z :param mu: scalar, unconditional mean of process :param rho: scalar :param sigma: scalar, std. dev. of epsilons :param m: max +- std. devs. :returns: Z, N*1 vector, nodes for Z. Z...
[ "Approximate", "an", "AR1", "process", "by", "a", "finite", "markov", "chain", "using", "Tauchen", "s", "method", "." ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/numeric/discretization/discretization.py#L13-L50
237,904
EconForge/dolo
dolo/numeric/discretization/discretization.py
rouwenhorst
def rouwenhorst(rho, sigma, N): """ Approximate an AR1 process by a finite markov chain using Rouwenhorst's method. :param rho: autocorrelation of the AR1 process :param sigma: conditional standard deviation of the AR1 process :param N: number of states :return [nodes, P]: equally spaced nodes ...
python
def rouwenhorst(rho, sigma, N): """ Approximate an AR1 process by a finite markov chain using Rouwenhorst's method. :param rho: autocorrelation of the AR1 process :param sigma: conditional standard deviation of the AR1 process :param N: number of states :return [nodes, P]: equally spaced nodes ...
[ "def", "rouwenhorst", "(", "rho", ",", "sigma", ",", "N", ")", ":", "from", "numpy", "import", "sqrt", ",", "linspace", ",", "array", ",", "zeros", "sigma", "=", "float", "(", "sigma", ")", "if", "N", "==", "1", ":", "nodes", "=", "array", "(", "...
Approximate an AR1 process by a finite markov chain using Rouwenhorst's method. :param rho: autocorrelation of the AR1 process :param sigma: conditional standard deviation of the AR1 process :param N: number of states :return [nodes, P]: equally spaced nodes and transition matrix
[ "Approximate", "an", "AR1", "process", "by", "a", "finite", "markov", "chain", "using", "Rouwenhorst", "s", "method", "." ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/numeric/discretization/discretization.py#L53-L97
237,905
EconForge/dolo
dolo/numeric/discretization/discretization.py
tensor_markov
def tensor_markov( *args ): """Computes the product of two independent markov chains. :param m1: a tuple containing the nodes and the transition matrix of the first chain :param m2: a tuple containing the nodes and the transition matrix of the second chain :return: a tuple containing the nodes and the ...
python
def tensor_markov( *args ): """Computes the product of two independent markov chains. :param m1: a tuple containing the nodes and the transition matrix of the first chain :param m2: a tuple containing the nodes and the transition matrix of the second chain :return: a tuple containing the nodes and the ...
[ "def", "tensor_markov", "(", "*", "args", ")", ":", "if", "len", "(", "args", ")", ">", "2", ":", "m1", "=", "args", "[", "0", "]", "m2", "=", "args", "[", "1", "]", "tail", "=", "args", "[", "2", ":", "]", "prod", "=", "tensor_markov", "(", ...
Computes the product of two independent markov chains. :param m1: a tuple containing the nodes and the transition matrix of the first chain :param m2: a tuple containing the nodes and the transition matrix of the second chain :return: a tuple containing the nodes and the transition matrix of the product ch...
[ "Computes", "the", "product", "of", "two", "independent", "markov", "chains", "." ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/numeric/discretization/discretization.py#L155-L201
237,906
EconForge/dolo
trash/dolo/misc/modfile.py
dynare_import
def dynare_import(filename,full_output=False, debug=False): '''Imports model defined in specified file''' import os basename = os.path.basename(filename) fname = re.compile('(.*)\.(.*)').match(basename).group(1) f = open(filename) txt = f.read() model = parse_dynare_text(txt,full_output=full...
python
def dynare_import(filename,full_output=False, debug=False): '''Imports model defined in specified file''' import os basename = os.path.basename(filename) fname = re.compile('(.*)\.(.*)').match(basename).group(1) f = open(filename) txt = f.read() model = parse_dynare_text(txt,full_output=full...
[ "def", "dynare_import", "(", "filename", ",", "full_output", "=", "False", ",", "debug", "=", "False", ")", ":", "import", "os", "basename", "=", "os", ".", "path", ".", "basename", "(", "filename", ")", "fname", "=", "re", ".", "compile", "(", "'(.*)\...
Imports model defined in specified file
[ "Imports", "model", "defined", "in", "specified", "file" ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/trash/dolo/misc/modfile.py#L311-L320
237,907
EconForge/dolo
dolo/algos/perfect_foresight.py
_shocks_to_epsilons
def _shocks_to_epsilons(model, shocks, T): """ Helper function to support input argument `shocks` being one of many different data types. Will always return a `T, n_e` matrix. """ n_e = len(model.calibration['exogenous']) # if we have a DataFrame, convert it to a dict and rely on the method bel...
python
def _shocks_to_epsilons(model, shocks, T): """ Helper function to support input argument `shocks` being one of many different data types. Will always return a `T, n_e` matrix. """ n_e = len(model.calibration['exogenous']) # if we have a DataFrame, convert it to a dict and rely on the method bel...
[ "def", "_shocks_to_epsilons", "(", "model", ",", "shocks", ",", "T", ")", ":", "n_e", "=", "len", "(", "model", ".", "calibration", "[", "'exogenous'", "]", ")", "# if we have a DataFrame, convert it to a dict and rely on the method below", "if", "isinstance", "(", ...
Helper function to support input argument `shocks` being one of many different data types. Will always return a `T, n_e` matrix.
[ "Helper", "function", "to", "support", "input", "argument", "shocks", "being", "one", "of", "many", "different", "data", "types", ".", "Will", "always", "return", "a", "T", "n_e", "matrix", "." ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/algos/perfect_foresight.py#L9-L49
237,908
EconForge/dolo
trash/dolo/misc/symbolic_interactive.py
clear_all
def clear_all(): """ Clears all parameters, variables, and shocks defined previously """ frame = inspect.currentframe().f_back try: if frame.f_globals.get('variables_order'): # we should avoid to declare symbols twice ! del frame.f_globals['variables_order'] ...
python
def clear_all(): """ Clears all parameters, variables, and shocks defined previously """ frame = inspect.currentframe().f_back try: if frame.f_globals.get('variables_order'): # we should avoid to declare symbols twice ! del frame.f_globals['variables_order'] ...
[ "def", "clear_all", "(", ")", ":", "frame", "=", "inspect", ".", "currentframe", "(", ")", ".", "f_back", "try", ":", "if", "frame", ".", "f_globals", ".", "get", "(", "'variables_order'", ")", ":", "# we should avoid to declare symbols twice !", "del", "frame...
Clears all parameters, variables, and shocks defined previously
[ "Clears", "all", "parameters", "variables", "and", "shocks", "defined", "previously" ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/trash/dolo/misc/symbolic_interactive.py#L319-L333
237,909
EconForge/dolo
trash/dolo/algos/dtcscc/nonlinearsystem.py
nonlinear_system
def nonlinear_system(model, initial_dr=None, maxit=10, tol=1e-8, grid={}, distribution={}, verbose=True): ''' Finds a global solution for ``model`` by solving one large system of equations using a simple newton algorithm. Parameters ---------- model: NumericModel "dtcscc" model to be ...
python
def nonlinear_system(model, initial_dr=None, maxit=10, tol=1e-8, grid={}, distribution={}, verbose=True): ''' Finds a global solution for ``model`` by solving one large system of equations using a simple newton algorithm. Parameters ---------- model: NumericModel "dtcscc" model to be ...
[ "def", "nonlinear_system", "(", "model", ",", "initial_dr", "=", "None", ",", "maxit", "=", "10", ",", "tol", "=", "1e-8", ",", "grid", "=", "{", "}", ",", "distribution", "=", "{", "}", ",", "verbose", "=", "True", ")", ":", "if", "verbose", ":", ...
Finds a global solution for ``model`` by solving one large system of equations using a simple newton algorithm. Parameters ---------- model: NumericModel "dtcscc" model to be solved verbose: boolean if True, display iterations initial_dr: decision rule initial guess for ...
[ "Finds", "a", "global", "solution", "for", "model", "by", "solving", "one", "large", "system", "of", "equations", "using", "a", "simple", "newton", "algorithm", "." ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/trash/dolo/algos/dtcscc/nonlinearsystem.py#L10-L97
237,910
EconForge/dolo
dolo/numeric/discretization/quadrature.py
gauss_hermite_nodes
def gauss_hermite_nodes(orders, sigma, mu=None): ''' Computes the weights and nodes for Gauss Hermite quadrature. Parameters ---------- orders : int, list, array The order of integration used in the quadrature routine sigma : array-like If one dimensional, the variance of the no...
python
def gauss_hermite_nodes(orders, sigma, mu=None): ''' Computes the weights and nodes for Gauss Hermite quadrature. Parameters ---------- orders : int, list, array The order of integration used in the quadrature routine sigma : array-like If one dimensional, the variance of the no...
[ "def", "gauss_hermite_nodes", "(", "orders", ",", "sigma", ",", "mu", "=", "None", ")", ":", "if", "isinstance", "(", "orders", ",", "int", ")", ":", "orders", "=", "[", "orders", "]", "import", "numpy", "if", "mu", "is", "None", ":", "mu", "=", "n...
Computes the weights and nodes for Gauss Hermite quadrature. Parameters ---------- orders : int, list, array The order of integration used in the quadrature routine sigma : array-like If one dimensional, the variance of the normal distribution being approximated. If multidimensi...
[ "Computes", "the", "weights", "and", "nodes", "for", "Gauss", "Hermite", "quadrature", "." ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/numeric/discretization/quadrature.py#L59-L122
237,911
EconForge/dolo
dolo/numeric/optimize/newton.py
newton
def newton(f, x, verbose=False, tol=1e-6, maxit=5, jactype='serial'): """Solve nonlinear system using safeguarded Newton iterations Parameters ---------- Return ------ """ if verbose: print = lambda txt: old_print(txt) else: print = lambda txt: None it = 0 e...
python
def newton(f, x, verbose=False, tol=1e-6, maxit=5, jactype='serial'): """Solve nonlinear system using safeguarded Newton iterations Parameters ---------- Return ------ """ if verbose: print = lambda txt: old_print(txt) else: print = lambda txt: None it = 0 e...
[ "def", "newton", "(", "f", ",", "x", ",", "verbose", "=", "False", ",", "tol", "=", "1e-6", ",", "maxit", "=", "5", ",", "jactype", "=", "'serial'", ")", ":", "if", "verbose", ":", "print", "=", "lambda", "txt", ":", "old_print", "(", "txt", ")",...
Solve nonlinear system using safeguarded Newton iterations Parameters ---------- Return ------
[ "Solve", "nonlinear", "system", "using", "safeguarded", "Newton", "iterations" ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/numeric/optimize/newton.py#L81-L151
237,912
EconForge/dolo
dolo/numeric/extern/qz.py
qzordered
def qzordered(A,B,crit=1.0): "Eigenvalues bigger than crit are sorted in the top-left." TOL = 1e-10 def select(alpha, beta): return alpha**2>crit*beta**2 [S,T,alpha,beta,U,V] = ordqz(A,B,output='real',sort=select) eigval = abs(numpy.diag(S)/numpy.diag(T)) return [S,T,U,V,eigval]
python
def qzordered(A,B,crit=1.0): "Eigenvalues bigger than crit are sorted in the top-left." TOL = 1e-10 def select(alpha, beta): return alpha**2>crit*beta**2 [S,T,alpha,beta,U,V] = ordqz(A,B,output='real',sort=select) eigval = abs(numpy.diag(S)/numpy.diag(T)) return [S,T,U,V,eigval]
[ "def", "qzordered", "(", "A", ",", "B", ",", "crit", "=", "1.0", ")", ":", "TOL", "=", "1e-10", "def", "select", "(", "alpha", ",", "beta", ")", ":", "return", "alpha", "**", "2", ">", "crit", "*", "beta", "**", "2", "[", "S", ",", "T", ",", ...
Eigenvalues bigger than crit are sorted in the top-left.
[ "Eigenvalues", "bigger", "than", "crit", "are", "sorted", "in", "the", "top", "-", "left", "." ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/numeric/extern/qz.py#L6-L18
237,913
EconForge/dolo
dolo/numeric/extern/qz.py
ordqz
def ordqz(A, B, sort='lhp', output='real', overwrite_a=False, overwrite_b=False, check_finite=True): """ QZ decomposition for a pair of matrices with reordering. .. versionadded:: 0.17.0 Parameters ---------- A : (N, N) array_like 2d array to decompose B : (N, N) array_li...
python
def ordqz(A, B, sort='lhp', output='real', overwrite_a=False, overwrite_b=False, check_finite=True): """ QZ decomposition for a pair of matrices with reordering. .. versionadded:: 0.17.0 Parameters ---------- A : (N, N) array_like 2d array to decompose B : (N, N) array_li...
[ "def", "ordqz", "(", "A", ",", "B", ",", "sort", "=", "'lhp'", ",", "output", "=", "'real'", ",", "overwrite_a", "=", "False", ",", "overwrite_b", "=", "False", ",", "check_finite", "=", "True", ")", ":", "import", "warnings", "import", "numpy", "as", ...
QZ decomposition for a pair of matrices with reordering. .. versionadded:: 0.17.0 Parameters ---------- A : (N, N) array_like 2d array to decompose B : (N, N) array_like 2d array to decompose sort : {callable, 'lhp', 'rhp', 'iuc', 'ouc'}, optional Specifies whether the ...
[ "QZ", "decomposition", "for", "a", "pair", "of", "matrices", "with", "reordering", "." ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/numeric/extern/qz.py#L21-L154
237,914
EconForge/dolo
trash/dolo/algos/dtcscc/time_iteration_2.py
parameterized_expectations_direct
def parameterized_expectations_direct(model, verbose=False, initial_dr=None, pert_order=1, grid={}, distribution={}, maxit=100, tol=1e-8): ''' Finds a global solution for ``model`` using parameterized expectations function. Requires...
python
def parameterized_expectations_direct(model, verbose=False, initial_dr=None, pert_order=1, grid={}, distribution={}, maxit=100, tol=1e-8): ''' Finds a global solution for ``model`` using parameterized expectations function. Requires...
[ "def", "parameterized_expectations_direct", "(", "model", ",", "verbose", "=", "False", ",", "initial_dr", "=", "None", ",", "pert_order", "=", "1", ",", "grid", "=", "{", "}", ",", "distribution", "=", "{", "}", ",", "maxit", "=", "100", ",", "tol", "...
Finds a global solution for ``model`` using parameterized expectations function. Requires the model to be written with controls as a direct function of the model objects. The algorithm iterates on the expectations function in the arbitrage equation. It follows the discussion in section 9.9 of Miranda a...
[ "Finds", "a", "global", "solution", "for", "model", "using", "parameterized", "expectations", "function", ".", "Requires", "the", "model", "to", "be", "written", "with", "controls", "as", "a", "direct", "function", "of", "the", "model", "objects", "." ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/trash/dolo/algos/dtcscc/time_iteration_2.py#L186-L312
237,915
EconForge/dolo
dolo/compiler/misc.py
numdiff
def numdiff(fun, args): """Vectorized numerical differentiation""" # vectorized version epsilon = 1e-8 args = list(args) v0 = fun(*args) N = v0.shape[0] l_v = len(v0) dvs = [] for i, a in enumerate(args): l_a = (a).shape[1] dv = numpy.zeros((N, l_v, l_a)) na...
python
def numdiff(fun, args): """Vectorized numerical differentiation""" # vectorized version epsilon = 1e-8 args = list(args) v0 = fun(*args) N = v0.shape[0] l_v = len(v0) dvs = [] for i, a in enumerate(args): l_a = (a).shape[1] dv = numpy.zeros((N, l_v, l_a)) na...
[ "def", "numdiff", "(", "fun", ",", "args", ")", ":", "# vectorized version", "epsilon", "=", "1e-8", "args", "=", "list", "(", "args", ")", "v0", "=", "fun", "(", "*", "args", ")", "N", "=", "v0", ".", "shape", "[", "0", "]", "l_v", "=", "len", ...
Vectorized numerical differentiation
[ "Vectorized", "numerical", "differentiation" ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/compiler/misc.py#L97-L118
237,916
EconForge/dolo
dolo/numeric/filters.py
bandpass_filter
def bandpass_filter(data, k, w1, w2): """ This function will apply a bandpass filter to data. It will be kth order and will select the band between w1 and w2. Parameters ---------- data: array, dtype=float The data you wish to filter k: number, int The order ...
python
def bandpass_filter(data, k, w1, w2): """ This function will apply a bandpass filter to data. It will be kth order and will select the band between w1 and w2. Parameters ---------- data: array, dtype=float The data you wish to filter k: number, int The order ...
[ "def", "bandpass_filter", "(", "data", ",", "k", ",", "w1", ",", "w2", ")", ":", "data", "=", "np", ".", "asarray", "(", "data", ")", "low_w", "=", "np", ".", "pi", "*", "2", "/", "w2", "high_w", "=", "np", ".", "pi", "*", "2", "/", "w1", "...
This function will apply a bandpass filter to data. It will be kth order and will select the band between w1 and w2. Parameters ---------- data: array, dtype=float The data you wish to filter k: number, int The order of approximation for the filter. A max value for ...
[ "This", "function", "will", "apply", "a", "bandpass", "filter", "to", "data", ".", "It", "will", "be", "kth", "order", "and", "will", "select", "the", "band", "between", "w1", "and", "w2", "." ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/numeric/filters.py#L83-L119
237,917
EconForge/dolo
dolo/misc/dprint.py
dprint
def dprint(s): '''Prints `s` with additional debugging informations''' import inspect frameinfo = inspect.stack()[1] callerframe = frameinfo.frame d = callerframe.f_locals if (isinstance(s,str)): val = eval(s, d) else: val = s cc = frameinfo.code_context[0] ...
python
def dprint(s): '''Prints `s` with additional debugging informations''' import inspect frameinfo = inspect.stack()[1] callerframe = frameinfo.frame d = callerframe.f_locals if (isinstance(s,str)): val = eval(s, d) else: val = s cc = frameinfo.code_context[0] ...
[ "def", "dprint", "(", "s", ")", ":", "import", "inspect", "frameinfo", "=", "inspect", ".", "stack", "(", ")", "[", "1", "]", "callerframe", "=", "frameinfo", ".", "frame", "d", "=", "callerframe", ".", "f_locals", "if", "(", "isinstance", "(", "s", ...
Prints `s` with additional debugging informations
[ "Prints", "s", "with", "additional", "debugging", "informations" ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/misc/dprint.py#L21-L46
237,918
EconForge/dolo
dolo/compiler/function_compiler_sympy.py
non_decreasing_series
def non_decreasing_series(n, size): '''Lists all combinations of 0,...,n-1 in increasing order''' if size == 1: return [[a] for a in range(n)] else: lc = non_decreasing_series(n, size-1) ll = [] for l in lc: last = l[-1] for i in range(last, n): ...
python
def non_decreasing_series(n, size): '''Lists all combinations of 0,...,n-1 in increasing order''' if size == 1: return [[a] for a in range(n)] else: lc = non_decreasing_series(n, size-1) ll = [] for l in lc: last = l[-1] for i in range(last, n): ...
[ "def", "non_decreasing_series", "(", "n", ",", "size", ")", ":", "if", "size", "==", "1", ":", "return", "[", "[", "a", "]", "for", "a", "in", "range", "(", "n", ")", "]", "else", ":", "lc", "=", "non_decreasing_series", "(", "n", ",", "size", "-...
Lists all combinations of 0,...,n-1 in increasing order
[ "Lists", "all", "combinations", "of", "0", "...", "n", "-", "1", "in", "increasing", "order" ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/compiler/function_compiler_sympy.py#L13-L26
237,919
EconForge/dolo
dolo/compiler/function_compiler_sympy.py
higher_order_diff
def higher_order_diff(eqs, syms, order=2): '''Takes higher order derivatives of a list of equations w.r.t a list of paramters''' import numpy eqs = list([sympy.sympify(eq) for eq in eqs]) syms = list([sympy.sympify(s) for s in syms]) neq = len(eqs) p = len(syms) D = [numpy.array(eqs)] ...
python
def higher_order_diff(eqs, syms, order=2): '''Takes higher order derivatives of a list of equations w.r.t a list of paramters''' import numpy eqs = list([sympy.sympify(eq) for eq in eqs]) syms = list([sympy.sympify(s) for s in syms]) neq = len(eqs) p = len(syms) D = [numpy.array(eqs)] ...
[ "def", "higher_order_diff", "(", "eqs", ",", "syms", ",", "order", "=", "2", ")", ":", "import", "numpy", "eqs", "=", "list", "(", "[", "sympy", ".", "sympify", "(", "eq", ")", "for", "eq", "in", "eqs", "]", ")", "syms", "=", "list", "(", "[", ...
Takes higher order derivatives of a list of equations w.r.t a list of paramters
[ "Takes", "higher", "order", "derivatives", "of", "a", "list", "of", "equations", "w", ".", "r", ".", "t", "a", "list", "of", "paramters" ]
d91ddf148b009bf79852d9aec70f3a1877e0f79a
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/compiler/function_compiler_sympy.py#L28-L60
237,920
pokerregion/poker
poker/website/pocketfives.py
get_ranked_players
def get_ranked_players(): """Get the list of the first 100 ranked players.""" rankings_page = requests.get(RANKINGS_URL) root = etree.HTML(rankings_page.text) player_rows = root.xpath('//div[@id="ranked"]//tr') for row in player_rows[1:]: player_row = row.xpath('td[@class!="country"]//text...
python
def get_ranked_players(): """Get the list of the first 100 ranked players.""" rankings_page = requests.get(RANKINGS_URL) root = etree.HTML(rankings_page.text) player_rows = root.xpath('//div[@id="ranked"]//tr') for row in player_rows[1:]: player_row = row.xpath('td[@class!="country"]//text...
[ "def", "get_ranked_players", "(", ")", ":", "rankings_page", "=", "requests", ".", "get", "(", "RANKINGS_URL", ")", "root", "=", "etree", ".", "HTML", "(", "rankings_page", ".", "text", ")", "player_rows", "=", "root", ".", "xpath", "(", "'//div[@id=\"ranked...
Get the list of the first 100 ranked players.
[ "Get", "the", "list", "of", "the", "first", "100", "ranked", "players", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/website/pocketfives.py#L31-L50
237,921
pokerregion/poker
poker/card.py
Rank.difference
def difference(cls, first, second): """Tells the numerical difference between two ranks.""" # so we always get a Rank instance even if string were passed in first, second = cls(first), cls(second) rank_list = list(cls) return abs(rank_list.index(first) - rank_list.index(second))
python
def difference(cls, first, second): """Tells the numerical difference between two ranks.""" # so we always get a Rank instance even if string were passed in first, second = cls(first), cls(second) rank_list = list(cls) return abs(rank_list.index(first) - rank_list.index(second))
[ "def", "difference", "(", "cls", ",", "first", ",", "second", ")", ":", "# so we always get a Rank instance even if string were passed in", "first", ",", "second", "=", "cls", "(", "first", ")", ",", "cls", "(", "second", ")", "rank_list", "=", "list", "(", "c...
Tells the numerical difference between two ranks.
[ "Tells", "the", "numerical", "difference", "between", "two", "ranks", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/card.py#L42-L48
237,922
pokerregion/poker
poker/card.py
_CardMeta.make_random
def make_random(cls): """Returns a random Card instance.""" self = object.__new__(cls) self.rank = Rank.make_random() self.suit = Suit.make_random() return self
python
def make_random(cls): """Returns a random Card instance.""" self = object.__new__(cls) self.rank = Rank.make_random() self.suit = Suit.make_random() return self
[ "def", "make_random", "(", "cls", ")", ":", "self", "=", "object", ".", "__new__", "(", "cls", ")", "self", ".", "rank", "=", "Rank", ".", "make_random", "(", ")", "self", ".", "suit", "=", "Suit", ".", "make_random", "(", ")", "return", "self" ]
Returns a random Card instance.
[ "Returns", "a", "random", "Card", "instance", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/card.py#L64-L69
237,923
pokerregion/poker
poker/commands.py
twoplustwo_player
def twoplustwo_player(username): """Get profile information about a Two plus Two Forum member given the username.""" from .website.twoplustwo import ForumMember, AmbiguousUserNameError, UserNotFoundError try: member = ForumMember(username) except UserNotFoundError: raise click.ClickExc...
python
def twoplustwo_player(username): """Get profile information about a Two plus Two Forum member given the username.""" from .website.twoplustwo import ForumMember, AmbiguousUserNameError, UserNotFoundError try: member = ForumMember(username) except UserNotFoundError: raise click.ClickExc...
[ "def", "twoplustwo_player", "(", "username", ")", ":", "from", ".", "website", ".", "twoplustwo", "import", "ForumMember", ",", "AmbiguousUserNameError", ",", "UserNotFoundError", "try", ":", "member", "=", "ForumMember", "(", "username", ")", "except", "UserNotFo...
Get profile information about a Two plus Two Forum member given the username.
[ "Get", "profile", "information", "about", "a", "Two", "plus", "Two", "Forum", "member", "given", "the", "username", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/commands.py#L59-L95
237,924
pokerregion/poker
poker/commands.py
p5list
def p5list(num): """List pocketfives ranked players, max 100 if no NUM, or NUM if specified.""" from .website.pocketfives import get_ranked_players format_str = '{:>4.4} {!s:<15.13}{!s:<18.15}{!s:<9.6}{!s:<10.7}'\ '{!s:<14.11}{!s:<12.9}{!s:<12.9}{!s:<12.9}{!s:<4.4}' click.echo(form...
python
def p5list(num): """List pocketfives ranked players, max 100 if no NUM, or NUM if specified.""" from .website.pocketfives import get_ranked_players format_str = '{:>4.4} {!s:<15.13}{!s:<18.15}{!s:<9.6}{!s:<10.7}'\ '{!s:<14.11}{!s:<12.9}{!s:<12.9}{!s:<12.9}{!s:<4.4}' click.echo(form...
[ "def", "p5list", "(", "num", ")", ":", "from", ".", "website", ".", "pocketfives", "import", "get_ranked_players", "format_str", "=", "'{:>4.4} {!s:<15.13}{!s:<18.15}{!s:<9.6}{!s:<10.7}'", "'{!s:<14.11}{!s:<12.9}{!s:<12.9}{!s:<12.9}{!s:<4.4}'", "click", ".", "echo", "(", ...
List pocketfives ranked players, max 100 if no NUM, or NUM if specified.
[ "List", "pocketfives", "ranked", "players", "max", "100", "if", "no", "NUM", "or", "NUM", "if", "specified", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/commands.py#L100-L119
237,925
pokerregion/poker
poker/commands.py
psstatus
def psstatus(): """Shows PokerStars status such as number of players, tournaments.""" from .website.pokerstars import get_status _print_header('PokerStars status') status = get_status() _print_values( ('Info updated', status.updated), ('Tables', status.tables), ('Players', ...
python
def psstatus(): """Shows PokerStars status such as number of players, tournaments.""" from .website.pokerstars import get_status _print_header('PokerStars status') status = get_status() _print_values( ('Info updated', status.updated), ('Tables', status.tables), ('Players', ...
[ "def", "psstatus", "(", ")", ":", "from", ".", "website", ".", "pokerstars", "import", "get_status", "_print_header", "(", "'PokerStars status'", ")", "status", "=", "get_status", "(", ")", "_print_values", "(", "(", "'Info updated'", ",", "status", ".", "upda...
Shows PokerStars status such as number of players, tournaments.
[ "Shows", "PokerStars", "status", "such", "as", "number", "of", "players", "tournaments", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/commands.py#L123-L145
237,926
pokerregion/poker
poker/room/pokerstars.py
Notes.notes
def notes(self): """Tuple of notes..""" return tuple(self._get_note_data(note) for note in self.root.iter('note'))
python
def notes(self): """Tuple of notes..""" return tuple(self._get_note_data(note) for note in self.root.iter('note'))
[ "def", "notes", "(", "self", ")", ":", "return", "tuple", "(", "self", ".", "_get_note_data", "(", "note", ")", "for", "note", "in", "self", ".", "root", ".", "iter", "(", "'note'", ")", ")" ]
Tuple of notes..
[ "Tuple", "of", "notes", ".." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/room/pokerstars.py#L335-L337
237,927
pokerregion/poker
poker/room/pokerstars.py
Notes.labels
def labels(self): """Tuple of labels.""" return tuple(_Label(label.get('id'), label.get('color'), label.text) for label in self.root.iter('label'))
python
def labels(self): """Tuple of labels.""" return tuple(_Label(label.get('id'), label.get('color'), label.text) for label in self.root.iter('label'))
[ "def", "labels", "(", "self", ")", ":", "return", "tuple", "(", "_Label", "(", "label", ".", "get", "(", "'id'", ")", ",", "label", ".", "get", "(", "'color'", ")", ",", "label", ".", "text", ")", "for", "label", "in", "self", ".", "root", ".", ...
Tuple of labels.
[ "Tuple", "of", "labels", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/room/pokerstars.py#L340-L343
237,928
pokerregion/poker
poker/room/pokerstars.py
Notes.add_note
def add_note(self, player, text, label=None, update=None): """Add a note to the xml. If update param is None, it will be the current time.""" if label is not None and (label not in self.label_names): raise LabelNotFoundError('Invalid label: {}'.format(label)) if update is None: ...
python
def add_note(self, player, text, label=None, update=None): """Add a note to the xml. If update param is None, it will be the current time.""" if label is not None and (label not in self.label_names): raise LabelNotFoundError('Invalid label: {}'.format(label)) if update is None: ...
[ "def", "add_note", "(", "self", ",", "player", ",", "text", ",", "label", "=", "None", ",", "update", "=", "None", ")", ":", "if", "label", "is", "not", "None", "and", "(", "label", "not", "in", "self", ".", "label_names", ")", ":", "raise", "Label...
Add a note to the xml. If update param is None, it will be the current time.
[ "Add", "a", "note", "to", "the", "xml", ".", "If", "update", "param", "is", "None", "it", "will", "be", "the", "current", "time", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/room/pokerstars.py#L354-L365
237,929
pokerregion/poker
poker/room/pokerstars.py
Notes.append_note
def append_note(self, player, text): """Append text to an already existing note.""" note = self._find_note(player) note.text += text
python
def append_note(self, player, text): """Append text to an already existing note.""" note = self._find_note(player) note.text += text
[ "def", "append_note", "(", "self", ",", "player", ",", "text", ")", ":", "note", "=", "self", ".", "_find_note", "(", "player", ")", "note", ".", "text", "+=", "text" ]
Append text to an already existing note.
[ "Append", "text", "to", "an", "already", "existing", "note", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/room/pokerstars.py#L367-L370
237,930
pokerregion/poker
poker/room/pokerstars.py
Notes.prepend_note
def prepend_note(self, player, text): """Prepend text to an already existing note.""" note = self._find_note(player) note.text = text + note.text
python
def prepend_note(self, player, text): """Prepend text to an already existing note.""" note = self._find_note(player) note.text = text + note.text
[ "def", "prepend_note", "(", "self", ",", "player", ",", "text", ")", ":", "note", "=", "self", ".", "_find_note", "(", "player", ")", "note", ".", "text", "=", "text", "+", "note", ".", "text" ]
Prepend text to an already existing note.
[ "Prepend", "text", "to", "an", "already", "existing", "note", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/room/pokerstars.py#L372-L375
237,931
pokerregion/poker
poker/room/pokerstars.py
Notes.get_label
def get_label(self, name): """Find the label by name.""" label_tag = self._find_label(name) return _Label(label_tag.get('id'), label_tag.get('color'), label_tag.text)
python
def get_label(self, name): """Find the label by name.""" label_tag = self._find_label(name) return _Label(label_tag.get('id'), label_tag.get('color'), label_tag.text)
[ "def", "get_label", "(", "self", ",", "name", ")", ":", "label_tag", "=", "self", ".", "_find_label", "(", "name", ")", "return", "_Label", "(", "label_tag", ".", "get", "(", "'id'", ")", ",", "label_tag", ".", "get", "(", "'color'", ")", ",", "label...
Find the label by name.
[ "Find", "the", "label", "by", "name", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/room/pokerstars.py#L412-L415
237,932
pokerregion/poker
poker/room/pokerstars.py
Notes.add_label
def add_label(self, name, color): """Add a new label. It's id will automatically be calculated.""" color_upper = color.upper() if not self._color_re.match(color_upper): raise ValueError('Invalid color: {}'.format(color)) labels_tag = self.root[0] last_id = int(labels...
python
def add_label(self, name, color): """Add a new label. It's id will automatically be calculated.""" color_upper = color.upper() if not self._color_re.match(color_upper): raise ValueError('Invalid color: {}'.format(color)) labels_tag = self.root[0] last_id = int(labels...
[ "def", "add_label", "(", "self", ",", "name", ",", "color", ")", ":", "color_upper", "=", "color", ".", "upper", "(", ")", "if", "not", "self", ".", "_color_re", ".", "match", "(", "color_upper", ")", ":", "raise", "ValueError", "(", "'Invalid color: {}'...
Add a new label. It's id will automatically be calculated.
[ "Add", "a", "new", "label", ".", "It", "s", "id", "will", "automatically", "be", "calculated", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/room/pokerstars.py#L417-L430
237,933
pokerregion/poker
poker/room/pokerstars.py
Notes.del_label
def del_label(self, name): """Delete a label by name.""" labels_tag = self.root[0] labels_tag.remove(self._find_label(name))
python
def del_label(self, name): """Delete a label by name.""" labels_tag = self.root[0] labels_tag.remove(self._find_label(name))
[ "def", "del_label", "(", "self", ",", "name", ")", ":", "labels_tag", "=", "self", ".", "root", "[", "0", "]", "labels_tag", ".", "remove", "(", "self", ".", "_find_label", "(", "name", ")", ")" ]
Delete a label by name.
[ "Delete", "a", "label", "by", "name", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/room/pokerstars.py#L432-L435
237,934
pokerregion/poker
poker/room/pokerstars.py
Notes.save
def save(self, filename): """Save the note XML to a file.""" with open(filename, 'w') as fp: fp.write(str(self))
python
def save(self, filename): """Save the note XML to a file.""" with open(filename, 'w') as fp: fp.write(str(self))
[ "def", "save", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "fp", ":", "fp", ".", "write", "(", "str", "(", "self", ")", ")" ]
Save the note XML to a file.
[ "Save", "the", "note", "XML", "to", "a", "file", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/room/pokerstars.py#L447-L450
237,935
pokerregion/poker
poker/handhistory.py
_BaseHandHistory.board
def board(self): """Calculates board from flop, turn and river.""" board = [] if self.flop: board.extend(self.flop.cards) if self.turn: board.append(self.turn) if self.river: board.append(self.river) return tuple...
python
def board(self): """Calculates board from flop, turn and river.""" board = [] if self.flop: board.extend(self.flop.cards) if self.turn: board.append(self.turn) if self.river: board.append(self.river) return tuple...
[ "def", "board", "(", "self", ")", ":", "board", "=", "[", "]", "if", "self", ".", "flop", ":", "board", ".", "extend", "(", "self", ".", "flop", ".", "cards", ")", "if", "self", ".", "turn", ":", "board", ".", "append", "(", "self", ".", "turn"...
Calculates board from flop, turn and river.
[ "Calculates", "board", "from", "flop", "turn", "and", "river", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/handhistory.py#L167-L176
237,936
pokerregion/poker
poker/handhistory.py
_BaseHandHistory._parse_date
def _parse_date(self, date_string): """Parse the date_string and return a datetime object as UTC.""" date = datetime.strptime(date_string, self._DATE_FORMAT) self.date = self._TZ.localize(date).astimezone(pytz.UTC)
python
def _parse_date(self, date_string): """Parse the date_string and return a datetime object as UTC.""" date = datetime.strptime(date_string, self._DATE_FORMAT) self.date = self._TZ.localize(date).astimezone(pytz.UTC)
[ "def", "_parse_date", "(", "self", ",", "date_string", ")", ":", "date", "=", "datetime", ".", "strptime", "(", "date_string", ",", "self", ".", "_DATE_FORMAT", ")", "self", ".", "date", "=", "self", ".", "_TZ", ".", "localize", "(", "date", ")", ".", ...
Parse the date_string and return a datetime object as UTC.
[ "Parse", "the", "date_string", "and", "return", "a", "datetime", "object", "as", "UTC", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/handhistory.py#L178-L181
237,937
pokerregion/poker
poker/handhistory.py
_SplittableHandHistoryMixin._split_raw
def _split_raw(self): """Split hand history by sections.""" self._splitted = self._split_re.split(self.raw) # search split locations (basically empty strings) self._sections = [ind for ind, elem in enumerate(self._splitted) if not elem]
python
def _split_raw(self): """Split hand history by sections.""" self._splitted = self._split_re.split(self.raw) # search split locations (basically empty strings) self._sections = [ind for ind, elem in enumerate(self._splitted) if not elem]
[ "def", "_split_raw", "(", "self", ")", ":", "self", ".", "_splitted", "=", "self", ".", "_split_re", ".", "split", "(", "self", ".", "raw", ")", "# search split locations (basically empty strings)", "self", ".", "_sections", "=", "[", "ind", "for", "ind", ",...
Split hand history by sections.
[ "Split", "hand", "history", "by", "sections", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/handhistory.py#L201-L206
237,938
pokerregion/poker
poker/website/twoplustwo.py
ForumMember._get_timezone
def _get_timezone(self, root): """Find timezone informatation on bottom of the page.""" tz_str = root.xpath('//div[@class="smallfont" and @align="center"]')[0].text hours = int(self._tz_re.search(tz_str).group(1)) return tzoffset(tz_str, hours * 60)
python
def _get_timezone(self, root): """Find timezone informatation on bottom of the page.""" tz_str = root.xpath('//div[@class="smallfont" and @align="center"]')[0].text hours = int(self._tz_re.search(tz_str).group(1)) return tzoffset(tz_str, hours * 60)
[ "def", "_get_timezone", "(", "self", ",", "root", ")", ":", "tz_str", "=", "root", ".", "xpath", "(", "'//div[@class=\"smallfont\" and @align=\"center\"]'", ")", "[", "0", "]", ".", "text", "hours", "=", "int", "(", "self", ".", "_tz_re", ".", "search", "(...
Find timezone informatation on bottom of the page.
[ "Find", "timezone", "informatation", "on", "bottom", "of", "the", "page", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/website/twoplustwo.py#L125-L129
237,939
pokerregion/poker
poker/website/pokerstars.py
get_current_tournaments
def get_current_tournaments(): """Get the next 200 tournaments from pokerstars.""" schedule_page = requests.get(TOURNAMENTS_XML_URL) root = etree.XML(schedule_page.content) for tour in root.iter('{*}tournament'): yield _Tournament( start_date=tour.findtext('{*}start_date'), ...
python
def get_current_tournaments(): """Get the next 200 tournaments from pokerstars.""" schedule_page = requests.get(TOURNAMENTS_XML_URL) root = etree.XML(schedule_page.content) for tour in root.iter('{*}tournament'): yield _Tournament( start_date=tour.findtext('{*}start_date'), ...
[ "def", "get_current_tournaments", "(", ")", ":", "schedule_page", "=", "requests", ".", "get", "(", "TOURNAMENTS_XML_URL", ")", "root", "=", "etree", ".", "XML", "(", "schedule_page", ".", "content", ")", "for", "tour", "in", "root", ".", "iter", "(", "'{*...
Get the next 200 tournaments from pokerstars.
[ "Get", "the", "next", "200", "tournaments", "from", "pokerstars", "." ]
2d8cf208fdf2b26bdc935972dcbe7a983a9e9768
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/website/pokerstars.py#L29-L42
237,940
RKrahl/pytest-dependency
setup.py
_filter_file
def _filter_file(src, dest, subst): """Copy src to dest doing substitutions on the fly. """ substre = re.compile(r'\$(%s)' % '|'.join(subst.keys())) def repl(m): return subst[m.group(1)] with open(src, "rt") as sf, open(dest, "wt") as df: while True: l = sf.readline() ...
python
def _filter_file(src, dest, subst): """Copy src to dest doing substitutions on the fly. """ substre = re.compile(r'\$(%s)' % '|'.join(subst.keys())) def repl(m): return subst[m.group(1)] with open(src, "rt") as sf, open(dest, "wt") as df: while True: l = sf.readline() ...
[ "def", "_filter_file", "(", "src", ",", "dest", ",", "subst", ")", ":", "substre", "=", "re", ".", "compile", "(", "r'\\$(%s)'", "%", "'|'", ".", "join", "(", "subst", ".", "keys", "(", ")", ")", ")", "def", "repl", "(", "m", ")", ":", "return", ...
Copy src to dest doing substitutions on the fly.
[ "Copy", "src", "to", "dest", "doing", "substitutions", "on", "the", "fly", "." ]
7b7c10818266ec4b05c36c341cf84f05d7ab53ce
https://github.com/RKrahl/pytest-dependency/blob/7b7c10818266ec4b05c36c341cf84f05d7ab53ce/setup.py#L18-L29
237,941
profusion/sgqlc
sgqlc/endpoint/base.py
BaseEndpoint._fixup_graphql_error
def _fixup_graphql_error(self, data): '''Given a possible GraphQL error payload, make sure it's in shape. This will ensure the given ``data`` is in the shape: .. code-block:: json {"errors": [{"message": "some string"}]} If ``errors`` is not an array, it will be made into ...
python
def _fixup_graphql_error(self, data): '''Given a possible GraphQL error payload, make sure it's in shape. This will ensure the given ``data`` is in the shape: .. code-block:: json {"errors": [{"message": "some string"}]} If ``errors`` is not an array, it will be made into ...
[ "def", "_fixup_graphql_error", "(", "self", ",", "data", ")", ":", "original_data", "=", "data", "errors", "=", "data", ".", "get", "(", "'errors'", ")", "original_errors", "=", "errors", "if", "not", "isinstance", "(", "errors", ",", "list", ")", ":", "...
Given a possible GraphQL error payload, make sure it's in shape. This will ensure the given ``data`` is in the shape: .. code-block:: json {"errors": [{"message": "some string"}]} If ``errors`` is not an array, it will be made into a single element array, with the object i...
[ "Given", "a", "possible", "GraphQL", "error", "payload", "make", "sure", "it", "s", "in", "shape", "." ]
684afb059c93f142150043cafac09b7fd52bfa27
https://github.com/profusion/sgqlc/blob/684afb059c93f142150043cafac09b7fd52bfa27/sgqlc/endpoint/base.py#L104-L163
237,942
profusion/sgqlc
sgqlc/endpoint/base.py
BaseEndpoint.snippet
def snippet(code, locations, sep=' | ', colmark=('-', '^'), context=5): '''Given a code and list of locations, convert to snippet lines. return will include line number, a separator (``sep``), then line contents. At most ``context`` lines are shown before each location line. A...
python
def snippet(code, locations, sep=' | ', colmark=('-', '^'), context=5): '''Given a code and list of locations, convert to snippet lines. return will include line number, a separator (``sep``), then line contents. At most ``context`` lines are shown before each location line. A...
[ "def", "snippet", "(", "code", ",", "locations", ",", "sep", "=", "' | '", ",", "colmark", "=", "(", "'-'", ",", "'^'", ")", ",", "context", "=", "5", ")", ":", "if", "not", "locations", ":", "return", "[", "]", "lines", "=", "code", ".", "split"...
Given a code and list of locations, convert to snippet lines. return will include line number, a separator (``sep``), then line contents. At most ``context`` lines are shown before each location line. After each location line, the column is marked using ``colmark``. The first ...
[ "Given", "a", "code", "and", "list", "of", "locations", "convert", "to", "snippet", "lines", "." ]
684afb059c93f142150043cafac09b7fd52bfa27
https://github.com/profusion/sgqlc/blob/684afb059c93f142150043cafac09b7fd52bfa27/sgqlc/endpoint/base.py#L206-L236
237,943
profusion/sgqlc
sgqlc/types/__init__.py
_create_non_null_wrapper
def _create_non_null_wrapper(name, t): 'creates type wrapper for non-null of given type' def __new__(cls, json_data, selection_list=None): if json_data is None: raise ValueError(name + ' received null value') return t(json_data, selection_list) def __to_graphql_input__(value, in...
python
def _create_non_null_wrapper(name, t): 'creates type wrapper for non-null of given type' def __new__(cls, json_data, selection_list=None): if json_data is None: raise ValueError(name + ' received null value') return t(json_data, selection_list) def __to_graphql_input__(value, in...
[ "def", "_create_non_null_wrapper", "(", "name", ",", "t", ")", ":", "def", "__new__", "(", "cls", ",", "json_data", ",", "selection_list", "=", "None", ")", ":", "if", "json_data", "is", "None", ":", "raise", "ValueError", "(", "name", "+", "' received nul...
creates type wrapper for non-null of given type
[ "creates", "type", "wrapper", "for", "non", "-", "null", "of", "given", "type" ]
684afb059c93f142150043cafac09b7fd52bfa27
https://github.com/profusion/sgqlc/blob/684afb059c93f142150043cafac09b7fd52bfa27/sgqlc/types/__init__.py#L869-L883
237,944
profusion/sgqlc
sgqlc/types/__init__.py
_create_list_of_wrapper
def _create_list_of_wrapper(name, t): 'creates type wrapper for list of given type' def __new__(cls, json_data, selection_list=None): if json_data is None: return None return [t(v, selection_list) for v in json_data] def __to_graphql_input__(value, indent=0, indent_string=' '):...
python
def _create_list_of_wrapper(name, t): 'creates type wrapper for list of given type' def __new__(cls, json_data, selection_list=None): if json_data is None: return None return [t(v, selection_list) for v in json_data] def __to_graphql_input__(value, indent=0, indent_string=' '):...
[ "def", "_create_list_of_wrapper", "(", "name", ",", "t", ")", ":", "def", "__new__", "(", "cls", ",", "json_data", ",", "selection_list", "=", "None", ")", ":", "if", "json_data", "is", "None", ":", "return", "None", "return", "[", "t", "(", "v", ",", ...
creates type wrapper for list of given type
[ "creates", "type", "wrapper", "for", "list", "of", "given", "type" ]
684afb059c93f142150043cafac09b7fd52bfa27
https://github.com/profusion/sgqlc/blob/684afb059c93f142150043cafac09b7fd52bfa27/sgqlc/types/__init__.py#L886-L909
237,945
profusion/sgqlc
sgqlc/endpoint/http.py
add_query_to_url
def add_query_to_url(url, extra_query): '''Adds an extra query to URL, returning the new URL. Extra query may be a dict or a list as returned by :func:`urllib.parse.parse_qsl()` and :func:`urllib.parse.parse_qs()`. ''' split = urllib.parse.urlsplit(url) merged_query = urllib.parse.parse_qsl(sp...
python
def add_query_to_url(url, extra_query): '''Adds an extra query to URL, returning the new URL. Extra query may be a dict or a list as returned by :func:`urllib.parse.parse_qsl()` and :func:`urllib.parse.parse_qs()`. ''' split = urllib.parse.urlsplit(url) merged_query = urllib.parse.parse_qsl(sp...
[ "def", "add_query_to_url", "(", "url", ",", "extra_query", ")", ":", "split", "=", "urllib", ".", "parse", ".", "urlsplit", "(", "url", ")", "merged_query", "=", "urllib", ".", "parse", ".", "parse_qsl", "(", "split", ".", "query", ")", "if", "isinstance...
Adds an extra query to URL, returning the new URL. Extra query may be a dict or a list as returned by :func:`urllib.parse.parse_qsl()` and :func:`urllib.parse.parse_qs()`.
[ "Adds", "an", "extra", "query", "to", "URL", "returning", "the", "new", "URL", "." ]
684afb059c93f142150043cafac09b7fd52bfa27
https://github.com/profusion/sgqlc/blob/684afb059c93f142150043cafac09b7fd52bfa27/sgqlc/endpoint/http.py#L33-L59
237,946
profusion/sgqlc
sgqlc/types/relay.py
connection_args
def connection_args(*lst, **mapping): '''Returns the default parameters for connection. Extra parameters may be given as argument, both as iterable, positional tuples or mapping. By default, provides: - ``after: String`` - ``before: String`` - ``first: Int`` - ``last: Int`` ''...
python
def connection_args(*lst, **mapping): '''Returns the default parameters for connection. Extra parameters may be given as argument, both as iterable, positional tuples or mapping. By default, provides: - ``after: String`` - ``before: String`` - ``first: Int`` - ``last: Int`` ''...
[ "def", "connection_args", "(", "*", "lst", ",", "*", "*", "mapping", ")", ":", "pd", "=", "ArgDict", "(", "*", "lst", ",", "*", "*", "mapping", ")", "pd", ".", "setdefault", "(", "'after'", ",", "String", ")", "pd", ".", "setdefault", "(", "'before...
Returns the default parameters for connection. Extra parameters may be given as argument, both as iterable, positional tuples or mapping. By default, provides: - ``after: String`` - ``before: String`` - ``first: Int`` - ``last: Int``
[ "Returns", "the", "default", "parameters", "for", "connection", "." ]
684afb059c93f142150043cafac09b7fd52bfa27
https://github.com/profusion/sgqlc/blob/684afb059c93f142150043cafac09b7fd52bfa27/sgqlc/types/relay.py#L406-L424
237,947
nchopin/particles
book/pmcmc/pmmh_lingauss_varying_scale.py
msjd
def msjd(theta): """Mean squared jumping distance. """ s = 0. for p in theta.dtype.names: s += np.sum(np.diff(theta[p], axis=0) ** 2) return s
python
def msjd(theta): """Mean squared jumping distance. """ s = 0. for p in theta.dtype.names: s += np.sum(np.diff(theta[p], axis=0) ** 2) return s
[ "def", "msjd", "(", "theta", ")", ":", "s", "=", "0.", "for", "p", "in", "theta", ".", "dtype", ".", "names", ":", "s", "+=", "np", ".", "sum", "(", "np", ".", "diff", "(", "theta", "[", "p", "]", ",", "axis", "=", "0", ")", "**", "2", ")...
Mean squared jumping distance.
[ "Mean", "squared", "jumping", "distance", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/book/pmcmc/pmmh_lingauss_varying_scale.py#L31-L37
237,948
nchopin/particles
particles/smc_samplers.py
StaticModel.loglik
def loglik(self, theta, t=None): """ log-likelihood at given parameter values. Parameters ---------- theta: dict-like theta['par'] is a ndarray containing the N values for parameter par t: int time (if set to None, the full log-likelihood is returned) ...
python
def loglik(self, theta, t=None): """ log-likelihood at given parameter values. Parameters ---------- theta: dict-like theta['par'] is a ndarray containing the N values for parameter par t: int time (if set to None, the full log-likelihood is returned) ...
[ "def", "loglik", "(", "self", ",", "theta", ",", "t", "=", "None", ")", ":", "if", "t", "is", "None", ":", "t", "=", "self", ".", "T", "-", "1", "l", "=", "np", ".", "zeros", "(", "shape", "=", "theta", ".", "shape", "[", "0", "]", ")", "...
log-likelihood at given parameter values. Parameters ---------- theta: dict-like theta['par'] is a ndarray containing the N values for parameter par t: int time (if set to None, the full log-likelihood is returned) Returns ------- l: fl...
[ "log", "-", "likelihood", "at", "given", "parameter", "values", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smc_samplers.py#L91-L111
237,949
nchopin/particles
particles/smc_samplers.py
StaticModel.logpost
def logpost(self, theta, t=None): """Posterior log-density at given parameter values. Parameters ---------- theta: dict-like theta['par'] is a ndarray containing the N values for parameter par t: int time (if set to None, the full posterior is returned)...
python
def logpost(self, theta, t=None): """Posterior log-density at given parameter values. Parameters ---------- theta: dict-like theta['par'] is a ndarray containing the N values for parameter par t: int time (if set to None, the full posterior is returned)...
[ "def", "logpost", "(", "self", ",", "theta", ",", "t", "=", "None", ")", ":", "return", "self", ".", "prior", ".", "logpdf", "(", "theta", ")", "+", "self", ".", "loglik", "(", "theta", ",", "t", ")" ]
Posterior log-density at given parameter values. Parameters ---------- theta: dict-like theta['par'] is a ndarray containing the N values for parameter par t: int time (if set to None, the full posterior is returned) Returns ------- l: ...
[ "Posterior", "log", "-", "density", "at", "given", "parameter", "values", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smc_samplers.py#L113-L128
237,950
nchopin/particles
particles/smc_samplers.py
FancyList.copyto
def copyto(self, src, where=None): """ Same syntax and functionality as numpy.copyto """ for n, _ in enumerate(self.l): if where[n]: self.l[n] = src.l[n]
python
def copyto(self, src, where=None): """ Same syntax and functionality as numpy.copyto """ for n, _ in enumerate(self.l): if where[n]: self.l[n] = src.l[n]
[ "def", "copyto", "(", "self", ",", "src", ",", "where", "=", "None", ")", ":", "for", "n", ",", "_", "in", "enumerate", "(", "self", ".", "l", ")", ":", "if", "where", "[", "n", "]", ":", "self", ".", "l", "[", "n", "]", "=", "src", ".", ...
Same syntax and functionality as numpy.copyto
[ "Same", "syntax", "and", "functionality", "as", "numpy", ".", "copyto" ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smc_samplers.py#L178-L185
237,951
nchopin/particles
particles/smc_samplers.py
ThetaParticles.copy
def copy(self): """Returns a copy of the object.""" attrs = {k: self.__dict__[k].copy() for k in self.containers} attrs.update({k: cp.deepcopy(self.__dict__[k]) for k in self.shared}) return self.__class__(**attrs)
python
def copy(self): """Returns a copy of the object.""" attrs = {k: self.__dict__[k].copy() for k in self.containers} attrs.update({k: cp.deepcopy(self.__dict__[k]) for k in self.shared}) return self.__class__(**attrs)
[ "def", "copy", "(", "self", ")", ":", "attrs", "=", "{", "k", ":", "self", ".", "__dict__", "[", "k", "]", ".", "copy", "(", ")", "for", "k", "in", "self", ".", "containers", "}", "attrs", ".", "update", "(", "{", "k", ":", "cp", ".", "deepco...
Returns a copy of the object.
[ "Returns", "a", "copy", "of", "the", "object", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smc_samplers.py#L245-L249
237,952
nchopin/particles
particles/smc_samplers.py
ThetaParticles.copyto
def copyto(self, src, where=None): """Emulates function `copyto` in NumPy. Parameters ---------- where: (N,) bool ndarray True if particle n in src must be copied. src: (N,) `ThetaParticles` object source for each n such that where[n] is True, cop...
python
def copyto(self, src, where=None): """Emulates function `copyto` in NumPy. Parameters ---------- where: (N,) bool ndarray True if particle n in src must be copied. src: (N,) `ThetaParticles` object source for each n such that where[n] is True, cop...
[ "def", "copyto", "(", "self", ",", "src", ",", "where", "=", "None", ")", ":", "for", "k", "in", "self", ".", "containers", ":", "v", "=", "self", ".", "__dict__", "[", "k", "]", "if", "isinstance", "(", "v", ",", "np", ".", "ndarray", ")", ":"...
Emulates function `copyto` in NumPy. Parameters ---------- where: (N,) bool ndarray True if particle n in src must be copied. src: (N,) `ThetaParticles` object source for each n such that where[n] is True, copy particle n in src into self (at locat...
[ "Emulates", "function", "copyto", "in", "NumPy", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smc_samplers.py#L251-L270
237,953
nchopin/particles
particles/smc_samplers.py
ThetaParticles.copyto_at
def copyto_at(self, n, src, m): """Copy to at a given location. Parameters ---------- n: int index where to copy src: `ThetaParticles` object source m: int index of the element to be copied Note ---- Basical...
python
def copyto_at(self, n, src, m): """Copy to at a given location. Parameters ---------- n: int index where to copy src: `ThetaParticles` object source m: int index of the element to be copied Note ---- Basical...
[ "def", "copyto_at", "(", "self", ",", "n", ",", "src", ",", "m", ")", ":", "for", "k", "in", "self", ".", "containers", ":", "self", ".", "__dict__", "[", "k", "]", "[", "n", "]", "=", "src", ".", "__dict__", "[", "k", "]", "[", "m", "]" ]
Copy to at a given location. Parameters ---------- n: int index where to copy src: `ThetaParticles` object source m: int index of the element to be copied Note ---- Basically, does self[n] <- src[m]
[ "Copy", "to", "at", "a", "given", "location", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smc_samplers.py#L272-L289
237,954
nchopin/particles
particles/smc_samplers.py
MetroParticles.Metropolis
def Metropolis(self, compute_target, mh_options): """Performs a certain number of Metropolis steps. Parameters ---------- compute_target: function computes the target density for the proposed values mh_options: dict + 'type_prop': {'random_walk', 'inde...
python
def Metropolis(self, compute_target, mh_options): """Performs a certain number of Metropolis steps. Parameters ---------- compute_target: function computes the target density for the proposed values mh_options: dict + 'type_prop': {'random_walk', 'inde...
[ "def", "Metropolis", "(", "self", ",", "compute_target", ",", "mh_options", ")", ":", "opts", "=", "mh_options", ".", "copy", "(", ")", "nsteps", "=", "opts", ".", "pop", "(", "'nsteps'", ",", "0", ")", "delta_dist", "=", "opts", ".", "pop", "(", "'d...
Performs a certain number of Metropolis steps. Parameters ---------- compute_target: function computes the target density for the proposed values mh_options: dict + 'type_prop': {'random_walk', 'independent'} type of proposal: either Gaussian ran...
[ "Performs", "a", "certain", "number", "of", "Metropolis", "steps", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smc_samplers.py#L375-L418
237,955
nchopin/particles
particles/hmm.py
BaumWelch.backward
def backward(self): """Backward recursion. Upon completion, the following list of length T is available: * smth: marginal smoothing probabilities Note ---- Performs the forward step in case it has not been performed before. """ if not self.filt: ...
python
def backward(self): """Backward recursion. Upon completion, the following list of length T is available: * smth: marginal smoothing probabilities Note ---- Performs the forward step in case it has not been performed before. """ if not self.filt: ...
[ "def", "backward", "(", "self", ")", ":", "if", "not", "self", ".", "filt", ":", "self", ".", "forward", "(", ")", "self", ".", "smth", "=", "[", "self", ".", "filt", "[", "-", "1", "]", "]", "log_trans", "=", "np", ".", "log", "(", "self", "...
Backward recursion. Upon completion, the following list of length T is available: * smth: marginal smoothing probabilities Note ---- Performs the forward step in case it has not been performed before.
[ "Backward", "recursion", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/hmm.py#L215-L238
237,956
nchopin/particles
particles/kalman.py
predict_step
def predict_step(F, covX, filt): """Predictive step of Kalman filter. Parameters ---------- F: (dx, dx) numpy array Mean of X_t | X_{t-1} is F * X_{t-1} covX: (dx, dx) numpy array covariance of X_t | X_{t-1} filt: MeanAndCov object filtering distribution at time t-1 ...
python
def predict_step(F, covX, filt): """Predictive step of Kalman filter. Parameters ---------- F: (dx, dx) numpy array Mean of X_t | X_{t-1} is F * X_{t-1} covX: (dx, dx) numpy array covariance of X_t | X_{t-1} filt: MeanAndCov object filtering distribution at time t-1 ...
[ "def", "predict_step", "(", "F", ",", "covX", ",", "filt", ")", ":", "pred_mean", "=", "np", ".", "matmul", "(", "filt", ".", "mean", ",", "F", ".", "T", ")", "pred_cov", "=", "dotdot", "(", "F", ",", "filt", ".", "cov", ",", "F", ".", "T", "...
Predictive step of Kalman filter. Parameters ---------- F: (dx, dx) numpy array Mean of X_t | X_{t-1} is F * X_{t-1} covX: (dx, dx) numpy array covariance of X_t | X_{t-1} filt: MeanAndCov object filtering distribution at time t-1 Returns ------- pred: MeanAn...
[ "Predictive", "step", "of", "Kalman", "filter", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/kalman.py#L163-L187
237,957
nchopin/particles
particles/kalman.py
filter_step
def filter_step(G, covY, pred, yt): """Filtering step of Kalman filter. Parameters ---------- G: (dy, dx) numpy array mean of Y_t | X_t is G * X_t covX: (dx, dx) numpy array covariance of Y_t | X_t pred: MeanAndCov object predictive distribution at time t Returns ...
python
def filter_step(G, covY, pred, yt): """Filtering step of Kalman filter. Parameters ---------- G: (dy, dx) numpy array mean of Y_t | X_t is G * X_t covX: (dx, dx) numpy array covariance of Y_t | X_t pred: MeanAndCov object predictive distribution at time t Returns ...
[ "def", "filter_step", "(", "G", ",", "covY", ",", "pred", ",", "yt", ")", ":", "# data prediction", "data_pred_mean", "=", "np", ".", "matmul", "(", "pred", ".", "mean", ",", "G", ".", "T", ")", "data_pred_cov", "=", "dotdot", "(", "G", ",", "pred", ...
Filtering step of Kalman filter. Parameters ---------- G: (dy, dx) numpy array mean of Y_t | X_t is G * X_t covX: (dx, dx) numpy array covariance of Y_t | X_t pred: MeanAndCov object predictive distribution at time t Returns ------- pred: MeanAndCov object ...
[ "Filtering", "step", "of", "Kalman", "filter", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/kalman.py#L190-L223
237,958
nchopin/particles
particles/kalman.py
MVLinearGauss.check_shapes
def check_shapes(self): """ Check all dimensions are correct. """ assert self.covX.shape == (self.dx, self.dx), error_msg assert self.covY.shape == (self.dy, self.dy), error_msg assert self.F.shape == (self.dx, self.dx), error_msg assert self.G.shape == (self.dy, ...
python
def check_shapes(self): """ Check all dimensions are correct. """ assert self.covX.shape == (self.dx, self.dx), error_msg assert self.covY.shape == (self.dy, self.dy), error_msg assert self.F.shape == (self.dx, self.dx), error_msg assert self.G.shape == (self.dy, ...
[ "def", "check_shapes", "(", "self", ")", ":", "assert", "self", ".", "covX", ".", "shape", "==", "(", "self", ".", "dx", ",", "self", ".", "dx", ")", ",", "error_msg", "assert", "self", ".", "covY", ".", "shape", "==", "(", "self", ".", "dy", ","...
Check all dimensions are correct.
[ "Check", "all", "dimensions", "are", "correct", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/kalman.py#L326-L335
237,959
nchopin/particles
particles/qmc.py
sobol
def sobol(N, dim, scrambled=1): """ Sobol sequence. Parameters ---------- N : int length of sequence dim: int dimension scrambled: int which scrambling method to use: + 0: no scrambling + 1: Owen's scrambling + 2: Faure-Tezuka ...
python
def sobol(N, dim, scrambled=1): """ Sobol sequence. Parameters ---------- N : int length of sequence dim: int dimension scrambled: int which scrambling method to use: + 0: no scrambling + 1: Owen's scrambling + 2: Faure-Tezuka ...
[ "def", "sobol", "(", "N", ",", "dim", ",", "scrambled", "=", "1", ")", ":", "while", "(", "True", ")", ":", "seed", "=", "np", ".", "random", ".", "randint", "(", "2", "**", "32", ")", "out", "=", "lowdiscrepancy", ".", "sobol", "(", "N", ",", ...
Sobol sequence. Parameters ---------- N : int length of sequence dim: int dimension scrambled: int which scrambling method to use: + 0: no scrambling + 1: Owen's scrambling + 2: Faure-Tezuka + 3: Owen + Faure-Tezuka Ret...
[ "Sobol", "sequence", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/qmc.py#L29-L64
237,960
nchopin/particles
particles/smoothing.py
smoothing_worker
def smoothing_worker(method=None, N=100, seed=None, fk=None, fk_info=None, add_func=None, log_gamma=None): """Generic worker for off-line smoothing algorithms. This worker may be used in conjunction with utils.multiplexer in order to run in parallel (and eventually compare) off-line s...
python
def smoothing_worker(method=None, N=100, seed=None, fk=None, fk_info=None, add_func=None, log_gamma=None): """Generic worker for off-line smoothing algorithms. This worker may be used in conjunction with utils.multiplexer in order to run in parallel (and eventually compare) off-line s...
[ "def", "smoothing_worker", "(", "method", "=", "None", ",", "N", "=", "100", ",", "seed", "=", "None", ",", "fk", "=", "None", ",", "fk_info", "=", "None", ",", "add_func", "=", "None", ",", "log_gamma", "=", "None", ")", ":", "T", "=", "fk", "."...
Generic worker for off-line smoothing algorithms. This worker may be used in conjunction with utils.multiplexer in order to run in parallel (and eventually compare) off-line smoothing algorithms. Parameters ---------- method: string ['FFBS_ON', 'FFBS_ON2', 'FFBS_QMC', 'tw...
[ "Generic", "worker", "for", "off", "-", "line", "smoothing", "algorithms", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smoothing.py#L367-L444
237,961
nchopin/particles
particles/smoothing.py
ParticleHistory.save
def save(self, X=None, w=None, A=None): """Save one "page" of history at a given time. .. note:: This method is used internally by `SMC` to store the state of the particle system at each time t. In most cases, users should not have to call this method directly. ...
python
def save(self, X=None, w=None, A=None): """Save one "page" of history at a given time. .. note:: This method is used internally by `SMC` to store the state of the particle system at each time t. In most cases, users should not have to call this method directly. ...
[ "def", "save", "(", "self", ",", "X", "=", "None", ",", "w", "=", "None", ",", "A", "=", "None", ")", ":", "self", ".", "X", ".", "append", "(", "X", ")", "self", ".", "wgt", ".", "append", "(", "w", ")", "self", ".", "A", ".", "append", ...
Save one "page" of history at a given time. .. note:: This method is used internally by `SMC` to store the state of the particle system at each time t. In most cases, users should not have to call this method directly.
[ "Save", "one", "page", "of", "history", "at", "a", "given", "time", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smoothing.py#L92-L102
237,962
nchopin/particles
particles/smoothing.py
ParticleHistory.extract_one_trajectory
def extract_one_trajectory(self): """Extract a single trajectory from the particle history. The final state is chosen randomly, then the corresponding trajectory is constructed backwards, until time t=0. """ traj = [] for t in reversed(range(self.T)): if t ...
python
def extract_one_trajectory(self): """Extract a single trajectory from the particle history. The final state is chosen randomly, then the corresponding trajectory is constructed backwards, until time t=0. """ traj = [] for t in reversed(range(self.T)): if t ...
[ "def", "extract_one_trajectory", "(", "self", ")", ":", "traj", "=", "[", "]", "for", "t", "in", "reversed", "(", "range", "(", "self", ".", "T", ")", ")", ":", "if", "t", "==", "self", ".", "T", "-", "1", ":", "n", "=", "rs", ".", "multinomial...
Extract a single trajectory from the particle history. The final state is chosen randomly, then the corresponding trajectory is constructed backwards, until time t=0.
[ "Extract", "a", "single", "trajectory", "from", "the", "particle", "history", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smoothing.py#L104-L117
237,963
nchopin/particles
particles/smoothing.py
ParticleHistory.compute_trajectories
def compute_trajectories(self): """Compute the N trajectories that constitute the current genealogy. Compute and add attribute ``B`` to ``self`` where ``B`` is an array such that ``B[t,n]`` is the index of ancestor at time t of particle X_T^n, where T is the current length of history. ...
python
def compute_trajectories(self): """Compute the N trajectories that constitute the current genealogy. Compute and add attribute ``B`` to ``self`` where ``B`` is an array such that ``B[t,n]`` is the index of ancestor at time t of particle X_T^n, where T is the current length of history. ...
[ "def", "compute_trajectories", "(", "self", ")", ":", "self", ".", "B", "=", "np", ".", "empty", "(", "(", "self", ".", "T", ",", "self", ".", "N", ")", ",", "'int'", ")", "self", ".", "B", "[", "-", "1", ",", ":", "]", "=", "self", ".", "A...
Compute the N trajectories that constitute the current genealogy. Compute and add attribute ``B`` to ``self`` where ``B`` is an array such that ``B[t,n]`` is the index of ancestor at time t of particle X_T^n, where T is the current length of history.
[ "Compute", "the", "N", "trajectories", "that", "constitute", "the", "current", "genealogy", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smoothing.py#L119-L129
237,964
nchopin/particles
particles/smoothing.py
ParticleHistory.twofilter_smoothing
def twofilter_smoothing(self, t, info, phi, loggamma, linear_cost=False, return_ess=False, modif_forward=None, modif_info=None): """Two-filter smoothing. Parameters ---------- t: time, in range 0 <= t < T-1 info: SMC object...
python
def twofilter_smoothing(self, t, info, phi, loggamma, linear_cost=False, return_ess=False, modif_forward=None, modif_info=None): """Two-filter smoothing. Parameters ---------- t: time, in range 0 <= t < T-1 info: SMC object...
[ "def", "twofilter_smoothing", "(", "self", ",", "t", ",", "info", ",", "phi", ",", "loggamma", ",", "linear_cost", "=", "False", ",", "return_ess", "=", "False", ",", "modif_forward", "=", "None", ",", "modif_info", "=", "None", ")", ":", "ti", "=", "s...
Two-filter smoothing. Parameters ---------- t: time, in range 0 <= t < T-1 info: SMC object the information filter phi: function test function, a function of (X_t,X_{t+1}) loggamma: function a function of (X_{t+1}) linear_cost...
[ "Two", "-", "filter", "smoothing", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smoothing.py#L286-L317
237,965
nchopin/particles
particles/core.py
multiSMC
def multiSMC(nruns=10, nprocs=0, out_func=None, **args): """Run SMC algorithms in parallel, for different combinations of parameters. `multiSMC` relies on the `multiplexer` utility, and obeys the same logic. A basic usage is:: results = multiSMC(fk=my_fk_model, N=100, nruns=20, nprocs=0) T...
python
def multiSMC(nruns=10, nprocs=0, out_func=None, **args): """Run SMC algorithms in parallel, for different combinations of parameters. `multiSMC` relies on the `multiplexer` utility, and obeys the same logic. A basic usage is:: results = multiSMC(fk=my_fk_model, N=100, nruns=20, nprocs=0) T...
[ "def", "multiSMC", "(", "nruns", "=", "10", ",", "nprocs", "=", "0", ",", "out_func", "=", "None", ",", "*", "*", "args", ")", ":", "def", "f", "(", "*", "*", "args", ")", ":", "pf", "=", "SMC", "(", "*", "*", "args", ")", "pf", ".", "run",...
Run SMC algorithms in parallel, for different combinations of parameters. `multiSMC` relies on the `multiplexer` utility, and obeys the same logic. A basic usage is:: results = multiSMC(fk=my_fk_model, N=100, nruns=20, nprocs=0) This runs the same SMC algorithm 20 times, using all available CP...
[ "Run", "SMC", "algorithms", "in", "parallel", "for", "different", "combinations", "of", "parameters", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/core.py#L438-L512
237,966
nchopin/particles
particles/core.py
SMC.reset_weights
def reset_weights(self): """Reset weights after a resampling step. """ if self.fk.isAPF: lw = (rs.log_mean_exp(self.logetat, W=self.W) - self.logetat[self.A]) self.wgts = rs.Weights(lw=lw) else: self.wgts = rs.Weights()
python
def reset_weights(self): """Reset weights after a resampling step. """ if self.fk.isAPF: lw = (rs.log_mean_exp(self.logetat, W=self.W) - self.logetat[self.A]) self.wgts = rs.Weights(lw=lw) else: self.wgts = rs.Weights()
[ "def", "reset_weights", "(", "self", ")", ":", "if", "self", ".", "fk", ".", "isAPF", ":", "lw", "=", "(", "rs", ".", "log_mean_exp", "(", "self", ".", "logetat", ",", "W", "=", "self", ".", "W", ")", "-", "self", ".", "logetat", "[", "self", "...
Reset weights after a resampling step.
[ "Reset", "weights", "after", "a", "resampling", "step", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/core.py#L317-L325
237,967
nchopin/particles
particles/resampling.py
log_sum_exp
def log_sum_exp(v): """Log of the sum of the exp of the arguments. Parameters ---------- v: ndarray Returns ------- l: float l = log(sum(exp(v))) Note ---- use the log_sum_exp trick to avoid overflow: i.e. we remove the max of v before exponentiating, then we add...
python
def log_sum_exp(v): """Log of the sum of the exp of the arguments. Parameters ---------- v: ndarray Returns ------- l: float l = log(sum(exp(v))) Note ---- use the log_sum_exp trick to avoid overflow: i.e. we remove the max of v before exponentiating, then we add...
[ "def", "log_sum_exp", "(", "v", ")", ":", "m", "=", "v", ".", "max", "(", ")", "return", "m", "+", "np", ".", "log", "(", "np", ".", "sum", "(", "np", ".", "exp", "(", "v", "-", "m", ")", ")", ")" ]
Log of the sum of the exp of the arguments. Parameters ---------- v: ndarray Returns ------- l: float l = log(sum(exp(v))) Note ---- use the log_sum_exp trick to avoid overflow: i.e. we remove the max of v before exponentiating, then we add it back See also ...
[ "Log", "of", "the", "sum", "of", "the", "exp", "of", "the", "arguments", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/resampling.py#L233-L256
237,968
nchopin/particles
particles/resampling.py
log_sum_exp_ab
def log_sum_exp_ab(a, b): """log_sum_exp for two scalars. Parameters ---------- a, b: float Returns ------- c: float c = log(e^a + e^b) """ if a > b: return a + np.log(1. + np.exp(b - a)) else: return b + np.log(1. + np.exp(a - b))
python
def log_sum_exp_ab(a, b): """log_sum_exp for two scalars. Parameters ---------- a, b: float Returns ------- c: float c = log(e^a + e^b) """ if a > b: return a + np.log(1. + np.exp(b - a)) else: return b + np.log(1. + np.exp(a - b))
[ "def", "log_sum_exp_ab", "(", "a", ",", "b", ")", ":", "if", "a", ">", "b", ":", "return", "a", "+", "np", ".", "log", "(", "1.", "+", "np", ".", "exp", "(", "b", "-", "a", ")", ")", "else", ":", "return", "b", "+", "np", ".", "log", "(",...
log_sum_exp for two scalars. Parameters ---------- a, b: float Returns ------- c: float c = log(e^a + e^b)
[ "log_sum_exp", "for", "two", "scalars", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/resampling.py#L259-L274
237,969
nchopin/particles
particles/resampling.py
wmean_and_var
def wmean_and_var(W, x): """Component-wise weighted mean and variance. Parameters ---------- W: (N,) ndarray normalised weights (must be >=0 and sum to one). x: ndarray (such that shape[0]==N) data Returns ------- dictionary {'mean':weighted_means, 'var':weig...
python
def wmean_and_var(W, x): """Component-wise weighted mean and variance. Parameters ---------- W: (N,) ndarray normalised weights (must be >=0 and sum to one). x: ndarray (such that shape[0]==N) data Returns ------- dictionary {'mean':weighted_means, 'var':weig...
[ "def", "wmean_and_var", "(", "W", ",", "x", ")", ":", "m", "=", "np", ".", "average", "(", "x", ",", "weights", "=", "W", ",", "axis", "=", "0", ")", "m2", "=", "np", ".", "average", "(", "x", "**", "2", ",", "weights", "=", "W", ",", "axis...
Component-wise weighted mean and variance. Parameters ---------- W: (N,) ndarray normalised weights (must be >=0 and sum to one). x: ndarray (such that shape[0]==N) data Returns ------- dictionary {'mean':weighted_means, 'var':weighted_variances}
[ "Component", "-", "wise", "weighted", "mean", "and", "variance", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/resampling.py#L306-L324
237,970
nchopin/particles
particles/resampling.py
wmean_and_var_str_array
def wmean_and_var_str_array(W, x): """Weighted mean and variance of each component of a structured array. Parameters ---------- W: (N,) ndarray normalised weights (must be >=0 and sum to one). x: (N,) structured array data Returns ------- dictionary {'mean':...
python
def wmean_and_var_str_array(W, x): """Weighted mean and variance of each component of a structured array. Parameters ---------- W: (N,) ndarray normalised weights (must be >=0 and sum to one). x: (N,) structured array data Returns ------- dictionary {'mean':...
[ "def", "wmean_and_var_str_array", "(", "W", ",", "x", ")", ":", "m", "=", "np", ".", "empty", "(", "shape", "=", "x", ".", "shape", "[", "1", ":", "]", ",", "dtype", "=", "x", ".", "dtype", ")", "v", "=", "np", ".", "empty_like", "(", "m", ")...
Weighted mean and variance of each component of a structured array. Parameters ---------- W: (N,) ndarray normalised weights (must be >=0 and sum to one). x: (N,) structured array data Returns ------- dictionary {'mean':weighted_means, 'var':weighted_variances}
[ "Weighted", "mean", "and", "variance", "of", "each", "component", "of", "a", "structured", "array", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/resampling.py#L326-L345
237,971
nchopin/particles
particles/resampling.py
wquantiles
def wquantiles(W, x, alphas=(0.25, 0.50, 0.75)): """Quantiles for weighted data. Parameters ---------- W: (N,) ndarray normalised weights (weights are >=0 and sum to one) x: (N,) or (N,d) ndarray data alphas: list-like of size k (default: (0.25, 0.50, 0.75)) probabilitie...
python
def wquantiles(W, x, alphas=(0.25, 0.50, 0.75)): """Quantiles for weighted data. Parameters ---------- W: (N,) ndarray normalised weights (weights are >=0 and sum to one) x: (N,) or (N,d) ndarray data alphas: list-like of size k (default: (0.25, 0.50, 0.75)) probabilitie...
[ "def", "wquantiles", "(", "W", ",", "x", ",", "alphas", "=", "(", "0.25", ",", "0.50", ",", "0.75", ")", ")", ":", "if", "len", "(", "x", ".", "shape", ")", "==", "1", ":", "return", "_wquantiles", "(", "W", ",", "x", ",", "alphas", "=", "alp...
Quantiles for weighted data. Parameters ---------- W: (N,) ndarray normalised weights (weights are >=0 and sum to one) x: (N,) or (N,d) ndarray data alphas: list-like of size k (default: (0.25, 0.50, 0.75)) probabilities (between 0. and 1.) Returns ------- a (k...
[ "Quantiles", "for", "weighted", "data", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/resampling.py#L359-L379
237,972
nchopin/particles
particles/resampling.py
wquantiles_str_array
def wquantiles_str_array(W, x, alphas=(0.25, 0.50, 0,75)): """quantiles for weighted data stored in a structured array. Parameters ---------- W: (N,) ndarray normalised weights (weights are >=0 and sum to one) x: (N,) structured array data alphas: list-like of size k (default: ...
python
def wquantiles_str_array(W, x, alphas=(0.25, 0.50, 0,75)): """quantiles for weighted data stored in a structured array. Parameters ---------- W: (N,) ndarray normalised weights (weights are >=0 and sum to one) x: (N,) structured array data alphas: list-like of size k (default: ...
[ "def", "wquantiles_str_array", "(", "W", ",", "x", ",", "alphas", "=", "(", "0.25", ",", "0.50", ",", "0", ",", "75", ")", ")", ":", "return", "{", "p", ":", "wquantiles", "(", "W", ",", "x", "[", "p", "]", ",", "alphas", ")", "for", "p", "in...
quantiles for weighted data stored in a structured array. Parameters ---------- W: (N,) ndarray normalised weights (weights are >=0 and sum to one) x: (N,) structured array data alphas: list-like of size k (default: (0.25, 0.50, 0.75)) probabilities (between 0. and 1.) ...
[ "quantiles", "for", "weighted", "data", "stored", "in", "a", "structured", "array", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/resampling.py#L381-L399
237,973
nchopin/particles
particles/resampling.py
resampling_scheme
def resampling_scheme(func): """Decorator for resampling schemes.""" @functools.wraps(func) def modif_func(W, M=None): M = W.shape[0] if M is None else M return func(W, M) rs_funcs[func.__name__] = modif_func modif_func.__doc__ = rs_doc % func.__name__.capitalize() return modif...
python
def resampling_scheme(func): """Decorator for resampling schemes.""" @functools.wraps(func) def modif_func(W, M=None): M = W.shape[0] if M is None else M return func(W, M) rs_funcs[func.__name__] = modif_func modif_func.__doc__ = rs_doc % func.__name__.capitalize() return modif...
[ "def", "resampling_scheme", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "modif_func", "(", "W", ",", "M", "=", "None", ")", ":", "M", "=", "W", ".", "shape", "[", "0", "]", "if", "M", "is", "None", "else", "M...
Decorator for resampling schemes.
[ "Decorator", "for", "resampling", "schemes", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/resampling.py#L423-L433
237,974
nchopin/particles
particles/resampling.py
inverse_cdf
def inverse_cdf(su, W): """Inverse CDF algorithm for a finite distribution. Parameters ---------- su: (M,) ndarray M sorted uniform variates (i.e. M ordered points in [0,1]). W: (N,) ndarray a vector of N normalized weights (>=0 and sum to one) Re...
python
def inverse_cdf(su, W): """Inverse CDF algorithm for a finite distribution. Parameters ---------- su: (M,) ndarray M sorted uniform variates (i.e. M ordered points in [0,1]). W: (N,) ndarray a vector of N normalized weights (>=0 and sum to one) Re...
[ "def", "inverse_cdf", "(", "su", ",", "W", ")", ":", "j", "=", "0", "s", "=", "W", "[", "0", "]", "M", "=", "su", ".", "shape", "[", "0", "]", "A", "=", "np", ".", "empty", "(", "M", ",", "'int'", ")", "for", "n", "in", "range", "(", "M...
Inverse CDF algorithm for a finite distribution. Parameters ---------- su: (M,) ndarray M sorted uniform variates (i.e. M ordered points in [0,1]). W: (N,) ndarray a vector of N normalized weights (>=0 and sum to one) Returns ------- ...
[ "Inverse", "CDF", "algorithm", "for", "a", "finite", "distribution", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/resampling.py#L443-L467
237,975
nchopin/particles
particles/hilbert.py
hilbert_array
def hilbert_array(xint): """Compute Hilbert indices. Parameters ---------- xint: (N, d) int numpy.ndarray Returns ------- h: (N,) int numpy.ndarray Hilbert indices """ N, d = xint.shape h = np.zeros(N, int64) for n in range(N): h[n] = Hilbert_to_int(xint[n...
python
def hilbert_array(xint): """Compute Hilbert indices. Parameters ---------- xint: (N, d) int numpy.ndarray Returns ------- h: (N,) int numpy.ndarray Hilbert indices """ N, d = xint.shape h = np.zeros(N, int64) for n in range(N): h[n] = Hilbert_to_int(xint[n...
[ "def", "hilbert_array", "(", "xint", ")", ":", "N", ",", "d", "=", "xint", ".", "shape", "h", "=", "np", ".", "zeros", "(", "N", ",", "int64", ")", "for", "n", "in", "range", "(", "N", ")", ":", "h", "[", "n", "]", "=", "Hilbert_to_int", "(",...
Compute Hilbert indices. Parameters ---------- xint: (N, d) int numpy.ndarray Returns ------- h: (N,) int numpy.ndarray Hilbert indices
[ "Compute", "Hilbert", "indices", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/hilbert.py#L17-L33
237,976
nchopin/particles
particles/mcmc.py
MCMC.mean_sq_jump_dist
def mean_sq_jump_dist(self, discard_frac=0.1): """Mean squared jumping distance estimated from chain. Parameters ---------- discard_frac: float fraction of iterations to discard at the beginning (as a burn-in) Returns ------- float """ ...
python
def mean_sq_jump_dist(self, discard_frac=0.1): """Mean squared jumping distance estimated from chain. Parameters ---------- discard_frac: float fraction of iterations to discard at the beginning (as a burn-in) Returns ------- float """ ...
[ "def", "mean_sq_jump_dist", "(", "self", ",", "discard_frac", "=", "0.1", ")", ":", "discard", "=", "int", "(", "self", ".", "niter", "*", "discard_frac", ")", "return", "msjd", "(", "self", ".", "chain", ".", "theta", "[", "discard", ":", "]", ")" ]
Mean squared jumping distance estimated from chain. Parameters ---------- discard_frac: float fraction of iterations to discard at the beginning (as a burn-in) Returns ------- float
[ "Mean", "squared", "jumping", "distance", "estimated", "from", "chain", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/mcmc.py#L99-L112
237,977
nchopin/particles
particles/mcmc.py
VanishCovTracker.update
def update(self, v): """Adds point v""" self.t += 1 g = self.gamma() self.mu = (1. - g) * self.mu + g * v mv = v - self.mu self.Sigma = ((1. - g) * self.Sigma + g * np.dot(mv[:, np.newaxis], mv[np.newaxis, :])) try: self.L = chole...
python
def update(self, v): """Adds point v""" self.t += 1 g = self.gamma() self.mu = (1. - g) * self.mu + g * v mv = v - self.mu self.Sigma = ((1. - g) * self.Sigma + g * np.dot(mv[:, np.newaxis], mv[np.newaxis, :])) try: self.L = chole...
[ "def", "update", "(", "self", ",", "v", ")", ":", "self", ".", "t", "+=", "1", "g", "=", "self", ".", "gamma", "(", ")", "self", ".", "mu", "=", "(", "1.", "-", "g", ")", "*", "self", ".", "mu", "+", "g", "*", "v", "mv", "=", "v", "-", ...
Adds point v
[ "Adds", "point", "v" ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/mcmc.py#L161-L172
237,978
nchopin/particles
particles/utils.py
cartesian_lists
def cartesian_lists(d): """ turns a dict of lists into a list of dicts that represents the cartesian product of the initial lists Example ------- cartesian_lists({'a':[0, 2], 'b':[3, 4, 5]} returns [ {'a':0, 'b':3}, {'a':0, 'b':4}, ... {'a':2, 'b':5} ] """ return [{k: v for k, ...
python
def cartesian_lists(d): """ turns a dict of lists into a list of dicts that represents the cartesian product of the initial lists Example ------- cartesian_lists({'a':[0, 2], 'b':[3, 4, 5]} returns [ {'a':0, 'b':3}, {'a':0, 'b':4}, ... {'a':2, 'b':5} ] """ return [{k: v for k, ...
[ "def", "cartesian_lists", "(", "d", ")", ":", "return", "[", "{", "k", ":", "v", "for", "k", ",", "v", "in", "zip", "(", "d", ".", "keys", "(", ")", ",", "args", ")", "}", "for", "args", "in", "itertools", ".", "product", "(", "*", "d", ".", ...
turns a dict of lists into a list of dicts that represents the cartesian product of the initial lists Example ------- cartesian_lists({'a':[0, 2], 'b':[3, 4, 5]} returns [ {'a':0, 'b':3}, {'a':0, 'b':4}, ... {'a':2, 'b':5} ]
[ "turns", "a", "dict", "of", "lists", "into", "a", "list", "of", "dicts", "that", "represents", "the", "cartesian", "product", "of", "the", "initial", "lists" ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/utils.py#L87-L100
237,979
nchopin/particles
particles/utils.py
cartesian_args
def cartesian_args(args, listargs, dictargs): """ Compute a list of inputs and outputs for a function with kw arguments. args: dict fixed arguments, e.g. {'x': 3}, then x=3 for all inputs listargs: dict arguments specified as a list; then the inputs should be the Cartesian product...
python
def cartesian_args(args, listargs, dictargs): """ Compute a list of inputs and outputs for a function with kw arguments. args: dict fixed arguments, e.g. {'x': 3}, then x=3 for all inputs listargs: dict arguments specified as a list; then the inputs should be the Cartesian product...
[ "def", "cartesian_args", "(", "args", ",", "listargs", ",", "dictargs", ")", ":", "ils", "=", "{", "k", ":", "[", "v", ",", "]", "for", "k", ",", "v", "in", "args", ".", "items", "(", ")", "}", "ils", ".", "update", "(", "listargs", ")", "ils",...
Compute a list of inputs and outputs for a function with kw arguments. args: dict fixed arguments, e.g. {'x': 3}, then x=3 for all inputs listargs: dict arguments specified as a list; then the inputs should be the Cartesian products of these lists dictargs: dict same as ab...
[ "Compute", "a", "list", "of", "inputs", "and", "outputs", "for", "a", "function", "with", "kw", "arguments", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/utils.py#L103-L122
237,980
nchopin/particles
particles/utils.py
worker
def worker(qin, qout, f): """Worker for muliprocessing. A worker repeatedly picks a dict of arguments in the queue and computes f for this set of arguments, until the input queue is empty. """ while not qin.empty(): i, args = qin.get() qout.put((i, f(**args)))
python
def worker(qin, qout, f): """Worker for muliprocessing. A worker repeatedly picks a dict of arguments in the queue and computes f for this set of arguments, until the input queue is empty. """ while not qin.empty(): i, args = qin.get() qout.put((i, f(**args)))
[ "def", "worker", "(", "qin", ",", "qout", ",", "f", ")", ":", "while", "not", "qin", ".", "empty", "(", ")", ":", "i", ",", "args", "=", "qin", ".", "get", "(", ")", "qout", ".", "put", "(", "(", "i", ",", "f", "(", "*", "*", "args", ")",...
Worker for muliprocessing. A worker repeatedly picks a dict of arguments in the queue and computes f for this set of arguments, until the input queue is empty.
[ "Worker", "for", "muliprocessing", ".", "A", "worker", "repeatedly", "picks", "a", "dict", "of", "arguments", "in", "the", "queue", "and", "computes", "f", "for", "this", "set", "of", "arguments", "until", "the", "input", "queue", "is", "empty", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/utils.py#L133-L141
237,981
nchopin/particles
particles/utils.py
distinct_seeds
def distinct_seeds(k): """ returns k distinct seeds for random number generation """ seeds = [] for _ in range(k): while True: s = random.randint(2**32 - 1) if s not in seeds: break seeds.append(s) return seeds
python
def distinct_seeds(k): """ returns k distinct seeds for random number generation """ seeds = [] for _ in range(k): while True: s = random.randint(2**32 - 1) if s not in seeds: break seeds.append(s) return seeds
[ "def", "distinct_seeds", "(", "k", ")", ":", "seeds", "=", "[", "]", "for", "_", "in", "range", "(", "k", ")", ":", "while", "True", ":", "s", "=", "random", ".", "randint", "(", "2", "**", "32", "-", "1", ")", "if", "s", "not", "in", "seeds"...
returns k distinct seeds for random number generation
[ "returns", "k", "distinct", "seeds", "for", "random", "number", "generation" ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/utils.py#L179-L189
237,982
nchopin/particles
particles/utils.py
multiplexer
def multiplexer(f=None, nruns=1, nprocs=1, seeding=None, **args): """Evaluate a function for different parameters, optionally in parallel. Parameters ---------- f: function function f to evaluate, must take only kw arguments as inputs nruns: int number of evaluations of f for each...
python
def multiplexer(f=None, nruns=1, nprocs=1, seeding=None, **args): """Evaluate a function for different parameters, optionally in parallel. Parameters ---------- f: function function f to evaluate, must take only kw arguments as inputs nruns: int number of evaluations of f for each...
[ "def", "multiplexer", "(", "f", "=", "None", ",", "nruns", "=", "1", ",", "nprocs", "=", "1", ",", "seeding", "=", "None", ",", "*", "*", "args", ")", ":", "if", "not", "callable", "(", "f", ")", ":", "raise", "ValueError", "(", "'multiplexer: func...
Evaluate a function for different parameters, optionally in parallel. Parameters ---------- f: function function f to evaluate, must take only kw arguments as inputs nruns: int number of evaluations of f for each set of arguments nprocs: int + if <=0, set to actual number ...
[ "Evaluate", "a", "function", "for", "different", "parameters", "optionally", "in", "parallel", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/utils.py#L192-L240
237,983
nchopin/particles
particles/state_space_models.py
StateSpaceModel.simulate
def simulate(self, T): """Simulate state and observation processes. Parameters ---------- T: int processes are simulated from time 0 to time T-1 Returns ------- x, y: lists lists of length T """ x = [] for t in ra...
python
def simulate(self, T): """Simulate state and observation processes. Parameters ---------- T: int processes are simulated from time 0 to time T-1 Returns ------- x, y: lists lists of length T """ x = [] for t in ra...
[ "def", "simulate", "(", "self", ",", "T", ")", ":", "x", "=", "[", "]", "for", "t", "in", "range", "(", "T", ")", ":", "law_x", "=", "self", ".", "PX0", "(", ")", "if", "t", "==", "0", "else", "self", ".", "PX", "(", "t", ",", "x", "[", ...
Simulate state and observation processes. Parameters ---------- T: int processes are simulated from time 0 to time T-1 Returns ------- x, y: lists lists of length T
[ "Simulate", "state", "and", "observation", "processes", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/state_space_models.py#L280-L298
237,984
nchopin/particles
book/mle/malikpitt_interpolation.py
interpoled_resampling
def interpoled_resampling(W, x): """Resampling based on an interpolated CDF, as described in Malik and Pitt. Parameters ---------- W: (N,) array weights x: (N,) array particles Returns ------- xrs: (N,) array the resampled particles """ N = W.shape[...
python
def interpoled_resampling(W, x): """Resampling based on an interpolated CDF, as described in Malik and Pitt. Parameters ---------- W: (N,) array weights x: (N,) array particles Returns ------- xrs: (N,) array the resampled particles """ N = W.shape[...
[ "def", "interpoled_resampling", "(", "W", ",", "x", ")", ":", "N", "=", "W", ".", "shape", "[", "0", "]", "idx", "=", "np", ".", "argsort", "(", "x", ")", "xs", "=", "x", "[", "idx", "]", "ws", "=", "W", "[", "idx", "]", "cs", "=", "np", ...
Resampling based on an interpolated CDF, as described in Malik and Pitt. Parameters ---------- W: (N,) array weights x: (N,) array particles Returns ------- xrs: (N,) array the resampled particles
[ "Resampling", "based", "on", "an", "interpolated", "CDF", "as", "described", "in", "Malik", "and", "Pitt", "." ]
3faa97a1073db45c5889eef3e015dd76ef350b52
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/book/mle/malikpitt_interpolation.py#L26-L59
237,985
Fortran-FOSS-Programmers/ford
ford/sourceform.py
sort_items
def sort_items(self,items,args=False): """ Sort the `self`'s contents, as contained in the list `items` as specified in `self`'s meta-data. """ if self.settings['sort'].lower() == 'src': return def alpha(i): return i.name def permission(i): if args: if i.intent ==...
python
def sort_items(self,items,args=False): """ Sort the `self`'s contents, as contained in the list `items` as specified in `self`'s meta-data. """ if self.settings['sort'].lower() == 'src': return def alpha(i): return i.name def permission(i): if args: if i.intent ==...
[ "def", "sort_items", "(", "self", ",", "items", ",", "args", "=", "False", ")", ":", "if", "self", ".", "settings", "[", "'sort'", "]", ".", "lower", "(", ")", "==", "'src'", ":", "return", "def", "alpha", "(", "i", ")", ":", "return", "i", ".", ...
Sort the `self`'s contents, as contained in the list `items` as specified in `self`'s meta-data.
[ "Sort", "the", "self", "s", "contents", "as", "contained", "in", "the", "list", "items", "as", "specified", "in", "self", "s", "meta", "-", "data", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/sourceform.py#L2402-L2451
237,986
Fortran-FOSS-Programmers/ford
ford/sourceform.py
FortranBase.contents_size
def contents_size(self): ''' Returns the number of different categories to be shown in the contents side-bar in the HTML documentation. ''' count = 0 if hasattr(self,'variables'): count += 1 if hasattr(self,'types'): count += 1 if hasattr(self,'modules'): ...
python
def contents_size(self): ''' Returns the number of different categories to be shown in the contents side-bar in the HTML documentation. ''' count = 0 if hasattr(self,'variables'): count += 1 if hasattr(self,'types'): count += 1 if hasattr(self,'modules'): ...
[ "def", "contents_size", "(", "self", ")", ":", "count", "=", "0", "if", "hasattr", "(", "self", ",", "'variables'", ")", ":", "count", "+=", "1", "if", "hasattr", "(", "self", ",", "'types'", ")", ":", "count", "+=", "1", "if", "hasattr", "(", "sel...
Returns the number of different categories to be shown in the contents side-bar in the HTML documentation.
[ "Returns", "the", "number", "of", "different", "categories", "to", "be", "shown", "in", "the", "contents", "side", "-", "bar", "in", "the", "HTML", "documentation", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/sourceform.py#L267-L292
237,987
Fortran-FOSS-Programmers/ford
ford/sourceform.py
FortranBase.sort
def sort(self): ''' Sorts components of the object. ''' if hasattr(self,'variables'): sort_items(self,self.variables) if hasattr(self,'modules'): sort_items(self,self.modules) if hasattr(self,'submodules'): sort_items(self,self.submodul...
python
def sort(self): ''' Sorts components of the object. ''' if hasattr(self,'variables'): sort_items(self,self.variables) if hasattr(self,'modules'): sort_items(self,self.modules) if hasattr(self,'submodules'): sort_items(self,self.submodul...
[ "def", "sort", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'variables'", ")", ":", "sort_items", "(", "self", ",", "self", ".", "variables", ")", "if", "hasattr", "(", "self", ",", "'modules'", ")", ":", "sort_items", "(", "self", ",",...
Sorts components of the object.
[ "Sorts", "components", "of", "the", "object", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/sourceform.py#L417-L451
237,988
Fortran-FOSS-Programmers/ford
ford/sourceform.py
FortranBase.make_links
def make_links(self, project): """ Process intra-site links to documentation of other parts of the program. """ self.doc = ford.utils.sub_links(self.doc,project) if 'summary' in self.meta: self.meta['summary'] = ford.utils.sub_links(self.meta['summary'],project) ...
python
def make_links(self, project): """ Process intra-site links to documentation of other parts of the program. """ self.doc = ford.utils.sub_links(self.doc,project) if 'summary' in self.meta: self.meta['summary'] = ford.utils.sub_links(self.meta['summary'],project) ...
[ "def", "make_links", "(", "self", ",", "project", ")", ":", "self", ".", "doc", "=", "ford", ".", "utils", ".", "sub_links", "(", "self", ".", "doc", ",", "project", ")", "if", "'summary'", "in", "self", ".", "meta", ":", "self", ".", "meta", "[", ...
Process intra-site links to documentation of other parts of the program.
[ "Process", "intra", "-", "site", "links", "to", "documentation", "of", "other", "parts", "of", "the", "program", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/sourceform.py#L454-L475
237,989
Fortran-FOSS-Programmers/ford
ford/sourceform.py
FortranBase.iterator
def iterator(self, *argv): """ Iterator returning any list of elements via attribute lookup in `self` This iterator retains the order of the arguments """ for arg in argv: if hasattr(self, arg): for item in getattr(self, arg): yield item
python
def iterator(self, *argv): """ Iterator returning any list of elements via attribute lookup in `self` This iterator retains the order of the arguments """ for arg in argv: if hasattr(self, arg): for item in getattr(self, arg): yield item
[ "def", "iterator", "(", "self", ",", "*", "argv", ")", ":", "for", "arg", "in", "argv", ":", "if", "hasattr", "(", "self", ",", "arg", ")", ":", "for", "item", "in", "getattr", "(", "self", ",", "arg", ")", ":", "yield", "item" ]
Iterator returning any list of elements via attribute lookup in `self` This iterator retains the order of the arguments
[ "Iterator", "returning", "any", "list", "of", "elements", "via", "attribute", "lookup", "in", "self" ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/sourceform.py#L486-L493
237,990
Fortran-FOSS-Programmers/ford
ford/sourceform.py
FortranModule.get_used_entities
def get_used_entities(self,use_specs): """ Returns the entities which are imported by a use statement. These are contained in dicts. """ if len(use_specs.strip()) == 0: return (self.pub_procs, self.pub_absints, self.pub_types, self.pub_vars) only = bool(self.O...
python
def get_used_entities(self,use_specs): """ Returns the entities which are imported by a use statement. These are contained in dicts. """ if len(use_specs.strip()) == 0: return (self.pub_procs, self.pub_absints, self.pub_types, self.pub_vars) only = bool(self.O...
[ "def", "get_used_entities", "(", "self", ",", "use_specs", ")", ":", "if", "len", "(", "use_specs", ".", "strip", "(", ")", ")", "==", "0", ":", "return", "(", "self", ".", "pub_procs", ",", "self", ".", "pub_absints", ",", "self", ".", "pub_types", ...
Returns the entities which are imported by a use statement. These are contained in dicts.
[ "Returns", "the", "entities", "which", "are", "imported", "by", "a", "use", "statement", ".", "These", "are", "contained", "in", "dicts", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/sourceform.py#L1138-L1188
237,991
Fortran-FOSS-Programmers/ford
ford/sourceform.py
NameSelector.get_name
def get_name(self,item): """ Return the name for this item registered with this NameSelector. If no name has previously been registered, then generate a new one. """ if not isinstance(item,ford.sourceform.FortranBase): raise Exception('{} is not of a type deri...
python
def get_name(self,item): """ Return the name for this item registered with this NameSelector. If no name has previously been registered, then generate a new one. """ if not isinstance(item,ford.sourceform.FortranBase): raise Exception('{} is not of a type deri...
[ "def", "get_name", "(", "self", ",", "item", ")", ":", "if", "not", "isinstance", "(", "item", ",", "ford", ".", "sourceform", ".", "FortranBase", ")", ":", "raise", "Exception", "(", "'{} is not of a type derived from FortranBase'", ".", "format", "(", "str",...
Return the name for this item registered with this NameSelector. If no name has previously been registered, then generate a new one.
[ "Return", "the", "name", "for", "this", "item", "registered", "with", "this", "NameSelector", ".", "If", "no", "name", "has", "previously", "been", "registered", "then", "generate", "a", "new", "one", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/sourceform.py#L2466-L2493
237,992
Fortran-FOSS-Programmers/ford
ford/__init__.py
main
def main(proj_data,proj_docs,md): """ Main driver of FORD. """ if proj_data['relative']: proj_data['project_url'] = '.' # Parse the files in your project project = ford.fortran_project.Project(proj_data) if len(project.files) < 1: print("Error: No source files with appropriate extens...
python
def main(proj_data,proj_docs,md): """ Main driver of FORD. """ if proj_data['relative']: proj_data['project_url'] = '.' # Parse the files in your project project = ford.fortran_project.Project(proj_data) if len(project.files) < 1: print("Error: No source files with appropriate extens...
[ "def", "main", "(", "proj_data", ",", "proj_docs", ",", "md", ")", ":", "if", "proj_data", "[", "'relative'", "]", ":", "proj_data", "[", "'project_url'", "]", "=", "'.'", "# Parse the files in your project", "project", "=", "ford", ".", "fortran_project", "."...
Main driver of FORD.
[ "Main", "driver", "of", "FORD", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/__init__.py#L337-L382
237,993
Fortran-FOSS-Programmers/ford
ford/fixed2free2.py
convertToFree
def convertToFree(stream, length_limit=True): """Convert stream from fixed source form to free source form.""" linestack = [] for line in stream: convline = FortranLine(line, length_limit) if convline.is_regular: if convline.isContinuation and linestack: ...
python
def convertToFree(stream, length_limit=True): """Convert stream from fixed source form to free source form.""" linestack = [] for line in stream: convline = FortranLine(line, length_limit) if convline.is_regular: if convline.isContinuation and linestack: ...
[ "def", "convertToFree", "(", "stream", ",", "length_limit", "=", "True", ")", ":", "linestack", "=", "[", "]", "for", "line", "in", "stream", ":", "convline", "=", "FortranLine", "(", "line", ",", "length_limit", ")", "if", "convline", ".", "is_regular", ...
Convert stream from fixed source form to free source form.
[ "Convert", "stream", "from", "fixed", "source", "form", "to", "free", "source", "form", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/fixed2free2.py#L110-L127
237,994
Fortran-FOSS-Programmers/ford
ford/fixed2free2.py
FortranLine.continueLine
def continueLine(self): """Insert line continuation symbol at end of line.""" if not (self.isLong and self.is_regular): self.line_conv = self.line_conv.rstrip() + " &\n" else: temp = self.line_conv[:72].rstrip() + " &" self.line_conv = temp.ljust(72) + self.e...
python
def continueLine(self): """Insert line continuation symbol at end of line.""" if not (self.isLong and self.is_regular): self.line_conv = self.line_conv.rstrip() + " &\n" else: temp = self.line_conv[:72].rstrip() + " &" self.line_conv = temp.ljust(72) + self.e...
[ "def", "continueLine", "(", "self", ")", ":", "if", "not", "(", "self", ".", "isLong", "and", "self", ".", "is_regular", ")", ":", "self", ".", "line_conv", "=", "self", ".", "line_conv", ".", "rstrip", "(", ")", "+", "\" &\\n\"", "else", ":", "temp"...
Insert line continuation symbol at end of line.
[ "Insert", "line", "continuation", "symbol", "at", "end", "of", "line", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/fixed2free2.py#L52-L59
237,995
Fortran-FOSS-Programmers/ford
ford/fortran_project.py
id_mods
def id_mods(obj,modlist,intrinsic_mods={},submodlist=[]): """ Match USE statements up with the right modules """ for i in range(len(obj.uses)): for candidate in modlist: if obj.uses[i][0].lower() == candidate.name.lower(): obj.uses[i] = [candidate, obj.uses[i][1]] ...
python
def id_mods(obj,modlist,intrinsic_mods={},submodlist=[]): """ Match USE statements up with the right modules """ for i in range(len(obj.uses)): for candidate in modlist: if obj.uses[i][0].lower() == candidate.name.lower(): obj.uses[i] = [candidate, obj.uses[i][1]] ...
[ "def", "id_mods", "(", "obj", ",", "modlist", ",", "intrinsic_mods", "=", "{", "}", ",", "submodlist", "=", "[", "]", ")", ":", "for", "i", "in", "range", "(", "len", "(", "obj", ".", "uses", ")", ")", ":", "for", "candidate", "in", "modlist", ":...
Match USE statements up with the right modules
[ "Match", "USE", "statements", "up", "with", "the", "right", "modules" ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/fortran_project.py#L338-L366
237,996
Fortran-FOSS-Programmers/ford
ford/fortran_project.py
Project.allfiles
def allfiles(self): """ Instead of duplicating files, it is much more efficient to create the itterator on the fly """ for f in self.files: yield f for f in self.extra_files: yield f
python
def allfiles(self): """ Instead of duplicating files, it is much more efficient to create the itterator on the fly """ for f in self.files: yield f for f in self.extra_files: yield f
[ "def", "allfiles", "(", "self", ")", ":", "for", "f", "in", "self", ".", "files", ":", "yield", "f", "for", "f", "in", "self", ".", "extra_files", ":", "yield", "f" ]
Instead of duplicating files, it is much more efficient to create the itterator on the fly
[ "Instead", "of", "duplicating", "files", "it", "is", "much", "more", "efficient", "to", "create", "the", "itterator", "on", "the", "fly" ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/fortran_project.py#L124-L129
237,997
Fortran-FOSS-Programmers/ford
ford/fortran_project.py
Project.make_links
def make_links(self,base_url='..'): """ Substitute intrasite links to documentation for other parts of the program. """ ford.sourceform.set_base_url(base_url) for src in self.allfiles: src.make_links(self)
python
def make_links(self,base_url='..'): """ Substitute intrasite links to documentation for other parts of the program. """ ford.sourceform.set_base_url(base_url) for src in self.allfiles: src.make_links(self)
[ "def", "make_links", "(", "self", ",", "base_url", "=", "'..'", ")", ":", "ford", ".", "sourceform", ".", "set_base_url", "(", "base_url", ")", "for", "src", "in", "self", ".", "allfiles", ":", "src", ".", "make_links", "(", "self", ")" ]
Substitute intrasite links to documentation for other parts of the program.
[ "Substitute", "intrasite", "links", "to", "documentation", "for", "other", "parts", "of", "the", "program", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/fortran_project.py#L305-L312
237,998
Fortran-FOSS-Programmers/ford
ford/utils.py
sub_notes
def sub_notes(docs): """ Substitutes the special controls for notes, warnings, todos, and bugs with the corresponding div. """ def substitute(match): ret = "</p><div class=\"alert alert-{}\" role=\"alert\"><h4>{}</h4>" \ "<p>{}</p></div>".format(NOTE_TYPE[match.group(1).lower()...
python
def sub_notes(docs): """ Substitutes the special controls for notes, warnings, todos, and bugs with the corresponding div. """ def substitute(match): ret = "</p><div class=\"alert alert-{}\" role=\"alert\"><h4>{}</h4>" \ "<p>{}</p></div>".format(NOTE_TYPE[match.group(1).lower()...
[ "def", "sub_notes", "(", "docs", ")", ":", "def", "substitute", "(", "match", ")", ":", "ret", "=", "\"</p><div class=\\\"alert alert-{}\\\" role=\\\"alert\\\"><h4>{}</h4>\"", "\"<p>{}</p></div>\"", ".", "format", "(", "NOTE_TYPE", "[", "match", ".", "group", "(", "...
Substitutes the special controls for notes, warnings, todos, and bugs with the corresponding div.
[ "Substitutes", "the", "special", "controls", "for", "notes", "warnings", "todos", "and", "bugs", "with", "the", "corresponding", "div", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/utils.py#L42-L55
237,999
Fortran-FOSS-Programmers/ford
ford/utils.py
paren_split
def paren_split(sep,string): """ Splits the string into pieces divided by sep, when sep is outside of parentheses. """ if len(sep) != 1: raise Exception("Separation string must be one character long") retlist = [] level = 0 blevel = 0 left = 0 for i in range(len(string)): if ...
python
def paren_split(sep,string): """ Splits the string into pieces divided by sep, when sep is outside of parentheses. """ if len(sep) != 1: raise Exception("Separation string must be one character long") retlist = [] level = 0 blevel = 0 left = 0 for i in range(len(string)): if ...
[ "def", "paren_split", "(", "sep", ",", "string", ")", ":", "if", "len", "(", "sep", ")", "!=", "1", ":", "raise", "Exception", "(", "\"Separation string must be one character long\"", ")", "retlist", "=", "[", "]", "level", "=", "0", "blevel", "=", "0", ...
Splits the string into pieces divided by sep, when sep is outside of parentheses.
[ "Splits", "the", "string", "into", "pieces", "divided", "by", "sep", "when", "sep", "is", "outside", "of", "parentheses", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/utils.py#L88-L106