repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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_pred_mean", "=", "np", ".", "matmul", "(", "pred", ".", "mean", ",", "G", ".", "T", ")", "data_pred_cov", "=", "dotdot", "(", "G", ",", "pred", ".", "cov", ",", ...
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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: function f...
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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'", "]", "=", "'.'", "project", "=", "ford", ".", "fortran_project", ".", "Project", "(", "proj_data", ...
Main driver of FORD.
[ "Main", "driver", "of", "FORD", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/__init__.py#L337-L382
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
Fortran-FOSS-Programmers/ford
ford/utils.py
quote_split
def quote_split(sep,string): """ Splits the strings into pieces divided by sep, when sep in not inside quotes. """ if len(sep) != 1: raise Exception("Separation string must be one character long") retlist = [] squote = False dquote = False left = 0 i = 0 while i < len(string): ...
python
def quote_split(sep,string): """ Splits the strings into pieces divided by sep, when sep in not inside quotes. """ if len(sep) != 1: raise Exception("Separation string must be one character long") retlist = [] squote = False dquote = False left = 0 i = 0 while i < len(string): ...
[ "def", "quote_split", "(", "sep", ",", "string", ")", ":", "if", "len", "(", "sep", ")", "!=", "1", ":", "raise", "Exception", "(", "\"Separation string must be one character long\"", ")", "retlist", "=", "[", "]", "squote", "=", "False", "dquote", "=", "F...
Splits the strings into pieces divided by sep, when sep in not inside quotes.
[ "Splits", "the", "strings", "into", "pieces", "divided", "by", "sep", "when", "sep", "in", "not", "inside", "quotes", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/utils.py#L110-L140
train
Fortran-FOSS-Programmers/ford
ford/utils.py
split_path
def split_path(path): ''' Splits the argument into its constituent directories and returns them as a list. ''' def recurse_path(path,retlist): if len(retlist) > 100: fullpath = os.path.join(*([ path, ] + retlist)) print("Directory '{}' contains too many levels".format...
python
def split_path(path): ''' Splits the argument into its constituent directories and returns them as a list. ''' def recurse_path(path,retlist): if len(retlist) > 100: fullpath = os.path.join(*([ path, ] + retlist)) print("Directory '{}' contains too many levels".format...
[ "def", "split_path", "(", "path", ")", ":", "def", "recurse_path", "(", "path", ",", "retlist", ")", ":", "if", "len", "(", "retlist", ")", ">", "100", ":", "fullpath", "=", "os", ".", "path", ".", "join", "(", "*", "(", "[", "path", ",", "]", ...
Splits the argument into its constituent directories and returns them as a list.
[ "Splits", "the", "argument", "into", "its", "constituent", "directories", "and", "returns", "them", "as", "a", "list", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/utils.py#L143-L167
train
Fortran-FOSS-Programmers/ford
ford/utils.py
sub_macros
def sub_macros(string,base_url): ''' Replaces macros in documentation with their appropriate values. These macros are used for things like providing URLs. ''' macros = { '|url|': base_url, '|media|': os.path.join(base_url,'media'), '|page|': os.path.join(base_url,'page'...
python
def sub_macros(string,base_url): ''' Replaces macros in documentation with their appropriate values. These macros are used for things like providing URLs. ''' macros = { '|url|': base_url, '|media|': os.path.join(base_url,'media'), '|page|': os.path.join(base_url,'page'...
[ "def", "sub_macros", "(", "string", ",", "base_url", ")", ":", "macros", "=", "{", "'|url|'", ":", "base_url", ",", "'|media|'", ":", "os", ".", "path", ".", "join", "(", "base_url", ",", "'media'", ")", ",", "'|page|'", ":", "os", ".", "path", ".", ...
Replaces macros in documentation with their appropriate values. These macros are used for things like providing URLs.
[ "Replaces", "macros", "in", "documentation", "with", "their", "appropriate", "values", ".", "These", "macros", "are", "used", "for", "things", "like", "providing", "URLs", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/utils.py#L279-L290
train
Fortran-FOSS-Programmers/ford
ford/output.py
copytree
def copytree(src, dst): """Replaces shutil.copytree to avoid problems on certain file systems. shutil.copytree() and shutil.copystat() invoke os.setxattr(), which seems to fail when called for directories on at least one NFS file system. The current routine is a simple replacement, which should be good...
python
def copytree(src, dst): """Replaces shutil.copytree to avoid problems on certain file systems. shutil.copytree() and shutil.copystat() invoke os.setxattr(), which seems to fail when called for directories on at least one NFS file system. The current routine is a simple replacement, which should be good...
[ "def", "copytree", "(", "src", ",", "dst", ")", ":", "def", "touch", "(", "path", ")", ":", "now", "=", "time", ".", "time", "(", ")", "try", ":", "os", ".", "utime", "(", "path", ",", "(", "now", ",", "now", ")", ")", "except", "os", ".", ...
Replaces shutil.copytree to avoid problems on certain file systems. shutil.copytree() and shutil.copystat() invoke os.setxattr(), which seems to fail when called for directories on at least one NFS file system. The current routine is a simple replacement, which should be good enough for Ford.
[ "Replaces", "shutil", ".", "copytree", "to", "avoid", "problems", "on", "certain", "file", "systems", "." ]
d46a44eae20d99205292c31785f936fbed47070f
https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/output.py#L520-L551
train
gem/oq-engine
openquake/calculators/export/hazard.py
export_hmaps_csv
def export_hmaps_csv(key, dest, sitemesh, array, comment): """ Export the hazard maps of the given realization into CSV. :param key: output_type and export_type :param dest: name of the exported file :param sitemesh: site collection :param array: a composite array of dtype hmap_dt :param co...
python
def export_hmaps_csv(key, dest, sitemesh, array, comment): """ Export the hazard maps of the given realization into CSV. :param key: output_type and export_type :param dest: name of the exported file :param sitemesh: site collection :param array: a composite array of dtype hmap_dt :param co...
[ "def", "export_hmaps_csv", "(", "key", ",", "dest", ",", "sitemesh", ",", "array", ",", "comment", ")", ":", "curves", "=", "util", ".", "compose_arrays", "(", "sitemesh", ",", "array", ")", "writers", ".", "write_csv", "(", "dest", ",", "curves", ",", ...
Export the hazard maps of the given realization into CSV. :param key: output_type and export_type :param dest: name of the exported file :param sitemesh: site collection :param array: a composite array of dtype hmap_dt :param comment: comment to use as header of the exported CSV file
[ "Export", "the", "hazard", "maps", "of", "the", "given", "realization", "into", "CSV", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/export/hazard.py#L223-L235
train
gem/oq-engine
openquake/calculators/export/hazard.py
export_hcurves_by_imt_csv
def export_hcurves_by_imt_csv( key, kind, rlzs_assoc, fname, sitecol, array, oq, checksum): """ Export the curves of the given realization into CSV. :param key: output_type and export_type :param kind: a string with the kind of output (realization or statistics) :param rlzs_assoc: a :class:...
python
def export_hcurves_by_imt_csv( key, kind, rlzs_assoc, fname, sitecol, array, oq, checksum): """ Export the curves of the given realization into CSV. :param key: output_type and export_type :param kind: a string with the kind of output (realization or statistics) :param rlzs_assoc: a :class:...
[ "def", "export_hcurves_by_imt_csv", "(", "key", ",", "kind", ",", "rlzs_assoc", ",", "fname", ",", "sitecol", ",", "array", ",", "oq", ",", "checksum", ")", ":", "nsites", "=", "len", "(", "sitecol", ")", "fnames", "=", "[", "]", "for", "imt", ",", "...
Export the curves of the given realization into CSV. :param key: output_type and export_type :param kind: a string with the kind of output (realization or statistics) :param rlzs_assoc: a :class:`openquake.commonlib.source.RlzsAssoc` instance :param fname: name of the exported file :param sitecol: ...
[ "Export", "the", "curves", "of", "the", "given", "realization", "into", "CSV", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/export/hazard.py#L248-L277
train
gem/oq-engine
openquake/calculators/export/hazard.py
export_hcurves_csv
def export_hcurves_csv(ekey, dstore): """ Exports the hazard curves into several .csv files :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ oq = dstore['oqparam'] info = get_info(dstore) rlzs_assoc = dstore['csm_info'].get_rlzs_assoc() R...
python
def export_hcurves_csv(ekey, dstore): """ Exports the hazard curves into several .csv files :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ oq = dstore['oqparam'] info = get_info(dstore) rlzs_assoc = dstore['csm_info'].get_rlzs_assoc() R...
[ "def", "export_hcurves_csv", "(", "ekey", ",", "dstore", ")", ":", "oq", "=", "dstore", "[", "'oqparam'", "]", "info", "=", "get_info", "(", "dstore", ")", "rlzs_assoc", "=", "dstore", "[", "'csm_info'", "]", ".", "get_rlzs_assoc", "(", ")", "R", "=", ...
Exports the hazard curves into several .csv files :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object
[ "Exports", "the", "hazard", "curves", "into", "several", ".", "csv", "files" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/export/hazard.py#L333-L373
train
gem/oq-engine
openquake/calculators/export/hazard.py
save_disagg_to_csv
def save_disagg_to_csv(metadata, matrices): """ Save disaggregation matrices to multiple .csv files. """ skip_keys = ('Mag', 'Dist', 'Lon', 'Lat', 'Eps', 'TRT') base_header = ','.join( '%s=%s' % (key, value) for key, value in metadata.items() if value is not None and key not in skip_...
python
def save_disagg_to_csv(metadata, matrices): """ Save disaggregation matrices to multiple .csv files. """ skip_keys = ('Mag', 'Dist', 'Lon', 'Lat', 'Eps', 'TRT') base_header = ','.join( '%s=%s' % (key, value) for key, value in metadata.items() if value is not None and key not in skip_...
[ "def", "save_disagg_to_csv", "(", "metadata", ",", "matrices", ")", ":", "skip_keys", "=", "(", "'Mag'", ",", "'Dist'", ",", "'Lon'", ",", "'Lat'", ",", "'Eps'", ",", "'TRT'", ")", "base_header", "=", "','", ".", "join", "(", "'%s=%s'", "%", "(", "key"...
Save disaggregation matrices to multiple .csv files.
[ "Save", "disaggregation", "matrices", "to", "multiple", ".", "csv", "files", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/export/hazard.py#L743-L776
train
gem/oq-engine
openquake/hazardlib/gsim/bradley_2013b.py
Bradley2013bChchCBD._interp_function
def _interp_function(self, y_ip1, y_i, t_ip1, t_i, imt_per): """ Generic interpolation function used in equation 19 of 2013 report. """ return y_i + (y_ip1 - y_i) / (t_ip1 - t_i) * (imt_per - t_i)
python
def _interp_function(self, y_ip1, y_i, t_ip1, t_i, imt_per): """ Generic interpolation function used in equation 19 of 2013 report. """ return y_i + (y_ip1 - y_i) / (t_ip1 - t_i) * (imt_per - t_i)
[ "def", "_interp_function", "(", "self", ",", "y_ip1", ",", "y_i", ",", "t_ip1", ",", "t_i", ",", "imt_per", ")", ":", "return", "y_i", "+", "(", "y_ip1", "-", "y_i", ")", "/", "(", "t_ip1", "-", "t_i", ")", "*", "(", "imt_per", "-", "t_i", ")" ]
Generic interpolation function used in equation 19 of 2013 report.
[ "Generic", "interpolation", "function", "used", "in", "equation", "19", "of", "2013", "report", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bradley_2013b.py#L154-L158
train
gem/oq-engine
openquake/hazardlib/gsim/bradley_2013b.py
Bradley2013bChchCBD._get_SRF_tau
def _get_SRF_tau(self, imt_per): """ Table 6 and equation 19 of 2013 report. """ if imt_per < 1: srf = 0.87 elif 1 <= imt_per < 5: srf = self._interp_function(0.58, 0.87, 5, 1, imt_per) elif 5 <= imt_per <= 10: srf = 0.58 else: ...
python
def _get_SRF_tau(self, imt_per): """ Table 6 and equation 19 of 2013 report. """ if imt_per < 1: srf = 0.87 elif 1 <= imt_per < 5: srf = self._interp_function(0.58, 0.87, 5, 1, imt_per) elif 5 <= imt_per <= 10: srf = 0.58 else: ...
[ "def", "_get_SRF_tau", "(", "self", ",", "imt_per", ")", ":", "if", "imt_per", "<", "1", ":", "srf", "=", "0.87", "elif", "1", "<=", "imt_per", "<", "5", ":", "srf", "=", "self", ".", "_interp_function", "(", "0.58", ",", "0.87", ",", "5", ",", "...
Table 6 and equation 19 of 2013 report.
[ "Table", "6", "and", "equation", "19", "of", "2013", "report", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bradley_2013b.py#L160-L173
train
gem/oq-engine
openquake/hazardlib/gsim/bradley_2013b.py
Bradley2013bChchCBD._get_SRF_phi
def _get_SRF_phi(self, imt_per): """ Table 7 and equation 19 of 2013 report. NB change in notation, 2013 report calls this term 'sigma' but it is referred to here as phi. """ if imt_per < 0.6: srf = 0.8 elif 0.6 <= imt_per < 1: srf = self._...
python
def _get_SRF_phi(self, imt_per): """ Table 7 and equation 19 of 2013 report. NB change in notation, 2013 report calls this term 'sigma' but it is referred to here as phi. """ if imt_per < 0.6: srf = 0.8 elif 0.6 <= imt_per < 1: srf = self._...
[ "def", "_get_SRF_phi", "(", "self", ",", "imt_per", ")", ":", "if", "imt_per", "<", "0.6", ":", "srf", "=", "0.8", "elif", "0.6", "<=", "imt_per", "<", "1", ":", "srf", "=", "self", ".", "_interp_function", "(", "0.7", ",", "0.8", ",", "1", ",", ...
Table 7 and equation 19 of 2013 report. NB change in notation, 2013 report calls this term 'sigma' but it is referred to here as phi.
[ "Table", "7", "and", "equation", "19", "of", "2013", "report", ".", "NB", "change", "in", "notation", "2013", "report", "calls", "this", "term", "sigma", "but", "it", "is", "referred", "to", "here", "as", "phi", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bradley_2013b.py#L175-L190
train
gem/oq-engine
openquake/hazardlib/gsim/bradley_2013b.py
Bradley2013bChchCBD._get_SRF_sigma
def _get_SRF_sigma(self, imt_per): """ Table 8 and equation 19 of 2013 report. NB change in notation, 2013 report calls this term 'sigma_t' but it is referred to here as sigma. Note that Table 8 is identical to Table 7 in the 2013 report. """ if imt_per < 0.6: ...
python
def _get_SRF_sigma(self, imt_per): """ Table 8 and equation 19 of 2013 report. NB change in notation, 2013 report calls this term 'sigma_t' but it is referred to here as sigma. Note that Table 8 is identical to Table 7 in the 2013 report. """ if imt_per < 0.6: ...
[ "def", "_get_SRF_sigma", "(", "self", ",", "imt_per", ")", ":", "if", "imt_per", "<", "0.6", ":", "srf", "=", "0.8", "elif", "0.6", "<=", "imt_per", "<", "1", ":", "srf", "=", "self", ".", "_interp_function", "(", "0.7", ",", "0.8", ",", "1", ",", ...
Table 8 and equation 19 of 2013 report. NB change in notation, 2013 report calls this term 'sigma_t' but it is referred to here as sigma. Note that Table 8 is identical to Table 7 in the 2013 report.
[ "Table", "8", "and", "equation", "19", "of", "2013", "report", ".", "NB", "change", "in", "notation", "2013", "report", "calls", "this", "term", "sigma_t", "but", "it", "is", "referred", "to", "here", "as", "sigma", ".", "Note", "that", "Table", "8", "...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bradley_2013b.py#L192-L208
train
gem/oq-engine
openquake/hazardlib/gsim/bradley_2013b.py
Bradley2013bChchCBD._get_dL2L
def _get_dL2L(self, imt_per): """ Table 3 and equation 19 of 2013 report. """ if imt_per < 0.18: dL2L = -0.06 elif 0.18 <= imt_per < 0.35: dL2L = self._interp_function(0.12, -0.06, 0.35, 0.18, imt_per) elif 0.35 <= imt_per <= 10: dL2L =...
python
def _get_dL2L(self, imt_per): """ Table 3 and equation 19 of 2013 report. """ if imt_per < 0.18: dL2L = -0.06 elif 0.18 <= imt_per < 0.35: dL2L = self._interp_function(0.12, -0.06, 0.35, 0.18, imt_per) elif 0.35 <= imt_per <= 10: dL2L =...
[ "def", "_get_dL2L", "(", "self", ",", "imt_per", ")", ":", "if", "imt_per", "<", "0.18", ":", "dL2L", "=", "-", "0.06", "elif", "0.18", "<=", "imt_per", "<", "0.35", ":", "dL2L", "=", "self", ".", "_interp_function", "(", "0.12", ",", "-", "0.06", ...
Table 3 and equation 19 of 2013 report.
[ "Table", "3", "and", "equation", "19", "of", "2013", "report", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bradley_2013b.py#L210-L223
train
gem/oq-engine
openquake/hazardlib/gsim/bradley_2013b.py
Bradley2013bChchCBD._get_dS2S
def _get_dS2S(self, imt_per): """ Table 4 of 2013 report """ if imt_per == 0: dS2S = 0.05 elif 0 < imt_per < 0.15: dS2S = self._interp_function(-0.15, 0.05, 0.15, 0, imt_per) elif 0.15 <= imt_per < 0.45: dS2S = self._interp_function(0.4...
python
def _get_dS2S(self, imt_per): """ Table 4 of 2013 report """ if imt_per == 0: dS2S = 0.05 elif 0 < imt_per < 0.15: dS2S = self._interp_function(-0.15, 0.05, 0.15, 0, imt_per) elif 0.15 <= imt_per < 0.45: dS2S = self._interp_function(0.4...
[ "def", "_get_dS2S", "(", "self", ",", "imt_per", ")", ":", "if", "imt_per", "==", "0", ":", "dS2S", "=", "0.05", "elif", "0", "<", "imt_per", "<", "0.15", ":", "dS2S", "=", "self", ".", "_interp_function", "(", "-", "0.15", ",", "0.05", ",", "0.15"...
Table 4 of 2013 report
[ "Table", "4", "of", "2013", "report" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bradley_2013b.py#L225-L244
train
gem/oq-engine
openquake/hazardlib/calc/filters.py
context
def context(src): """ Used to add the source_id to the error message. To be used as with context(src): operation_with(src) Typically the operation is filtering a source, that can fail for tricky geometries. """ try: yield except Exception: etype, err, tb = sys.e...
python
def context(src): """ Used to add the source_id to the error message. To be used as with context(src): operation_with(src) Typically the operation is filtering a source, that can fail for tricky geometries. """ try: yield except Exception: etype, err, tb = sys.e...
[ "def", "context", "(", "src", ")", ":", "try", ":", "yield", "except", "Exception", ":", "etype", ",", "err", ",", "tb", "=", "sys", ".", "exc_info", "(", ")", "msg", "=", "'An error occurred with source id=%s. Error: %s'", "msg", "%=", "(", "src", ".", ...
Used to add the source_id to the error message. To be used as with context(src): operation_with(src) Typically the operation is filtering a source, that can fail for tricky geometries.
[ "Used", "to", "add", "the", "source_id", "to", "the", "error", "message", ".", "To", "be", "used", "as" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/filters.py#L39-L55
train
gem/oq-engine
openquake/hazardlib/calc/filters.py
IntegrationDistance.get_bounding_box
def get_bounding_box(self, lon, lat, trt=None, mag=None): """ Build a bounding box around the given lon, lat by computing the maximum_distance at the given tectonic region type and magnitude. :param lon: longitude :param lat: latitude :param trt: tectonic region type, po...
python
def get_bounding_box(self, lon, lat, trt=None, mag=None): """ Build a bounding box around the given lon, lat by computing the maximum_distance at the given tectonic region type and magnitude. :param lon: longitude :param lat: latitude :param trt: tectonic region type, po...
[ "def", "get_bounding_box", "(", "self", ",", "lon", ",", "lat", ",", "trt", "=", "None", ",", "mag", "=", "None", ")", ":", "if", "trt", "is", "None", ":", "maxdist", "=", "max", "(", "self", "(", "trt", ",", "mag", ")", "for", "trt", "in", "se...
Build a bounding box around the given lon, lat by computing the maximum_distance at the given tectonic region type and magnitude. :param lon: longitude :param lat: latitude :param trt: tectonic region type, possibly None :param mag: magnitude, possibly None :returns: min...
[ "Build", "a", "bounding", "box", "around", "the", "given", "lon", "lat", "by", "computing", "the", "maximum_distance", "at", "the", "given", "tectonic", "region", "type", "and", "magnitude", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/filters.py#L138-L155
train
gem/oq-engine
openquake/hazardlib/calc/filters.py
IntegrationDistance.get_affected_box
def get_affected_box(self, src): """ Get the enlarged bounding box of a source. :param src: a source object :returns: a bounding box (min_lon, min_lat, max_lon, max_lat) """ mag = src.get_min_max_mag()[1] maxdist = self(src.tectonic_region_type, mag) bbox...
python
def get_affected_box(self, src): """ Get the enlarged bounding box of a source. :param src: a source object :returns: a bounding box (min_lon, min_lat, max_lon, max_lat) """ mag = src.get_min_max_mag()[1] maxdist = self(src.tectonic_region_type, mag) bbox...
[ "def", "get_affected_box", "(", "self", ",", "src", ")", ":", "mag", "=", "src", ".", "get_min_max_mag", "(", ")", "[", "1", "]", "maxdist", "=", "self", "(", "src", ".", "tectonic_region_type", ",", "mag", ")", "bbox", "=", "get_bounding_box", "(", "s...
Get the enlarged bounding box of a source. :param src: a source object :returns: a bounding box (min_lon, min_lat, max_lon, max_lat)
[ "Get", "the", "enlarged", "bounding", "box", "of", "a", "source", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/filters.py#L157-L167
train
gem/oq-engine
openquake/hazardlib/calc/filters.py
SourceFilter.sitecol
def sitecol(self): """ Read the site collection from .filename and cache it """ if 'sitecol' in vars(self): return self.__dict__['sitecol'] if self.filename is None or not os.path.exists(self.filename): # case of nofilter/None sitecol return ...
python
def sitecol(self): """ Read the site collection from .filename and cache it """ if 'sitecol' in vars(self): return self.__dict__['sitecol'] if self.filename is None or not os.path.exists(self.filename): # case of nofilter/None sitecol return ...
[ "def", "sitecol", "(", "self", ")", ":", "if", "'sitecol'", "in", "vars", "(", "self", ")", ":", "return", "self", ".", "__dict__", "[", "'sitecol'", "]", "if", "self", ".", "filename", "is", "None", "or", "not", "os", ".", "path", ".", "exists", "...
Read the site collection from .filename and cache it
[ "Read", "the", "site", "collection", "from", ".", "filename", "and", "cache", "it" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/filters.py#L276-L287
train
gem/oq-engine
openquake/hazardlib/geo/surface/simple_fault.py
SimpleFaultSurface.hypocentre_patch_index
def hypocentre_patch_index(cls, hypocentre, rupture_top_edge, upper_seismogenic_depth, lower_seismogenic_depth, dip): """ This methods finds the index of the fault patch including the hypocentre. :param hypocentre: ...
python
def hypocentre_patch_index(cls, hypocentre, rupture_top_edge, upper_seismogenic_depth, lower_seismogenic_depth, dip): """ This methods finds the index of the fault patch including the hypocentre. :param hypocentre: ...
[ "def", "hypocentre_patch_index", "(", "cls", ",", "hypocentre", ",", "rupture_top_edge", ",", "upper_seismogenic_depth", ",", "lower_seismogenic_depth", ",", "dip", ")", ":", "totaln_patch", "=", "len", "(", "rupture_top_edge", ")", "indexlist", "=", "[", "]", "di...
This methods finds the index of the fault patch including the hypocentre. :param hypocentre: :class:`~openquake.hazardlib.geo.point.Point` object representing the location of hypocentre. :param rupture_top_edge: A instances of :class:`openquake.hazardlib.geo....
[ "This", "methods", "finds", "the", "index", "of", "the", "fault", "patch", "including", "the", "hypocentre", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/simple_fault.py#L256-L298
train
gem/oq-engine
openquake/hazardlib/geo/surface/simple_fault.py
SimpleFaultSurface.get_surface_vertexes
def get_surface_vertexes(cls, fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip): """ Get surface main vertexes. Parameters are the same as for :meth:`from_fault_data`, excluding mesh spacing. :returns: ...
python
def get_surface_vertexes(cls, fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip): """ Get surface main vertexes. Parameters are the same as for :meth:`from_fault_data`, excluding mesh spacing. :returns: ...
[ "def", "get_surface_vertexes", "(", "cls", ",", "fault_trace", ",", "upper_seismogenic_depth", ",", "lower_seismogenic_depth", ",", "dip", ")", ":", "dip_tan", "=", "math", ".", "tan", "(", "math", ".", "radians", "(", "dip", ")", ")", "hdist_top", "=", "upp...
Get surface main vertexes. Parameters are the same as for :meth:`from_fault_data`, excluding mesh spacing. :returns: Instance of :class:`~openquake.hazardlib.geo.polygon.Polygon` describing the surface projection of the simple fault with specified parameters...
[ "Get", "surface", "main", "vertexes", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/simple_fault.py#L301-L336
train
gem/oq-engine
openquake/hazardlib/geo/surface/simple_fault.py
SimpleFaultSurface.surface_projection_from_fault_data
def surface_projection_from_fault_data(cls, fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip): """ Get a surface projection of the simple fault surface. Parameters are the same as for :meth:`...
python
def surface_projection_from_fault_data(cls, fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip): """ Get a surface projection of the simple fault surface. Parameters are the same as for :meth:`...
[ "def", "surface_projection_from_fault_data", "(", "cls", ",", "fault_trace", ",", "upper_seismogenic_depth", ",", "lower_seismogenic_depth", ",", "dip", ")", ":", "lons", ",", "lats", "=", "cls", ".", "get_surface_vertexes", "(", "fault_trace", ",", "upper_seismogenic...
Get a surface projection of the simple fault surface. Parameters are the same as for :meth:`from_fault_data`, excluding mesh spacing. :returns: Instance of :class:`~openquake.hazardlib.geo.polygon.Polygon` describing the surface projection of the simple fault with ...
[ "Get", "a", "surface", "projection", "of", "the", "simple", "fault", "surface", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/simple_fault.py#L339-L356
train
gem/oq-engine
openquake/hazardlib/gsim/zhao_2006.py
ZhaoEtAl2006Asc._compute_distance_term
def _compute_distance_term(self, C, mag, rrup): """ Compute second and third terms in equation 1, p. 901. """ term1 = C['b'] * rrup term2 = - np.log(rrup + C['c'] * np.exp(C['d'] * mag)) return term1 + term2
python
def _compute_distance_term(self, C, mag, rrup): """ Compute second and third terms in equation 1, p. 901. """ term1 = C['b'] * rrup term2 = - np.log(rrup + C['c'] * np.exp(C['d'] * mag)) return term1 + term2
[ "def", "_compute_distance_term", "(", "self", ",", "C", ",", "mag", ",", "rrup", ")", ":", "term1", "=", "C", "[", "'b'", "]", "*", "rrup", "term2", "=", "-", "np", ".", "log", "(", "rrup", "+", "C", "[", "'c'", "]", "*", "np", ".", "exp", "(...
Compute second and third terms in equation 1, p. 901.
[ "Compute", "second", "and", "third", "terms", "in", "equation", "1", "p", ".", "901", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2006.py#L133-L140
train
gem/oq-engine
openquake/hazardlib/gsim/zhao_2006.py
ZhaoEtAl2006Asc._compute_focal_depth_term
def _compute_focal_depth_term(self, C, hypo_depth): """ Compute fourth term in equation 1, p. 901. """ # p. 901. "(i.e, depth is capped at 125 km)". focal_depth = hypo_depth if focal_depth > 125.0: focal_depth = 125.0 # p. 902. "We used the value of 1...
python
def _compute_focal_depth_term(self, C, hypo_depth): """ Compute fourth term in equation 1, p. 901. """ # p. 901. "(i.e, depth is capped at 125 km)". focal_depth = hypo_depth if focal_depth > 125.0: focal_depth = 125.0 # p. 902. "We used the value of 1...
[ "def", "_compute_focal_depth_term", "(", "self", ",", "C", ",", "hypo_depth", ")", ":", "focal_depth", "=", "hypo_depth", "if", "focal_depth", ">", "125.0", ":", "focal_depth", "=", "125.0", "hc", "=", "15.0", "return", "float", "(", "focal_depth", ">=", "hc...
Compute fourth term in equation 1, p. 901.
[ "Compute", "fourth", "term", "in", "equation", "1", "p", ".", "901", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2006.py#L142-L157
train
gem/oq-engine
openquake/hazardlib/gsim/zhao_2006.py
ZhaoEtAl2006Asc._compute_site_class_term
def _compute_site_class_term(self, C, vs30): """ Compute nine-th term in equation 1, p. 901. """ # map vs30 value to site class, see table 2, p. 901. site_term = np.zeros(len(vs30)) # hard rock site_term[vs30 > 1100.0] = C['CH'] # rock site_term[...
python
def _compute_site_class_term(self, C, vs30): """ Compute nine-th term in equation 1, p. 901. """ # map vs30 value to site class, see table 2, p. 901. site_term = np.zeros(len(vs30)) # hard rock site_term[vs30 > 1100.0] = C['CH'] # rock site_term[...
[ "def", "_compute_site_class_term", "(", "self", ",", "C", ",", "vs30", ")", ":", "site_term", "=", "np", ".", "zeros", "(", "len", "(", "vs30", ")", ")", "site_term", "[", "vs30", ">", "1100.0", "]", "=", "C", "[", "'CH'", "]", "site_term", "[", "(...
Compute nine-th term in equation 1, p. 901.
[ "Compute", "nine", "-", "th", "term", "in", "equation", "1", "p", ".", "901", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2006.py#L168-L190
train
gem/oq-engine
openquake/hazardlib/gsim/zhao_2006.py
ZhaoEtAl2006Asc._compute_magnitude_squared_term
def _compute_magnitude_squared_term(self, P, M, Q, W, mag): """ Compute magnitude squared term, equation 5, p. 909. """ return P * (mag - M) + Q * (mag - M) ** 2 + W
python
def _compute_magnitude_squared_term(self, P, M, Q, W, mag): """ Compute magnitude squared term, equation 5, p. 909. """ return P * (mag - M) + Q * (mag - M) ** 2 + W
[ "def", "_compute_magnitude_squared_term", "(", "self", ",", "P", ",", "M", ",", "Q", ",", "W", ",", "mag", ")", ":", "return", "P", "*", "(", "mag", "-", "M", ")", "+", "Q", "*", "(", "mag", "-", "M", ")", "**", "2", "+", "W" ]
Compute magnitude squared term, equation 5, p. 909.
[ "Compute", "magnitude", "squared", "term", "equation", "5", "p", ".", "909", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2006.py#L192-L196
train
gem/oq-engine
openquake/hazardlib/gsim/zhao_2006.py
ZhaoEtAl2006SSlab._compute_slab_correction_term
def _compute_slab_correction_term(self, C, rrup): """ Compute path modification term for slab events, that is the 8-th term in equation 1, p. 901. """ slab_term = C['SSL'] * np.log(rrup) return slab_term
python
def _compute_slab_correction_term(self, C, rrup): """ Compute path modification term for slab events, that is the 8-th term in equation 1, p. 901. """ slab_term = C['SSL'] * np.log(rrup) return slab_term
[ "def", "_compute_slab_correction_term", "(", "self", ",", "C", ",", "rrup", ")", ":", "slab_term", "=", "C", "[", "'SSL'", "]", "*", "np", ".", "log", "(", "rrup", ")", "return", "slab_term" ]
Compute path modification term for slab events, that is the 8-th term in equation 1, p. 901.
[ "Compute", "path", "modification", "term", "for", "slab", "events", "that", "is", "the", "8", "-", "th", "term", "in", "equation", "1", "p", ".", "901", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2006.py#L369-L376
train
gem/oq-engine
openquake/hazardlib/gsim/zhao_2006.py
ZhaoEtAl2006AscSGS.get_mean_and_stddevs
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ Using a minimum distance of 5km for the calculation. """ dists_mod = copy.deepcopy(dists) dists_mod.rrup[dists.rrup <= 5.] = 5. return super().get_mean_and_stddevs( sites, rup, dists_m...
python
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ Using a minimum distance of 5km for the calculation. """ dists_mod = copy.deepcopy(dists) dists_mod.rrup[dists.rrup <= 5.] = 5. return super().get_mean_and_stddevs( sites, rup, dists_m...
[ "def", "get_mean_and_stddevs", "(", "self", ",", "sites", ",", "rup", ",", "dists", ",", "imt", ",", "stddev_types", ")", ":", "dists_mod", "=", "copy", ".", "deepcopy", "(", "dists", ")", "dists_mod", ".", "rrup", "[", "dists", ".", "rrup", "<=", "5."...
Using a minimum distance of 5km for the calculation.
[ "Using", "a", "minimum", "distance", "of", "5km", "for", "the", "calculation", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2006.py#L654-L663
train
gem/oq-engine
openquake/engine/utils/__init__.py
confirm
def confirm(prompt): """ Ask for confirmation, given a ``prompt`` and return a boolean value. """ while True: try: answer = input(prompt) except KeyboardInterrupt: # the user presses ctrl+c, just say 'no' return False answer = answer.strip().lo...
python
def confirm(prompt): """ Ask for confirmation, given a ``prompt`` and return a boolean value. """ while True: try: answer = input(prompt) except KeyboardInterrupt: # the user presses ctrl+c, just say 'no' return False answer = answer.strip().lo...
[ "def", "confirm", "(", "prompt", ")", ":", "while", "True", ":", "try", ":", "answer", "=", "input", "(", "prompt", ")", "except", "KeyboardInterrupt", ":", "return", "False", "answer", "=", "answer", ".", "strip", "(", ")", ".", "lower", "(", ")", "...
Ask for confirmation, given a ``prompt`` and return a boolean value.
[ "Ask", "for", "confirmation", "given", "a", "prompt", "and", "return", "a", "boolean", "value", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/engine/utils/__init__.py#L20-L34
train
gem/oq-engine
openquake/risklib/asset.py
Exposure._csv_header
def _csv_header(self): """ Extract the expected CSV header from the exposure metadata """ fields = ['id', 'number', 'taxonomy', 'lon', 'lat'] for name in self.cost_types['name']: fields.append(name) if 'per_area' in self.cost_types['type']: fields....
python
def _csv_header(self): """ Extract the expected CSV header from the exposure metadata """ fields = ['id', 'number', 'taxonomy', 'lon', 'lat'] for name in self.cost_types['name']: fields.append(name) if 'per_area' in self.cost_types['type']: fields....
[ "def", "_csv_header", "(", "self", ")", ":", "fields", "=", "[", "'id'", ",", "'number'", ",", "'taxonomy'", ",", "'lon'", ",", "'lat'", "]", "for", "name", "in", "self", ".", "cost_types", "[", "'name'", "]", ":", "fields", ".", "append", "(", "name...
Extract the expected CSV header from the exposure metadata
[ "Extract", "the", "expected", "CSV", "header", "from", "the", "exposure", "metadata" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/asset.py#L885-L897
train
gem/oq-engine
openquake/risklib/riskmodels.py
build_vf_node
def build_vf_node(vf): """ Convert a VulnerabilityFunction object into a Node suitable for XML conversion. """ nodes = [Node('imls', {'imt': vf.imt}, vf.imls), Node('meanLRs', {}, vf.mean_loss_ratios), Node('covLRs', {}, vf.covs)] return Node( 'vulnerabilityFunc...
python
def build_vf_node(vf): """ Convert a VulnerabilityFunction object into a Node suitable for XML conversion. """ nodes = [Node('imls', {'imt': vf.imt}, vf.imls), Node('meanLRs', {}, vf.mean_loss_ratios), Node('covLRs', {}, vf.covs)] return Node( 'vulnerabilityFunc...
[ "def", "build_vf_node", "(", "vf", ")", ":", "nodes", "=", "[", "Node", "(", "'imls'", ",", "{", "'imt'", ":", "vf", ".", "imt", "}", ",", "vf", ".", "imls", ")", ",", "Node", "(", "'meanLRs'", ",", "{", "}", ",", "vf", ".", "mean_loss_ratios", ...
Convert a VulnerabilityFunction object into a Node suitable for XML conversion.
[ "Convert", "a", "VulnerabilityFunction", "object", "into", "a", "Node", "suitable", "for", "XML", "conversion", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/riskmodels.py#L69-L79
train
gem/oq-engine
openquake/risklib/riskmodels.py
get_riskmodel
def get_riskmodel(taxonomy, oqparam, **extra): """ Return an instance of the correct riskmodel class, depending on the attribute `calculation_mode` of the object `oqparam`. :param taxonomy: a taxonomy string :param oqparam: an object containing the parameters needed by the riskmodel...
python
def get_riskmodel(taxonomy, oqparam, **extra): """ Return an instance of the correct riskmodel class, depending on the attribute `calculation_mode` of the object `oqparam`. :param taxonomy: a taxonomy string :param oqparam: an object containing the parameters needed by the riskmodel...
[ "def", "get_riskmodel", "(", "taxonomy", ",", "oqparam", ",", "**", "extra", ")", ":", "riskmodel_class", "=", "registry", "[", "oqparam", ".", "calculation_mode", "]", "argnames", "=", "inspect", ".", "getfullargspec", "(", "riskmodel_class", ".", "__init__", ...
Return an instance of the correct riskmodel class, depending on the attribute `calculation_mode` of the object `oqparam`. :param taxonomy: a taxonomy string :param oqparam: an object containing the parameters needed by the riskmodel class :param extra: extra parameters to pass t...
[ "Return", "an", "instance", "of", "the", "correct", "riskmodel", "class", "depending", "on", "the", "attribute", "calculation_mode", "of", "the", "object", "oqparam", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/riskmodels.py#L548-L580
train
gem/oq-engine
openquake/hmtk/plotting/beachball.py
Beachball
def Beachball(fm, linewidth=2, facecolor='b', bgcolor='w', edgecolor='k', alpha=1.0, xy=(0, 0), width=200, size=100, nofill=False, zorder=100, outfile=None, format=None, fig=None): """ Draws a beach ball diagram of an earthquake focal mechanism. S1, D1, and R1, the strike, dip a...
python
def Beachball(fm, linewidth=2, facecolor='b', bgcolor='w', edgecolor='k', alpha=1.0, xy=(0, 0), width=200, size=100, nofill=False, zorder=100, outfile=None, format=None, fig=None): """ Draws a beach ball diagram of an earthquake focal mechanism. S1, D1, and R1, the strike, dip a...
[ "def", "Beachball", "(", "fm", ",", "linewidth", "=", "2", ",", "facecolor", "=", "'b'", ",", "bgcolor", "=", "'w'", ",", "edgecolor", "=", "'k'", ",", "alpha", "=", "1.0", ",", "xy", "=", "(", "0", ",", "0", ")", ",", "width", "=", "200", ",",...
Draws a beach ball diagram of an earthquake focal mechanism. S1, D1, and R1, the strike, dip and rake of one of the focal planes, can be vectors of multiple focal mechanisms. :param fm: Focal mechanism that is either number of mechanisms (NM) by 3 (strike, dip, and rake) or NM x 6 (M11, M22, M33, ...
[ "Draws", "a", "beach", "ball", "diagram", "of", "an", "earthquake", "focal", "mechanism", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/beachball.py#L147-L230
train
gem/oq-engine
openquake/hmtk/plotting/beachball.py
StrikeDip
def StrikeDip(n, e, u): """ Finds strike and dip of plane given normal vector having components n, e, and u. Adapted from MATLAB script `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_ written by Andy Michael and Oliver Boyd. """ r2d = 180 / np.pi if u < 0:...
python
def StrikeDip(n, e, u): """ Finds strike and dip of plane given normal vector having components n, e, and u. Adapted from MATLAB script `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_ written by Andy Michael and Oliver Boyd. """ r2d = 180 / np.pi if u < 0:...
[ "def", "StrikeDip", "(", "n", ",", "e", ",", "u", ")", ":", "r2d", "=", "180", "/", "np", ".", "pi", "if", "u", "<", "0", ":", "n", "=", "-", "n", "e", "=", "-", "e", "u", "=", "-", "u", "strike", "=", "np", ".", "arctan2", "(", "e", ...
Finds strike and dip of plane given normal vector having components n, e, and u. Adapted from MATLAB script `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_ written by Andy Michael and Oliver Boyd.
[ "Finds", "strike", "and", "dip", "of", "plane", "given", "normal", "vector", "having", "components", "n", "e", "and", "u", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/beachball.py#L669-L692
train
gem/oq-engine
openquake/hmtk/plotting/beachball.py
AuxPlane
def AuxPlane(s1, d1, r1): """ Get Strike and dip of second plane. Adapted from MATLAB script `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_ written by Andy Michael and Oliver Boyd. """ r2d = 180 / np.pi z = (s1 + 90) / r2d z2 = d1 / r2d z3 = r1 / r2d...
python
def AuxPlane(s1, d1, r1): """ Get Strike and dip of second plane. Adapted from MATLAB script `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_ written by Andy Michael and Oliver Boyd. """ r2d = 180 / np.pi z = (s1 + 90) / r2d z2 = d1 / r2d z3 = r1 / r2d...
[ "def", "AuxPlane", "(", "s1", ",", "d1", ",", "r1", ")", ":", "r2d", "=", "180", "/", "np", ".", "pi", "z", "=", "(", "s1", "+", "90", ")", "/", "r2d", "z2", "=", "d1", "/", "r2d", "z3", "=", "r1", "/", "r2d", "sl1", "=", "-", "np", "."...
Get Strike and dip of second plane. Adapted from MATLAB script `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_ written by Andy Michael and Oliver Boyd.
[ "Get", "Strike", "and", "dip", "of", "second", "plane", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/beachball.py#L695-L729
train
gem/oq-engine
openquake/hmtk/plotting/beachball.py
MT2Plane
def MT2Plane(mt): """ Calculates a nodal plane of a given moment tensor. :param mt: :class:`~MomentTensor` :return: :class:`~NodalPlane` Adapted from MATLAB script `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_ written by Andy Michael and Oliver Boyd. """ ...
python
def MT2Plane(mt): """ Calculates a nodal plane of a given moment tensor. :param mt: :class:`~MomentTensor` :return: :class:`~NodalPlane` Adapted from MATLAB script `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_ written by Andy Michael and Oliver Boyd. """ ...
[ "def", "MT2Plane", "(", "mt", ")", ":", "(", "d", ",", "v", ")", "=", "np", ".", "linalg", ".", "eig", "(", "mt", ".", "mt", ")", "D", "=", "np", ".", "array", "(", "[", "d", "[", "1", "]", ",", "d", "[", "0", "]", ",", "d", "[", "2",...
Calculates a nodal plane of a given moment tensor. :param mt: :class:`~MomentTensor` :return: :class:`~NodalPlane` Adapted from MATLAB script `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_ written by Andy Michael and Oliver Boyd.
[ "Calculates", "a", "nodal", "plane", "of", "a", "given", "moment", "tensor", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/beachball.py#L732-L766
train
gem/oq-engine
openquake/hmtk/plotting/beachball.py
TDL
def TDL(AN, BN): """ Helper function for MT2Plane. Adapted from MATLAB script `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_ written by Andy Michael and Oliver Boyd. """ XN = AN[0] YN = AN[1] ZN = AN[2] XE = BN[0] YE = BN[1] ZE = BN[2] AAA...
python
def TDL(AN, BN): """ Helper function for MT2Plane. Adapted from MATLAB script `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_ written by Andy Michael and Oliver Boyd. """ XN = AN[0] YN = AN[1] ZN = AN[2] XE = BN[0] YE = BN[1] ZE = BN[2] AAA...
[ "def", "TDL", "(", "AN", ",", "BN", ")", ":", "XN", "=", "AN", "[", "0", "]", "YN", "=", "AN", "[", "1", "]", "ZN", "=", "AN", "[", "2", "]", "XE", "=", "BN", "[", "0", "]", "YE", "=", "BN", "[", "1", "]", "ZE", "=", "BN", "[", "2",...
Helper function for MT2Plane. Adapted from MATLAB script `bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_ written by Andy Michael and Oliver Boyd.
[ "Helper", "function", "for", "MT2Plane", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/beachball.py#L769-L849
train
gem/oq-engine
openquake/hmtk/plotting/beachball.py
MT2Axes
def MT2Axes(mt): """ Calculates the principal axes of a given moment tensor. :param mt: :class:`~MomentTensor` :return: tuple of :class:`~PrincipalAxis` T, N and P Adapted from ps_tensor / utilmeca.c / `Generic Mapping Tools (GMT) <http://gmt.soest.hawaii.edu>`_. """ (D, V) = np.linalg...
python
def MT2Axes(mt): """ Calculates the principal axes of a given moment tensor. :param mt: :class:`~MomentTensor` :return: tuple of :class:`~PrincipalAxis` T, N and P Adapted from ps_tensor / utilmeca.c / `Generic Mapping Tools (GMT) <http://gmt.soest.hawaii.edu>`_. """ (D, V) = np.linalg...
[ "def", "MT2Axes", "(", "mt", ")", ":", "(", "D", ",", "V", ")", "=", "np", ".", "linalg", ".", "eigh", "(", "mt", ".", "mt", ")", "pl", "=", "np", ".", "arcsin", "(", "-", "V", "[", "0", "]", ")", "az", "=", "np", ".", "arctan2", "(", "...
Calculates the principal axes of a given moment tensor. :param mt: :class:`~MomentTensor` :return: tuple of :class:`~PrincipalAxis` T, N and P Adapted from ps_tensor / utilmeca.c / `Generic Mapping Tools (GMT) <http://gmt.soest.hawaii.edu>`_.
[ "Calculates", "the", "principal", "axes", "of", "a", "given", "moment", "tensor", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/beachball.py#L852-L879
train
gem/oq-engine
openquake/hmtk/strain/strain_utils.py
tapered_gutenberg_richter_cdf
def tapered_gutenberg_richter_cdf(moment, moment_threshold, beta, corner_moment): ''' Tapered Gutenberg Richter Cumulative Density Function :param float or numpy.ndarray moment: Moment for calculation of rate :param float or numpy.ndarray moment_threshold: ...
python
def tapered_gutenberg_richter_cdf(moment, moment_threshold, beta, corner_moment): ''' Tapered Gutenberg Richter Cumulative Density Function :param float or numpy.ndarray moment: Moment for calculation of rate :param float or numpy.ndarray moment_threshold: ...
[ "def", "tapered_gutenberg_richter_cdf", "(", "moment", ",", "moment_threshold", ",", "beta", ",", "corner_moment", ")", ":", "cdf", "=", "np", ".", "exp", "(", "(", "moment_threshold", "-", "moment", ")", "/", "corner_moment", ")", "return", "(", "(", "momen...
Tapered Gutenberg Richter Cumulative Density Function :param float or numpy.ndarray moment: Moment for calculation of rate :param float or numpy.ndarray moment_threshold: Threshold Moment of the distribution (moment rate essentially!) :param float beta: Beta value (b * ln(10.)) of...
[ "Tapered", "Gutenberg", "Richter", "Cumulative", "Density", "Function" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/strain/strain_utils.py#L111-L134
train
gem/oq-engine
openquake/hmtk/strain/strain_utils.py
tapered_gutenberg_richter_pdf
def tapered_gutenberg_richter_pdf(moment, moment_threshold, beta, corner_moment): ''' Tapered Gutenberg-Richter Probability Density Function :param float or numpy.ndarray moment: Moment for calculation of rate :param float or numpy.ndarray moment_threshold: ...
python
def tapered_gutenberg_richter_pdf(moment, moment_threshold, beta, corner_moment): ''' Tapered Gutenberg-Richter Probability Density Function :param float or numpy.ndarray moment: Moment for calculation of rate :param float or numpy.ndarray moment_threshold: ...
[ "def", "tapered_gutenberg_richter_pdf", "(", "moment", ",", "moment_threshold", ",", "beta", ",", "corner_moment", ")", ":", "return", "(", "(", "beta", "/", "moment", "+", "1.", "/", "corner_moment", ")", "*", "tapered_gutenberg_richter_cdf", "(", "moment", ","...
Tapered Gutenberg-Richter Probability Density Function :param float or numpy.ndarray moment: Moment for calculation of rate :param float or numpy.ndarray moment_threshold: Threshold Moment of the distribution (moment rate essentially!) :param float beta: Beta value (b * ln(10.)) o...
[ "Tapered", "Gutenberg", "-", "Richter", "Probability", "Density", "Function" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/strain/strain_utils.py#L137-L159
train
gem/oq-engine
openquake/engine/export/core.py
makedirs
def makedirs(path): """ Make all of the directories in the ``path`` using `os.makedirs`. """ if os.path.exists(path): if not os.path.isdir(path): # If it's not a directory, we can't do anything. # This is a problem raise RuntimeError('%s already exists and is ...
python
def makedirs(path): """ Make all of the directories in the ``path`` using `os.makedirs`. """ if os.path.exists(path): if not os.path.isdir(path): # If it's not a directory, we can't do anything. # This is a problem raise RuntimeError('%s already exists and is ...
[ "def", "makedirs", "(", "path", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "raise", "RuntimeError", "(", "'%s already exists and is not a directory.'", "%"...
Make all of the directories in the ``path`` using `os.makedirs`.
[ "Make", "all", "of", "the", "directories", "in", "the", "path", "using", "os", ".", "makedirs", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/engine/export/core.py#L80-L91
train
gem/oq-engine
openquake/hmtk/seismicity/max_magnitude/base.py
_get_observed_mmax
def _get_observed_mmax(catalogue, config): '''Check see if observed mmax values are input, if not then take from the catalogue''' if config['input_mmax']: obsmax = config['input_mmax'] if config['input_mmax_uncertainty']: return config['input_mmax'], config['input_mmax_uncertaint...
python
def _get_observed_mmax(catalogue, config): '''Check see if observed mmax values are input, if not then take from the catalogue''' if config['input_mmax']: obsmax = config['input_mmax'] if config['input_mmax_uncertainty']: return config['input_mmax'], config['input_mmax_uncertaint...
[ "def", "_get_observed_mmax", "(", "catalogue", ",", "config", ")", ":", "if", "config", "[", "'input_mmax'", "]", ":", "obsmax", "=", "config", "[", "'input_mmax'", "]", "if", "config", "[", "'input_mmax_uncertainty'", "]", ":", "return", "config", "[", "'in...
Check see if observed mmax values are input, if not then take from the catalogue
[ "Check", "see", "if", "observed", "mmax", "values", "are", "input", "if", "not", "then", "take", "from", "the", "catalogue" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/max_magnitude/base.py#L57-L83
train
gem/oq-engine
openquake/hmtk/seismicity/max_magnitude/base.py
_get_magnitude_vector_properties
def _get_magnitude_vector_properties(catalogue, config): '''If an input minimum magnitude is given then consider catalogue only above the minimum magnitude - returns corresponding properties''' mmin = config.get('input_mmin', np.min(catalogue['magnitude'])) neq = np.float(np.sum(catalogue['magnitude'] ...
python
def _get_magnitude_vector_properties(catalogue, config): '''If an input minimum magnitude is given then consider catalogue only above the minimum magnitude - returns corresponding properties''' mmin = config.get('input_mmin', np.min(catalogue['magnitude'])) neq = np.float(np.sum(catalogue['magnitude'] ...
[ "def", "_get_magnitude_vector_properties", "(", "catalogue", ",", "config", ")", ":", "mmin", "=", "config", ".", "get", "(", "'input_mmin'", ",", "np", ".", "min", "(", "catalogue", "[", "'magnitude'", "]", ")", ")", "neq", "=", "np", ".", "float", "(",...
If an input minimum magnitude is given then consider catalogue only above the minimum magnitude - returns corresponding properties
[ "If", "an", "input", "minimum", "magnitude", "is", "given", "then", "consider", "catalogue", "only", "above", "the", "minimum", "magnitude", "-", "returns", "corresponding", "properties" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/max_magnitude/base.py#L104-L110
train
gem/oq-engine
openquake/hazardlib/geo/surface/complex_fault.py
ComplexFaultSurface.get_dip
def get_dip(self): """ Return the fault dip as the average dip over the mesh. The average dip is defined as the weighted mean inclination of all the mesh cells. See :meth:`openquake.hazardlib.geo.mesh.RectangularMesh.get_mean_inclination_and_azimuth` :returns: ...
python
def get_dip(self): """ Return the fault dip as the average dip over the mesh. The average dip is defined as the weighted mean inclination of all the mesh cells. See :meth:`openquake.hazardlib.geo.mesh.RectangularMesh.get_mean_inclination_and_azimuth` :returns: ...
[ "def", "get_dip", "(", "self", ")", ":", "if", "self", ".", "dip", "is", "None", ":", "mesh", "=", "self", ".", "mesh", "self", ".", "dip", ",", "self", ".", "strike", "=", "mesh", ".", "get_mean_inclination_and_azimuth", "(", ")", "return", "self", ...
Return the fault dip as the average dip over the mesh. The average dip is defined as the weighted mean inclination of all the mesh cells. See :meth:`openquake.hazardlib.geo.mesh.RectangularMesh.get_mean_inclination_and_azimuth` :returns: The average dip, in decimal degrees.
[ "Return", "the", "fault", "dip", "as", "the", "average", "dip", "over", "the", "mesh", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/complex_fault.py#L96-L111
train
gem/oq-engine
openquake/hazardlib/geo/surface/complex_fault.py
ComplexFaultSurface.check_surface_validity
def check_surface_validity(cls, edges): """ Check validity of the surface. Project edge points to vertical plane anchored to surface upper left edge and with strike equal to top edge strike. Check that resulting polygon is valid. This method doesn't have to be called by...
python
def check_surface_validity(cls, edges): """ Check validity of the surface. Project edge points to vertical plane anchored to surface upper left edge and with strike equal to top edge strike. Check that resulting polygon is valid. This method doesn't have to be called by...
[ "def", "check_surface_validity", "(", "cls", ",", "edges", ")", ":", "full_boundary", "=", "[", "]", "left_boundary", "=", "[", "]", "right_boundary", "=", "[", "]", "for", "i", "in", "range", "(", "1", ",", "len", "(", "edges", ")", "-", "1", ")", ...
Check validity of the surface. Project edge points to vertical plane anchored to surface upper left edge and with strike equal to top edge strike. Check that resulting polygon is valid. This method doesn't have to be called by hands before creating the surface object, because i...
[ "Check", "validity", "of", "the", "surface", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/complex_fault.py#L182-L230
train
gem/oq-engine
openquake/hazardlib/geo/surface/complex_fault.py
ComplexFaultSurface.surface_projection_from_fault_data
def surface_projection_from_fault_data(cls, edges): """ Get a surface projection of the complex fault surface. :param edges: A list of horizontal edges of the surface as instances of :class:`openquake.hazardlib.geo.line.Line`. :returns: Instance of :c...
python
def surface_projection_from_fault_data(cls, edges): """ Get a surface projection of the complex fault surface. :param edges: A list of horizontal edges of the surface as instances of :class:`openquake.hazardlib.geo.line.Line`. :returns: Instance of :c...
[ "def", "surface_projection_from_fault_data", "(", "cls", ",", "edges", ")", ":", "lons", "=", "[", "]", "lats", "=", "[", "]", "for", "edge", "in", "edges", ":", "for", "point", "in", "edge", ":", "lons", ".", "append", "(", "point", ".", "longitude", ...
Get a surface projection of the complex fault surface. :param edges: A list of horizontal edges of the surface as instances of :class:`openquake.hazardlib.geo.line.Line`. :returns: Instance of :class:`~openquake.hazardlib.geo.polygon.Polygon` describing t...
[ "Get", "a", "surface", "projection", "of", "the", "complex", "fault", "surface", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/complex_fault.py#L302-L323
train
gem/oq-engine
openquake/calculators/base.py
check_time_event
def check_time_event(oqparam, occupancy_periods): """ Check the `time_event` parameter in the datastore, by comparing with the periods found in the exposure. """ time_event = oqparam.time_event if time_event and time_event not in occupancy_periods: raise ValueError( 'time_eve...
python
def check_time_event(oqparam, occupancy_periods): """ Check the `time_event` parameter in the datastore, by comparing with the periods found in the exposure. """ time_event = oqparam.time_event if time_event and time_event not in occupancy_periods: raise ValueError( 'time_eve...
[ "def", "check_time_event", "(", "oqparam", ",", "occupancy_periods", ")", ":", "time_event", "=", "oqparam", ".", "time_event", "if", "time_event", "and", "time_event", "not", "in", "occupancy_periods", ":", "raise", "ValueError", "(", "'time_event is %s in %s, but th...
Check the `time_event` parameter in the datastore, by comparing with the periods found in the exposure.
[ "Check", "the", "time_event", "parameter", "in", "the", "datastore", "by", "comparing", "with", "the", "periods", "found", "in", "the", "exposure", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L321-L331
train