partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
low_mem_sq
np.dot(m, m.T) with low mem usage, by doing it in small steps
peri/opt/optimize.py
def low_mem_sq(m, step=100000): """np.dot(m, m.T) with low mem usage, by doing it in small steps""" if not m.flags.c_contiguous: raise ValueError('m must be C ordered for this to work with less mem.') # -- can make this even faster with pre-allocating arrays, but not worth it # right now # m...
def low_mem_sq(m, step=100000): """np.dot(m, m.T) with low mem usage, by doing it in small steps""" if not m.flags.c_contiguous: raise ValueError('m must be C ordered for this to work with less mem.') # -- can make this even faster with pre-allocating arrays, but not worth it # right now # m...
[ "np", ".", "dot", "(", "m", "m", ".", "T", ")", "with", "low", "mem", "usage", "by", "doing", "it", "in", "small", "steps" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L212-L234
[ "def", "low_mem_sq", "(", "m", ",", "step", "=", "100000", ")", ":", "if", "not", "m", ".", "flags", ".", "c_contiguous", ":", "raise", "ValueError", "(", "'m must be C ordered for this to work with less mem.'", ")", "# -- can make this even faster with pre-allocating a...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
find_particles_in_tile
Finds the particles in a tile, as numpy.ndarray of ints. Parameters ---------- positions : `numpy.ndarray` [N,3] array of the particle positions to check in the tile tile : :class:`peri.util.Tile` instance Tile of the region inside which to check for particles. Retu...
peri/opt/optimize.py
def find_particles_in_tile(positions, tile): """ Finds the particles in a tile, as numpy.ndarray of ints. Parameters ---------- positions : `numpy.ndarray` [N,3] array of the particle positions to check in the tile tile : :class:`peri.util.Tile` instance Tile of ...
def find_particles_in_tile(positions, tile): """ Finds the particles in a tile, as numpy.ndarray of ints. Parameters ---------- positions : `numpy.ndarray` [N,3] array of the particle positions to check in the tile tile : :class:`peri.util.Tile` instance Tile of ...
[ "Finds", "the", "particles", "in", "a", "tile", "as", "numpy", ".", "ndarray", "of", "ints", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L239-L256
[ "def", "find_particles_in_tile", "(", "positions", ",", "tile", ")", ":", "bools", "=", "tile", ".", "contains", "(", "positions", ")", "return", "np", ".", "arange", "(", "bools", ".", "size", ")", "[", "bools", "]" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
separate_particles_into_groups
Separates particles into convenient groups for optimization. Given a state, returns a list of groups of particles. Each group of particles are located near each other in the image. Every particle located in the desired region is contained in exactly 1 group. Parameters ---------- s : :class:`p...
peri/opt/optimize.py
def separate_particles_into_groups(s, region_size=40, bounds=None, doshift=False): """ Separates particles into convenient groups for optimization. Given a state, returns a list of groups of particles. Each group of particles are located near each other in the image. Every particle located ...
def separate_particles_into_groups(s, region_size=40, bounds=None, doshift=False): """ Separates particles into convenient groups for optimization. Given a state, returns a list of groups of particles. Each group of particles are located near each other in the image. Every particle located ...
[ "Separates", "particles", "into", "convenient", "groups", "for", "optimization", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L258-L328
[ "def", "separate_particles_into_groups", "(", "s", ",", "region_size", "=", "40", ",", "bounds", "=", "None", ",", "doshift", "=", "False", ")", ":", "imtile", "=", "s", ".", "oshape", ".", "translate", "(", "-", "s", ".", "pad", ")", "bounding_tile", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
_check_groups
Ensures that all particles are included in exactly 1 group
peri/opt/optimize.py
def _check_groups(s, groups): """Ensures that all particles are included in exactly 1 group""" ans = [] for g in groups: ans.extend(g) if np.unique(ans).size != np.size(ans): return False elif np.unique(ans).size != s.obj_get_positions().shape[0]: return False else: ...
def _check_groups(s, groups): """Ensures that all particles are included in exactly 1 group""" ans = [] for g in groups: ans.extend(g) if np.unique(ans).size != np.size(ans): return False elif np.unique(ans).size != s.obj_get_positions().shape[0]: return False else: ...
[ "Ensures", "that", "all", "particles", "are", "included", "in", "exactly", "1", "group" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L330-L340
[ "def", "_check_groups", "(", "s", ",", "groups", ")", ":", "ans", "=", "[", "]", "for", "g", "in", "groups", ":", "ans", ".", "extend", "(", "g", ")", "if", "np", ".", "unique", "(", "ans", ")", ".", "size", "!=", "np", ".", "size", "(", "ans...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
calc_particle_group_region_size
Finds the biggest region size for LM particle optimization with a given memory constraint. Input Parameters ---------------- s : :class:`peri.states.ImageState` The state with the particles region_size : Int or 3-element list-like of ints, optional. The initial guess...
peri/opt/optimize.py
def calc_particle_group_region_size(s, region_size=40, max_mem=1e9, **kwargs): """ Finds the biggest region size for LM particle optimization with a given memory constraint. Input Parameters ---------------- s : :class:`peri.states.ImageState` The state with the particles ...
def calc_particle_group_region_size(s, region_size=40, max_mem=1e9, **kwargs): """ Finds the biggest region size for LM particle optimization with a given memory constraint. Input Parameters ---------------- s : :class:`peri.states.ImageState` The state with the particles ...
[ "Finds", "the", "biggest", "region", "size", "for", "LM", "particle", "optimization", "with", "a", "given", "memory", "constraint", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L342-L398
[ "def", "calc_particle_group_region_size", "(", "s", ",", "region_size", "=", "40", ",", "max_mem", "=", "1e9", ",", "*", "*", "kwargs", ")", ":", "region_size", "=", "np", ".", "array", "(", "region_size", ")", ".", "astype", "(", "'int'", ")", "def", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
get_residuals_update_tile
Translates a tile in the padded image to the unpadded image. Given a state and a tile that corresponds to the padded image, returns a tile that corresponds to the the corresponding pixels of the difference image Parameters ---------- st : :class:`peri.states.State` The state ...
peri/opt/optimize.py
def get_residuals_update_tile(st, padded_tile): """ Translates a tile in the padded image to the unpadded image. Given a state and a tile that corresponds to the padded image, returns a tile that corresponds to the the corresponding pixels of the difference image Parameters ---------- ...
def get_residuals_update_tile(st, padded_tile): """ Translates a tile in the padded image to the unpadded image. Given a state and a tile that corresponds to the padded image, returns a tile that corresponds to the the corresponding pixels of the difference image Parameters ---------- ...
[ "Translates", "a", "tile", "in", "the", "padded", "image", "to", "the", "unpadded", "image", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L400-L421
[ "def", "get_residuals_update_tile", "(", "st", ",", "padded_tile", ")", ":", "inner_tile", "=", "st", ".", "ishape", ".", "intersection", "(", "[", "st", ".", "ishape", ",", "padded_tile", "]", ")", "return", "inner_tile", ".", "translate", "(", "-", "st",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
find_best_step
Returns the index of the lowest of the passed values. Catches nans etc.
peri/opt/optimize.py
def find_best_step(err_vals): """ Returns the index of the lowest of the passed values. Catches nans etc. """ if np.all(np.isnan(err_vals)): raise ValueError('All err_vals are nans!') return np.nanargmin(err_vals)
def find_best_step(err_vals): """ Returns the index of the lowest of the passed values. Catches nans etc. """ if np.all(np.isnan(err_vals)): raise ValueError('All err_vals are nans!') return np.nanargmin(err_vals)
[ "Returns", "the", "index", "of", "the", "lowest", "of", "the", "passed", "values", ".", "Catches", "nans", "etc", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L427-L433
[ "def", "find_best_step", "(", "err_vals", ")", ":", "if", "np", ".", "all", "(", "np", ".", "isnan", "(", "err_vals", ")", ")", ":", "raise", "ValueError", "(", "'All err_vals are nans!'", ")", "return", "np", ".", "nanargmin", "(", "err_vals", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
do_levmarq
Runs Levenberg-Marquardt optimization on a state. Convenience wrapper for LMGlobals. Same keyword args, but the defaults have been set to useful values for optimizing globals. See LMGlobals and LMEngine for documentation. See Also -------- do_levmarq_particles : Levenberg-Marquardt optimiz...
peri/opt/optimize.py
def do_levmarq(s, param_names, damping=0.1, decrease_damp_factor=10., run_length=6, eig_update=True, collect_stats=False, rz_order=0, run_type=2, **kwargs): """ Runs Levenberg-Marquardt optimization on a state. Convenience wrapper for LMGlobals. Same keyword args, but the defaults have ...
def do_levmarq(s, param_names, damping=0.1, decrease_damp_factor=10., run_length=6, eig_update=True, collect_stats=False, rz_order=0, run_type=2, **kwargs): """ Runs Levenberg-Marquardt optimization on a state. Convenience wrapper for LMGlobals. Same keyword args, but the defaults have ...
[ "Runs", "Levenberg", "-", "Marquardt", "optimization", "on", "a", "state", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2312-L2350
[ "def", "do_levmarq", "(", "s", ",", "param_names", ",", "damping", "=", "0.1", ",", "decrease_damp_factor", "=", "10.", ",", "run_length", "=", "6", ",", "eig_update", "=", "True", ",", "collect_stats", "=", "False", ",", "rz_order", "=", "0", ",", "run_...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
do_levmarq_particles
Levenberg-Marquardt optimization on a set of particles. Convenience wrapper for LMParticles. Same keyword args, but the defaults have been set to useful values for optimizing particles. See LMParticles and LMEngine for documentation. See Also -------- do_levmarq_all_particle_groups : Leven...
peri/opt/optimize.py
def do_levmarq_particles(s, particles, damping=1.0, decrease_damp_factor=10., run_length=4, collect_stats=False, max_iter=2, **kwargs): """ Levenberg-Marquardt optimization on a set of particles. Convenience wrapper for LMParticles. Same keyword args, but the defaults have been set to useful va...
def do_levmarq_particles(s, particles, damping=1.0, decrease_damp_factor=10., run_length=4, collect_stats=False, max_iter=2, **kwargs): """ Levenberg-Marquardt optimization on a set of particles. Convenience wrapper for LMParticles. Same keyword args, but the defaults have been set to useful va...
[ "Levenberg", "-", "Marquardt", "optimization", "on", "a", "set", "of", "particles", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2352-L2378
[ "def", "do_levmarq_particles", "(", "s", ",", "particles", ",", "damping", "=", "1.0", ",", "decrease_damp_factor", "=", "10.", ",", "run_length", "=", "4", ",", "collect_stats", "=", "False", ",", "max_iter", "=", "2", ",", "*", "*", "kwargs", ")", ":",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
do_levmarq_all_particle_groups
Levenberg-Marquardt optimization for every particle in the state. Convenience wrapper for LMParticleGroupCollection. Same keyword args, but I've set the defaults to what I've found to be useful values for optimizing particles. See LMParticleGroupCollection for documentation. See Also -------- ...
peri/opt/optimize.py
def do_levmarq_all_particle_groups(s, region_size=40, max_iter=2, damping=1.0, decrease_damp_factor=10., run_length=4, collect_stats=False, **kwargs): """ Levenberg-Marquardt optimization for every particle in the state. Convenience wrapper for LMParticleGroupCollection. Same keyword args, but ...
def do_levmarq_all_particle_groups(s, region_size=40, max_iter=2, damping=1.0, decrease_damp_factor=10., run_length=4, collect_stats=False, **kwargs): """ Levenberg-Marquardt optimization for every particle in the state. Convenience wrapper for LMParticleGroupCollection. Same keyword args, but ...
[ "Levenberg", "-", "Marquardt", "optimization", "for", "every", "particle", "in", "the", "state", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2380-L2406
[ "def", "do_levmarq_all_particle_groups", "(", "s", ",", "region_size", "=", "40", ",", "max_iter", "=", "2", ",", "damping", "=", "1.0", ",", "decrease_damp_factor", "=", "10.", ",", "run_length", "=", "4", ",", "collect_stats", "=", "False", ",", "*", "*"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
do_levmarq_n_directions
Optimization of a state along a specific set of directions in parameter space. Parameters ---------- s : :class:`peri.states.State` The state to optimize directions : np.ndarray [n,d] element numpy.ndarray of the n directions in the d- dimensional space t...
peri/opt/optimize.py
def do_levmarq_n_directions(s, directions, max_iter=2, run_length=2, damping=1e-3, collect_stats=False, marquardt_damping=True, **kwargs): """ Optimization of a state along a specific set of directions in parameter space. Parameters ---------- s : :class:`peri.states.State` ...
def do_levmarq_n_directions(s, directions, max_iter=2, run_length=2, damping=1e-3, collect_stats=False, marquardt_damping=True, **kwargs): """ Optimization of a state along a specific set of directions in parameter space. Parameters ---------- s : :class:`peri.states.State` ...
[ "Optimization", "of", "a", "state", "along", "a", "specific", "set", "of", "directions", "in", "parameter", "space", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2408-L2435
[ "def", "do_levmarq_n_directions", "(", "s", ",", "directions", ",", "max_iter", "=", "2", ",", "run_length", "=", "2", ",", "damping", "=", "1e-3", ",", "collect_stats", "=", "False", ",", "marquardt_damping", "=", "True", ",", "*", "*", "kwargs", ")", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
burn
Optimizes all the parameters of a state. Burns a state through calling LMParticleGroupCollection and LMGlobals/ LMAugmentedState. Parameters ---------- s : :class:`peri.states.ImageState` The state to optimize n_loop : Int, optional The number of times to loop o...
peri/opt/optimize.py
def burn(s, n_loop=6, collect_stats=False, desc='', rz_order=0, fractol=1e-4, errtol=1e-2, mode='burn', max_mem=1e9, include_rad=True, do_line_min='default', partial_log=False, dowarn=True): """ Optimizes all the parameters of a state. Burns a state through calling LMParticleGroupCollection...
def burn(s, n_loop=6, collect_stats=False, desc='', rz_order=0, fractol=1e-4, errtol=1e-2, mode='burn', max_mem=1e9, include_rad=True, do_line_min='default', partial_log=False, dowarn=True): """ Optimizes all the parameters of a state. Burns a state through calling LMParticleGroupCollection...
[ "Optimizes", "all", "the", "parameters", "of", "a", "state", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2437-L2637
[ "def", "burn", "(", "s", ",", "n_loop", "=", "6", ",", "collect_stats", "=", "False", ",", "desc", "=", "''", ",", "rz_order", "=", "0", ",", "fractol", "=", "1e-4", ",", "errtol", "=", "1e-2", ",", "mode", "=", "'burn'", ",", "max_mem", "=", "1e...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
finish
Crawls slowly to the minimum-cost state. Blocks the global parameters into small enough sections such that each can be optimized separately while including all the pixels (i.e. no decimation). Optimizes the globals, then the psf separately if desired, then particles, then a line minimization along the ...
peri/opt/optimize.py
def finish(s, desc='finish', n_loop=4, max_mem=1e9, separate_psf=True, fractol=1e-7, errtol=1e-3, dowarn=True): """ Crawls slowly to the minimum-cost state. Blocks the global parameters into small enough sections such that each can be optimized separately while including all the pixels (i.e. no...
def finish(s, desc='finish', n_loop=4, max_mem=1e9, separate_psf=True, fractol=1e-7, errtol=1e-3, dowarn=True): """ Crawls slowly to the minimum-cost state. Blocks the global parameters into small enough sections such that each can be optimized separately while including all the pixels (i.e. no...
[ "Crawls", "slowly", "to", "the", "minimum", "-", "cost", "state", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2639-L2728
[ "def", "finish", "(", "s", ",", "desc", "=", "'finish'", ",", "n_loop", "=", "4", ",", "max_mem", "=", "1e9", ",", "separate_psf", "=", "True", ",", "fractol", "=", "1e-7", ",", "errtol", "=", "1e-3", ",", "dowarn", "=", "True", ")", ":", "values",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
fit_comp
Fits a new component to an old component Calls do_levmarq to match the .get() fields of the two objects. The parameters of new_comp are modified in place. Parameters ---------- new_comp : :class:`peri.comps.comp` The new object, whose parameters to update to fit the field of `old_c...
peri/opt/optimize.py
def fit_comp(new_comp, old_comp, **kwargs): """ Fits a new component to an old component Calls do_levmarq to match the .get() fields of the two objects. The parameters of new_comp are modified in place. Parameters ---------- new_comp : :class:`peri.comps.comp` The new object, whose...
def fit_comp(new_comp, old_comp, **kwargs): """ Fits a new component to an old component Calls do_levmarq to match the .get() fields of the two objects. The parameters of new_comp are modified in place. Parameters ---------- new_comp : :class:`peri.comps.comp` The new object, whose...
[ "Fits", "a", "new", "component", "to", "an", "old", "component" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2730-L2761
[ "def", "fit_comp", "(", "new_comp", ",", "old_comp", ",", "*", "*", "kwargs", ")", ":", "#resetting the category to ilm:", "new_cat", "=", "new_comp", ".", "category", "new_comp", ".", "category", "=", "'ilm'", "fake_s", "=", "states", ".", "ImageState", "(", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.reset
Keeps all user supplied options the same, but resets counters etc.
peri/opt/optimize.py
def reset(self, new_damping=None): """ Keeps all user supplied options the same, but resets counters etc. """ self._num_iter = 0 self._inner_run_counter = 0 self._J_update_counter = self.update_J_frequency self._fresh_JTJ = False self._has_run = False ...
def reset(self, new_damping=None): """ Keeps all user supplied options the same, but resets counters etc. """ self._num_iter = 0 self._inner_run_counter = 0 self._J_update_counter = self.update_J_frequency self._fresh_JTJ = False self._has_run = False ...
[ "Keeps", "all", "user", "supplied", "options", "the", "same", "but", "resets", "counters", "etc", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L690-L701
[ "def", "reset", "(", "self", ",", "new_damping", "=", "None", ")", ":", "self", ".", "_num_iter", "=", "0", "self", ".", "_inner_run_counter", "=", "0", "self", ".", "_J_update_counter", "=", "self", ".", "update_J_frequency", "self", ".", "_fresh_JTJ", "=...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.do_run_1
LM run, evaluating 1 step at a time. Broyden or eigendirection updates replace full-J updates until a full-J update occurs. Does not run with the calculated J (no internal run).
peri/opt/optimize.py
def do_run_1(self): """ LM run, evaluating 1 step at a time. Broyden or eigendirection updates replace full-J updates until a full-J update occurs. Does not run with the calculated J (no internal run). """ while not self.check_terminate(): self._has_r...
def do_run_1(self): """ LM run, evaluating 1 step at a time. Broyden or eigendirection updates replace full-J updates until a full-J update occurs. Does not run with the calculated J (no internal run). """ while not self.check_terminate(): self._has_r...
[ "LM", "run", "evaluating", "1", "step", "at", "a", "time", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L722-L733
[ "def", "do_run_1", "(", "self", ")", ":", "while", "not", "self", ".", "check_terminate", "(", ")", ":", "self", ".", "_has_run", "=", "True", "self", ".", "_run1", "(", ")", "self", ".", "_num_iter", "+=", "1", "self", ".", "_inner_run_counter", "+=",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine._run1
workhorse for do_run_1
peri/opt/optimize.py
def _run1(self): """workhorse for do_run_1""" if self.check_update_J(): self.update_J() else: if self.check_Broyden_J(): self.update_Broyden_J() if self.check_update_eig_J(): self.update_eig_J() #1. Assuming that J star...
def _run1(self): """workhorse for do_run_1""" if self.check_update_J(): self.update_J() else: if self.check_Broyden_J(): self.update_Broyden_J() if self.check_update_eig_J(): self.update_eig_J() #1. Assuming that J star...
[ "workhorse", "for", "do_run_1" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L735-L777
[ "def", "_run1", "(", "self", ")", ":", "if", "self", ".", "check_update_J", "(", ")", ":", "self", ".", "update_J", "(", ")", "else", ":", "if", "self", ".", "check_Broyden_J", "(", ")", ":", "self", ".", "update_Broyden_J", "(", ")", "if", "self", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.do_run_2
LM run evaluating 2 steps (damped and not) and choosing the best. After finding the best of 2 steps, runs with that damping + Broyden or eigendirection updates, until deciding to do a full-J update. Only changes damping after full-J updates.
peri/opt/optimize.py
def do_run_2(self): """ LM run evaluating 2 steps (damped and not) and choosing the best. After finding the best of 2 steps, runs with that damping + Broyden or eigendirection updates, until deciding to do a full-J update. Only changes damping after full-J updates. """ ...
def do_run_2(self): """ LM run evaluating 2 steps (damped and not) and choosing the best. After finding the best of 2 steps, runs with that damping + Broyden or eigendirection updates, until deciding to do a full-J update. Only changes damping after full-J updates. """ ...
[ "LM", "run", "evaluating", "2", "steps", "(", "damped", "and", "not", ")", "and", "choosing", "the", "best", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L779-L790
[ "def", "do_run_2", "(", "self", ")", ":", "while", "not", "self", ".", "check_terminate", "(", ")", ":", "self", ".", "_has_run", "=", "True", "self", ".", "_run2", "(", ")", "self", ".", "_num_iter", "+=", "1" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine._run2
Workhorse for do_run_2
peri/opt/optimize.py
def _run2(self): """Workhorse for do_run_2""" if self.check_update_J(): self.update_J() else: if self.check_Broyden_J(): self.update_Broyden_J() if self.check_update_eig_J(): self.update_eig_J() #0. Find _last_residuals...
def _run2(self): """Workhorse for do_run_2""" if self.check_update_J(): self.update_J() else: if self.check_Broyden_J(): self.update_Broyden_J() if self.check_update_eig_J(): self.update_eig_J() #0. Find _last_residuals...
[ "Workhorse", "for", "do_run_2" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L792-L872
[ "def", "_run2", "(", "self", ")", ":", "if", "self", ".", "check_update_J", "(", ")", ":", "self", ".", "update_J", "(", ")", "else", ":", "if", "self", ".", "check_Broyden_J", "(", ")", ":", "self", ".", "update_Broyden_J", "(", ")", "if", "self", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.do_internal_run
Takes more steps without calculating J again. Given a fixed damping, J, JTJ, iterates calculating steps, with optional Broyden or eigendirection updates. Iterates either until a bad step is taken or for self.run_length times. Called internally by do_run_2() but is also useful on its own...
peri/opt/optimize.py
def do_internal_run(self, initial_count=0, subblock=None, update_derr=True): """ Takes more steps without calculating J again. Given a fixed damping, J, JTJ, iterates calculating steps, with optional Broyden or eigendirection updates. Iterates either until a bad step is taken or...
def do_internal_run(self, initial_count=0, subblock=None, update_derr=True): """ Takes more steps without calculating J again. Given a fixed damping, J, JTJ, iterates calculating steps, with optional Broyden or eigendirection updates. Iterates either until a bad step is taken or...
[ "Takes", "more", "steps", "without", "calculating", "J", "again", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L874-L940
[ "def", "do_internal_run", "(", "self", ",", "initial_count", "=", "0", ",", "subblock", "=", "None", ",", "update_derr", "=", "True", ")", ":", "self", ".", "_inner_run_counter", "=", "initial_count", "good_step", "=", "True", "n_good_steps", "=", "0", "CLOG...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.find_LM_updates
Calculates LM updates, with or without the acceleration correction. Parameters ---------- grad : numpy.ndarray The gradient of the model cost. do_correct_damping : Bool, optional If `self.use_accel`, then set to True to correct damping ...
peri/opt/optimize.py
def find_LM_updates(self, grad, do_correct_damping=True, subblock=None): """ Calculates LM updates, with or without the acceleration correction. Parameters ---------- grad : numpy.ndarray The gradient of the model cost. do_correct_damping : Bool, ...
def find_LM_updates(self, grad, do_correct_damping=True, subblock=None): """ Calculates LM updates, with or without the acceleration correction. Parameters ---------- grad : numpy.ndarray The gradient of the model cost. do_correct_damping : Bool, ...
[ "Calculates", "LM", "updates", "with", "or", "without", "the", "acceleration", "correction", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L957-L1009
[ "def", "find_LM_updates", "(", "self", ",", "grad", ",", "do_correct_damping", "=", "True", ",", "subblock", "=", "None", ")", ":", "if", "subblock", "is", "not", "None", ":", "if", "(", "subblock", ".", "sum", "(", ")", "==", "0", ")", "or", "(", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine._calc_lm_step
Calculates a Levenberg-Marquard step w/o acceleration
peri/opt/optimize.py
def _calc_lm_step(self, damped_JTJ, grad, subblock=None): """Calculates a Levenberg-Marquard step w/o acceleration""" delta0, res, rank, s = np.linalg.lstsq(damped_JTJ, -0.5*grad, rcond=self.min_eigval) if self._fresh_JTJ: CLOG.debug('%d degenerate of %d total directi...
def _calc_lm_step(self, damped_JTJ, grad, subblock=None): """Calculates a Levenberg-Marquard step w/o acceleration""" delta0, res, rank, s = np.linalg.lstsq(damped_JTJ, -0.5*grad, rcond=self.min_eigval) if self._fresh_JTJ: CLOG.debug('%d degenerate of %d total directi...
[ "Calculates", "a", "Levenberg", "-", "Marquard", "step", "w", "/", "o", "acceleration" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1011-L1023
[ "def", "_calc_lm_step", "(", "self", ",", "damped_JTJ", ",", "grad", ",", "subblock", "=", "None", ")", ":", "delta0", ",", "res", ",", "rank", ",", "s", "=", "np", ".", "linalg", ".", "lstsq", "(", "damped_JTJ", ",", "-", "0.5", "*", "grad", ",", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.update_param_vals
Updates the current set of parameter values and previous values, sets a flag to re-calculate J. Parameters ---------- new_vals : numpy.ndarray The new values to update to incremental : Bool, optional Set to True to make it an incremental u...
peri/opt/optimize.py
def update_param_vals(self, new_vals, incremental=False): """ Updates the current set of parameter values and previous values, sets a flag to re-calculate J. Parameters ---------- new_vals : numpy.ndarray The new values to update to increm...
def update_param_vals(self, new_vals, incremental=False): """ Updates the current set of parameter values and previous values, sets a flag to re-calculate J. Parameters ---------- new_vals : numpy.ndarray The new values to update to increm...
[ "Updates", "the", "current", "set", "of", "parameter", "values", "and", "previous", "values", "sets", "a", "flag", "to", "re", "-", "calculate", "J", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1034-L1053
[ "def", "update_param_vals", "(", "self", ",", "new_vals", ",", "incremental", "=", "False", ")", ":", "self", ".", "_last_vals", "=", "self", ".", "param_vals", ".", "copy", "(", ")", "if", "incremental", ":", "self", ".", "param_vals", "+=", "new_vals", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.find_expected_error
Returns the error expected after an update if the model were linear. Parameters ---------- delta_params : {numpy.ndarray, 'calc', or 'perfect'}, optional The relative change in parameters. If 'calc', uses update calculated from the current damping, J, etc; if...
peri/opt/optimize.py
def find_expected_error(self, delta_params='calc'): """ Returns the error expected after an update if the model were linear. Parameters ---------- delta_params : {numpy.ndarray, 'calc', or 'perfect'}, optional The relative change in parameters. If 'calc', use...
def find_expected_error(self, delta_params='calc'): """ Returns the error expected after an update if the model were linear. Parameters ---------- delta_params : {numpy.ndarray, 'calc', or 'perfect'}, optional The relative change in parameters. If 'calc', use...
[ "Returns", "the", "error", "expected", "after", "an", "update", "if", "the", "model", "were", "linear", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1055-L1080
[ "def", "find_expected_error", "(", "self", ",", "delta_params", "=", "'calc'", ")", ":", "grad", "=", "self", ".", "calc_grad", "(", ")", "if", "list", "(", "delta_params", ")", "in", "[", "list", "(", "'calc'", ")", ",", "list", "(", "'perfect'", ")",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.calc_model_cosine
Calculates the cosine of the residuals with the model. Parameters ---------- decimate : Int or None, optional Decimate the residuals by `decimate` pixels. If None, no decimation is used. Valid only with mode='svd'. Default is None ...
peri/opt/optimize.py
def calc_model_cosine(self, decimate=None, mode='err'): """ Calculates the cosine of the residuals with the model. Parameters ---------- decimate : Int or None, optional Decimate the residuals by `decimate` pixels. If None, no decimation is us...
def calc_model_cosine(self, decimate=None, mode='err'): """ Calculates the cosine of the residuals with the model. Parameters ---------- decimate : Int or None, optional Decimate the residuals by `decimate` pixels. If None, no decimation is us...
[ "Calculates", "the", "cosine", "of", "the", "residuals", "with", "the", "model", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1082-L1136
[ "def", "calc_model_cosine", "(", "self", ",", "decimate", "=", "None", ",", "mode", "=", "'err'", ")", ":", "if", "mode", "==", "'svd'", ":", "slicer", "=", "slice", "(", "0", ",", "None", ",", "decimate", ")", "#1. Calculate projection term", "u", ",", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.get_termination_stats
Returns a dict of termination statistics Parameters ---------- get_cos : Bool, optional Whether or not to calcualte the cosine of the residuals with the tangent plane of the model using the current J. The calculation may take some time. Defaul...
peri/opt/optimize.py
def get_termination_stats(self, get_cos=True): """ Returns a dict of termination statistics Parameters ---------- get_cos : Bool, optional Whether or not to calcualte the cosine of the residuals with the tangent plane of the model using the cu...
def get_termination_stats(self, get_cos=True): """ Returns a dict of termination statistics Parameters ---------- get_cos : Bool, optional Whether or not to calcualte the cosine of the residuals with the tangent plane of the model using the cu...
[ "Returns", "a", "dict", "of", "termination", "statistics" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1138-L1169
[ "def", "get_termination_stats", "(", "self", ",", "get_cos", "=", "True", ")", ":", "delta_vals", "=", "self", ".", "_last_vals", "-", "self", ".", "param_vals", "delta_err", "=", "self", ".", "_last_error", "-", "self", ".", "error", "frac_err", "=", "del...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.check_completion
Returns a Bool of whether the algorithm has found a satisfactory minimum
peri/opt/optimize.py
def check_completion(self): """ Returns a Bool of whether the algorithm has found a satisfactory minimum """ terminate = False term_dict = self.get_termination_stats(get_cos=self.costol is not None) terminate |= np.all(np.abs(term_dict['delta_vals']) < self.paramtol) ...
def check_completion(self): """ Returns a Bool of whether the algorithm has found a satisfactory minimum """ terminate = False term_dict = self.get_termination_stats(get_cos=self.costol is not None) terminate |= np.all(np.abs(term_dict['delta_vals']) < self.paramtol) ...
[ "Returns", "a", "Bool", "of", "whether", "the", "algorithm", "has", "found", "a", "satisfactory", "minimum" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1171-L1184
[ "def", "check_completion", "(", "self", ")", ":", "terminate", "=", "False", "term_dict", "=", "self", ".", "get_termination_stats", "(", "get_cos", "=", "self", ".", "costol", "is", "not", "None", ")", "terminate", "|=", "np", ".", "all", "(", "np", "."...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.check_terminate
Returns a Bool of whether to terminate. Checks whether a satisfactory minimum has been found or whether too many iterations have occurred.
peri/opt/optimize.py
def check_terminate(self): """ Returns a Bool of whether to terminate. Checks whether a satisfactory minimum has been found or whether too many iterations have occurred. """ if not self._has_run: return False else: #1-3. errtol, paramtol, ...
def check_terminate(self): """ Returns a Bool of whether to terminate. Checks whether a satisfactory minimum has been found or whether too many iterations have occurred. """ if not self._has_run: return False else: #1-3. errtol, paramtol, ...
[ "Returns", "a", "Bool", "of", "whether", "to", "terminate", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1186-L1201
[ "def", "check_terminate", "(", "self", ")", ":", "if", "not", "self", ".", "_has_run", ":", "return", "False", "else", ":", "#1-3. errtol, paramtol, model cosine low enough?", "terminate", "=", "self", ".", "check_completion", "(", ")", "#4. too many iterations??", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.check_update_J
Checks if the full J should be updated. Right now, just updates after update_J_frequency loops
peri/opt/optimize.py
def check_update_J(self): """ Checks if the full J should be updated. Right now, just updates after update_J_frequency loops """ self._J_update_counter += 1 update = self._J_update_counter >= self.update_J_frequency return update & (not self._fresh_JTJ)
def check_update_J(self): """ Checks if the full J should be updated. Right now, just updates after update_J_frequency loops """ self._J_update_counter += 1 update = self._J_update_counter >= self.update_J_frequency return update & (not self._fresh_JTJ)
[ "Checks", "if", "the", "full", "J", "should", "be", "updated", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1203-L1211
[ "def", "check_update_J", "(", "self", ")", ":", "self", ".", "_J_update_counter", "+=", "1", "update", "=", "self", ".", "_J_update_counter", ">=", "self", ".", "update_J_frequency", "return", "update", "&", "(", "not", "self", ".", "_fresh_JTJ", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.update_J
Updates J, JTJ, and internal counters.
peri/opt/optimize.py
def update_J(self): """Updates J, JTJ, and internal counters.""" self.calc_J() # np.dot(j, j.T) is slightly faster but 2x as much mem step = np.ceil(1e-2 * self.J.shape[1]).astype('int') # 1% more mem... self.JTJ = low_mem_sq(self.J, step=step) #copies still, since J is ...
def update_J(self): """Updates J, JTJ, and internal counters.""" self.calc_J() # np.dot(j, j.T) is slightly faster but 2x as much mem step = np.ceil(1e-2 * self.J.shape[1]).astype('int') # 1% more mem... self.JTJ = low_mem_sq(self.J, step=step) #copies still, since J is ...
[ "Updates", "J", "JTJ", "and", "internal", "counters", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1213-L1226
[ "def", "update_J", "(", "self", ")", ":", "self", ".", "calc_J", "(", ")", "# np.dot(j, j.T) is slightly faster but 2x as much mem", "step", "=", "np", ".", "ceil", "(", "1e-2", "*", "self", ".", "J", ".", "shape", "[", "1", "]", ")", ".", "astype", "(",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.calc_grad
The gradient of the cost w.r.t. the parameters.
peri/opt/optimize.py
def calc_grad(self): """The gradient of the cost w.r.t. the parameters.""" residuals = self.calc_residuals() return 2*np.dot(self.J, residuals)
def calc_grad(self): """The gradient of the cost w.r.t. the parameters.""" residuals = self.calc_residuals() return 2*np.dot(self.J, residuals)
[ "The", "gradient", "of", "the", "cost", "w", ".", "r", ".", "t", ".", "the", "parameters", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1228-L1231
[ "def", "calc_grad", "(", "self", ")", ":", "residuals", "=", "self", ".", "calc_residuals", "(", ")", "return", "2", "*", "np", ".", "dot", "(", "self", ".", "J", ",", "residuals", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine._rank_1_J_update
Does J += np.outer(direction, new_values - old_values) without using lots of memory
peri/opt/optimize.py
def _rank_1_J_update(self, direction, values): """ Does J += np.outer(direction, new_values - old_values) without using lots of memory """ vals_to_sub = np.dot(direction, self.J) delta_vals = values - vals_to_sub for a in range(direction.size): self.J[...
def _rank_1_J_update(self, direction, values): """ Does J += np.outer(direction, new_values - old_values) without using lots of memory """ vals_to_sub = np.dot(direction, self.J) delta_vals = values - vals_to_sub for a in range(direction.size): self.J[...
[ "Does", "J", "+", "=", "np", ".", "outer", "(", "direction", "new_values", "-", "old_values", ")", "without", "using", "lots", "of", "memory" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1233-L1241
[ "def", "_rank_1_J_update", "(", "self", ",", "direction", ",", "values", ")", ":", "vals_to_sub", "=", "np", ".", "dot", "(", "direction", ",", "self", ".", "J", ")", "delta_vals", "=", "values", "-", "vals_to_sub", "for", "a", "in", "range", "(", "dir...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.update_Broyden_J
Execute a Broyden update of J
peri/opt/optimize.py
def update_Broyden_J(self): """Execute a Broyden update of J""" CLOG.debug('Broyden update.') delta_vals = self.param_vals - self._last_vals delta_residuals = self.calc_residuals() - self._last_residuals nrm = np.sqrt(np.dot(delta_vals, delta_vals)) direction = delta_vals...
def update_Broyden_J(self): """Execute a Broyden update of J""" CLOG.debug('Broyden update.') delta_vals = self.param_vals - self._last_vals delta_residuals = self.calc_residuals() - self._last_residuals nrm = np.sqrt(np.dot(delta_vals, delta_vals)) direction = delta_vals...
[ "Execute", "a", "Broyden", "update", "of", "J" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1248-L1257
[ "def", "update_Broyden_J", "(", "self", ")", ":", "CLOG", ".", "debug", "(", "'Broyden update.'", ")", "delta_vals", "=", "self", ".", "param_vals", "-", "self", ".", "_last_vals", "delta_residuals", "=", "self", ".", "calc_residuals", "(", ")", "-", "self",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.update_eig_J
Execute an eigen update of J
peri/opt/optimize.py
def update_eig_J(self): """Execute an eigen update of J""" CLOG.debug('Eigen update.') vls, vcs = np.linalg.eigh(self.JTJ) res0 = self.calc_residuals() for a in range(min([self.num_eig_dirs, vls.size])): #1. Finding stiff directions stif_dir = vcs[-(a+1)] ...
def update_eig_J(self): """Execute an eigen update of J""" CLOG.debug('Eigen update.') vls, vcs = np.linalg.eigh(self.JTJ) res0 = self.calc_residuals() for a in range(min([self.num_eig_dirs, vls.size])): #1. Finding stiff directions stif_dir = vcs[-(a+1)] ...
[ "Execute", "an", "eigen", "update", "of", "J" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1264-L1284
[ "def", "update_eig_J", "(", "self", ")", ":", "CLOG", ".", "debug", "(", "'Eigen update.'", ")", "vls", ",", "vcs", "=", "np", ".", "linalg", ".", "eigh", "(", "self", ".", "JTJ", ")", "res0", "=", "self", ".", "calc_residuals", "(", ")", "for", "a...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.calc_accel_correction
Geodesic acceleration correction to the LM step. Parameters ---------- damped_JTJ : numpy.ndarray The damped JTJ used to calculate the initial step. delta0 : numpy.ndarray The initial LM step. Returns ------- corr : nu...
peri/opt/optimize.py
def calc_accel_correction(self, damped_JTJ, delta0): """ Geodesic acceleration correction to the LM step. Parameters ---------- damped_JTJ : numpy.ndarray The damped JTJ used to calculate the initial step. delta0 : numpy.ndarray Th...
def calc_accel_correction(self, damped_JTJ, delta0): """ Geodesic acceleration correction to the LM step. Parameters ---------- damped_JTJ : numpy.ndarray The damped JTJ used to calculate the initial step. delta0 : numpy.ndarray Th...
[ "Geodesic", "acceleration", "correction", "to", "the", "LM", "step", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1286-L1314
[ "def", "calc_accel_correction", "(", "self", ",", "damped_JTJ", ",", "delta0", ")", ":", "#Get the derivative:", "_", "=", "self", ".", "update_function", "(", "self", ".", "param_vals", ")", "rm0", "=", "self", ".", "calc_residuals", "(", ")", ".", "copy", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMEngine.update_select_J
Updates J only for certain parameters, described by the boolean mask `blk`.
peri/opt/optimize.py
def update_select_J(self, blk): """ Updates J only for certain parameters, described by the boolean mask `blk`. """ p0 = self.param_vals.copy() self.update_function(p0) #in case things are not put back... r0 = self.calc_residuals().copy() dl = np.zeros(p0...
def update_select_J(self, blk): """ Updates J only for certain parameters, described by the boolean mask `blk`. """ p0 = self.param_vals.copy() self.update_function(p0) #in case things are not put back... r0 = self.calc_residuals().copy() dl = np.zeros(p0...
[ "Updates", "J", "only", "for", "certain", "parameters", "described", "by", "the", "boolean", "mask", "blk", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1316-L1336
[ "def", "update_select_J", "(", "self", ",", "blk", ")", ":", "p0", "=", "self", ".", "param_vals", ".", "copy", "(", ")", "self", ".", "update_function", "(", "p0", ")", "#in case things are not put back...", "r0", "=", "self", ".", "calc_residuals", "(", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMFunction._set_err_paramvals
Must update: self.error, self._last_error, self.param_vals, self._last_vals
peri/opt/optimize.py
def _set_err_paramvals(self): """ Must update: self.error, self._last_error, self.param_vals, self._last_vals """ # self.param_vals = p0 #sloppy... self._last_vals = self.param_vals.copy() self.error = self.update_function(self.param_vals) self._last_e...
def _set_err_paramvals(self): """ Must update: self.error, self._last_error, self.param_vals, self._last_vals """ # self.param_vals = p0 #sloppy... self._last_vals = self.param_vals.copy() self.error = self.update_function(self.param_vals) self._last_e...
[ "Must", "update", ":", "self", ".", "error", "self", ".", "_last_error", "self", ".", "param_vals", "self", ".", "_last_vals" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1387-L1395
[ "def", "_set_err_paramvals", "(", "self", ")", ":", "# self.param_vals = p0 #sloppy...", "self", ".", "_last_vals", "=", "self", ".", "param_vals", ".", "copy", "(", ")", "self", ".", "error", "=", "self", ".", "update_function", "(", "self", ".", "param_vals"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMFunction.calc_J
Updates self.J, returns nothing
peri/opt/optimize.py
def calc_J(self): """Updates self.J, returns nothing""" del self.J self.J = np.zeros([self.param_vals.size, self.data.size]) dp = np.zeros_like(self.param_vals) f0 = self.model.copy() for a in range(self.param_vals.size): dp *= 0 dp[a] = self.dl[a]...
def calc_J(self): """Updates self.J, returns nothing""" del self.J self.J = np.zeros([self.param_vals.size, self.data.size]) dp = np.zeros_like(self.param_vals) f0 = self.model.copy() for a in range(self.param_vals.size): dp *= 0 dp[a] = self.dl[a]...
[ "Updates", "self", ".", "J", "returns", "nothing" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1397-L1409
[ "def", "calc_J", "(", "self", ")", ":", "del", "self", ".", "J", "self", ".", "J", "=", "np", ".", "zeros", "(", "[", "self", ".", "param_vals", ".", "size", ",", "self", ".", "data", ".", "size", "]", ")", "dp", "=", "np", ".", "zeros_like", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMFunction.update_function
Takes an array param_vals, updates function, returns the new error
peri/opt/optimize.py
def update_function(self, param_vals): """Takes an array param_vals, updates function, returns the new error""" self.model = self.func(param_vals, *self.func_args, **self.func_kwargs) d = self.calc_residuals() return np.dot(d.flat, d.flat)
def update_function(self, param_vals): """Takes an array param_vals, updates function, returns the new error""" self.model = self.func(param_vals, *self.func_args, **self.func_kwargs) d = self.calc_residuals() return np.dot(d.flat, d.flat)
[ "Takes", "an", "array", "param_vals", "updates", "function", "returns", "the", "new", "error" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1414-L1418
[ "def", "update_function", "(", "self", ",", "param_vals", ")", ":", "self", ".", "model", "=", "self", ".", "func", "(", "param_vals", ",", "*", "self", ".", "func_args", ",", "*", "*", "self", ".", "func_kwargs", ")", "d", "=", "self", ".", "calc_re...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMOptObj.update_function
Updates the opt_obj, returns new error.
peri/opt/optimize.py
def update_function(self, param_vals): """Updates the opt_obj, returns new error.""" self.opt_obj.update_function(param_vals) return self.opt_obj.get_error()
def update_function(self, param_vals): """Updates the opt_obj, returns new error.""" self.opt_obj.update_function(param_vals) return self.opt_obj.get_error()
[ "Updates", "the", "opt_obj", "returns", "new", "error", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1469-L1472
[ "def", "update_function", "(", "self", ",", "param_vals", ")", ":", "self", ".", "opt_obj", ".", "update_function", "(", "param_vals", ")", "return", "self", ".", "opt_obj", ".", "get_error", "(", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
OptState.update_function
Updates with param_vals[i] = distance from self.p0 along self.direction[i].
peri/opt/optimize.py
def update_function(self, param_vals): """Updates with param_vals[i] = distance from self.p0 along self.direction[i].""" dp = np.zeros(self.p0.size) for a in range(param_vals.size): dp += param_vals[a] * self.directions[a] self.state.update(self.state.params, self.p0 + dp) ...
def update_function(self, param_vals): """Updates with param_vals[i] = distance from self.p0 along self.direction[i].""" dp = np.zeros(self.p0.size) for a in range(param_vals.size): dp += param_vals[a] * self.directions[a] self.state.update(self.state.params, self.p0 + dp) ...
[ "Updates", "with", "param_vals", "[", "i", "]", "=", "distance", "from", "self", ".", "p0", "along", "self", ".", "direction", "[", "i", "]", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1550-L1557
[ "def", "update_function", "(", "self", ",", "param_vals", ")", ":", "dp", "=", "np", ".", "zeros", "(", "self", ".", "p0", ".", "size", ")", "for", "a", "in", "range", "(", "param_vals", ".", "size", ")", ":", "dp", "+=", "param_vals", "[", "a", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
OptState.calc_J
Calculates J along the direction.
peri/opt/optimize.py
def calc_J(self): """Calculates J along the direction.""" r0 = self.state.residuals.copy().ravel() dl = np.zeros(self.param_vals.size) p0 = self.param_vals.copy() J = [] for a in range(self.param_vals.size): dl *= 0 dl[a] += self.dl sel...
def calc_J(self): """Calculates J along the direction.""" r0 = self.state.residuals.copy().ravel() dl = np.zeros(self.param_vals.size) p0 = self.param_vals.copy() J = [] for a in range(self.param_vals.size): dl *= 0 dl[a] += self.dl sel...
[ "Calculates", "J", "along", "the", "direction", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1570-L1583
[ "def", "calc_J", "(", "self", ")", ":", "r0", "=", "self", ".", "state", ".", "residuals", ".", "copy", "(", ")", ".", "ravel", "(", ")", "dl", "=", "np", ".", "zeros", "(", "self", ".", "param_vals", ".", "size", ")", "p0", "=", "self", ".", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMGlobals.update_select_J
Updates J only for certain parameters, described by the boolean mask blk.
peri/opt/optimize.py
def update_select_J(self, blk): """ Updates J only for certain parameters, described by the boolean mask blk. """ self.update_function(self.param_vals) params = np.array(self.param_names)[blk].tolist() blk_J = -self.state.gradmodel(params=params, inds=self._inds, ...
def update_select_J(self, blk): """ Updates J only for certain parameters, described by the boolean mask blk. """ self.update_function(self.param_vals) params = np.array(self.param_names)[blk].tolist() blk_J = -self.state.gradmodel(params=params, inds=self._inds, ...
[ "Updates", "J", "only", "for", "certain", "parameters", "described", "by", "the", "boolean", "mask", "blk", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1670-L1682
[ "def", "update_select_J", "(", "self", ",", "blk", ")", ":", "self", ".", "update_function", "(", "self", ".", "param_vals", ")", "params", "=", "np", ".", "array", "(", "self", ".", "param_names", ")", "[", "blk", "]", ".", "tolist", "(", ")", "blk_...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMGlobals.find_expected_error
Returns the error expected after an update if the model were linear. Parameters ---------- delta_params : {numpy.ndarray, 'calc', or 'perfect'}, optional The relative change in parameters. If 'calc', uses update calculated from the current damping, J, etc; if...
peri/opt/optimize.py
def find_expected_error(self, delta_params='calc', adjust=True): """ Returns the error expected after an update if the model were linear. Parameters ---------- delta_params : {numpy.ndarray, 'calc', or 'perfect'}, optional The relative change in parameters. I...
def find_expected_error(self, delta_params='calc', adjust=True): """ Returns the error expected after an update if the model were linear. Parameters ---------- delta_params : {numpy.ndarray, 'calc', or 'perfect'}, optional The relative change in parameters. I...
[ "Returns", "the", "error", "expected", "after", "an", "update", "if", "the", "model", "were", "linear", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1684-L1707
[ "def", "find_expected_error", "(", "self", ",", "delta_params", "=", "'calc'", ",", "adjust", "=", "True", ")", ":", "expected_error", "=", "super", "(", "LMGlobals", ",", "self", ")", ".", "find_expected_error", "(", "delta_params", "=", "delta_params", ")", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMGlobals.calc_model_cosine
Calculates the cosine of the residuals with the model. Parameters ---------- decimate : Int or None, optional Decimate the residuals by `decimate` pixels. If None, no decimation is used. Valid only with mode='svd'. Default is None ...
peri/opt/optimize.py
def calc_model_cosine(self, decimate=None, mode='err'): """ Calculates the cosine of the residuals with the model. Parameters ---------- decimate : Int or None, optional Decimate the residuals by `decimate` pixels. If None, no decimation is us...
def calc_model_cosine(self, decimate=None, mode='err'): """ Calculates the cosine of the residuals with the model. Parameters ---------- decimate : Int or None, optional Decimate the residuals by `decimate` pixels. If None, no decimation is us...
[ "Calculates", "the", "cosine", "of", "the", "residuals", "with", "the", "model", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1709-L1759
[ "def", "calc_model_cosine", "(", "self", ",", "decimate", "=", "None", ",", "mode", "=", "'err'", ")", ":", "#we calculate the model cosine only in the data space of the", "#sampled indices", "if", "mode", "==", "'err'", ":", "expected_error", "=", "self", ".", "fin...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMGlobals.calc_grad
The gradient of the cost w.r.t. the parameters.
peri/opt/optimize.py
def calc_grad(self): """The gradient of the cost w.r.t. the parameters.""" if self._fresh_JTJ: return self._graderr else: residuals = self.calc_residuals() return 2*np.dot(self.J, residuals)
def calc_grad(self): """The gradient of the cost w.r.t. the parameters.""" if self._fresh_JTJ: return self._graderr else: residuals = self.calc_residuals() return 2*np.dot(self.J, residuals)
[ "The", "gradient", "of", "the", "cost", "w", ".", "r", ".", "t", ".", "the", "parameters", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1761-L1767
[ "def", "calc_grad", "(", "self", ")", ":", "if", "self", ".", "_fresh_JTJ", ":", "return", "self", ".", "_graderr", "else", ":", "residuals", "=", "self", ".", "calc_residuals", "(", ")", "return", "2", "*", "np", ".", "dot", "(", "self", ".", "J", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMParticleGroupCollection.reset
Resets the particle groups and optionally the region size and damping. Parameters ---------- new_region_size : : Int or 3-element list-like of ints, optional The region size for sub-blocking particles. Default is 40 do_calc_size : Bool, optional I...
peri/opt/optimize.py
def reset(self, new_region_size=None, do_calc_size=True, new_damping=None, new_max_mem=None): """ Resets the particle groups and optionally the region size and damping. Parameters ---------- new_region_size : : Int or 3-element list-like of ints, optional ...
def reset(self, new_region_size=None, do_calc_size=True, new_damping=None, new_max_mem=None): """ Resets the particle groups and optionally the region size and damping. Parameters ---------- new_region_size : : Int or 3-element list-like of ints, optional ...
[ "Resets", "the", "particle", "groups", "and", "optionally", "the", "region", "size", "and", "damping", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L1984-L2023
[ "def", "reset", "(", "self", ",", "new_region_size", "=", "None", ",", "do_calc_size", "=", "True", ",", "new_damping", "=", "None", ",", "new_max_mem", "=", "None", ")", ":", "if", "new_region_size", "is", "not", "None", ":", "self", ".", "region_size", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMParticleGroupCollection._do_run
workhorse for the self.do_run_xx methods.
peri/opt/optimize.py
def _do_run(self, mode='1'): """workhorse for the self.do_run_xx methods.""" for a in range(len(self.particle_groups)): group = self.particle_groups[a] lp = LMParticles(self.state, group, **self._kwargs) if mode == 'internal': lp.J, lp.JTJ, lp._dif_til...
def _do_run(self, mode='1'): """workhorse for the self.do_run_xx methods.""" for a in range(len(self.particle_groups)): group = self.particle_groups[a] lp = LMParticles(self.state, group, **self._kwargs) if mode == 'internal': lp.J, lp.JTJ, lp._dif_til...
[ "workhorse", "for", "the", "self", ".", "do_run_xx", "methods", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2045-L2063
[ "def", "_do_run", "(", "self", ",", "mode", "=", "'1'", ")", ":", "for", "a", "in", "range", "(", "len", "(", "self", ".", "particle_groups", ")", ")", ":", "group", "=", "self", ".", "particle_groups", "[", "a", "]", "lp", "=", "LMParticles", "(",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMParticleGroupCollection.do_internal_run
Calls LMParticles.do_internal_run for each group of particles.
peri/opt/optimize.py
def do_internal_run(self): """Calls LMParticles.do_internal_run for each group of particles.""" if not self.save_J: raise RuntimeError('self.save_J=True required for do_internal_run()') if not np.all(self._has_saved_J): raise RuntimeError('J, JTJ have not been pre-compute...
def do_internal_run(self): """Calls LMParticles.do_internal_run for each group of particles.""" if not self.save_J: raise RuntimeError('self.save_J=True required for do_internal_run()') if not np.all(self._has_saved_J): raise RuntimeError('J, JTJ have not been pre-compute...
[ "Calls", "LMParticles", ".", "do_internal_run", "for", "each", "group", "of", "particles", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2073-L2079
[ "def", "do_internal_run", "(", "self", ")", ":", "if", "not", "self", ".", "save_J", ":", "raise", "RuntimeError", "(", "'self.save_J=True required for do_internal_run()'", ")", "if", "not", "np", ".", "all", "(", "self", ".", "_has_saved_J", ")", ":", "raise"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
AugmentedState.reset
Resets the initial radii used for updating the particles. Call if any of the particle radii or positions have been changed external to the augmented state.
peri/opt/optimize.py
def reset(self): """ Resets the initial radii used for updating the particles. Call if any of the particle radii or positions have been changed external to the augmented state. """ inds = list(range(self.state.obj_get_positions().shape[0])) self._rad_nms = self.st...
def reset(self): """ Resets the initial radii used for updating the particles. Call if any of the particle radii or positions have been changed external to the augmented state. """ inds = list(range(self.state.obj_get_positions().shape[0])) self._rad_nms = self.st...
[ "Resets", "the", "initial", "radii", "used", "for", "updating", "the", "particles", ".", "Call", "if", "any", "of", "the", "particle", "radii", "or", "positions", "have", "been", "changed", "external", "to", "the", "augmented", "state", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2143-L2154
[ "def", "reset", "(", "self", ")", ":", "inds", "=", "list", "(", "range", "(", "self", ".", "state", ".", "obj_get_positions", "(", ")", ".", "shape", "[", "0", "]", ")", ")", "self", ".", "_rad_nms", "=", "self", ".", "state", ".", "param_particle...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
AugmentedState._poly
Right now legval(z)
peri/opt/optimize.py
def _poly(self, z): """Right now legval(z)""" shp = self.state.oshape.shape zmax = float(shp[0]) zmin = 0.0 zmid = zmax * 0.5 coeffs = self.param_vals[self.rscale_mask].copy() if coeffs.size == 0: ans = 0*z else: ans = np.polynomia...
def _poly(self, z): """Right now legval(z)""" shp = self.state.oshape.shape zmax = float(shp[0]) zmin = 0.0 zmid = zmax * 0.5 coeffs = self.param_vals[self.rscale_mask].copy() if coeffs.size == 0: ans = 0*z else: ans = np.polynomia...
[ "Right", "now", "legval", "(", "z", ")" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2160-L2173
[ "def", "_poly", "(", "self", ",", "z", ")", ":", "shp", "=", "self", ".", "state", ".", "oshape", ".", "shape", "zmax", "=", "float", "(", "shp", "[", "0", "]", ")", "zmin", "=", "0.0", "zmid", "=", "zmax", "*", "0.5", "coeffs", "=", "self", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
AugmentedState.update
Updates all the parameters of the state + rscale(z)
peri/opt/optimize.py
def update(self, param_vals): """Updates all the parameters of the state + rscale(z)""" self.update_rscl_x_params(param_vals[self.rscale_mask]) self.state.update(self.param_names, param_vals[self.globals_mask]) self.param_vals[:] = param_vals.copy() if np.any(np.isnan(self.state....
def update(self, param_vals): """Updates all the parameters of the state + rscale(z)""" self.update_rscl_x_params(param_vals[self.rscale_mask]) self.state.update(self.param_names, param_vals[self.globals_mask]) self.param_vals[:] = param_vals.copy() if np.any(np.isnan(self.state....
[ "Updates", "all", "the", "parameters", "of", "the", "state", "+", "rscale", "(", "z", ")" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2175-L2181
[ "def", "update", "(", "self", ",", "param_vals", ")", ":", "self", ".", "update_rscl_x_params", "(", "param_vals", "[", "self", ".", "rscale_mask", "]", ")", "self", ".", "state", ".", "update", "(", "self", ".", "param_names", ",", "param_vals", "[", "s...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
LMAugmentedState.reset
Resets the aug_state and the LMEngine
peri/opt/optimize.py
def reset(self, **kwargs): """Resets the aug_state and the LMEngine""" self.aug_state.reset() super(LMAugmentedState, self).reset(**kwargs)
def reset(self, **kwargs): """Resets the aug_state and the LMEngine""" self.aug_state.reset() super(LMAugmentedState, self).reset(**kwargs)
[ "Resets", "the", "aug_state", "and", "the", "LMEngine" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2298-L2301
[ "def", "reset", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "aug_state", ".", "reset", "(", ")", "super", "(", "LMAugmentedState", ",", "self", ")", ".", "reset", "(", "*", "*", "kwargs", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Link.get_shares
Returns an object with a the numbers of shares a link has had using Buffer. www will be stripped, but other subdomains will not.
buffpy/models/link.py
def get_shares(self): ''' Returns an object with a the numbers of shares a link has had using Buffer. www will be stripped, but other subdomains will not. ''' self.shares = self.api.get(url=PATHS['GET_SHARES'] % self.url)['shares'] return self.shares
def get_shares(self): ''' Returns an object with a the numbers of shares a link has had using Buffer. www will be stripped, but other subdomains will not. ''' self.shares = self.api.get(url=PATHS['GET_SHARES'] % self.url)['shares'] return self.shares
[ "Returns", "an", "object", "with", "a", "the", "numbers", "of", "shares", "a", "link", "has", "had", "using", "Buffer", "." ]
vtemian/buffpy
python
https://github.com/vtemian/buffpy/blob/6c9236fd3b6a8f9e2d70dbf1bc01529242b73075/buffpy/models/link.py#L18-L28
[ "def", "get_shares", "(", "self", ")", ":", "self", ".", "shares", "=", "self", ".", "api", ".", "get", "(", "url", "=", "PATHS", "[", "'GET_SHARES'", "]", "%", "self", ".", "url", ")", "[", "'shares'", "]", "return", "self", ".", "shares" ]
6c9236fd3b6a8f9e2d70dbf1bc01529242b73075
valid
sample
Take a sample from a field given flat indices or a shaped slice Parameters ----------- inds : list of indices One dimensional (raveled) indices to return from the field slicer : slice object A shaped (3D) slicer that returns a section of image flat : boolean Whether to fla...
peri/states.py
def sample(field, inds=None, slicer=None, flat=True): """ Take a sample from a field given flat indices or a shaped slice Parameters ----------- inds : list of indices One dimensional (raveled) indices to return from the field slicer : slice object A shaped (3D) slicer that ret...
def sample(field, inds=None, slicer=None, flat=True): """ Take a sample from a field given flat indices or a shaped slice Parameters ----------- inds : list of indices One dimensional (raveled) indices to return from the field slicer : slice object A shaped (3D) slicer that ret...
[ "Take", "a", "sample", "from", "a", "field", "given", "flat", "indices", "or", "a", "shaped", "slice" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L20-L44
[ "def", "sample", "(", "field", ",", "inds", "=", "None", ",", "slicer", "=", "None", ",", "flat", "=", "True", ")", ":", "if", "inds", "is", "not", "None", ":", "out", "=", "field", ".", "ravel", "(", ")", "[", "inds", "]", "elif", "slicer", "i...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
save
Save the current state with extra information (for example samples and LL from the optimization procedure). Parameters ---------- state : peri.states.ImageState the state object which to save filename : string if provided, will override the default that is constructed based on ...
peri/states.py
def save(state, filename=None, desc='', extra=None): """ Save the current state with extra information (for example samples and LL from the optimization procedure). Parameters ---------- state : peri.states.ImageState the state object which to save filename : string if prov...
def save(state, filename=None, desc='', extra=None): """ Save the current state with extra information (for example samples and LL from the optimization procedure). Parameters ---------- state : peri.states.ImageState the state object which to save filename : string if prov...
[ "Save", "the", "current", "state", "with", "extra", "information", "(", "for", "example", "samples", "and", "LL", "from", "the", "optimization", "procedure", ")", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L850-L892
[ "def", "save", "(", "state", ",", "filename", "=", "None", ",", "desc", "=", "''", ",", "extra", "=", "None", ")", ":", "if", "isinstance", "(", "state", ".", "image", ",", "util", ".", "RawImage", ")", ":", "desc", "=", "desc", "or", "'save'", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
load
Load the state from the given file, moving to the file's directory during load (temporarily, moving back after loaded) Parameters ---------- filename : string name of the file to open, should be a .pkl file
peri/states.py
def load(filename): """ Load the state from the given file, moving to the file's directory during load (temporarily, moving back after loaded) Parameters ---------- filename : string name of the file to open, should be a .pkl file """ path, name = os.path.split(filename) pat...
def load(filename): """ Load the state from the given file, moving to the file's directory during load (temporarily, moving back after loaded) Parameters ---------- filename : string name of the file to open, should be a .pkl file """ path, name = os.path.split(filename) pat...
[ "Load", "the", "state", "from", "the", "given", "file", "moving", "to", "the", "file", "s", "directory", "during", "load", "(", "temporarily", "moving", "back", "after", "loaded", ")" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L894-L908
[ "def", "load", "(", "filename", ")", ":", "path", ",", "name", "=", "os", ".", "path", ".", "split", "(", "filename", ")", "path", "=", "path", "or", "'.'", "with", "util", ".", "indir", "(", "path", ")", ":", "return", "pickle", ".", "load", "("...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State.error
Class property: Sum of the squared errors, :math:`E = \sum_i (D_i - M_i(\\theta))^2`
peri/states.py
def error(self): """ Class property: Sum of the squared errors, :math:`E = \sum_i (D_i - M_i(\\theta))^2` """ r = self.residuals.ravel() return np.dot(r,r)
def error(self): """ Class property: Sum of the squared errors, :math:`E = \sum_i (D_i - M_i(\\theta))^2` """ r = self.residuals.ravel() return np.dot(r,r)
[ "Class", "property", ":", "Sum", "of", "the", "squared", "errors", ":", "math", ":", "E", "=", "\\", "sum_i", "(", "D_i", "-", "M_i", "(", "\\\\", "theta", "))", "^2" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L166-L172
[ "def", "error", "(", "self", ")", ":", "r", "=", "self", ".", "residuals", ".", "ravel", "(", ")", "return", "np", ".", "dot", "(", "r", ",", "r", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State.loglikelihood
Class property: loglikelihood calculated by the model error, :math:`\\mathcal{L} = - \\frac{1}{2} \\sum\\left[ \\left(\\frac{D_i - M_i(\\theta)}{\sigma}\\right)^2 + \\log{(2\pi \sigma^2)} \\right]`
peri/states.py
def loglikelihood(self): """ Class property: loglikelihood calculated by the model error, :math:`\\mathcal{L} = - \\frac{1}{2} \\sum\\left[ \\left(\\frac{D_i - M_i(\\theta)}{\sigma}\\right)^2 + \\log{(2\pi \sigma^2)} \\right]` """ sig = self.hyper_parameters.get_v...
def loglikelihood(self): """ Class property: loglikelihood calculated by the model error, :math:`\\mathcal{L} = - \\frac{1}{2} \\sum\\left[ \\left(\\frac{D_i - M_i(\\theta)}{\sigma}\\right)^2 + \\log{(2\pi \sigma^2)} \\right]` """ sig = self.hyper_parameters.get_v...
[ "Class", "property", ":", "loglikelihood", "calculated", "by", "the", "model", "error", ":", "math", ":", "\\\\", "mathcal", "{", "L", "}", "=", "-", "\\\\", "frac", "{", "1", "}", "{", "2", "}", "\\\\", "sum", "\\\\", "left", "[", "\\\\", "left", ...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L175-L185
[ "def", "loglikelihood", "(", "self", ")", ":", "sig", "=", "self", ".", "hyper_parameters", ".", "get_values", "(", "'sigma'", ")", "err", "=", "self", ".", "error", "N", "=", "np", ".", "size", "(", "self", ".", "data", ")", "return", "-", "0.5", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State.update
Update a single parameter or group of parameters ``params`` with ``values``. Parameters ---------- params : string or list of strings Parameter names which to update value : number or list of numbers Values of those parameters which to update
peri/states.py
def update(self, params, values): """ Update a single parameter or group of parameters ``params`` with ``values``. Parameters ---------- params : string or list of strings Parameter names which to update value : number or list of numbers ...
def update(self, params, values): """ Update a single parameter or group of parameters ``params`` with ``values``. Parameters ---------- params : string or list of strings Parameter names which to update value : number or list of numbers ...
[ "Update", "a", "single", "parameter", "or", "group", "of", "parameters", "params", "with", "values", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L204-L217
[ "def", "update", "(", "self", ",", "params", ",", "values", ")", ":", "return", "super", "(", "State", ",", "self", ")", ".", "update", "(", "params", ",", "values", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State.push_update
Perform a parameter update and keep track of the change on the state. Same call structure as :func:`peri.states.States.update`
peri/states.py
def push_update(self, params, values): """ Perform a parameter update and keep track of the change on the state. Same call structure as :func:`peri.states.States.update` """ curr = self.get_values(params) self.stack.append((params, curr)) self.update(params, value...
def push_update(self, params, values): """ Perform a parameter update and keep track of the change on the state. Same call structure as :func:`peri.states.States.update` """ curr = self.get_values(params) self.stack.append((params, curr)) self.update(params, value...
[ "Perform", "a", "parameter", "update", "and", "keep", "track", "of", "the", "change", "on", "the", "state", ".", "Same", "call", "structure", "as", ":", "func", ":", "peri", ".", "states", ".", "States", ".", "update" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L238-L245
[ "def", "push_update", "(", "self", ",", "params", ",", "values", ")", ":", "curr", "=", "self", ".", "get_values", "(", "params", ")", "self", ".", "stack", ".", "append", "(", "(", "params", ",", "curr", ")", ")", "self", ".", "update", "(", "para...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State.pop_update
Pop the last update from the stack push by :func:`peri.states.States.push_update` by undoing the chnage last performed.
peri/states.py
def pop_update(self): """ Pop the last update from the stack push by :func:`peri.states.States.push_update` by undoing the chnage last performed. """ params, values = self.stack.pop() self.update(params, values)
def pop_update(self): """ Pop the last update from the stack push by :func:`peri.states.States.push_update` by undoing the chnage last performed. """ params, values = self.stack.pop() self.update(params, values)
[ "Pop", "the", "last", "update", "from", "the", "stack", "push", "by", ":", "func", ":", "peri", ".", "states", ".", "States", ".", "push_update", "by", "undoing", "the", "chnage", "last", "performed", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L247-L254
[ "def", "pop_update", "(", "self", ")", ":", "params", ",", "values", "=", "self", ".", "stack", ".", "pop", "(", ")", "self", ".", "update", "(", "params", ",", "values", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State.temp_update
Context manager to temporarily perform a parameter update (by using the stack structure). To use: with state.temp_update(params, values): # measure the cost or something state.error
peri/states.py
def temp_update(self, params, values): """ Context manager to temporarily perform a parameter update (by using the stack structure). To use: with state.temp_update(params, values): # measure the cost or something state.error """ self.p...
def temp_update(self, params, values): """ Context manager to temporarily perform a parameter update (by using the stack structure). To use: with state.temp_update(params, values): # measure the cost or something state.error """ self.p...
[ "Context", "manager", "to", "temporarily", "perform", "a", "parameter", "update", "(", "by", "using", "the", "stack", "structure", ")", ".", "To", "use", ":" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L257-L268
[ "def", "temp_update", "(", "self", ",", "params", ",", "values", ")", ":", "self", ".", "push_update", "(", "params", ",", "values", ")", "yield", "self", ".", "pop_update", "(", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State._grad_one_param
Gradient of `func` wrt a single parameter `p`. (see _graddoc)
peri/states.py
def _grad_one_param(self, funct, p, dl=2e-5, rts=False, nout=1, **kwargs): """ Gradient of `func` wrt a single parameter `p`. (see _graddoc) """ vals = self.get_values(p) f0 = funct(**kwargs) self.update(p, vals+dl) f1 = funct(**kwargs) if rts: ...
def _grad_one_param(self, funct, p, dl=2e-5, rts=False, nout=1, **kwargs): """ Gradient of `func` wrt a single parameter `p`. (see _graddoc) """ vals = self.get_values(p) f0 = funct(**kwargs) self.update(p, vals+dl) f1 = funct(**kwargs) if rts: ...
[ "Gradient", "of", "func", "wrt", "a", "single", "parameter", "p", ".", "(", "see", "_graddoc", ")" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L273-L288
[ "def", "_grad_one_param", "(", "self", ",", "funct", ",", "p", ",", "dl", "=", "2e-5", ",", "rts", "=", "False", ",", "nout", "=", "1", ",", "*", "*", "kwargs", ")", ":", "vals", "=", "self", ".", "get_values", "(", "p", ")", "f0", "=", "funct"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State._hess_two_param
Hessian of `func` wrt two parameters `p0` and `p1`. (see _graddoc)
peri/states.py
def _hess_two_param(self, funct, p0, p1, dl=2e-5, rts=False, **kwargs): """ Hessian of `func` wrt two parameters `p0` and `p1`. (see _graddoc) """ vals0 = self.get_values(p0) vals1 = self.get_values(p1) f00 = funct(**kwargs) self.update(p0, vals0+dl) f10...
def _hess_two_param(self, funct, p0, p1, dl=2e-5, rts=False, **kwargs): """ Hessian of `func` wrt two parameters `p0` and `p1`. (see _graddoc) """ vals0 = self.get_values(p0) vals1 = self.get_values(p1) f00 = funct(**kwargs) self.update(p0, vals0+dl) f10...
[ "Hessian", "of", "func", "wrt", "two", "parameters", "p0", "and", "p1", ".", "(", "see", "_graddoc", ")" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L290-L311
[ "def", "_hess_two_param", "(", "self", ",", "funct", ",", "p0", ",", "p1", ",", "dl", "=", "2e-5", ",", "rts", "=", "False", ",", "*", "*", "kwargs", ")", ":", "vals0", "=", "self", ".", "get_values", "(", "p0", ")", "vals1", "=", "self", ".", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State._grad
Gradient of `func` wrt a set of parameters params. (see _graddoc)
peri/states.py
def _grad(self, funct, params=None, dl=2e-5, rts=False, nout=1, out=None, **kwargs): """ Gradient of `func` wrt a set of parameters params. (see _graddoc) """ if params is None: params = self.param_all() ps = util.listify(params) f0 = funct(**kwar...
def _grad(self, funct, params=None, dl=2e-5, rts=False, nout=1, out=None, **kwargs): """ Gradient of `func` wrt a set of parameters params. (see _graddoc) """ if params is None: params = self.param_all() ps = util.listify(params) f0 = funct(**kwar...
[ "Gradient", "of", "func", "wrt", "a", "set", "of", "parameters", "params", ".", "(", "see", "_graddoc", ")" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L313-L345
[ "def", "_grad", "(", "self", ",", "funct", ",", "params", "=", "None", ",", "dl", "=", "2e-5", ",", "rts", "=", "False", ",", "nout", "=", "1", ",", "out", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "params", "is", "None", ":", "pa...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State._jtj
jTj of a `func` wrt to parmaeters `params`. (see _graddoc)
peri/states.py
def _jtj(self, funct, params=None, dl=2e-5, rts=False, **kwargs): """ jTj of a `func` wrt to parmaeters `params`. (see _graddoc) """ grad = self._grad(funct=funct, params=params, dl=dl, rts=rts, **kwargs) return np.dot(grad, grad.T)
def _jtj(self, funct, params=None, dl=2e-5, rts=False, **kwargs): """ jTj of a `func` wrt to parmaeters `params`. (see _graddoc) """ grad = self._grad(funct=funct, params=params, dl=dl, rts=rts, **kwargs) return np.dot(grad, grad.T)
[ "jTj", "of", "a", "func", "wrt", "to", "parmaeters", "params", ".", "(", "see", "_graddoc", ")" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L348-L353
[ "def", "_jtj", "(", "self", ",", "funct", ",", "params", "=", "None", ",", "dl", "=", "2e-5", ",", "rts", "=", "False", ",", "*", "*", "kwargs", ")", ":", "grad", "=", "self", ".", "_grad", "(", "funct", "=", "funct", ",", "params", "=", "param...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State._hess
Hessian of a `func` wrt to parmaeters `params`. (see _graddoc)
peri/states.py
def _hess(self, funct, params=None, dl=2e-5, rts=False, **kwargs): """ Hessian of a `func` wrt to parmaeters `params`. (see _graddoc) """ if params is None: params = self.param_all() ps = util.listify(params) f0 = funct(**kwargs) # get the shape of t...
def _hess(self, funct, params=None, dl=2e-5, rts=False, **kwargs): """ Hessian of a `func` wrt to parmaeters `params`. (see _graddoc) """ if params is None: params = self.param_all() ps = util.listify(params) f0 = funct(**kwargs) # get the shape of t...
[ "Hessian", "of", "a", "func", "wrt", "to", "parmaeters", "params", ".", "(", "see", "_graddoc", ")" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L355-L376
[ "def", "_hess", "(", "self", ",", "funct", ",", "params", "=", "None", ",", "dl", "=", "2e-5", ",", "rts", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "params", "is", "None", ":", "params", "=", "self", ".", "param_all", "(", ")", "p...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State.build_funcs
Here, we build gradient and hessian functions based on the properties of a state that are generally wanted. For each one, we fill in _grad or _hess with a function that takes care of various options such as slicing and flattening. For example, `m` below takes the model, selects different...
peri/states.py
def build_funcs(self): """ Here, we build gradient and hessian functions based on the properties of a state that are generally wanted. For each one, we fill in _grad or _hess with a function that takes care of various options such as slicing and flattening. For example, `m` below...
def build_funcs(self): """ Here, we build gradient and hessian functions based on the properties of a state that are generally wanted. For each one, we fill in _grad or _hess with a function that takes care of various options such as slicing and flattening. For example, `m` below...
[ "Here", "we", "build", "gradient", "and", "hessian", "functions", "based", "on", "the", "properties", "of", "a", "state", "that", "are", "generally", "wanted", ".", "For", "each", "one", "we", "fill", "in", "_grad", "or", "_hess", "with", "a", "function", ...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L381-L445
[ "def", "build_funcs", "(", "self", ")", ":", "# create essentially lambda functions, but with a nice signature", "def", "m", "(", "inds", "=", "None", ",", "slicer", "=", "None", ",", "flat", "=", "True", ")", ":", "return", "sample", "(", "self", ".", "model"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
State.crb
Calculate the diagonal elements of the minimum covariance of the model with respect to parameters params. ``*args`` and ``**kwargs`` go to ``fisherinformation``.
peri/states.py
def crb(self, params=None, *args, **kwargs): """ Calculate the diagonal elements of the minimum covariance of the model with respect to parameters params. ``*args`` and ``**kwargs`` go to ``fisherinformation``. """ fish = self.fisherinformation(params=params, *args, **kwa...
def crb(self, params=None, *args, **kwargs): """ Calculate the diagonal elements of the minimum covariance of the model with respect to parameters params. ``*args`` and ``**kwargs`` go to ``fisherinformation``. """ fish = self.fisherinformation(params=params, *args, **kwa...
[ "Calculate", "the", "diagonal", "elements", "of", "the", "minimum", "covariance", "of", "the", "model", "with", "respect", "to", "parameters", "params", ".", "*", "args", "and", "**", "kwargs", "go", "to", "fisherinformation", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L447-L454
[ "def", "crb", "(", "self", ",", "params", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "fish", "=", "self", ".", "fisherinformation", "(", "params", "=", "params", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", "np...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ImageState.set_model
Setup the image model formation equation and corresponding objects into their various objects. `mdl` is a `peri.models.Model` object
peri/states.py
def set_model(self, mdl): """ Setup the image model formation equation and corresponding objects into their various objects. `mdl` is a `peri.models.Model` object """ self.mdl = mdl self.mdl.check_inputs(self.comps) for c in self.comps: setattr(self, ...
def set_model(self, mdl): """ Setup the image model formation equation and corresponding objects into their various objects. `mdl` is a `peri.models.Model` object """ self.mdl = mdl self.mdl.check_inputs(self.comps) for c in self.comps: setattr(self, ...
[ "Setup", "the", "image", "model", "formation", "equation", "and", "corresponding", "objects", "into", "their", "various", "objects", ".", "mdl", "is", "a", "peri", ".", "models", ".", "Model", "object" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L558-L567
[ "def", "set_model", "(", "self", ",", "mdl", ")", ":", "self", ".", "mdl", "=", "mdl", "self", ".", "mdl", ".", "check_inputs", "(", "self", ".", "comps", ")", "for", "c", "in", "self", ".", "comps", ":", "setattr", "(", "self", ",", "'_comp_'", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ImageState.set_image
Update the current comparison (real) image
peri/states.py
def set_image(self, image): """ Update the current comparison (real) image """ if isinstance(image, np.ndarray): image = util.Image(image) if isinstance(image, util.NullImage): self.model_as_data = True else: self.model_as_data = False...
def set_image(self, image): """ Update the current comparison (real) image """ if isinstance(image, np.ndarray): image = util.Image(image) if isinstance(image, util.NullImage): self.model_as_data = True else: self.model_as_data = False...
[ "Update", "the", "current", "comparison", "(", "real", ")", "image" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L569-L594
[ "def", "set_image", "(", "self", ",", "image", ")", ":", "if", "isinstance", "(", "image", ",", "np", ".", "ndarray", ")", ":", "image", "=", "util", ".", "Image", "(", "image", ")", "if", "isinstance", "(", "image", ",", "util", ".", "NullImage", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ImageState.model_to_data
Switch out the data for the model's recreation of the data.
peri/states.py
def model_to_data(self, sigma=0.0): """ Switch out the data for the model's recreation of the data. """ im = self.model.copy() im += sigma*np.random.randn(*im.shape) self.set_image(util.NullImage(image=im))
def model_to_data(self, sigma=0.0): """ Switch out the data for the model's recreation of the data. """ im = self.model.copy() im += sigma*np.random.randn(*im.shape) self.set_image(util.NullImage(image=im))
[ "Switch", "out", "the", "data", "for", "the", "model", "s", "recreation", "of", "the", "data", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L599-L603
[ "def", "model_to_data", "(", "self", ",", "sigma", "=", "0.0", ")", ":", "im", "=", "self", ".", "model", ".", "copy", "(", ")", "im", "+=", "sigma", "*", "np", ".", "random", ".", "randn", "(", "*", "im", ".", "shape", ")", "self", ".", "set_i...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ImageState.get_update_io_tiles
Get the tiles corresponding to a particular section of image needed to be updated. Inputs are the parameters and values. Returned is the padded tile, inner tile, and slicer to go between, but accounting for wrap with the edge of the image as necessary.
peri/states.py
def get_update_io_tiles(self, params, values): """ Get the tiles corresponding to a particular section of image needed to be updated. Inputs are the parameters and values. Returned is the padded tile, inner tile, and slicer to go between, but accounting for wrap with the edge of ...
def get_update_io_tiles(self, params, values): """ Get the tiles corresponding to a particular section of image needed to be updated. Inputs are the parameters and values. Returned is the padded tile, inner tile, and slicer to go between, but accounting for wrap with the edge of ...
[ "Get", "the", "tiles", "corresponding", "to", "a", "particular", "section", "of", "image", "needed", "to", "be", "updated", ".", "Inputs", "are", "the", "parameters", "and", "values", ".", "Returned", "is", "the", "padded", "tile", "inner", "tile", "and", ...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L634-L664
[ "def", "get_update_io_tiles", "(", "self", ",", "params", ",", "values", ")", ":", "# get the affected area of the model image", "otile", "=", "self", ".", "get_update_tile", "(", "params", ",", "values", ")", "if", "otile", "is", "None", ":", "return", "[", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ImageState.update
Actually perform an image (etc) update based on a set of params and values. These parameter can be any present in the components in any number. If there is only one component affected then difference image updates will be employed.
peri/states.py
def update(self, params, values): """ Actually perform an image (etc) update based on a set of params and values. These parameter can be any present in the components in any number. If there is only one component affected then difference image updates will be employed. ""...
def update(self, params, values): """ Actually perform an image (etc) update based on a set of params and values. These parameter can be any present in the components in any number. If there is only one component affected then difference image updates will be employed. ""...
[ "Actually", "perform", "an", "image", "(", "etc", ")", "update", "based", "on", "a", "set", "of", "params", "and", "values", ".", "These", "parameter", "can", "be", "any", "present", "in", "the", "components", "in", "any", "number", ".", "If", "there", ...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L666-L720
[ "def", "update", "(", "self", ",", "params", ",", "values", ")", ":", "# FIXME needs to update priors", "comps", "=", "self", ".", "affected_components", "(", "params", ")", "if", "len", "(", "comps", ")", "==", "0", ":", "return", "False", "# get the affect...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ImageState.get
Return component by category name
peri/states.py
def get(self, name): """ Return component by category name """ for c in self.comps: if c.category == name: return c return None
def get(self, name): """ Return component by category name """ for c in self.comps: if c.category == name: return c return None
[ "Return", "component", "by", "category", "name" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L722-L727
[ "def", "get", "(", "self", ",", "name", ")", ":", "for", "c", "in", "self", ".", "comps", ":", "if", "c", ".", "category", "==", "name", ":", "return", "c", "return", "None" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ImageState._calc_loglikelihood
Allows for fast local updates of log-likelihood
peri/states.py
def _calc_loglikelihood(self, model=None, tile=None): """Allows for fast local updates of log-likelihood""" if model is None: res = self.residuals else: res = model - self._data[tile.slicer] sig, isig = self.sigma, 1.0/self.sigma nlogs = -np.log(np.sqrt(2...
def _calc_loglikelihood(self, model=None, tile=None): """Allows for fast local updates of log-likelihood""" if model is None: res = self.residuals else: res = model - self._data[tile.slicer] sig, isig = self.sigma, 1.0/self.sigma nlogs = -np.log(np.sqrt(2...
[ "Allows", "for", "fast", "local", "updates", "of", "log", "-", "likelihood" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L745-L754
[ "def", "_calc_loglikelihood", "(", "self", ",", "model", "=", "None", ",", "tile", "=", "None", ")", ":", "if", "model", "is", "None", ":", "res", "=", "self", ".", "residuals", "else", ":", "res", "=", "model", "-", "self", ".", "_data", "[", "til...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ImageState.update_from_model_change
Update various internal variables from a model update from oldmodel to newmodel for the tile `tile`
peri/states.py
def update_from_model_change(self, oldmodel, newmodel, tile): """ Update various internal variables from a model update from oldmodel to newmodel for the tile `tile` """ self._loglikelihood -= self._calc_loglikelihood(oldmodel, tile=tile) self._loglikelihood += self._calc...
def update_from_model_change(self, oldmodel, newmodel, tile): """ Update various internal variables from a model update from oldmodel to newmodel for the tile `tile` """ self._loglikelihood -= self._calc_loglikelihood(oldmodel, tile=tile) self._loglikelihood += self._calc...
[ "Update", "various", "internal", "variables", "from", "a", "model", "update", "from", "oldmodel", "to", "newmodel", "for", "the", "tile", "tile" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L761-L768
[ "def", "update_from_model_change", "(", "self", ",", "oldmodel", ",", "newmodel", ",", "tile", ")", ":", "self", ".", "_loglikelihood", "-=", "self", ".", "_calc_loglikelihood", "(", "oldmodel", ",", "tile", "=", "tile", ")", "self", ".", "_loglikelihood", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ImageState.set_mem_level
Sets the memory usage level of the state. Parameters ---------- mem_level : string Can be set to one of: * hi : all mem's are np.float64 * med-hi : image, platonic are float32, rest are float64 * med : all mem's are float32 ...
peri/states.py
def set_mem_level(self, mem_level='hi'): """ Sets the memory usage level of the state. Parameters ---------- mem_level : string Can be set to one of: * hi : all mem's are np.float64 * med-hi : image, platonic are float32, rest ar...
def set_mem_level(self, mem_level='hi'): """ Sets the memory usage level of the state. Parameters ---------- mem_level : string Can be set to one of: * hi : all mem's are np.float64 * med-hi : image, platonic are float32, rest ar...
[ "Sets", "the", "memory", "usage", "level", "of", "the", "state", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/states.py#L797-L847
[ "def", "set_mem_level", "(", "self", ",", "mem_level", "=", "'hi'", ")", ":", "#A little thing to parse strings for convenience:", "key", "=", "''", ".", "join", "(", "[", "c", "if", "c", "in", "'mlh'", "else", "''", "for", "c", "in", "mem_level", "]", ")"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
scramble_positions
randomly deletes particles and adds 1-px noise for a realistic initial featuring guess
scripts/tutorial.py
def scramble_positions(p, delete_frac=0.1): """randomly deletes particles and adds 1-px noise for a realistic initial featuring guess""" probs = [1-delete_frac, delete_frac] m = np.random.choice([True, False], p.shape[0], p=probs) jumble = np.random.randn(m.sum(), 3) return p[m] + jumble
def scramble_positions(p, delete_frac=0.1): """randomly deletes particles and adds 1-px noise for a realistic initial featuring guess""" probs = [1-delete_frac, delete_frac] m = np.random.choice([True, False], p.shape[0], p=probs) jumble = np.random.randn(m.sum(), 3) return p[m] + jumble
[ "randomly", "deletes", "particles", "and", "adds", "1", "-", "px", "noise", "for", "a", "realistic", "initial", "featuring", "guess" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/scripts/tutorial.py#L82-L88
[ "def", "scramble_positions", "(", "p", ",", "delete_frac", "=", "0.1", ")", ":", "probs", "=", "[", "1", "-", "delete_frac", ",", "delete_frac", "]", "m", "=", "np", ".", "random", ".", "choice", "(", "[", "True", ",", "False", "]", ",", "p", ".", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
create_img
Creates an image, as a `peri.util.Image`, which is similar to the image in the tutorial
scripts/tutorial.py
def create_img(): """Creates an image, as a `peri.util.Image`, which is similar to the image in the tutorial""" # 1. particles + coverslip rad = 0.5 * np.random.randn(POS.shape[0]) + 4.5 # 4.5 +- 0.5 px particles part = objs.PlatonicSpheresCollection(POS, rad, zscale=0.89) slab = objs.Slab(zpos...
def create_img(): """Creates an image, as a `peri.util.Image`, which is similar to the image in the tutorial""" # 1. particles + coverslip rad = 0.5 * np.random.randn(POS.shape[0]) + 4.5 # 4.5 +- 0.5 px particles part = objs.PlatonicSpheresCollection(POS, rad, zscale=0.89) slab = objs.Slab(zpos...
[ "Creates", "an", "image", "as", "a", "peri", ".", "util", ".", "Image", "which", "is", "similar", "to", "the", "image", "in", "the", "tutorial" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/scripts/tutorial.py#L91-L112
[ "def", "create_img", "(", ")", ":", "# 1. particles + coverslip", "rad", "=", "0.5", "*", "np", ".", "random", ".", "randn", "(", "POS", ".", "shape", "[", "0", "]", ")", "+", "4.5", "# 4.5 +- 0.5 px particles", "part", "=", "objs", ".", "PlatonicSpheresCo...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ParameterGroup.get_values
Get the value of a list or single parameter. Parameters ---------- params : string, list of string name of parameters which to retrieve
peri/comp/comp.py
def get_values(self, params): """ Get the value of a list or single parameter. Parameters ---------- params : string, list of string name of parameters which to retrieve """ return util.delistify( [self.param_dict[p] for p in util.listify(...
def get_values(self, params): """ Get the value of a list or single parameter. Parameters ---------- params : string, list of string name of parameters which to retrieve """ return util.delistify( [self.param_dict[p] for p in util.listify(...
[ "Get", "the", "value", "of", "a", "list", "or", "single", "parameter", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/comp.py#L88-L99
[ "def", "get_values", "(", "self", ",", "params", ")", ":", "return", "util", ".", "delistify", "(", "[", "self", ".", "param_dict", "[", "p", "]", "for", "p", "in", "util", ".", "listify", "(", "params", ")", "]", ",", "params", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ParameterGroup.set_values
Directly set the values corresponding to certain parameters. This does not necessarily trigger and update of the calculation, See also -------- :func:`~peri.comp.comp.ParameterGroup.update` : full update func
peri/comp/comp.py
def set_values(self, params, values): """ Directly set the values corresponding to certain parameters. This does not necessarily trigger and update of the calculation, See also -------- :func:`~peri.comp.comp.ParameterGroup.update` : full update func """ ...
def set_values(self, params, values): """ Directly set the values corresponding to certain parameters. This does not necessarily trigger and update of the calculation, See also -------- :func:`~peri.comp.comp.ParameterGroup.update` : full update func """ ...
[ "Directly", "set", "the", "values", "corresponding", "to", "certain", "parameters", ".", "This", "does", "not", "necessarily", "trigger", "and", "update", "of", "the", "calculation", "See", "also", "--------", ":", "func", ":", "~peri", ".", "comp", ".", "co...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/comp.py#L101-L111
[ "def", "set_values", "(", "self", ",", "params", ",", "values", ")", ":", "for", "p", ",", "v", "in", "zip", "(", "util", ".", "listify", "(", "params", ")", ",", "util", ".", "listify", "(", "values", ")", ")", ":", "self", ".", "param_dict", "[...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Component.set_shape
Set the overall shape of the calculation area. The total shape of that the calculation can possibly occupy, in pixels. The second, inner, is the region of interest within the image.
peri/comp/comp.py
def set_shape(self, shape, inner): """ Set the overall shape of the calculation area. The total shape of that the calculation can possibly occupy, in pixels. The second, inner, is the region of interest within the image. """ if self.shape != shape or self.inner != inner: ...
def set_shape(self, shape, inner): """ Set the overall shape of the calculation area. The total shape of that the calculation can possibly occupy, in pixels. The second, inner, is the region of interest within the image. """ if self.shape != shape or self.inner != inner: ...
[ "Set", "the", "overall", "shape", "of", "the", "calculation", "area", ".", "The", "total", "shape", "of", "that", "the", "calculation", "can", "possibly", "occupy", "in", "pixels", ".", "The", "second", "inner", "is", "the", "region", "of", "interest", "wi...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/comp.py#L263-L272
[ "def", "set_shape", "(", "self", ",", "shape", ",", "inner", ")", ":", "if", "self", ".", "shape", "!=", "shape", "or", "self", ".", "inner", "!=", "inner", ":", "self", ".", "shape", "=", "shape", "self", ".", "inner", "=", "inner", "self", ".", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Component.trigger_update
Notify parent of a parameter change
peri/comp/comp.py
def trigger_update(self, params, values): """ Notify parent of a parameter change """ if self._parent: self._parent.trigger_update(params, values) else: self.update(params, values)
def trigger_update(self, params, values): """ Notify parent of a parameter change """ if self._parent: self._parent.trigger_update(params, values) else: self.update(params, values)
[ "Notify", "parent", "of", "a", "parameter", "change" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/comp.py#L303-L308
[ "def", "trigger_update", "(", "self", ",", "params", ",", "values", ")", ":", "if", "self", ".", "_parent", ":", "self", ".", "_parent", ".", "trigger_update", "(", "params", ",", "values", ")", "else", ":", "self", ".", "update", "(", "params", ",", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ComponentCollection.split_params
Split params, values into groups that correspond to the ordering in self.comps. For example, given a sphere collection and slab:: [ (spheres) [pos rad etc] [pos val, rad val, etc] (slab) [slab params] [slab vals] ]
peri/comp/comp.py
def split_params(self, params, values=None): """ Split params, values into groups that correspond to the ordering in self.comps. For example, given a sphere collection and slab:: [ (spheres) [pos rad etc] [pos val, rad val, etc] (slab) [slab params] [...
def split_params(self, params, values=None): """ Split params, values into groups that correspond to the ordering in self.comps. For example, given a sphere collection and slab:: [ (spheres) [pos rad etc] [pos val, rad val, etc] (slab) [slab params] [...
[ "Split", "params", "values", "into", "groups", "that", "correspond", "to", "the", "ordering", "in", "self", ".", "comps", ".", "For", "example", "given", "a", "sphere", "collection", "and", "slab", "::" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/comp.py#L413-L444
[ "def", "split_params", "(", "self", ",", "params", ",", "values", "=", "None", ")", ":", "pc", ",", "vc", "=", "[", "]", ",", "[", "]", "returnvalues", "=", "values", "is", "not", "None", "if", "values", "is", "None", ":", "values", "=", "[", "0"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ComponentCollection.get
Combine the fields from all components
peri/comp/comp.py
def get(self): """ Combine the fields from all components """ fields = [c.get() for c in self.comps] return self.field_reduce_func(fields)
def get(self): """ Combine the fields from all components """ fields = [c.get() for c in self.comps] return self.field_reduce_func(fields)
[ "Combine", "the", "fields", "from", "all", "components" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/comp.py#L522-L525
[ "def", "get", "(", "self", ")", ":", "fields", "=", "[", "c", ".", "get", "(", ")", "for", "c", "in", "self", ".", "comps", "]", "return", "self", ".", "field_reduce_func", "(", "fields", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ComponentCollection.set_shape
Set the shape for all components
peri/comp/comp.py
def set_shape(self, shape, inner): """ Set the shape for all components """ for c in self.comps: c.set_shape(shape, inner)
def set_shape(self, shape, inner): """ Set the shape for all components """ for c in self.comps: c.set_shape(shape, inner)
[ "Set", "the", "shape", "for", "all", "components" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/comp.py#L532-L535
[ "def", "set_shape", "(", "self", ",", "shape", ",", "inner", ")", ":", "for", "c", "in", "self", ".", "comps", ":", "c", ".", "set_shape", "(", "shape", ",", "inner", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ComponentCollection.sync_params
Ensure that shared parameters are the same value everywhere
peri/comp/comp.py
def sync_params(self): """ Ensure that shared parameters are the same value everywhere """ def _normalize(comps, param): vals = [c.get_values(param) for c in comps] diff = any([vals[i] != vals[i+1] for i in range(len(vals)-1)]) if diff: for c in comps...
def sync_params(self): """ Ensure that shared parameters are the same value everywhere """ def _normalize(comps, param): vals = [c.get_values(param) for c in comps] diff = any([vals[i] != vals[i+1] for i in range(len(vals)-1)]) if diff: for c in comps...
[ "Ensure", "that", "shared", "parameters", "are", "the", "same", "value", "everywhere" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/comp.py#L537-L549
[ "def", "sync_params", "(", "self", ")", ":", "def", "_normalize", "(", "comps", ",", "param", ")", ":", "vals", "=", "[", "c", ".", "get_values", "(", "param", ")", "for", "c", "in", "comps", "]", "diff", "=", "any", "(", "[", "vals", "[", "i", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ComponentCollection.setup_passthroughs
Inherit some functions from the components that we own. In particular, let's grab all functions that begin with `param_` so the super class knows how to get parameter groups. Also, take anything that is listed under Component.exports and rename with the category type, i.e., SphereCollect...
peri/comp/comp.py
def setup_passthroughs(self): """ Inherit some functions from the components that we own. In particular, let's grab all functions that begin with `param_` so the super class knows how to get parameter groups. Also, take anything that is listed under Component.exports and rename w...
def setup_passthroughs(self): """ Inherit some functions from the components that we own. In particular, let's grab all functions that begin with `param_` so the super class knows how to get parameter groups. Also, take anything that is listed under Component.exports and rename w...
[ "Inherit", "some", "functions", "from", "the", "components", "that", "we", "own", ".", "In", "particular", "let", "s", "grab", "all", "functions", "that", "begin", "with", "param_", "so", "the", "super", "class", "knows", "how", "to", "get", "parameter", "...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/comp.py#L558-L581
[ "def", "setup_passthroughs", "(", "self", ")", ":", "self", ".", "_nopickle", "=", "[", "]", "for", "c", "in", "self", ".", "comps", ":", "# take all member functions that start with 'param_'", "funcs", "=", "inspect", ".", "getmembers", "(", "c", ",", "predic...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
get_conf_filename
The configuration file either lives in ~/.peri.json or is specified on the command line via the environment variables PERI_CONF_FILE
peri/conf.py
def get_conf_filename(): """ The configuration file either lives in ~/.peri.json or is specified on the command line via the environment variables PERI_CONF_FILE """ default = os.path.join(os.path.expanduser("~"), ".peri.json") return os.environ.get('PERI_CONF_FILE', default)
def get_conf_filename(): """ The configuration file either lives in ~/.peri.json or is specified on the command line via the environment variables PERI_CONF_FILE """ default = os.path.join(os.path.expanduser("~"), ".peri.json") return os.environ.get('PERI_CONF_FILE', default)
[ "The", "configuration", "file", "either", "lives", "in", "~", "/", ".", "peri", ".", "json", "or", "is", "specified", "on", "the", "command", "line", "via", "the", "environment", "variables", "PERI_CONF_FILE" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/conf.py#L37-L43
[ "def", "get_conf_filename", "(", ")", ":", "default", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", ",", "\".peri.json\"", ")", "return", "os", ".", "environ", ".", "get", "(", "'PERI_CONF_FILE'", ",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
read_environment
Read all environment variables to see if they contain PERI
peri/conf.py
def read_environment(): """ Read all environment variables to see if they contain PERI """ out = {} for k,v in iteritems(os.environ): if transform(k) in default_conf: out[transform(k)] = v return out
def read_environment(): """ Read all environment variables to see if they contain PERI """ out = {} for k,v in iteritems(os.environ): if transform(k) in default_conf: out[transform(k)] = v return out
[ "Read", "all", "environment", "variables", "to", "see", "if", "they", "contain", "PERI" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/conf.py#L55-L61
[ "def", "read_environment", "(", ")", ":", "out", "=", "{", "}", "for", "k", ",", "v", "in", "iteritems", "(", "os", ".", "environ", ")", ":", "if", "transform", "(", "k", ")", "in", "default_conf", ":", "out", "[", "transform", "(", "k", ")", "]"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
load_conf
Load the configuration with the priority: 1. environment variables 2. configuration file 3. defaults here (default_conf)
peri/conf.py
def load_conf(): """ Load the configuration with the priority: 1. environment variables 2. configuration file 3. defaults here (default_conf) """ try: conf = copy.copy(default_conf) conf.update(json.load(open(get_conf_filename()))) conf.update(read_environ...
def load_conf(): """ Load the configuration with the priority: 1. environment variables 2. configuration file 3. defaults here (default_conf) """ try: conf = copy.copy(default_conf) conf.update(json.load(open(get_conf_filename()))) conf.update(read_environ...
[ "Load", "the", "configuration", "with", "the", "priority", ":", "1", ".", "environment", "variables", "2", ".", "configuration", "file", "3", ".", "defaults", "here", "(", "default_conf", ")" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/conf.py#L68-L82
[ "def", "load_conf", "(", ")", ":", "try", ":", "conf", "=", "copy", ".", "copy", "(", "default_conf", ")", "conf", ".", "update", "(", "json", ".", "load", "(", "open", "(", "get_conf_filename", "(", ")", ")", ")", ")", "conf", ".", "update", "(", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
get_group_name
Used for breadcrumb dynamic_list_constructor.
invenio_groups/views.py
def get_group_name(id_group): """Used for breadcrumb dynamic_list_constructor.""" group = Group.query.get(id_group) if group is not None: return group.name
def get_group_name(id_group): """Used for breadcrumb dynamic_list_constructor.""" group = Group.query.get(id_group) if group is not None: return group.name
[ "Used", "for", "breadcrumb", "dynamic_list_constructor", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L52-L56
[ "def", "get_group_name", "(", "id_group", ")", ":", "group", "=", "Group", ".", "query", ".", "get", "(", "id_group", ")", "if", "group", "is", "not", "None", ":", "return", "group", ".", "name" ]
109481d6b02701db00b72223dd4a65e167c589a6
valid
index
List all user memberships.
invenio_groups/views.py
def index(): """List all user memberships.""" page = request.args.get('page', 1, type=int) per_page = request.args.get('per_page', 5, type=int) q = request.args.get('q', '') groups = Group.query_by_user(current_user, eager=True) if q: groups = Group.search(groups, q) groups = groups...
def index(): """List all user memberships.""" page = request.args.get('page', 1, type=int) per_page = request.args.get('per_page', 5, type=int) q = request.args.get('q', '') groups = Group.query_by_user(current_user, eager=True) if q: groups = Group.search(groups, q) groups = groups...
[ "List", "all", "user", "memberships", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L69-L91
[ "def", "index", "(", ")", ":", "page", "=", "request", ".", "args", ".", "get", "(", "'page'", ",", "1", ",", "type", "=", "int", ")", "per_page", "=", "request", ".", "args", ".", "get", "(", "'per_page'", ",", "5", ",", "type", "=", "int", ")...
109481d6b02701db00b72223dd4a65e167c589a6
valid
requests
List all pending memberships, listed only for group admins.
invenio_groups/views.py
def requests(): """List all pending memberships, listed only for group admins.""" page = request.args.get('page', 1, type=int) per_page = request.args.get('per_page', 5, type=int) memberships = Membership.query_requests(current_user, eager=True).all() return render_template( 'invenio_groups...
def requests(): """List all pending memberships, listed only for group admins.""" page = request.args.get('page', 1, type=int) per_page = request.args.get('per_page', 5, type=int) memberships = Membership.query_requests(current_user, eager=True).all() return render_template( 'invenio_groups...
[ "List", "all", "pending", "memberships", "listed", "only", "for", "group", "admins", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L97-L109
[ "def", "requests", "(", ")", ":", "page", "=", "request", ".", "args", ".", "get", "(", "'page'", ",", "1", ",", "type", "=", "int", ")", "per_page", "=", "request", ".", "args", ".", "get", "(", "'per_page'", ",", "5", ",", "type", "=", "int", ...
109481d6b02701db00b72223dd4a65e167c589a6
valid
invitations
List all user pending memberships.
invenio_groups/views.py
def invitations(): """List all user pending memberships.""" page = request.args.get('page', 1, type=int) per_page = request.args.get('per_page', 5, type=int) memberships = Membership.query_invitations(current_user, eager=True).all() return render_template( 'invenio_groups/pending.html', ...
def invitations(): """List all user pending memberships.""" page = request.args.get('page', 1, type=int) per_page = request.args.get('per_page', 5, type=int) memberships = Membership.query_invitations(current_user, eager=True).all() return render_template( 'invenio_groups/pending.html', ...
[ "List", "all", "user", "pending", "memberships", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L115-L126
[ "def", "invitations", "(", ")", ":", "page", "=", "request", ".", "args", ".", "get", "(", "'page'", ",", "1", ",", "type", "=", "int", ")", "per_page", "=", "request", ".", "args", ".", "get", "(", "'per_page'", ",", "5", ",", "type", "=", "int"...
109481d6b02701db00b72223dd4a65e167c589a6
valid
new
Create new group.
invenio_groups/views.py
def new(): """Create new group.""" form = GroupForm(request.form) if form.validate_on_submit(): try: group = Group.create(admins=[current_user], **form.data) flash(_('Group "%(name)s" created', name=group.name), 'success') return redirect(url_for(".index")) ...
def new(): """Create new group.""" form = GroupForm(request.form) if form.validate_on_submit(): try: group = Group.create(admins=[current_user], **form.data) flash(_('Group "%(name)s" created', name=group.name), 'success') return redirect(url_for(".index")) ...
[ "Create", "new", "group", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L132-L148
[ "def", "new", "(", ")", ":", "form", "=", "GroupForm", "(", "request", ".", "form", ")", "if", "form", ".", "validate_on_submit", "(", ")", ":", "try", ":", "group", "=", "Group", ".", "create", "(", "admins", "=", "[", "current_user", "]", ",", "*...
109481d6b02701db00b72223dd4a65e167c589a6
valid
manage
Manage your group.
invenio_groups/views.py
def manage(group_id): """Manage your group.""" group = Group.query.get_or_404(group_id) form = GroupForm(request.form, obj=group) if form.validate_on_submit(): if group.can_edit(current_user): try: group.update(**form.data) flash(_('Group "%(name)s" w...
def manage(group_id): """Manage your group.""" group = Group.query.get_or_404(group_id) form = GroupForm(request.form, obj=group) if form.validate_on_submit(): if group.can_edit(current_user): try: group.update(**form.data) flash(_('Group "%(name)s" w...
[ "Manage", "your", "group", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L160-L191
[ "def", "manage", "(", "group_id", ")", ":", "group", "=", "Group", ".", "query", ".", "get_or_404", "(", "group_id", ")", "form", "=", "GroupForm", "(", "request", ".", "form", ",", "obj", "=", "group", ")", "if", "form", ".", "validate_on_submit", "("...
109481d6b02701db00b72223dd4a65e167c589a6
valid
delete
Delete group.
invenio_groups/views.py
def delete(group_id): """Delete group.""" group = Group.query.get_or_404(group_id) if group.can_edit(current_user): try: group.delete() except Exception as e: flash(str(e), "error") return redirect(url_for(".index")) flash(_('Successfully removed...
def delete(group_id): """Delete group.""" group = Group.query.get_or_404(group_id) if group.can_edit(current_user): try: group.delete() except Exception as e: flash(str(e), "error") return redirect(url_for(".index")) flash(_('Successfully removed...
[ "Delete", "group", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L196-L218
[ "def", "delete", "(", "group_id", ")", ":", "group", "=", "Group", ".", "query", ".", "get_or_404", "(", "group_id", ")", "if", "group", ".", "can_edit", "(", "current_user", ")", ":", "try", ":", "group", ".", "delete", "(", ")", "except", "Exception"...
109481d6b02701db00b72223dd4a65e167c589a6