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
Updates.reorder
Edit the order at which statuses for the specified social media profile will be sent out of the buffer.
buffpy/managers/updates.py
def reorder(self, updates_ids, offset=None, utc=None): ''' Edit the order at which statuses for the specified social media profile will be sent out of the buffer. ''' url = PATHS['REORDER'] % self.profile_id order_format = "order[]=%s&" post_data = '' if offset: post_data +=...
def reorder(self, updates_ids, offset=None, utc=None): ''' Edit the order at which statuses for the specified social media profile will be sent out of the buffer. ''' url = PATHS['REORDER'] % self.profile_id order_format = "order[]=%s&" post_data = '' if offset: post_data +=...
[ "Edit", "the", "order", "at", "which", "statuses", "for", "the", "specified", "social", "media", "profile", "will", "be", "sent", "out", "of", "the", "buffer", "." ]
vtemian/buffpy
python
https://github.com/vtemian/buffpy/blob/6c9236fd3b6a8f9e2d70dbf1bc01529242b73075/buffpy/managers/updates.py#L79-L99
[ "def", "reorder", "(", "self", ",", "updates_ids", ",", "offset", "=", "None", ",", "utc", "=", "None", ")", ":", "url", "=", "PATHS", "[", "'REORDER'", "]", "%", "self", ".", "profile_id", "order_format", "=", "\"order[]=%s&\"", "post_data", "=", "''", ...
6c9236fd3b6a8f9e2d70dbf1bc01529242b73075
valid
Updates.new
Create one or more new status updates.
buffpy/managers/updates.py
def new(self, text, shorten=None, now=None, top=None, media=None, when=None): ''' Create one or more new status updates. ''' url = PATHS['CREATE'] post_data = "text=%s&" % text post_data += "profile_ids[]=%s&" % self.profile_id if shorten: post_data += "shorten=%s&" % shorten ...
def new(self, text, shorten=None, now=None, top=None, media=None, when=None): ''' Create one or more new status updates. ''' url = PATHS['CREATE'] post_data = "text=%s&" % text post_data += "profile_ids[]=%s&" % self.profile_id if shorten: post_data += "shorten=%s&" % shorten ...
[ "Create", "one", "or", "more", "new", "status", "updates", "." ]
vtemian/buffpy
python
https://github.com/vtemian/buffpy/blob/6c9236fd3b6a8f9e2d70dbf1bc01529242b73075/buffpy/managers/updates.py#L102-L135
[ "def", "new", "(", "self", ",", "text", ",", "shorten", "=", "None", ",", "now", "=", "None", ",", "top", "=", "None", ",", "media", "=", "None", ",", "when", "=", "None", ")", ":", "url", "=", "PATHS", "[", "'CREATE'", "]", "post_data", "=", "...
6c9236fd3b6a8f9e2d70dbf1bc01529242b73075
valid
Logger.set_level
Set the logging level (which types of logs are actually printed / recorded) to one of ['debug', 'info', 'warn', 'error', 'fatal'] in that order of severity
peri/logger.py
def set_level(self, level='info', handlers=None): """ Set the logging level (which types of logs are actually printed / recorded) to one of ['debug', 'info', 'warn', 'error', 'fatal'] in that order of severity """ for h in self.get_handlers(handlers): h.setLev...
def set_level(self, level='info', handlers=None): """ Set the logging level (which types of logs are actually printed / recorded) to one of ['debug', 'info', 'warn', 'error', 'fatal'] in that order of severity """ for h in self.get_handlers(handlers): h.setLev...
[ "Set", "the", "logging", "level", "(", "which", "types", "of", "logs", "are", "actually", "printed", "/", "recorded", ")", "to", "one", "of", "[", "debug", "info", "warn", "error", "fatal", "]", "in", "that", "order", "of", "severity" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/logger.py#L73-L80
[ "def", "set_level", "(", "self", ",", "level", "=", "'info'", ",", "handlers", "=", "None", ")", ":", "for", "h", "in", "self", ".", "get_handlers", "(", "handlers", ")", ":", "h", ".", "setLevel", "(", "levels", "[", "level", "]", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Logger.set_formatter
Set the text format of messages to one of the pre-determined forms, one of ['quiet', 'minimal', 'standard', 'verbose']
peri/logger.py
def set_formatter(self, formatter='standard', handlers=None): """ Set the text format of messages to one of the pre-determined forms, one of ['quiet', 'minimal', 'standard', 'verbose'] """ for h in self.get_handlers(handlers): h.setFormatter(logging.Formatter(formatte...
def set_formatter(self, formatter='standard', handlers=None): """ Set the text format of messages to one of the pre-determined forms, one of ['quiet', 'minimal', 'standard', 'verbose'] """ for h in self.get_handlers(handlers): h.setFormatter(logging.Formatter(formatte...
[ "Set", "the", "text", "format", "of", "messages", "to", "one", "of", "the", "pre", "-", "determined", "forms", "one", "of", "[", "quiet", "minimal", "standard", "verbose", "]" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/logger.py#L82-L88
[ "def", "set_formatter", "(", "self", ",", "formatter", "=", "'standard'", ",", "handlers", "=", "None", ")", ":", "for", "h", "in", "self", ".", "get_handlers", "(", "handlers", ")", ":", "h", ".", "setFormatter", "(", "logging", ".", "Formatter", "(", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Logger.add_handler
Add another handler to the logging system if not present already. Available handlers are currently: ['console-bw', 'console-color', 'rotating-log']
peri/logger.py
def add_handler(self, name='console-color', level='info', formatter='standard', **kwargs): """ Add another handler to the logging system if not present already. Available handlers are currently: ['console-bw', 'console-color', 'rotating-log'] """ # make sure the the log file has ...
def add_handler(self, name='console-color', level='info', formatter='standard', **kwargs): """ Add another handler to the logging system if not present already. Available handlers are currently: ['console-bw', 'console-color', 'rotating-log'] """ # make sure the the log file has ...
[ "Add", "another", "handler", "to", "the", "logging", "system", "if", "not", "present", "already", ".", "Available", "handlers", "are", "currently", ":", "[", "console", "-", "bw", "console", "-", "color", "rotating", "-", "log", "]" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/logger.py#L90-L104
[ "def", "add_handler", "(", "self", ",", "name", "=", "'console-color'", ",", "level", "=", "'info'", ",", "formatter", "=", "'standard'", ",", "*", "*", "kwargs", ")", ":", "# make sure the the log file has a name", "if", "name", "==", "'rotating-log'", "and", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Logger.remove_handler
Remove handler from the logging system if present already. Available handlers are currently: ['console-bw', 'console-color', 'rotating-log']
peri/logger.py
def remove_handler(self, name): """ Remove handler from the logging system if present already. Available handlers are currently: ['console-bw', 'console-color', 'rotating-log'] """ if name in self.handlers: self.log.removeHandler(self.handlers[name])
def remove_handler(self, name): """ Remove handler from the logging system if present already. Available handlers are currently: ['console-bw', 'console-color', 'rotating-log'] """ if name in self.handlers: self.log.removeHandler(self.handlers[name])
[ "Remove", "handler", "from", "the", "logging", "system", "if", "present", "already", ".", "Available", "handlers", "are", "currently", ":", "[", "console", "-", "bw", "console", "-", "color", "rotating", "-", "log", "]" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/logger.py#L115-L121
[ "def", "remove_handler", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "handlers", ":", "self", ".", "log", ".", "removeHandler", "(", "self", ".", "handlers", "[", "name", "]", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Logger.noformat
Temporarily do not use any formatter so that text printed is raw
peri/logger.py
def noformat(self): """ Temporarily do not use any formatter so that text printed is raw """ try: formats = {} for h in self.get_handlers(): formats[h] = h.formatter self.set_formatter(formatter='quiet') yield except Exception as e:...
def noformat(self): """ Temporarily do not use any formatter so that text printed is raw """ try: formats = {} for h in self.get_handlers(): formats[h] = h.formatter self.set_formatter(formatter='quiet') yield except Exception as e:...
[ "Temporarily", "do", "not", "use", "any", "formatter", "so", "that", "text", "printed", "is", "raw" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/logger.py#L124-L136
[ "def", "noformat", "(", "self", ")", ":", "try", ":", "formats", "=", "{", "}", "for", "h", "in", "self", ".", "get_handlers", "(", ")", ":", "formats", "[", "h", "]", "=", "h", ".", "formatter", "self", ".", "set_formatter", "(", "formatter", "=",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Logger.set_verbosity
Set the verbosity level of a certain log handler or of all handlers. Parameters ---------- verbosity : 'v' to 'vvvvv' the level of verbosity, more v's is more verbose handlers : string, or list of strings handler names can be found in ``peri.logger.types.keys()`...
peri/logger.py
def set_verbosity(self, verbosity='vvv', handlers=None): """ Set the verbosity level of a certain log handler or of all handlers. Parameters ---------- verbosity : 'v' to 'vvvvv' the level of verbosity, more v's is more verbose handlers : string, or list of ...
def set_verbosity(self, verbosity='vvv', handlers=None): """ Set the verbosity level of a certain log handler or of all handlers. Parameters ---------- verbosity : 'v' to 'vvvvv' the level of verbosity, more v's is more verbose handlers : string, or list of ...
[ "Set", "the", "verbosity", "level", "of", "a", "certain", "log", "handler", "or", "of", "all", "handlers", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/logger.py#L138-L155
[ "def", "set_verbosity", "(", "self", ",", "verbosity", "=", "'vvv'", ",", "handlers", "=", "None", ")", ":", "self", ".", "verbosity", "=", "sanitize", "(", "verbosity", ")", "self", ".", "set_level", "(", "v2l", "[", "verbosity", "]", ",", "handlers", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
normalize
Normalize a field to a (min, max) exposure range, default is (0, 255). (min, max) exposure values. Invert the image if requested.
peri/initializers.py
def normalize(im, invert=False, scale=None, dtype=np.float64): """ Normalize a field to a (min, max) exposure range, default is (0, 255). (min, max) exposure values. Invert the image if requested. """ if dtype not in {np.float16, np.float32, np.float64}: raise ValueError('dtype must be numpy...
def normalize(im, invert=False, scale=None, dtype=np.float64): """ Normalize a field to a (min, max) exposure range, default is (0, 255). (min, max) exposure values. Invert the image if requested. """ if dtype not in {np.float16, np.float32, np.float64}: raise ValueError('dtype must be numpy...
[ "Normalize", "a", "field", "to", "a", "(", "min", "max", ")", "exposure", "range", "default", "is", "(", "0", "255", ")", ".", "(", "min", "max", ")", "exposure", "values", ".", "Invert", "the", "image", "if", "requested", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/initializers.py#L65-L79
[ "def", "normalize", "(", "im", ",", "invert", "=", "False", ",", "scale", "=", "None", ",", "dtype", "=", "np", ".", "float64", ")", ":", "if", "dtype", "not", "in", "{", "np", ".", "float16", ",", "np", ".", "float32", ",", "np", ".", "float64",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
generate_sphere
Generates a centered boolean mask of a 3D sphere
peri/initializers.py
def generate_sphere(radius): """Generates a centered boolean mask of a 3D sphere""" rint = np.ceil(radius).astype('int') t = np.arange(-rint, rint+1, 1) x,y,z = np.meshgrid(t, t, t, indexing='ij') r = np.sqrt(x*x + y*y + z*z) sphere = r < radius return sphere
def generate_sphere(radius): """Generates a centered boolean mask of a 3D sphere""" rint = np.ceil(radius).astype('int') t = np.arange(-rint, rint+1, 1) x,y,z = np.meshgrid(t, t, t, indexing='ij') r = np.sqrt(x*x + y*y + z*z) sphere = r < radius return sphere
[ "Generates", "a", "centered", "boolean", "mask", "of", "a", "3D", "sphere" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/initializers.py#L81-L88
[ "def", "generate_sphere", "(", "radius", ")", ":", "rint", "=", "np", ".", "ceil", "(", "radius", ")", ".", "astype", "(", "'int'", ")", "t", "=", "np", ".", "arange", "(", "-", "rint", ",", "rint", "+", "1", ",", "1", ")", "x", ",", "y", ","...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
local_max_featuring
Local max featuring to identify bright spherical particles on a dark background. Parameters ---------- im : numpy.ndarray The image to identify particles in. radius : Float > 0, optional Featuring radius of the particles. Default is 2.5 noise_size : Float, op...
peri/initializers.py
def local_max_featuring(im, radius=2.5, noise_size=1., bkg_size=None, minmass=1., trim_edge=False): """Local max featuring to identify bright spherical particles on a dark background. Parameters ---------- im : numpy.ndarray The image to identify particles in. radius...
def local_max_featuring(im, radius=2.5, noise_size=1., bkg_size=None, minmass=1., trim_edge=False): """Local max featuring to identify bright spherical particles on a dark background. Parameters ---------- im : numpy.ndarray The image to identify particles in. radius...
[ "Local", "max", "featuring", "to", "identify", "bright", "spherical", "particles", "on", "a", "dark", "background", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/initializers.py#L90-L137
[ "def", "local_max_featuring", "(", "im", ",", "radius", "=", "2.5", ",", "noise_size", "=", "1.", ",", "bkg_size", "=", "None", ",", "minmass", "=", "1.", ",", "trim_edge", "=", "False", ")", ":", "if", "radius", "<=", "0", ":", "raise", "ValueError", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
otsu_threshold
Otsu threshold on data. Otsu thresholding [1]_is a method for selecting an intensity value for thresholding an image into foreground and background. The sel- ected intensity threshold maximizes the inter-class variance. Parameters ---------- data : numpy.ndarray The data to thr...
peri/initializers.py
def otsu_threshold(data, bins=255): """ Otsu threshold on data. Otsu thresholding [1]_is a method for selecting an intensity value for thresholding an image into foreground and background. The sel- ected intensity threshold maximizes the inter-class variance. Parameters ---------- ...
def otsu_threshold(data, bins=255): """ Otsu threshold on data. Otsu thresholding [1]_is a method for selecting an intensity value for thresholding an image into foreground and background. The sel- ected intensity threshold maximizes the inter-class variance. Parameters ---------- ...
[ "Otsu", "threshold", "on", "data", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/initializers.py#L181-L219
[ "def", "otsu_threshold", "(", "data", ",", "bins", "=", "255", ")", ":", "h0", ",", "x0", "=", "np", ".", "histogram", "(", "data", ".", "ravel", "(", ")", ",", "bins", "=", "bins", ")", "h", "=", "h0", ".", "astype", "(", "'float'", ")", "/", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
harris_feature
Harris-motivated feature detection on a d-dimensional image. Parameters --------- im region_size to_return : {'harris','matrix','trace-determinant'}
peri/initializers.py
def harris_feature(im, region_size=5, to_return='harris', scale=0.05): """ Harris-motivated feature detection on a d-dimensional image. Parameters --------- im region_size to_return : {'harris','matrix','trace-determinant'} """ ndim = im.ndim #1. Gradient of image ...
def harris_feature(im, region_size=5, to_return='harris', scale=0.05): """ Harris-motivated feature detection on a d-dimensional image. Parameters --------- im region_size to_return : {'harris','matrix','trace-determinant'} """ ndim = im.ndim #1. Gradient of image ...
[ "Harris", "-", "motivated", "feature", "detection", "on", "a", "d", "-", "dimensional", "image", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/initializers.py#L221-L251
[ "def", "harris_feature", "(", "im", ",", "region_size", "=", "5", ",", "to_return", "=", "'harris'", ",", "scale", "=", "0.05", ")", ":", "ndim", "=", "im", ".", "ndim", "#1. Gradient of image", "grads", "=", "[", "nd", ".", "sobel", "(", "im", ",", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
identify_slab
Identifies slabs in an image. Functions by running a Harris-inspired edge detection on the image, thresholding the edge, then clustering. Parameters ---------- im : numpy.ndarray 3D array of the image to analyze. sigma : Float, optional Gaussian blurring kernel ...
peri/initializers.py
def identify_slab(im, sigma=5., region_size=10, masscut=1e4, asdict=False): """ Identifies slabs in an image. Functions by running a Harris-inspired edge detection on the image, thresholding the edge, then clustering. Parameters ---------- im : numpy.ndarray 3D array of the...
def identify_slab(im, sigma=5., region_size=10, masscut=1e4, asdict=False): """ Identifies slabs in an image. Functions by running a Harris-inspired edge detection on the image, thresholding the edge, then clustering. Parameters ---------- im : numpy.ndarray 3D array of the...
[ "Identifies", "slabs", "in", "an", "image", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/initializers.py#L253-L329
[ "def", "identify_slab", "(", "im", ",", "sigma", "=", "5.", ",", "region_size", "=", "10", ",", "masscut", "=", "1e4", ",", "asdict", "=", "False", ")", ":", "#1. edge detect:", "fim", "=", "nd", ".", "filters", ".", "gaussian_filter", "(", "im", ",", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
plot_errors_single
ax = fig.add_axes([0.6, 0.6, 0.28, 0.28]) ax.plot(rad, crb[:,0,:], lw=2.5) for c, error in enumerate(errors): mu = np.sqrt((error**2).mean(axis=1))[:,0,:] std = np.std(np.sqrt((error**2)), axis=1)[:,0,:] for i in range(len(mu[0])): ax.errorbar(rad, mu[:,i], yerr=std[:,i], fm...
scripts/quick_bench.py
def plot_errors_single(rad, crb, errors, labels=['trackpy', 'peri']): fig = pl.figure() comps = ['z', 'y', 'x'] markers = ['o', '^', '*'] colors = COLORS for i in reversed(range(3)): pl.plot(rad, crb[:,0,i], lw=2.5, label='CRB-'+comps[i], color=colors[i]) for c, (error, label) in enume...
def plot_errors_single(rad, crb, errors, labels=['trackpy', 'peri']): fig = pl.figure() comps = ['z', 'y', 'x'] markers = ['o', '^', '*'] colors = COLORS for i in reversed(range(3)): pl.plot(rad, crb[:,0,i], lw=2.5, label='CRB-'+comps[i], color=colors[i]) for c, (error, label) in enume...
[ "ax", "=", "fig", ".", "add_axes", "(", "[", "0", ".", "6", "0", ".", "6", "0", ".", "28", "0", ".", "28", "]", ")", "ax", ".", "plot", "(", "rad", "crb", "[", ":", "0", ":", "]", "lw", "=", "2", ".", "5", ")", "for", "c", "error", "i...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/scripts/quick_bench.py#L99-L131
[ "def", "plot_errors_single", "(", "rad", ",", "crb", ",", "errors", ",", "labels", "=", "[", "'trackpy'", ",", "'peri'", "]", ")", ":", "fig", "=", "pl", ".", "figure", "(", ")", "comps", "=", "[", "'z'", ",", "'y'", ",", "'x'", "]", "markers", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
sphere_triangle_cdf
Cumulative distribution function for the traingle distribution
peri/comp/objs.py
def sphere_triangle_cdf(dr, a, alpha): """ Cumulative distribution function for the traingle distribution """ p0 = (dr+alpha)**2/(2*alpha**2)*(0 > dr)*(dr>-alpha) p1 = 1*(dr>0)-(alpha-dr)**2/(2*alpha**2)*(0<dr)*(dr<alpha) return (1-np.clip(p0+p1, 0, 1))
def sphere_triangle_cdf(dr, a, alpha): """ Cumulative distribution function for the traingle distribution """ p0 = (dr+alpha)**2/(2*alpha**2)*(0 > dr)*(dr>-alpha) p1 = 1*(dr>0)-(alpha-dr)**2/(2*alpha**2)*(0<dr)*(dr<alpha) return (1-np.clip(p0+p1, 0, 1))
[ "Cumulative", "distribution", "function", "for", "the", "traingle", "distribution" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L315-L319
[ "def", "sphere_triangle_cdf", "(", "dr", ",", "a", ",", "alpha", ")", ":", "p0", "=", "(", "dr", "+", "alpha", ")", "**", "2", "/", "(", "2", "*", "alpha", "**", "2", ")", "*", "(", "0", ">", "dr", ")", "*", "(", "dr", ">", "-", "alpha", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
sphere_analytical_gaussian
Analytically calculate the sphere's functional form by convolving the Heavyside function with first order approximation to the sinc, a Gaussian. The alpha parameters controls the width of the approximation -- should be 1, but is fit to be roughly 0.2765
peri/comp/objs.py
def sphere_analytical_gaussian(dr, a, alpha=0.2765): """ Analytically calculate the sphere's functional form by convolving the Heavyside function with first order approximation to the sinc, a Gaussian. The alpha parameters controls the width of the approximation -- should be 1, but is fit to be roug...
def sphere_analytical_gaussian(dr, a, alpha=0.2765): """ Analytically calculate the sphere's functional form by convolving the Heavyside function with first order approximation to the sinc, a Gaussian. The alpha parameters controls the width of the approximation -- should be 1, but is fit to be roug...
[ "Analytically", "calculate", "the", "sphere", "s", "functional", "form", "by", "convolving", "the", "Heavyside", "function", "with", "first", "order", "approximation", "to", "the", "sinc", "a", "Gaussian", ".", "The", "alpha", "parameters", "controls", "the", "w...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L322-L333
[ "def", "sphere_analytical_gaussian", "(", "dr", ",", "a", ",", "alpha", "=", "0.2765", ")", ":", "term1", "=", "0.5", "*", "(", "erf", "(", "(", "dr", "+", "2", "*", "a", ")", "/", "(", "alpha", "*", "np", ".", "sqrt", "(", "2", ")", ")", ")"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
sphere_analytical_gaussian_trim
See sphere_analytical_gaussian_exact. I trimmed to terms from the functional form that are essentially zero (1e-8) for r0 > cut (~1.5), a fine approximation for these platonic anyway.
peri/comp/objs.py
def sphere_analytical_gaussian_trim(dr, a, alpha=0.2765, cut=1.6): """ See sphere_analytical_gaussian_exact. I trimmed to terms from the functional form that are essentially zero (1e-8) for r0 > cut (~1.5), a fine approximation for these platonic anyway. """ m = np.abs(dr) <= cut # only co...
def sphere_analytical_gaussian_trim(dr, a, alpha=0.2765, cut=1.6): """ See sphere_analytical_gaussian_exact. I trimmed to terms from the functional form that are essentially zero (1e-8) for r0 > cut (~1.5), a fine approximation for these platonic anyway. """ m = np.abs(dr) <= cut # only co...
[ "See", "sphere_analytical_gaussian_exact", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L335-L354
[ "def", "sphere_analytical_gaussian_trim", "(", "dr", ",", "a", ",", "alpha", "=", "0.2765", ",", "cut", "=", "1.6", ")", ":", "m", "=", "np", ".", "abs", "(", "dr", ")", "<=", "cut", "# only compute on the relevant scales", "rr", "=", "dr", "[", "m", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
sphere_analytical_gaussian_fast
See sphere_analytical_gaussian_trim, but implemented in C with fast erf and exp approximations found at Abramowitz and Stegun: Handbook of Mathematical Functions A Fast, Compact Approximation of the Exponential Function The default cut 1.25 was chosen based on the accuracy of fast_erf
peri/comp/objs.py
def sphere_analytical_gaussian_fast(dr, a, alpha=0.2765, cut=1.20): """ See sphere_analytical_gaussian_trim, but implemented in C with fast erf and exp approximations found at Abramowitz and Stegun: Handbook of Mathematical Functions A Fast, Compact Approximation of the Exponential Function ...
def sphere_analytical_gaussian_fast(dr, a, alpha=0.2765, cut=1.20): """ See sphere_analytical_gaussian_trim, but implemented in C with fast erf and exp approximations found at Abramowitz and Stegun: Handbook of Mathematical Functions A Fast, Compact Approximation of the Exponential Function ...
[ "See", "sphere_analytical_gaussian_trim", "but", "implemented", "in", "C", "with", "fast", "erf", "and", "exp", "approximations", "found", "at", "Abramowitz", "and", "Stegun", ":", "Handbook", "of", "Mathematical", "Functions", "A", "Fast", "Compact", "Approximation...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L356-L389
[ "def", "sphere_analytical_gaussian_fast", "(", "dr", ",", "a", ",", "alpha", "=", "0.2765", ",", "cut", "=", "1.20", ")", ":", "code", "=", "\"\"\"\n double coeff1 = 1.0/(alpha*sqrt(2.0));\n double coeff2 = sqrt(0.5/pi)*alpha;\n\n for (int i=0; i<N; i++){\n double...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
sphere_constrained_cubic
Sphere generated by a cubic interpolant constrained to be (1,0) on (r0-sqrt(3)/2, r0+sqrt(3)/2), the size of the cube in the (111) direction.
peri/comp/objs.py
def sphere_constrained_cubic(dr, a, alpha): """ Sphere generated by a cubic interpolant constrained to be (1,0) on (r0-sqrt(3)/2, r0+sqrt(3)/2), the size of the cube in the (111) direction. """ sqrt3 = np.sqrt(3) b_coeff = a*0.5/sqrt3*(1 - 0.6*sqrt3*alpha)/(0.15 + a*a) rscl = np.clip(dr, -0...
def sphere_constrained_cubic(dr, a, alpha): """ Sphere generated by a cubic interpolant constrained to be (1,0) on (r0-sqrt(3)/2, r0+sqrt(3)/2), the size of the cube in the (111) direction. """ sqrt3 = np.sqrt(3) b_coeff = a*0.5/sqrt3*(1 - 0.6*sqrt3*alpha)/(0.15 + a*a) rscl = np.clip(dr, -0...
[ "Sphere", "generated", "by", "a", "cubic", "interpolant", "constrained", "to", "be", "(", "1", "0", ")", "on", "(", "r0", "-", "sqrt", "(", "3", ")", "/", "2", "r0", "+", "sqrt", "(", "3", ")", "/", "2", ")", "the", "size", "of", "the", "cube",...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L391-L402
[ "def", "sphere_constrained_cubic", "(", "dr", ",", "a", ",", "alpha", ")", ":", "sqrt3", "=", "np", ".", "sqrt", "(", "3", ")", "b_coeff", "=", "a", "*", "0.5", "/", "sqrt3", "*", "(", "1", "-", "0.6", "*", "sqrt3", "*", "alpha", ")", "/", "(",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
exact_volume_sphere
Perform an iterative method to calculate the effective sphere that perfectly (up to the volume_error) conserves volume. Return the resulting image
peri/comp/objs.py
def exact_volume_sphere(rvec, pos, radius, zscale=1.0, volume_error=1e-5, function=sphere_analytical_gaussian, max_radius_change=1e-2, args=()): """ Perform an iterative method to calculate the effective sphere that perfectly (up to the volume_error) conserves volume. Return the resulting image ...
def exact_volume_sphere(rvec, pos, radius, zscale=1.0, volume_error=1e-5, function=sphere_analytical_gaussian, max_radius_change=1e-2, args=()): """ Perform an iterative method to calculate the effective sphere that perfectly (up to the volume_error) conserves volume. Return the resulting image ...
[ "Perform", "an", "iterative", "method", "to", "calculate", "the", "effective", "sphere", "that", "perfectly", "(", "up", "to", "the", "volume_error", ")", "conserves", "volume", ".", "Return", "the", "resulting", "image" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L409-L433
[ "def", "exact_volume_sphere", "(", "rvec", ",", "pos", ",", "radius", ",", "zscale", "=", "1.0", ",", "volume_error", "=", "1e-5", ",", "function", "=", "sphere_analytical_gaussian", ",", "max_radius_change", "=", "1e-2", ",", "args", "=", "(", ")", ")", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicParticlesCollection._tile
Get the update tile surrounding particle `n`
peri/comp/objs.py
def _tile(self, n): """Get the update tile surrounding particle `n` """ pos = self._trans(self.pos[n]) return Tile(pos, pos).pad(self.support_pad)
def _tile(self, n): """Get the update tile surrounding particle `n` """ pos = self._trans(self.pos[n]) return Tile(pos, pos).pad(self.support_pad)
[ "Get", "the", "update", "tile", "surrounding", "particle", "n" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L160-L163
[ "def", "_tile", "(", "self", ",", "n", ")", ":", "pos", "=", "self", ".", "_trans", "(", "self", ".", "pos", "[", "n", "]", ")", "return", "Tile", "(", "pos", ",", "pos", ")", ".", "pad", "(", "self", ".", "support_pad", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicParticlesCollection._p2i
Parameter to indices, returns (coord, index), e.g. for a pos pos : ('x', 100)
peri/comp/objs.py
def _p2i(self, param): """ Parameter to indices, returns (coord, index), e.g. for a pos pos : ('x', 100) """ g = param.split('-') if len(g) == 3: return g[2], int(g[1]) else: raise ValueError('`param` passed as incorrect format')
def _p2i(self, param): """ Parameter to indices, returns (coord, index), e.g. for a pos pos : ('x', 100) """ g = param.split('-') if len(g) == 3: return g[2], int(g[1]) else: raise ValueError('`param` passed as incorrect format')
[ "Parameter", "to", "indices", "returns", "(", "coord", "index", ")", "e", ".", "g", ".", "for", "a", "pos", "pos", ":", "(", "x", "100", ")" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L174-L183
[ "def", "_p2i", "(", "self", ",", "param", ")", ":", "g", "=", "param", ".", "split", "(", "'-'", ")", "if", "len", "(", "g", ")", "==", "3", ":", "return", "g", "[", "2", "]", ",", "int", "(", "g", "[", "1", "]", ")", "else", ":", "raise"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicParticlesCollection.initialize
Start from scratch and initialize all objects / draw self.particles
peri/comp/objs.py
def initialize(self): """Start from scratch and initialize all objects / draw self.particles""" self.particles = np.zeros(self.shape.shape, dtype=self.float_precision) for p0, arg0 in zip(self.pos, self._drawargs()): self._draw_particle(p0, *listify(arg0))
def initialize(self): """Start from scratch and initialize all objects / draw self.particles""" self.particles = np.zeros(self.shape.shape, dtype=self.float_precision) for p0, arg0 in zip(self.pos, self._drawargs()): self._draw_particle(p0, *listify(arg0))
[ "Start", "from", "scratch", "and", "initialize", "all", "objects", "/", "draw", "self", ".", "particles" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L186-L191
[ "def", "initialize", "(", "self", ")", ":", "self", ".", "particles", "=", "np", ".", "zeros", "(", "self", ".", "shape", ".", "shape", ",", "dtype", "=", "self", ".", "float_precision", ")", "for", "p0", ",", "arg0", "in", "zip", "(", "self", ".",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicParticlesCollection._vps
Clips a list of inds to be on [0, self.N]
peri/comp/objs.py
def _vps(self, inds): """Clips a list of inds to be on [0, self.N]""" return [j for j in inds if j >= 0 and j < self.N]
def _vps(self, inds): """Clips a list of inds to be on [0, self.N]""" return [j for j in inds if j >= 0 and j < self.N]
[ "Clips", "a", "list", "of", "inds", "to", "be", "on", "[", "0", "self", ".", "N", "]" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L200-L202
[ "def", "_vps", "(", "self", ",", "inds", ")", ":", "return", "[", "j", "for", "j", "in", "inds", "if", "j", ">=", "0", "and", "j", "<", "self", ".", "N", "]" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicParticlesCollection._i2p
Translate index info to parameter name
peri/comp/objs.py
def _i2p(self, ind, coord): """ Translate index info to parameter name """ return '-'.join([self.param_prefix, str(ind), coord])
def _i2p(self, ind, coord): """ Translate index info to parameter name """ return '-'.join([self.param_prefix, str(ind), coord])
[ "Translate", "index", "info", "to", "parameter", "name" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L232-L234
[ "def", "_i2p", "(", "self", ",", "ind", ",", "coord", ")", ":", "return", "'-'", ".", "join", "(", "[", "self", ".", "param_prefix", ",", "str", "(", "ind", ")", ",", "coord", "]", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicParticlesCollection.get_update_tile
Get the amount of support size required for a particular update.
peri/comp/objs.py
def get_update_tile(self, params, values): """ Get the amount of support size required for a particular update.""" doglobal, particles = self._update_type(params) if doglobal: return self.shape.copy() # 1) store the current parameters of interest values0 = self.get_v...
def get_update_tile(self, params, values): """ Get the amount of support size required for a particular update.""" doglobal, particles = self._update_type(params) if doglobal: return self.shape.copy() # 1) store the current parameters of interest values0 = self.get_v...
[ "Get", "the", "amount", "of", "support", "size", "required", "for", "a", "particular", "update", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L236-L253
[ "def", "get_update_tile", "(", "self", ",", "params", ",", "values", ")", ":", "doglobal", ",", "particles", "=", "self", ".", "_update_type", "(", "params", ")", "if", "doglobal", ":", "return", "self", ".", "shape", ".", "copy", "(", ")", "# 1) store t...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicParticlesCollection.update
Update the particles field given new parameter values
peri/comp/objs.py
def update(self, params, values): """ Update the particles field given new parameter values """ #1. Figure out if we're going to do a global update, in which # case we just draw from scratch. global_update, particles = self._update_type(params) # if we are doin...
def update(self, params, values): """ Update the particles field given new parameter values """ #1. Figure out if we're going to do a global update, in which # case we just draw from scratch. global_update, particles = self._update_type(params) # if we are doin...
[ "Update", "the", "particles", "field", "given", "new", "parameter", "values" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L255-L281
[ "def", "update", "(", "self", ",", "params", ",", "values", ")", ":", "#1. Figure out if we're going to do a global update, in which", "# case we just draw from scratch.", "global_update", ",", "particles", "=", "self", ".", "_update_type", "(", "params", ")", "# if we ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicSpheresCollection.param_particle
Get position and radius of one or more particles
peri/comp/objs.py
def param_particle(self, ind): """ Get position and radius of one or more particles """ ind = self._vps(listify(ind)) return [self._i2p(i, j) for i in ind for j in ['z', 'y', 'x', 'a']]
def param_particle(self, ind): """ Get position and radius of one or more particles """ ind = self._vps(listify(ind)) return [self._i2p(i, j) for i in ind for j in ['z', 'y', 'x', 'a']]
[ "Get", "position", "and", "radius", "of", "one", "or", "more", "particles" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L647-L650
[ "def", "param_particle", "(", "self", ",", "ind", ")", ":", "ind", "=", "self", ".", "_vps", "(", "listify", "(", "ind", ")", ")", "return", "[", "self", ".", "_i2p", "(", "i", ",", "j", ")", "for", "i", "in", "ind", "for", "j", "in", "[", "'...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicSpheresCollection.param_particle_pos
Get position of one or more particles
peri/comp/objs.py
def param_particle_pos(self, ind): """ Get position of one or more particles """ ind = self._vps(listify(ind)) return [self._i2p(i, j) for i in ind for j in ['z', 'y', 'x']]
def param_particle_pos(self, ind): """ Get position of one or more particles """ ind = self._vps(listify(ind)) return [self._i2p(i, j) for i in ind for j in ['z', 'y', 'x']]
[ "Get", "position", "of", "one", "or", "more", "particles" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L652-L655
[ "def", "param_particle_pos", "(", "self", ",", "ind", ")", ":", "ind", "=", "self", ".", "_vps", "(", "listify", "(", "ind", ")", ")", "return", "[", "self", ".", "_i2p", "(", "i", ",", "j", ")", "for", "i", "in", "ind", "for", "j", "in", "[", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicSpheresCollection.param_particle_rad
Get radius of one or more particles
peri/comp/objs.py
def param_particle_rad(self, ind): """ Get radius of one or more particles """ ind = self._vps(listify(ind)) return [self._i2p(i, 'a') for i in ind]
def param_particle_rad(self, ind): """ Get radius of one or more particles """ ind = self._vps(listify(ind)) return [self._i2p(i, 'a') for i in ind]
[ "Get", "radius", "of", "one", "or", "more", "particles" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L657-L660
[ "def", "param_particle_rad", "(", "self", ",", "ind", ")", ":", "ind", "=", "self", ".", "_vps", "(", "listify", "(", "ind", ")", ")", "return", "[", "self", ".", "_i2p", "(", "i", ",", "'a'", ")", "for", "i", "in", "ind", "]" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicSpheresCollection.add_particle
Add a particle or list of particles given by a list of positions and radii, both need to be array-like. Parameters ---------- pos : array-like [N, 3] Positions of all new particles rad : array-like [N] Corresponding radii of new particles Return...
peri/comp/objs.py
def add_particle(self, pos, rad): """ Add a particle or list of particles given by a list of positions and radii, both need to be array-like. Parameters ---------- pos : array-like [N, 3] Positions of all new particles rad : array-like [N] ...
def add_particle(self, pos, rad): """ Add a particle or list of particles given by a list of positions and radii, both need to be array-like. Parameters ---------- pos : array-like [N, 3] Positions of all new particles rad : array-like [N] ...
[ "Add", "a", "particle", "or", "list", "of", "particles", "given", "by", "a", "list", "of", "positions", "and", "radii", "both", "need", "to", "be", "array", "-", "like", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L662-L694
[ "def", "add_particle", "(", "self", ",", "pos", ",", "rad", ")", ":", "rad", "=", "listify", "(", "rad", ")", "# add some zero mass particles to the list (same as not having these", "# particles in the image, which is true at this moment)", "inds", "=", "np", ".", "arange...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicSpheresCollection.remove_particle
Remove the particle at index `inds`, may be a list. Returns [3,N], [N] element numpy.ndarray of pos, rad.
peri/comp/objs.py
def remove_particle(self, inds): """ Remove the particle at index `inds`, may be a list. Returns [3,N], [N] element numpy.ndarray of pos, rad. """ if self.rad.shape[0] == 0: return inds = listify(inds) # Here's the game plan: # 1. get all p...
def remove_particle(self, inds): """ Remove the particle at index `inds`, may be a list. Returns [3,N], [N] element numpy.ndarray of pos, rad. """ if self.rad.shape[0] == 0: return inds = listify(inds) # Here's the game plan: # 1. get all p...
[ "Remove", "the", "particle", "at", "index", "inds", "may", "be", "a", "list", ".", "Returns", "[", "3", "N", "]", "[", "N", "]", "element", "numpy", ".", "ndarray", "of", "pos", "rad", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L696-L724
[ "def", "remove_particle", "(", "self", ",", "inds", ")", ":", "if", "self", ".", "rad", ".", "shape", "[", "0", "]", "==", "0", ":", "return", "inds", "=", "listify", "(", "inds", ")", "# Here's the game plan:", "# 1. get all positions and sizes of particles...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicSpheresCollection._update_type
Returns dozscale and particle list of update
peri/comp/objs.py
def _update_type(self, params): """ Returns dozscale and particle list of update """ dozscale = False particles = [] for p in listify(params): typ, ind = self._p2i(p) particles.append(ind) dozscale = dozscale or typ == 'zscale' particles = set(...
def _update_type(self, params): """ Returns dozscale and particle list of update """ dozscale = False particles = [] for p in listify(params): typ, ind = self._p2i(p) particles.append(ind) dozscale = dozscale or typ == 'zscale' particles = set(...
[ "Returns", "dozscale", "and", "particle", "list", "of", "update" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L746-L755
[ "def", "_update_type", "(", "self", ",", "params", ")", ":", "dozscale", "=", "False", "particles", "=", "[", "]", "for", "p", "in", "listify", "(", "params", ")", ":", "typ", ",", "ind", "=", "self", ".", "_p2i", "(", "p", ")", "particles", ".", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicSpheresCollection._tile
Get the tile surrounding particle `n`
peri/comp/objs.py
def _tile(self, n): """ Get the tile surrounding particle `n` """ zsc = np.array([1.0/self.zscale, 1, 1]) pos, rad = self.pos[n], self.rad[n] pos = self._trans(pos) return Tile(pos - zsc*rad, pos + zsc*rad).pad(self.support_pad)
def _tile(self, n): """ Get the tile surrounding particle `n` """ zsc = np.array([1.0/self.zscale, 1, 1]) pos, rad = self.pos[n], self.rad[n] pos = self._trans(pos) return Tile(pos - zsc*rad, pos + zsc*rad).pad(self.support_pad)
[ "Get", "the", "tile", "surrounding", "particle", "n" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L757-L762
[ "def", "_tile", "(", "self", ",", "n", ")", ":", "zsc", "=", "np", ".", "array", "(", "[", "1.0", "/", "self", ".", "zscale", ",", "1", ",", "1", "]", ")", "pos", ",", "rad", "=", "self", ".", "pos", "[", "n", "]", ",", "self", ".", "rad"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
PlatonicSpheresCollection.update
Calls an update, but clips radii to be > 0
peri/comp/objs.py
def update(self, params, values): """Calls an update, but clips radii to be > 0""" # radparams = self.param_radii() params = listify(params) values = listify(values) for i, p in enumerate(params): # if (p in radparams) & (values[i] < 0): if (p[-2:] == '-a'...
def update(self, params, values): """Calls an update, but clips radii to be > 0""" # radparams = self.param_radii() params = listify(params) values = listify(values) for i, p in enumerate(params): # if (p in radparams) & (values[i] < 0): if (p[-2:] == '-a'...
[ "Calls", "an", "update", "but", "clips", "radii", "to", "be", ">", "0" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L764-L773
[ "def", "update", "(", "self", ",", "params", ",", "values", ")", ":", "# radparams = self.param_radii()", "params", "=", "listify", "(", "params", ")", "values", "=", "listify", "(", "values", ")", "for", "i", ",", "p", "in", "enumerate", "(", "params", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Slab.rmatrix
Generate the composite rotation matrix that rotates the slab normal. The rotation is a rotation about the x-axis, followed by a rotation about the z-axis.
peri/comp/objs.py
def rmatrix(self): """ Generate the composite rotation matrix that rotates the slab normal. The rotation is a rotation about the x-axis, followed by a rotation about the z-axis. """ t = self.param_dict[self.lbl_theta] r0 = np.array([ [np.cos(t), -np.sin(t), 0], ...
def rmatrix(self): """ Generate the composite rotation matrix that rotates the slab normal. The rotation is a rotation about the x-axis, followed by a rotation about the z-axis. """ t = self.param_dict[self.lbl_theta] r0 = np.array([ [np.cos(t), -np.sin(t), 0], ...
[ "Generate", "the", "composite", "rotation", "matrix", "that", "rotates", "the", "slab", "normal", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/objs.py#L848-L864
[ "def", "rmatrix", "(", "self", ")", ":", "t", "=", "self", ".", "param_dict", "[", "self", ".", "lbl_theta", "]", "r0", "=", "np", ".", "array", "(", "[", "[", "np", ".", "cos", "(", "t", ")", ",", "-", "np", ".", "sin", "(", "t", ")", ",",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
j2
A fast j2 defined in terms of other special functions
peri/comp/psfcalc.py
def j2(x): """ A fast j2 defined in terms of other special functions """ to_return = 2./(x+1e-15)*j1(x) - j0(x) to_return[x==0] = 0 return to_return
def j2(x): """ A fast j2 defined in terms of other special functions """ to_return = 2./(x+1e-15)*j1(x) - j0(x) to_return[x==0] = 0 return to_return
[ "A", "fast", "j2", "defined", "in", "terms", "of", "other", "special", "functions" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L12-L16
[ "def", "j2", "(", "x", ")", ":", "to_return", "=", "2.", "/", "(", "x", "+", "1e-15", ")", "*", "j1", "(", "x", ")", "-", "j0", "(", "x", ")", "to_return", "[", "x", "==", "0", "]", "=", "0", "return", "to_return" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
calc_pts_hg
Returns Hermite-Gauss quadrature points for even functions
peri/comp/psfcalc.py
def calc_pts_hg(npts=20): """Returns Hermite-Gauss quadrature points for even functions""" pts_hg, wts_hg = np.polynomial.hermite.hermgauss(npts*2) pts_hg = pts_hg[npts:] wts_hg = wts_hg[npts:] * np.exp(pts_hg*pts_hg) return pts_hg, wts_hg
def calc_pts_hg(npts=20): """Returns Hermite-Gauss quadrature points for even functions""" pts_hg, wts_hg = np.polynomial.hermite.hermgauss(npts*2) pts_hg = pts_hg[npts:] wts_hg = wts_hg[npts:] * np.exp(pts_hg*pts_hg) return pts_hg, wts_hg
[ "Returns", "Hermite", "-", "Gauss", "quadrature", "points", "for", "even", "functions" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L20-L25
[ "def", "calc_pts_hg", "(", "npts", "=", "20", ")", ":", "pts_hg", ",", "wts_hg", "=", "np", ".", "polynomial", ".", "hermite", ".", "hermgauss", "(", "npts", "*", "2", ")", "pts_hg", "=", "pts_hg", "[", "npts", ":", "]", "wts_hg", "=", "wts_hg", "[...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
calc_pts_lag
Returns Gauss-Laguerre quadrature points rescaled for line scan integration Parameters ---------- npts : {15, 20, 25}, optional The number of points to Notes ----- The scale is set internally as the best rescaling for a line scan integral; it was checked numerically...
peri/comp/psfcalc.py
def calc_pts_lag(npts=20): """ Returns Gauss-Laguerre quadrature points rescaled for line scan integration Parameters ---------- npts : {15, 20, 25}, optional The number of points to Notes ----- The scale is set internally as the best rescaling for a line scan ...
def calc_pts_lag(npts=20): """ Returns Gauss-Laguerre quadrature points rescaled for line scan integration Parameters ---------- npts : {15, 20, 25}, optional The number of points to Notes ----- The scale is set internally as the best rescaling for a line scan ...
[ "Returns", "Gauss", "-", "Laguerre", "quadrature", "points", "rescaled", "for", "line", "scan", "integration" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L27-L55
[ "def", "calc_pts_lag", "(", "npts", "=", "20", ")", ":", "scl", "=", "{", "15", ":", "0.072144", ",", "20", ":", "0.051532", ",", "25", ":", "0.043266", "}", "[", "npts", "]", "pts0", ",", "wts0", "=", "np", ".", "polynomial", ".", "laguerre", "....
61beed5deaaf978ab31ed716e8470d86ba639867
valid
f_theta
Returns the wavefront aberration for an aberrated, defocused lens. Calculates the portions of the wavefront distortion due to z, theta only, for a lens with defocus and spherical aberration induced by coverslip mismatch. (The rho portion can be analytically integrated to Bessels.) Parameters -...
peri/comp/psfcalc.py
def f_theta(cos_theta, zint, z, n2n1=0.95, sph6_ab=None, **kwargs): """ Returns the wavefront aberration for an aberrated, defocused lens. Calculates the portions of the wavefront distortion due to z, theta only, for a lens with defocus and spherical aberration induced by coverslip mismatch. (The r...
def f_theta(cos_theta, zint, z, n2n1=0.95, sph6_ab=None, **kwargs): """ Returns the wavefront aberration for an aberrated, defocused lens. Calculates the portions of the wavefront distortion due to z, theta only, for a lens with defocus and spherical aberration induced by coverslip mismatch. (The r...
[ "Returns", "the", "wavefront", "aberration", "for", "an", "aberrated", "defocused", "lens", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L61-L101
[ "def", "f_theta", "(", "cos_theta", ",", "zint", ",", "z", ",", "n2n1", "=", "0.95", ",", "sph6_ab", "=", "None", ",", "*", "*", "kwargs", ")", ":", "wvfront", "=", "(", "np", ".", "outer", "(", "np", ".", "ones_like", "(", "z", ")", "*", "zint...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
get_Kprefactor
Returns a prefactor in the electric field integral. This is an internal function called by get_K. The returned prefactor in the integrand is independent of which integral is being called; it is a combination of the exp(1j*phase) and apodization. Parameters ---------- z : numpy.ndarray ...
peri/comp/psfcalc.py
def get_Kprefactor(z, cos_theta, zint=100.0, n2n1=0.95, get_hdet=False, **kwargs): """ Returns a prefactor in the electric field integral. This is an internal function called by get_K. The returned prefactor in the integrand is independent of which integral is being called; it is a combinat...
def get_Kprefactor(z, cos_theta, zint=100.0, n2n1=0.95, get_hdet=False, **kwargs): """ Returns a prefactor in the electric field integral. This is an internal function called by get_K. The returned prefactor in the integrand is independent of which integral is being called; it is a combinat...
[ "Returns", "a", "prefactor", "in", "the", "electric", "field", "integral", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L145-L186
[ "def", "get_Kprefactor", "(", "z", ",", "cos_theta", ",", "zint", "=", "100.0", ",", "n2n1", "=", "0.95", ",", "get_hdet", "=", "False", ",", "*", "*", "kwargs", ")", ":", "phase", "=", "f_theta", "(", "cos_theta", ",", "zint", ",", "z", ",", "n2n1...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
get_K
Calculates one of three electric field integrals. Internal function for calculating point spread functions. Returns one of three electric field integrals that describe the electric field near the focus of a lens; these integrals appear in Hell's psf calculation. Parameters ---------- r...
peri/comp/psfcalc.py
def get_K(rho, z, alpha=1.0, zint=100.0, n2n1=0.95, get_hdet=False, K=1, Kprefactor=None, return_Kprefactor=False, npts=20, **kwargs): """ Calculates one of three electric field integrals. Internal function for calculating point spread functions. Returns one of three electric field integrals th...
def get_K(rho, z, alpha=1.0, zint=100.0, n2n1=0.95, get_hdet=False, K=1, Kprefactor=None, return_Kprefactor=False, npts=20, **kwargs): """ Calculates one of three electric field integrals. Internal function for calculating point spread functions. Returns one of three electric field integrals th...
[ "Calculates", "one", "of", "three", "electric", "field", "integrals", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L188-L294
[ "def", "get_K", "(", "rho", ",", "z", ",", "alpha", "=", "1.0", ",", "zint", "=", "100.0", ",", "n2n1", "=", "0.95", ",", "get_hdet", "=", "False", ",", "K", "=", "1", ",", "Kprefactor", "=", "None", ",", "return_Kprefactor", "=", "False", ",", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
get_hsym_asym
Calculates the symmetric and asymmetric portions of a confocal PSF. Parameters ---------- rho : numpy.ndarray Rho in cylindrical coordinates, in units of 1/k. z : numpy.ndarray Z in cylindrical coordinates, in units of 1/k. Must be the same shape as `rho` ...
peri/comp/psfcalc.py
def get_hsym_asym(rho, z, get_hdet=False, include_K3_det=True, **kwargs): """ Calculates the symmetric and asymmetric portions of a confocal PSF. Parameters ---------- rho : numpy.ndarray Rho in cylindrical coordinates, in units of 1/k. z : numpy.ndarray Z in cyl...
def get_hsym_asym(rho, z, get_hdet=False, include_K3_det=True, **kwargs): """ Calculates the symmetric and asymmetric portions of a confocal PSF. Parameters ---------- rho : numpy.ndarray Rho in cylindrical coordinates, in units of 1/k. z : numpy.ndarray Z in cyl...
[ "Calculates", "the", "symmetric", "and", "asymmetric", "portions", "of", "a", "confocal", "PSF", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L300-L355
[ "def", "get_hsym_asym", "(", "rho", ",", "z", ",", "get_hdet", "=", "False", ",", "include_K3_det", "=", "True", ",", "*", "*", "kwargs", ")", ":", "K1", ",", "Kprefactor", "=", "get_K", "(", "rho", ",", "z", ",", "K", "=", "1", ",", "get_hdet", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
calculate_pinhole_psf
Calculates the perfect-pinhole PSF, for a set of points (x,y,z). Parameters ----------- x : numpy.ndarray The x-coordinate of the PSF in units of 1/ the wavevector of the incoming light. y : numpy.ndarray The y-coordinate. z : numpy.ndarray ...
peri/comp/psfcalc.py
def calculate_pinhole_psf(x, y, z, kfki=0.89, zint=100.0, normalize=False, **kwargs): """ Calculates the perfect-pinhole PSF, for a set of points (x,y,z). Parameters ----------- x : numpy.ndarray The x-coordinate of the PSF in units of 1/ the wavevector of the in...
def calculate_pinhole_psf(x, y, z, kfki=0.89, zint=100.0, normalize=False, **kwargs): """ Calculates the perfect-pinhole PSF, for a set of points (x,y,z). Parameters ----------- x : numpy.ndarray The x-coordinate of the PSF in units of 1/ the wavevector of the in...
[ "Calculates", "the", "perfect", "-", "pinhole", "PSF", "for", "a", "set", "of", "points", "(", "x", "y", "z", ")", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L357-L419
[ "def", "calculate_pinhole_psf", "(", "x", ",", "y", ",", "z", ",", "kfki", "=", "0.89", ",", "zint", "=", "100.0", ",", "normalize", "=", "False", ",", "*", "*", "kwargs", ")", ":", "rho", "=", "np", ".", "sqrt", "(", "x", "**", "2", "+", "y", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
get_polydisp_pts_wts
Calculates a set of Gauss quadrature points & weights for polydisperse light. Returns a list of points and weights of the final wavevector's distri- bution, in units of the initial wavevector. Parameters ---------- kfki : Float The mean of the polydisperse outgoing wavevectors....
peri/comp/psfcalc.py
def get_polydisp_pts_wts(kfki, sigkf, dist_type='gaussian', nkpts=3): """ Calculates a set of Gauss quadrature points & weights for polydisperse light. Returns a list of points and weights of the final wavevector's distri- bution, in units of the initial wavevector. Parameters ---------- ...
def get_polydisp_pts_wts(kfki, sigkf, dist_type='gaussian', nkpts=3): """ Calculates a set of Gauss quadrature points & weights for polydisperse light. Returns a list of points and weights of the final wavevector's distri- bution, in units of the initial wavevector. Parameters ---------- ...
[ "Calculates", "a", "set", "of", "Gauss", "quadrature", "points", "&", "weights", "for", "polydisperse", "light", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L421-L462
[ "def", "get_polydisp_pts_wts", "(", "kfki", ",", "sigkf", ",", "dist_type", "=", "'gaussian'", ",", "nkpts", "=", "3", ")", ":", "if", "dist_type", ".", "lower", "(", ")", "==", "'gaussian'", ":", "pts", ",", "wts", "=", "np", ".", "polynomial", ".", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
calculate_polychrome_pinhole_psf
Calculates the perfect-pinhole PSF, for a set of points (x,y,z). Parameters ----------- x : numpy.ndarray The x-coordinate of the PSF in units of 1/ the wavevector of the incoming light. y : numpy.ndarray The y-coordinate. z : numpy.ndarray ...
peri/comp/psfcalc.py
def calculate_polychrome_pinhole_psf(x, y, z, normalize=False, kfki=0.889, sigkf=0.1, zint=100., nkpts=3, dist_type='gaussian', **kwargs): """ Calculates the perfect-pinhole PSF, for a set of points (x,y,z). Parameters ----------- x : numpy.ndarray The x-coordinate of the PS...
def calculate_polychrome_pinhole_psf(x, y, z, normalize=False, kfki=0.889, sigkf=0.1, zint=100., nkpts=3, dist_type='gaussian', **kwargs): """ Calculates the perfect-pinhole PSF, for a set of points (x,y,z). Parameters ----------- x : numpy.ndarray The x-coordinate of the PS...
[ "Calculates", "the", "perfect", "-", "pinhole", "PSF", "for", "a", "set", "of", "points", "(", "x", "y", "z", ")", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L464-L543
[ "def", "calculate_polychrome_pinhole_psf", "(", "x", ",", "y", ",", "z", ",", "normalize", "=", "False", ",", "kfki", "=", "0.889", ",", "sigkf", "=", "0.1", ",", "zint", "=", "100.", ",", "nkpts", "=", "3", ",", "dist_type", "=", "'gaussian'", ",", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
get_psf_scalar
Calculates a scalar (non-vectorial light) approximation to a confocal PSF The calculation is approximate, since it ignores the effects of polarization and apodization, but should be ~3x faster. Parameters ---------- x : numpy.ndarray The x-coordinate of the PSF in units of 1/ the w...
peri/comp/psfcalc.py
def get_psf_scalar(x, y, z, kfki=1., zint=100.0, normalize=False, **kwargs): """ Calculates a scalar (non-vectorial light) approximation to a confocal PSF The calculation is approximate, since it ignores the effects of polarization and apodization, but should be ~3x faster. Parameters --------...
def get_psf_scalar(x, y, z, kfki=1., zint=100.0, normalize=False, **kwargs): """ Calculates a scalar (non-vectorial light) approximation to a confocal PSF The calculation is approximate, since it ignores the effects of polarization and apodization, but should be ~3x faster. Parameters --------...
[ "Calculates", "a", "scalar", "(", "non", "-", "vectorial", "light", ")", "approximation", "to", "a", "confocal", "PSF" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L545-L618
[ "def", "get_psf_scalar", "(", "x", ",", "y", ",", "z", ",", "kfki", "=", "1.", ",", "zint", "=", "100.0", ",", "normalize", "=", "False", ",", "*", "*", "kwargs", ")", ":", "rho", "=", "np", ".", "sqrt", "(", "x", "**", "2", "+", "y", "**", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
calculate_linescan_ilm_psf
Calculates the illumination PSF for a line-scanning confocal with the confocal line oriented along the x direction. Parameters ---------- y : numpy.ndarray The y points (in-plane, perpendicular to the line direction) at which to evaluate the illumination PSF, in units of 1/k...
peri/comp/psfcalc.py
def calculate_linescan_ilm_psf(y,z, polar_angle=0., nlpts=1, pinhole_width=1, use_laggauss=False, **kwargs): """ Calculates the illumination PSF for a line-scanning confocal with the confocal line oriented along the x direction. Parameters ---------- y : numpy.ndarray Th...
def calculate_linescan_ilm_psf(y,z, polar_angle=0., nlpts=1, pinhole_width=1, use_laggauss=False, **kwargs): """ Calculates the illumination PSF for a line-scanning confocal with the confocal line oriented along the x direction. Parameters ---------- y : numpy.ndarray Th...
[ "Calculates", "the", "illumination", "PSF", "for", "a", "line", "-", "scanning", "confocal", "with", "the", "confocal", "line", "oriented", "along", "the", "x", "direction", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L620-L700
[ "def", "calculate_linescan_ilm_psf", "(", "y", ",", "z", ",", "polar_angle", "=", "0.", ",", "nlpts", "=", "1", ",", "pinhole_width", "=", "1", ",", "use_laggauss", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "use_laggauss", ":", "x_vals", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
calculate_linescan_psf
Calculates the point spread function of a line-scanning confocal. Make x,y,z __1D__ numpy.arrays, with x the direction along the scan line. (to make the calculation faster since I dont' need the line ilm for each x). Parameters ---------- x : numpy.ndarray _One_dimensional_ ar...
peri/comp/psfcalc.py
def calculate_linescan_psf(x, y, z, normalize=False, kfki=0.889, zint=100., polar_angle=0., wrap=True, **kwargs): """ Calculates the point spread function of a line-scanning confocal. Make x,y,z __1D__ numpy.arrays, with x the direction along the scan line. (to make the calculation faster sinc...
def calculate_linescan_psf(x, y, z, normalize=False, kfki=0.889, zint=100., polar_angle=0., wrap=True, **kwargs): """ Calculates the point spread function of a line-scanning confocal. Make x,y,z __1D__ numpy.arrays, with x the direction along the scan line. (to make the calculation faster sinc...
[ "Calculates", "the", "point", "spread", "function", "of", "a", "line", "-", "scanning", "confocal", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L702-L797
[ "def", "calculate_linescan_psf", "(", "x", ",", "y", ",", "z", ",", "normalize", "=", "False", ",", "kfki", "=", "0.889", ",", "zint", "=", "100.", ",", "polar_angle", "=", "0.", ",", "wrap", "=", "True", ",", "*", "*", "kwargs", ")", ":", "#0. Set...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
calculate_polychrome_linescan_psf
Calculates the point spread function of a line-scanning confocal with polydisperse dye emission. Make x,y,z __1D__ numpy.arrays, with x the direction along the scan line. (to make the calculation faster since I dont' need the line ilm for each x). Parameters ---------- x : numpy.ndarr...
peri/comp/psfcalc.py
def calculate_polychrome_linescan_psf(x, y, z, normalize=False, kfki=0.889, sigkf=0.1, zint=100., nkpts=3, dist_type='gaussian', wrap=True, **kwargs): """ Calculates the point spread function of a line-scanning confocal with polydisperse dye emission. Make x,y,z __1D__ numpy.arrays, wi...
def calculate_polychrome_linescan_psf(x, y, z, normalize=False, kfki=0.889, sigkf=0.1, zint=100., nkpts=3, dist_type='gaussian', wrap=True, **kwargs): """ Calculates the point spread function of a line-scanning confocal with polydisperse dye emission. Make x,y,z __1D__ numpy.arrays, wi...
[ "Calculates", "the", "point", "spread", "function", "of", "a", "line", "-", "scanning", "confocal", "with", "polydisperse", "dye", "emission", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L799-L913
[ "def", "calculate_polychrome_linescan_psf", "(", "x", ",", "y", ",", "z", ",", "normalize", "=", "False", ",", "kfki", "=", "0.889", ",", "sigkf", "=", "0.1", ",", "zint", "=", "100.", ",", "nkpts", "=", "3", ",", "dist_type", "=", "'gaussian'", ",", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
wrap_and_calc_psf
Wraps a point-spread function in x and y. Speeds up psf calculations by a factor of 4 for free / some broadcasting by exploiting the x->-x, y->-y symmetry of a psf function. Pass x and y as the positive (say) values of the coordinates at which to evaluate func, and it will return the function sampled a...
peri/comp/psfcalc.py
def wrap_and_calc_psf(xpts, ypts, zpts, func, **kwargs): """ Wraps a point-spread function in x and y. Speeds up psf calculations by a factor of 4 for free / some broadcasting by exploiting the x->-x, y->-y symmetry of a psf function. Pass x and y as the positive (say) values of the coordinates at ...
def wrap_and_calc_psf(xpts, ypts, zpts, func, **kwargs): """ Wraps a point-spread function in x and y. Speeds up psf calculations by a factor of 4 for free / some broadcasting by exploiting the x->-x, y->-y symmetry of a psf function. Pass x and y as the positive (say) values of the coordinates at ...
[ "Wraps", "a", "point", "-", "spread", "function", "in", "x", "and", "y", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L920-L992
[ "def", "wrap_and_calc_psf", "(", "xpts", ",", "ypts", ",", "zpts", ",", "func", ",", "*", "*", "kwargs", ")", ":", "#1. Checking that everything is hunky-dory:", "for", "t", "in", "[", "xpts", ",", "ypts", ",", "zpts", "]", ":", "if", "len", "(", "t", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
vec_to_halfvec
Transforms a vector np.arange(-N, M, dx) to np.arange(min(|vec|), max(N,M),dx)]
peri/comp/psfcalc.py
def vec_to_halfvec(vec): """Transforms a vector np.arange(-N, M, dx) to np.arange(min(|vec|), max(N,M),dx)]""" d = vec[1:] - vec[:-1] if ((d/d.mean()).std() > 1e-14) or (d.mean() < 0): raise ValueError('vec must be np.arange() in increasing order') dx = d.mean() lowest = np.abs(vec).min() ...
def vec_to_halfvec(vec): """Transforms a vector np.arange(-N, M, dx) to np.arange(min(|vec|), max(N,M),dx)]""" d = vec[1:] - vec[:-1] if ((d/d.mean()).std() > 1e-14) or (d.mean() < 0): raise ValueError('vec must be np.arange() in increasing order') dx = d.mean() lowest = np.abs(vec).min() ...
[ "Transforms", "a", "vector", "np", ".", "arange", "(", "-", "N", "M", "dx", ")", "to", "np", ".", "arange", "(", "min", "(", "|vec|", ")", "max", "(", "N", "M", ")", "dx", ")", "]" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/psfcalc.py#L994-L1002
[ "def", "vec_to_halfvec", "(", "vec", ")", ":", "d", "=", "vec", "[", "1", ":", "]", "-", "vec", "[", ":", "-", "1", "]", "if", "(", "(", "d", "/", "d", ".", "mean", "(", ")", ")", ".", "std", "(", ")", ">", "1e-14", ")", "or", "(", "d",...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
listify
Convert a scalar ``a`` to a list and all iterables to list as well. Examples -------- >>> listify(0) [0] >>> listify([1,2,3]) [1, 2, 3] >>> listify('a') ['a'] >>> listify(np.array([1,2,3])) [1, 2, 3] >>> listify('string') ['string']
peri/util.py
def listify(a): """ Convert a scalar ``a`` to a list and all iterables to list as well. Examples -------- >>> listify(0) [0] >>> listify([1,2,3]) [1, 2, 3] >>> listify('a') ['a'] >>> listify(np.array([1,2,3])) [1, 2, 3] >>> listify('string') ['string'] ""...
def listify(a): """ Convert a scalar ``a`` to a list and all iterables to list as well. Examples -------- >>> listify(0) [0] >>> listify([1,2,3]) [1, 2, 3] >>> listify('a') ['a'] >>> listify(np.array([1,2,3])) [1, 2, 3] >>> listify('string') ['string'] ""...
[ "Convert", "a", "scalar", "a", "to", "a", "list", "and", "all", "iterables", "to", "list", "as", "well", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L34-L59
[ "def", "listify", "(", "a", ")", ":", "if", "a", "is", "None", ":", "return", "[", "]", "elif", "not", "isinstance", "(", "a", ",", "(", "tuple", ",", "list", ",", "np", ".", "ndarray", ")", ")", ":", "return", "[", "a", "]", "return", "list", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
delistify
If a single element list, extract the element as an object, otherwise leave as it is. Examples -------- >>> delistify('string') 'string' >>> delistify(['string']) 'string' >>> delistify(['string', 'other']) ['string', 'other'] >>> delistify(np.array([1.0])) 1.0 >>> d...
peri/util.py
def delistify(a, b=None): """ If a single element list, extract the element as an object, otherwise leave as it is. Examples -------- >>> delistify('string') 'string' >>> delistify(['string']) 'string' >>> delistify(['string', 'other']) ['string', 'other'] >>> delisti...
def delistify(a, b=None): """ If a single element list, extract the element as an object, otherwise leave as it is. Examples -------- >>> delistify('string') 'string' >>> delistify(['string']) 'string' >>> delistify(['string', 'other']) ['string', 'other'] >>> delisti...
[ "If", "a", "single", "element", "list", "extract", "the", "element", "as", "an", "object", "otherwise", "leave", "as", "it", "is", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L61-L91
[ "def", "delistify", "(", "a", ",", "b", "=", "None", ")", ":", "if", "isinstance", "(", "b", ",", "(", "tuple", ",", "list", ",", "np", ".", "ndarray", ")", ")", ":", "if", "isinstance", "(", "a", ",", "(", "tuple", ",", "list", ",", "np", "....
61beed5deaaf978ab31ed716e8470d86ba639867
valid
aN
Convert an integer or iterable list to numpy array of length dim. This func is used to allow other methods to take both scalars non-numpy arrays with flexibility. Parameters ---------- a : number, iterable, array-like The object to convert to numpy array dim : integer The lengt...
peri/util.py
def aN(a, dim=3, dtype='int'): """ Convert an integer or iterable list to numpy array of length dim. This func is used to allow other methods to take both scalars non-numpy arrays with flexibility. Parameters ---------- a : number, iterable, array-like The object to convert to numpy...
def aN(a, dim=3, dtype='int'): """ Convert an integer or iterable list to numpy array of length dim. This func is used to allow other methods to take both scalars non-numpy arrays with flexibility. Parameters ---------- a : number, iterable, array-like The object to convert to numpy...
[ "Convert", "an", "integer", "or", "iterable", "list", "to", "numpy", "array", "of", "length", "dim", ".", "This", "func", "is", "used", "to", "allow", "other", "methods", "to", "take", "both", "scalars", "non", "-", "numpy", "arrays", "with", "flexibility"...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L99-L134
[ "def", "aN", "(", "a", ",", "dim", "=", "3", ",", "dtype", "=", "'int'", ")", ":", "if", "not", "hasattr", "(", "a", ",", "'__iter__'", ")", ":", "return", "np", ".", "array", "(", "[", "a", "]", "*", "dim", ",", "dtype", "=", "dtype", ")", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
cdd
Conditionally delete key (or list of keys) 'k' from dict 'd'
peri/util.py
def cdd(d, k): """ Conditionally delete key (or list of keys) 'k' from dict 'd' """ if not isinstance(k, list): k = [k] for i in k: if i in d: d.pop(i)
def cdd(d, k): """ Conditionally delete key (or list of keys) 'k' from dict 'd' """ if not isinstance(k, list): k = [k] for i in k: if i in d: d.pop(i)
[ "Conditionally", "delete", "key", "(", "or", "list", "of", "keys", ")", "k", "from", "dict", "d" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L883-L889
[ "def", "cdd", "(", "d", ",", "k", ")", ":", "if", "not", "isinstance", "(", "k", ",", "list", ")", ":", "k", "=", "[", "k", "]", "for", "i", "in", "k", ":", "if", "i", "in", "d", ":", "d", ".", "pop", "(", "i", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
patch_docs
Apply the documentation from ``superclass`` to ``subclass`` by filling in all overridden member function docstrings with those from the parent class
peri/util.py
def patch_docs(subclass, superclass): """ Apply the documentation from ``superclass`` to ``subclass`` by filling in all overridden member function docstrings with those from the parent class """ funcs0 = inspect.getmembers(subclass, predicate=inspect.ismethod) funcs1 = inspect.getmembers(sup...
def patch_docs(subclass, superclass): """ Apply the documentation from ``superclass`` to ``subclass`` by filling in all overridden member function docstrings with those from the parent class """ funcs0 = inspect.getmembers(subclass, predicate=inspect.ismethod) funcs1 = inspect.getmembers(sup...
[ "Apply", "the", "documentation", "from", "superclass", "to", "subclass", "by", "filling", "in", "all", "overridden", "member", "function", "docstrings", "with", "those", "from", "the", "parent", "class" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L1119-L1139
[ "def", "patch_docs", "(", "subclass", ",", "superclass", ")", ":", "funcs0", "=", "inspect", ".", "getmembers", "(", "subclass", ",", "predicate", "=", "inspect", ".", "ismethod", ")", "funcs1", "=", "inspect", ".", "getmembers", "(", "superclass", ",", "p...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
indir
Context manager for switching the current path of the process. Can be used: with indir('/tmp'): <do something in tmp>
peri/util.py
def indir(path): """ Context manager for switching the current path of the process. Can be used: with indir('/tmp'): <do something in tmp> """ cwd = os.getcwd() try: os.chdir(path) yield except Exception as e: raise finally: os.chdir(cwd)
def indir(path): """ Context manager for switching the current path of the process. Can be used: with indir('/tmp'): <do something in tmp> """ cwd = os.getcwd() try: os.chdir(path) yield except Exception as e: raise finally: os.chdir(cwd)
[ "Context", "manager", "for", "switching", "the", "current", "path", "of", "the", "process", ".", "Can", "be", "used", ":" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L1145-L1160
[ "def", "indir", "(", "path", ")", ":", "cwd", "=", "os", ".", "getcwd", "(", ")", "try", ":", "os", ".", "chdir", "(", "path", ")", "yield", "except", "Exception", "as", "e", ":", "raise", "finally", ":", "os", ".", "chdir", "(", "cwd", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile.slicer
Array slicer object for this tile >>> Tile((2,3)).slicer (slice(0, 2, None), slice(0, 3, None)) >>> np.arange(10)[Tile((4,)).slicer] array([0, 1, 2, 3])
peri/util.py
def slicer(self): """ Array slicer object for this tile >>> Tile((2,3)).slicer (slice(0, 2, None), slice(0, 3, None)) >>> np.arange(10)[Tile((4,)).slicer] array([0, 1, 2, 3]) """ return tuple(np.s_[l:r] for l,r in zip(*self.bounds))
def slicer(self): """ Array slicer object for this tile >>> Tile((2,3)).slicer (slice(0, 2, None), slice(0, 3, None)) >>> np.arange(10)[Tile((4,)).slicer] array([0, 1, 2, 3]) """ return tuple(np.s_[l:r] for l,r in zip(*self.bounds))
[ "Array", "slicer", "object", "for", "this", "tile" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L298-L308
[ "def", "slicer", "(", "self", ")", ":", "return", "tuple", "(", "np", ".", "s_", "[", "l", ":", "r", "]", "for", "l", ",", "r", "in", "zip", "(", "*", "self", ".", "bounds", ")", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile.oslicer
Opposite slicer, the outer part wrt to a field
peri/util.py
def oslicer(self, tile): """ Opposite slicer, the outer part wrt to a field """ mask = None vecs = tile.coords(form='meshed') for v in vecs: v[self.slicer] = -1 mask = mask & (v > 0) if mask is not None else (v>0) return tuple(np.array(i).astype('int') for...
def oslicer(self, tile): """ Opposite slicer, the outer part wrt to a field """ mask = None vecs = tile.coords(form='meshed') for v in vecs: v[self.slicer] = -1 mask = mask & (v > 0) if mask is not None else (v>0) return tuple(np.array(i).astype('int') for...
[ "Opposite", "slicer", "the", "outer", "part", "wrt", "to", "a", "field" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L310-L317
[ "def", "oslicer", "(", "self", ",", "tile", ")", ":", "mask", "=", "None", "vecs", "=", "tile", ".", "coords", "(", "form", "=", "'meshed'", ")", "for", "v", "in", "vecs", ":", "v", "[", "self", ".", "slicer", "]", "=", "-", "1", "mask", "=", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile.kcenter
Return the frequency center of the tile (says fftshift)
peri/util.py
def kcenter(self): """ Return the frequency center of the tile (says fftshift) """ return np.array([ np.abs(np.fft.fftshift(np.fft.fftfreq(q))).argmin() for q in self.shape ]).astype('float')
def kcenter(self): """ Return the frequency center of the tile (says fftshift) """ return np.array([ np.abs(np.fft.fftshift(np.fft.fftfreq(q))).argmin() for q in self.shape ]).astype('float')
[ "Return", "the", "frequency", "center", "of", "the", "tile", "(", "says", "fftshift", ")" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L351-L356
[ "def", "kcenter", "(", "self", ")", ":", "return", "np", ".", "array", "(", "[", "np", ".", "abs", "(", "np", ".", "fft", ".", "fftshift", "(", "np", ".", "fft", ".", "fftfreq", "(", "q", ")", ")", ")", ".", "argmin", "(", ")", "for", "q", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile.corners
Iterate the vector of all corners of the hyperrectangles >>> Tile(3, dim=2).corners array([[0, 0], [0, 3], [3, 0], [3, 3]])
peri/util.py
def corners(self): """ Iterate the vector of all corners of the hyperrectangles >>> Tile(3, dim=2).corners array([[0, 0], [0, 3], [3, 0], [3, 3]]) """ corners = [] for ind in itertools.product(*((0,1),)*self.dim): ...
def corners(self): """ Iterate the vector of all corners of the hyperrectangles >>> Tile(3, dim=2).corners array([[0, 0], [0, 3], [3, 0], [3, 3]]) """ corners = [] for ind in itertools.product(*((0,1),)*self.dim): ...
[ "Iterate", "the", "vector", "of", "all", "corners", "of", "the", "hyperrectangles" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L359-L373
[ "def", "corners", "(", "self", ")", ":", "corners", "=", "[", "]", "for", "ind", "in", "itertools", ".", "product", "(", "*", "(", "(", "0", ",", "1", ")", ",", ")", "*", "self", ".", "dim", ")", ":", "ind", "=", "np", ".", "array", "(", "i...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile._format_vector
Format a 3d vector field in certain ways, see `coords` for a description of each formatting method.
peri/util.py
def _format_vector(self, vecs, form='broadcast'): """ Format a 3d vector field in certain ways, see `coords` for a description of each formatting method. """ if form == 'meshed': return np.meshgrid(*vecs, indexing='ij') elif form == 'vector': vecs ...
def _format_vector(self, vecs, form='broadcast'): """ Format a 3d vector field in certain ways, see `coords` for a description of each formatting method. """ if form == 'meshed': return np.meshgrid(*vecs, indexing='ij') elif form == 'vector': vecs ...
[ "Format", "a", "3d", "vector", "field", "in", "certain", "ways", "see", "coords", "for", "a", "description", "of", "each", "formatting", "method", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L375-L388
[ "def", "_format_vector", "(", "self", ",", "vecs", ",", "form", "=", "'broadcast'", ")", ":", "if", "form", "==", "'meshed'", ":", "return", "np", ".", "meshgrid", "(", "*", "vecs", ",", "indexing", "=", "'ij'", ")", "elif", "form", "==", "'vector'", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile.coords
Returns the coordinate vectors associated with the tile. Parameters ----------- norm : boolean can rescale the coordinates for you. False is no rescaling, True is rescaling so that all coordinates are from 0 -> 1. If a scalar, the same norm is applied unifor...
peri/util.py
def coords(self, norm=False, form='broadcast'): """ Returns the coordinate vectors associated with the tile. Parameters ----------- norm : boolean can rescale the coordinates for you. False is no rescaling, True is rescaling so that all coordinates are fr...
def coords(self, norm=False, form='broadcast'): """ Returns the coordinate vectors associated with the tile. Parameters ----------- norm : boolean can rescale the coordinates for you. False is no rescaling, True is rescaling so that all coordinates are fr...
[ "Returns", "the", "coordinate", "vectors", "associated", "with", "the", "tile", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L390-L440
[ "def", "coords", "(", "self", ",", "norm", "=", "False", ",", "form", "=", "'broadcast'", ")", ":", "if", "norm", "is", "False", ":", "norm", "=", "1", "if", "norm", "is", "True", ":", "norm", "=", "np", ".", "array", "(", "self", ".", "shape", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile.kvectors
Return the kvectors associated with this tile, given the standard form of -0.5 to 0.5. `norm` and `form` arguments arethe same as that passed to `Tile.coords`. Parameters ----------- real : boolean whether to return kvectors associated with the real fft instead
peri/util.py
def kvectors(self, norm=False, form='broadcast', real=False, shift=False): """ Return the kvectors associated with this tile, given the standard form of -0.5 to 0.5. `norm` and `form` arguments arethe same as that passed to `Tile.coords`. Parameters ----------- r...
def kvectors(self, norm=False, form='broadcast', real=False, shift=False): """ Return the kvectors associated with this tile, given the standard form of -0.5 to 0.5. `norm` and `form` arguments arethe same as that passed to `Tile.coords`. Parameters ----------- r...
[ "Return", "the", "kvectors", "associated", "with", "this", "tile", "given", "the", "standard", "form", "of", "-", "0", ".", "5", "to", "0", ".", "5", ".", "norm", "and", "form", "arguments", "arethe", "same", "as", "that", "passed", "to", "Tile", ".", ...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L442-L467
[ "def", "kvectors", "(", "self", ",", "norm", "=", "False", ",", "form", "=", "'broadcast'", ",", "real", "=", "False", ",", "shift", "=", "False", ")", ":", "if", "norm", "is", "False", ":", "norm", "=", "1", "if", "norm", "is", "True", ":", "nor...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile.contains
Test whether coordinates are contained within this tile. Parameters ---------- items : ndarray [3] or [N, 3] N coordinates to check are within the bounds of the tile pad : integer or ndarray [3] anisotropic padding to apply in the contain test Examples ...
peri/util.py
def contains(self, items, pad=0): """ Test whether coordinates are contained within this tile. Parameters ---------- items : ndarray [3] or [N, 3] N coordinates to check are within the bounds of the tile pad : integer or ndarray [3] anisotropic p...
def contains(self, items, pad=0): """ Test whether coordinates are contained within this tile. Parameters ---------- items : ndarray [3] or [N, 3] N coordinates to check are within the bounds of the tile pad : integer or ndarray [3] anisotropic p...
[ "Test", "whether", "coordinates", "are", "contained", "within", "this", "tile", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L477-L499
[ "def", "contains", "(", "self", ",", "items", ",", "pad", "=", "0", ")", ":", "o", "=", "(", "(", "items", ">=", "self", ".", "l", "-", "pad", ")", "&", "(", "items", "<", "self", ".", "r", "+", "pad", ")", ")", "if", "len", "(", "o", "."...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile.intersection
Intersection of tiles, returned as a tile >>> Tile.intersection(Tile([0, 1], [5, 4]), Tile([1, 0], [4, 5])) Tile [1, 1] -> [4, 4] ([3, 3])
peri/util.py
def intersection(tiles, *args): """ Intersection of tiles, returned as a tile >>> Tile.intersection(Tile([0, 1], [5, 4]), Tile([1, 0], [4, 5])) Tile [1, 1] -> [4, 4] ([3, 3]) """ tiles = listify(tiles) + listify(args) if len(tiles) < 2: return tiles[...
def intersection(tiles, *args): """ Intersection of tiles, returned as a tile >>> Tile.intersection(Tile([0, 1], [5, 4]), Tile([1, 0], [4, 5])) Tile [1, 1] -> [4, 4] ([3, 3]) """ tiles = listify(tiles) + listify(args) if len(tiles) < 2: return tiles[...
[ "Intersection", "of", "tiles", "returned", "as", "a", "tile" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L502-L519
[ "def", "intersection", "(", "tiles", ",", "*", "args", ")", ":", "tiles", "=", "listify", "(", "tiles", ")", "+", "listify", "(", "args", ")", "if", "len", "(", "tiles", ")", "<", "2", ":", "return", "tiles", "[", "0", "]", "tile", "=", "tiles", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile.translate
Translate a tile by an amount dr >>> Tile(5).translate(1) Tile [1, 1, 1] -> [6, 6, 6] ([5, 5, 5])
peri/util.py
def translate(self, dr): """ Translate a tile by an amount dr >>> Tile(5).translate(1) Tile [1, 1, 1] -> [6, 6, 6] ([5, 5, 5]) """ tile = self.copy() tile.l += dr tile.r += dr return tile
def translate(self, dr): """ Translate a tile by an amount dr >>> Tile(5).translate(1) Tile [1, 1, 1] -> [6, 6, 6] ([5, 5, 5]) """ tile = self.copy() tile.l += dr tile.r += dr return tile
[ "Translate", "a", "tile", "by", "an", "amount", "dr" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L560-L570
[ "def", "translate", "(", "self", ",", "dr", ")", ":", "tile", "=", "self", ".", "copy", "(", ")", "tile", ".", "l", "+=", "dr", "tile", ".", "r", "+=", "dr", "return", "tile" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile.pad
Pad this tile by an equal amount on each side as specified by pad >>> Tile(10).pad(2) Tile [-2, -2, -2] -> [12, 12, 12] ([14, 14, 14]) >>> Tile(10).pad([1,2,3]) Tile [-1, -2, -3] -> [11, 12, 13] ([12, 14, 16])
peri/util.py
def pad(self, pad): """ Pad this tile by an equal amount on each side as specified by pad >>> Tile(10).pad(2) Tile [-2, -2, -2] -> [12, 12, 12] ([14, 14, 14]) >>> Tile(10).pad([1,2,3]) Tile [-1, -2, -3] -> [11, 12, 13] ([12, 14, 16]) """ tile = self.copy...
def pad(self, pad): """ Pad this tile by an equal amount on each side as specified by pad >>> Tile(10).pad(2) Tile [-2, -2, -2] -> [12, 12, 12] ([14, 14, 14]) >>> Tile(10).pad([1,2,3]) Tile [-1, -2, -3] -> [11, 12, 13] ([12, 14, 16]) """ tile = self.copy...
[ "Pad", "this", "tile", "by", "an", "equal", "amount", "on", "each", "side", "as", "specified", "by", "pad" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L572-L585
[ "def", "pad", "(", "self", ",", "pad", ")", ":", "tile", "=", "self", ".", "copy", "(", ")", "tile", ".", "l", "-=", "pad", "tile", ".", "r", "+=", "pad", "return", "tile" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile.overhang
Get the left and right absolute overflow -- the amount of box overhanging `tile`, can be viewed as self \\ tile (set theory relative complement, but in a bounding sense)
peri/util.py
def overhang(self, tile): """ Get the left and right absolute overflow -- the amount of box overhanging `tile`, can be viewed as self \\ tile (set theory relative complement, but in a bounding sense) """ ll = np.abs(amin(self.l - tile.l, aN(0, dim=self.dim))) rr =...
def overhang(self, tile): """ Get the left and right absolute overflow -- the amount of box overhanging `tile`, can be viewed as self \\ tile (set theory relative complement, but in a bounding sense) """ ll = np.abs(amin(self.l - tile.l, aN(0, dim=self.dim))) rr =...
[ "Get", "the", "left", "and", "right", "absolute", "overflow", "--", "the", "amount", "of", "box", "overhanging", "tile", "can", "be", "viewed", "as", "self", "\\\\", "tile", "(", "set", "theory", "relative", "complement", "but", "in", "a", "bounding", "sen...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L587-L595
[ "def", "overhang", "(", "self", ",", "tile", ")", ":", "ll", "=", "np", ".", "abs", "(", "amin", "(", "self", ".", "l", "-", "tile", ".", "l", ",", "aN", "(", "0", ",", "dim", "=", "self", ".", "dim", ")", ")", ")", "rr", "=", "np", ".", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Tile.reflect_overhang
Compute the overhang and reflect it internally so respect periodic padding rules (see states._tile_from_particle_change). Returns both the inner tile and the inner tile with necessary pad.
peri/util.py
def reflect_overhang(self, clip): """ Compute the overhang and reflect it internally so respect periodic padding rules (see states._tile_from_particle_change). Returns both the inner tile and the inner tile with necessary pad. """ orig = self.copy() tile = self.co...
def reflect_overhang(self, clip): """ Compute the overhang and reflect it internally so respect periodic padding rules (see states._tile_from_particle_change). Returns both the inner tile and the inner tile with necessary pad. """ orig = self.copy() tile = self.co...
[ "Compute", "the", "overhang", "and", "reflect", "it", "internally", "so", "respect", "periodic", "padding", "rules", "(", "see", "states", ".", "_tile_from_particle_change", ")", ".", "Returns", "both", "the", "inner", "tile", "and", "the", "inner", "tile", "w...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L597-L612
[ "def", "reflect_overhang", "(", "self", ",", "clip", ")", ":", "orig", "=", "self", ".", "copy", "(", ")", "tile", "=", "self", ".", "copy", "(", ")", "hangl", ",", "hangr", "=", "tile", ".", "overhang", "(", "clip", ")", "tile", "=", "tile", "."...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Image.filtered_image
Returns a filtered image after applying the Fourier-space filters
peri/util.py
def filtered_image(self, im): """Returns a filtered image after applying the Fourier-space filters""" q = np.fft.fftn(im) for k,v in self.filters: q[k] -= v return np.real(np.fft.ifftn(q))
def filtered_image(self, im): """Returns a filtered image after applying the Fourier-space filters""" q = np.fft.fftn(im) for k,v in self.filters: q[k] -= v return np.real(np.fft.ifftn(q))
[ "Returns", "a", "filtered", "image", "after", "applying", "the", "Fourier", "-", "space", "filters" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L665-L670
[ "def", "filtered_image", "(", "self", ",", "im", ")", ":", "q", "=", "np", ".", "fft", ".", "fftn", "(", "im", ")", "for", "k", ",", "v", "in", "self", ".", "filters", ":", "q", "[", "k", "]", "-=", "v", "return", "np", ".", "real", "(", "n...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Image.set_filter
Sets Fourier-space filters for the image. The image is filtered by subtracting values from the image at slices. Parameters ---------- slices : List of indices or slice objects. The q-values in Fourier space to filter. values : np.ndarray The complete arra...
peri/util.py
def set_filter(self, slices, values): """ Sets Fourier-space filters for the image. The image is filtered by subtracting values from the image at slices. Parameters ---------- slices : List of indices or slice objects. The q-values in Fourier space to filter....
def set_filter(self, slices, values): """ Sets Fourier-space filters for the image. The image is filtered by subtracting values from the image at slices. Parameters ---------- slices : List of indices or slice objects. The q-values in Fourier space to filter....
[ "Sets", "Fourier", "-", "space", "filters", "for", "the", "image", ".", "The", "image", "is", "filtered", "by", "subtracting", "values", "from", "the", "image", "at", "slices", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L676-L699
[ "def", "set_filter", "(", "self", ",", "slices", ",", "values", ")", ":", "self", ".", "filters", "=", "[", "[", "sl", ",", "values", "[", "sl", "]", "]", "for", "sl", "in", "slices", "]" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
RawImage.load_image
Read the file and perform any transforms to get a loaded image
peri/util.py
def load_image(self): """ Read the file and perform any transforms to get a loaded image """ try: image = initializers.load_tiff(self.filename) image = initializers.normalize( image, invert=self.invert, scale=self.exposure, dtype=self.float_precisi...
def load_image(self): """ Read the file and perform any transforms to get a loaded image """ try: image = initializers.load_tiff(self.filename) image = initializers.normalize( image, invert=self.invert, scale=self.exposure, dtype=self.float_precisi...
[ "Read", "the", "file", "and", "perform", "any", "transforms", "to", "get", "a", "loaded", "image" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L793-L805
[ "def", "load_image", "(", "self", ")", ":", "try", ":", "image", "=", "initializers", ".", "load_tiff", "(", "self", ".", "filename", ")", "image", "=", "initializers", ".", "normalize", "(", "image", ",", "invert", "=", "self", ".", "invert", ",", "sc...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
RawImage.get_scale
If exposure was not set in the __init__, get the exposure associated with this RawImage so that it may be used in other :class:`~peri.util.RawImage`. This is useful for transferring exposure parameters to a series of images. Returns ------- exposure : tuple of floats ...
peri/util.py
def get_scale(self): """ If exposure was not set in the __init__, get the exposure associated with this RawImage so that it may be used in other :class:`~peri.util.RawImage`. This is useful for transferring exposure parameters to a series of images. Returns -----...
def get_scale(self): """ If exposure was not set in the __init__, get the exposure associated with this RawImage so that it may be used in other :class:`~peri.util.RawImage`. This is useful for transferring exposure parameters to a series of images. Returns -----...
[ "If", "exposure", "was", "not", "set", "in", "the", "__init__", "get", "the", "exposure", "associated", "with", "this", "RawImage", "so", "that", "it", "may", "be", "used", "in", "other", ":", "class", ":", "~peri", ".", "util", ".", "RawImage", ".", "...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L818-L834
[ "def", "get_scale", "(", "self", ")", ":", "if", "self", ".", "exposure", "is", "not", "None", ":", "return", "self", ".", "exposure", "raw", "=", "initializers", ".", "load_tiff", "(", "self", ".", "filename", ")", "return", "raw", ".", "min", "(", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
RawImage.get_scale_from_raw
When given a raw image and the scaled version of the same image, it extracts the ``exposure`` parameters associated with those images. This is useful when Parameters ---------- raw : array_like The image loaded fresh from a file scaled : array_like ...
peri/util.py
def get_scale_from_raw(raw, scaled): """ When given a raw image and the scaled version of the same image, it extracts the ``exposure`` parameters associated with those images. This is useful when Parameters ---------- raw : array_like The image loaded...
def get_scale_from_raw(raw, scaled): """ When given a raw image and the scaled version of the same image, it extracts the ``exposure`` parameters associated with those images. This is useful when Parameters ---------- raw : array_like The image loaded...
[ "When", "given", "a", "raw", "image", "and", "the", "scaled", "version", "of", "the", "same", "image", "it", "extracts", "the", "exposure", "parameters", "associated", "with", "those", "images", ".", "This", "is", "useful", "when" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L837-L863
[ "def", "get_scale_from_raw", "(", "raw", ",", "scaled", ")", ":", "t0", ",", "t1", "=", "scaled", ".", "min", "(", ")", ",", "scaled", ".", "max", "(", ")", "r0", ",", "r1", "=", "float", "(", "raw", ".", "min", "(", ")", ")", ",", "float", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ProgressBar._draw
Interal draw method, simply prints to screen
peri/util.py
def _draw(self): """ Interal draw method, simply prints to screen """ if self.display: print(self._formatstr.format(**self.__dict__), end='') sys.stdout.flush()
def _draw(self): """ Interal draw method, simply prints to screen """ if self.display: print(self._formatstr.format(**self.__dict__), end='') sys.stdout.flush()
[ "Interal", "draw", "method", "simply", "prints", "to", "screen" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L1004-L1008
[ "def", "_draw", "(", "self", ")", ":", "if", "self", ".", "display", ":", "print", "(", "self", ".", "_formatstr", ".", "format", "(", "*", "*", "self", ".", "__dict__", ")", ",", "end", "=", "''", ")", "sys", ".", "stdout", ".", "flush", "(", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
ProgressBar.update
Update the value of the progress and update progress bar. Parameters ----------- value : integer The current iteration of the progress
peri/util.py
def update(self, value=0): """ Update the value of the progress and update progress bar. Parameters ----------- value : integer The current iteration of the progress """ self._deltas.append(time.time()) self.value = value self._percen...
def update(self, value=0): """ Update the value of the progress and update progress bar. Parameters ----------- value : integer The current iteration of the progress """ self._deltas.append(time.time()) self.value = value self._percen...
[ "Update", "the", "value", "of", "the", "progress", "and", "update", "progress", "bar", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/util.py#L1013-L1035
[ "def", "update", "(", "self", ",", "value", "=", "0", ")", ":", "self", ".", "_deltas", ".", "append", "(", "time", ".", "time", "(", ")", ")", "self", ".", "value", "=", "value", "self", ".", "_percent", "=", "100.0", "*", "self", ".", "value", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
InvenioGroups.init_app
Flask application initialization.
invenio_groups/ext.py
def init_app(self, app): """Flask application initialization.""" self.init_config(app) app.register_blueprint(blueprint) app.extensions['invenio-groups'] = self
def init_app(self, app): """Flask application initialization.""" self.init_config(app) app.register_blueprint(blueprint) app.extensions['invenio-groups'] = self
[ "Flask", "application", "initialization", "." ]
inveniosoftware-contrib/invenio-groups
python
https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/ext.py#L40-L44
[ "def", "init_app", "(", "self", ",", "app", ")", ":", "self", ".", "init_config", "(", "app", ")", "app", ".", "register_blueprint", "(", "blueprint", ")", "app", ".", "extensions", "[", "'invenio-groups'", "]", "=", "self" ]
109481d6b02701db00b72223dd4a65e167c589a6
valid
Model.check_consistency
Make sure that the required comps are included in the list of components supplied by the user. Also check that the parameters are consistent across the many components.
peri/models.py
def check_consistency(self): """ Make sure that the required comps are included in the list of components supplied by the user. Also check that the parameters are consistent across the many components. """ error = False regex = re.compile('([a-zA-Z_][a-zA-Z0-9_]*)...
def check_consistency(self): """ Make sure that the required comps are included in the list of components supplied by the user. Also check that the parameters are consistent across the many components. """ error = False regex = re.compile('([a-zA-Z_][a-zA-Z0-9_]*)...
[ "Make", "sure", "that", "the", "required", "comps", "are", "included", "in", "the", "list", "of", "components", "supplied", "by", "the", "user", ".", "Also", "check", "that", "the", "parameters", "are", "consistent", "across", "the", "many", "components", "....
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/models.py#L81-L111
[ "def", "check_consistency", "(", "self", ")", ":", "error", "=", "False", "regex", "=", "re", ".", "compile", "(", "'([a-zA-Z_][a-zA-Z0-9_]*)'", ")", "# there at least must be the full model, not necessarily partial updates", "if", "'full'", "not", "in", "self", ".", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Model.check_inputs
Check that the list of components `comp` is compatible with both the varmap and modelstr for this Model
peri/models.py
def check_inputs(self, comps): """ Check that the list of components `comp` is compatible with both the varmap and modelstr for this Model """ error = False compcats = [c.category for c in comps] # Check that the components are all provided, given the categories ...
def check_inputs(self, comps): """ Check that the list of components `comp` is compatible with both the varmap and modelstr for this Model """ error = False compcats = [c.category for c in comps] # Check that the components are all provided, given the categories ...
[ "Check", "that", "the", "list", "of", "components", "comp", "is", "compatible", "with", "both", "the", "varmap", "and", "modelstr", "for", "this", "Model" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/models.py#L113-L131
[ "def", "check_inputs", "(", "self", ",", "comps", ")", ":", "error", "=", "False", "compcats", "=", "[", "c", ".", "category", "for", "c", "in", "comps", "]", "# Check that the components are all provided, given the categories", "for", "k", ",", "v", "in", "it...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Model.get_difference_model
Get the equation corresponding to a variation wrt category. For example if:: modelstr = { 'full' :'H(I) + B', 'dH' : 'dH(I)', 'dI' : 'H(dI)', 'dB' : 'dB' } varmap = {'H': 'psf', 'I': 'obj', 'B': 'bkg'} ...
peri/models.py
def get_difference_model(self, category): """ Get the equation corresponding to a variation wrt category. For example if:: modelstr = { 'full' :'H(I) + B', 'dH' : 'dH(I)', 'dI' : 'H(dI)', 'dB' : 'dB' } ...
def get_difference_model(self, category): """ Get the equation corresponding to a variation wrt category. For example if:: modelstr = { 'full' :'H(I) + B', 'dH' : 'dH(I)', 'dI' : 'H(dI)', 'dB' : 'dB' } ...
[ "Get", "the", "equation", "corresponding", "to", "a", "variation", "wrt", "category", ".", "For", "example", "if", "::" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/models.py#L141-L158
[ "def", "get_difference_model", "(", "self", ",", "category", ")", ":", "name", "=", "self", ".", "diffname", "(", "self", ".", "ivarmap", "[", "category", "]", ")", "return", "self", ".", "modelstr", ".", "get", "(", "name", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Model.map_vars
Map component function ``funcname`` result into model variables dictionary for use in eval of the model. If ``diffmap`` is provided then that symbol is translated into 'd'+diffmap.key and is replaced by diffmap.value. ``**kwargs` are passed to the ``comp.funcname(**kwargs)``.
peri/models.py
def map_vars(self, comps, funcname='get', diffmap=None, **kwargs): """ Map component function ``funcname`` result into model variables dictionary for use in eval of the model. If ``diffmap`` is provided then that symbol is translated into 'd'+diffmap.key and is replaced by diffma...
def map_vars(self, comps, funcname='get', diffmap=None, **kwargs): """ Map component function ``funcname`` result into model variables dictionary for use in eval of the model. If ``diffmap`` is provided then that symbol is translated into 'd'+diffmap.key and is replaced by diffma...
[ "Map", "component", "function", "funcname", "result", "into", "model", "variables", "dictionary", "for", "use", "in", "eval", "of", "the", "model", ".", "If", "diffmap", "is", "provided", "then", "that", "symbol", "is", "translated", "into", "d", "+", "diffm...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/models.py#L160-L180
[ "def", "map_vars", "(", "self", ",", "comps", ",", "funcname", "=", "'get'", ",", "diffmap", "=", "None", ",", "*", "*", "kwargs", ")", ":", "out", "=", "{", "}", "diffmap", "=", "diffmap", "or", "{", "}", "for", "c", "in", "comps", ":", "cat", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
Model.evaluate
Calculate the output of a model. It is recommended that at some point before using `evaluate`, that you make sure the inputs are valid using :class:`~peri.models.Model.check_inputs` Parameters ----------- comps : list of :class:`~peri.comp.comp.Component` Components ...
peri/models.py
def evaluate(self, comps, funcname='get', diffmap=None, **kwargs): """ Calculate the output of a model. It is recommended that at some point before using `evaluate`, that you make sure the inputs are valid using :class:`~peri.models.Model.check_inputs` Parameters -------...
def evaluate(self, comps, funcname='get', diffmap=None, **kwargs): """ Calculate the output of a model. It is recommended that at some point before using `evaluate`, that you make sure the inputs are valid using :class:`~peri.models.Model.check_inputs` Parameters -------...
[ "Calculate", "the", "output", "of", "a", "model", ".", "It", "is", "recommended", "that", "at", "some", "point", "before", "using", "evaluate", "that", "you", "make", "sure", "the", "inputs", "are", "valid", "using", ":", "class", ":", "~peri", ".", "mod...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/models.py#L182-L212
[ "def", "evaluate", "(", "self", ",", "comps", ",", "funcname", "=", "'get'", ",", "diffmap", "=", "None", ",", "*", "*", "kwargs", ")", ":", "evar", "=", "self", ".", "map_vars", "(", "comps", ",", "funcname", ",", "diffmap", "=", "diffmap", ")", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
lbl
Put a figure label in an axis
peri/viz/plots.py
def lbl(axis, label, size=22): """ Put a figure label in an axis """ at = AnchoredText(label, loc=2, prop=dict(size=size), frameon=True) at.patch.set_boxstyle("round,pad=0.,rounding_size=0.0") #bb = axis.get_yaxis_transform() #at = AnchoredText(label, # loc=3, prop=dict(size=18), frameon=...
def lbl(axis, label, size=22): """ Put a figure label in an axis """ at = AnchoredText(label, loc=2, prop=dict(size=size), frameon=True) at.patch.set_boxstyle("round,pad=0.,rounding_size=0.0") #bb = axis.get_yaxis_transform() #at = AnchoredText(label, # loc=3, prop=dict(size=18), frameon=...
[ "Put", "a", "figure", "label", "in", "an", "axis" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/viz/plots.py#L30-L40
[ "def", "lbl", "(", "axis", ",", "label", ",", "size", "=", "22", ")", ":", "at", "=", "AnchoredText", "(", "label", ",", "loc", "=", "2", ",", "prop", "=", "dict", "(", "size", "=", "size", ")", ",", "frameon", "=", "True", ")", "at", ".", "p...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
generative_model
Samples x,y,z,r are created by: b = s.blocks_particle(#) h = runner.sample_state(s, b, stepout=0.05, N=2000, doprint=True) z,y,x,r = h.get_histogram().T
peri/viz/plots.py
def generative_model(s,x,y,z,r, factor=1.1): """ Samples x,y,z,r are created by: b = s.blocks_particle(#) h = runner.sample_state(s, b, stepout=0.05, N=2000, doprint=True) z,y,x,r = h.get_histogram().T """ pl.close('all') slicez = int(round(z.mean())) slicex = s.image.shape[2]//2 ...
def generative_model(s,x,y,z,r, factor=1.1): """ Samples x,y,z,r are created by: b = s.blocks_particle(#) h = runner.sample_state(s, b, stepout=0.05, N=2000, doprint=True) z,y,x,r = h.get_histogram().T """ pl.close('all') slicez = int(round(z.mean())) slicex = s.image.shape[2]//2 ...
[ "Samples", "x", "y", "z", "r", "are", "created", "by", ":", "b", "=", "s", ".", "blocks_particle", "(", "#", ")", "h", "=", "runner", ".", "sample_state", "(", "s", "b", "stepout", "=", "0", ".", "05", "N", "=", "2000", "doprint", "=", "True", ...
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/viz/plots.py#L280-L406
[ "def", "generative_model", "(", "s", ",", "x", ",", "y", ",", "z", ",", "r", ",", "factor", "=", "1.1", ")", ":", "pl", ".", "close", "(", "'all'", ")", "slicez", "=", "int", "(", "round", "(", "z", ".", "mean", "(", ")", ")", ")", "slicex", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
examine_unexplained_noise
Compares a state's residuals in real and Fourier space with a Gaussian. Point out that Fourier space should always be Gaussian and white Parameters ---------- state : `peri.states.State` The state to examine. bins : int or sequence of scalars or str, optional The nu...
peri/viz/plots.py
def examine_unexplained_noise(state, bins=1000, xlim=(-10,10)): """ Compares a state's residuals in real and Fourier space with a Gaussian. Point out that Fourier space should always be Gaussian and white Parameters ---------- state : `peri.states.State` The state to examine. ...
def examine_unexplained_noise(state, bins=1000, xlim=(-10,10)): """ Compares a state's residuals in real and Fourier space with a Gaussian. Point out that Fourier space should always be Gaussian and white Parameters ---------- state : `peri.states.State` The state to examine. ...
[ "Compares", "a", "state", "s", "residuals", "in", "real", "and", "Fourier", "space", "with", "a", "Gaussian", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/viz/plots.py#L421-L468
[ "def", "examine_unexplained_noise", "(", "state", ",", "bins", "=", "1000", ",", "xlim", "=", "(", "-", "10", ",", "10", ")", ")", ":", "r", "=", "state", ".", "residuals", "q", "=", "np", ".", "fft", ".", "fftn", "(", "r", ")", "#Get the expected ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
compare_data_model_residuals
Compare the data, model, and residuals of a state. Makes an image of any 2D slice of a state that compares the data, model, and residuals. The upper left portion of the image is the raw data, the central portion the model, and the lower right portion the image. Either plots the image using plt.imshow()...
peri/viz/plots.py
def compare_data_model_residuals(s, tile, data_vmin='calc', data_vmax='calc', res_vmin=-0.1, res_vmax=0.1, edgepts='calc', do_imshow=True, data_cmap=plt.cm.bone, res_cmap=plt.cm.RdBu): """ Compare the data, model, and residuals of a state. Makes an image of any 2D slice of a state that co...
def compare_data_model_residuals(s, tile, data_vmin='calc', data_vmax='calc', res_vmin=-0.1, res_vmax=0.1, edgepts='calc', do_imshow=True, data_cmap=plt.cm.bone, res_cmap=plt.cm.RdBu): """ Compare the data, model, and residuals of a state. Makes an image of any 2D slice of a state that co...
[ "Compare", "the", "data", "model", "and", "residuals", "of", "a", "state", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/viz/plots.py#L470-L557
[ "def", "compare_data_model_residuals", "(", "s", ",", "tile", ",", "data_vmin", "=", "'calc'", ",", "data_vmax", "=", "'calc'", ",", "res_vmin", "=", "-", "0.1", ",", "res_vmax", "=", "0.1", ",", "edgepts", "=", "'calc'", ",", "do_imshow", "=", "True", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
trisect_image
Returns 3 masks that trisect an image into 3 triangular portions. Parameters ---------- imshape : 2-element list-like of ints The shape of the image. Elements after the first 2 are ignored. edgepts : Nested list-like, float, or `calc`, optional. The vertices of the tria...
peri/viz/plots.py
def trisect_image(imshape, edgepts='calc'): """ Returns 3 masks that trisect an image into 3 triangular portions. Parameters ---------- imshape : 2-element list-like of ints The shape of the image. Elements after the first 2 are ignored. edgepts : Nested list-like, float, o...
def trisect_image(imshape, edgepts='calc'): """ Returns 3 masks that trisect an image into 3 triangular portions. Parameters ---------- imshape : 2-element list-like of ints The shape of the image. Elements after the first 2 are ignored. edgepts : Nested list-like, float, o...
[ "Returns", "3", "masks", "that", "trisect", "an", "image", "into", "3", "triangular", "portions", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/viz/plots.py#L559-L610
[ "def", "trisect_image", "(", "imshape", ",", "edgepts", "=", "'calc'", ")", ":", "im_x", ",", "im_y", "=", "np", ".", "meshgrid", "(", "np", ".", "arange", "(", "imshape", "[", "0", "]", ")", ",", "np", ".", "arange", "(", "imshape", "[", "1", "]...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
center_data
Clips data on [vmin, vmax]; then rescales to [0,1]
peri/viz/plots.py
def center_data(data, vmin, vmax): """Clips data on [vmin, vmax]; then rescales to [0,1]""" ans = data - vmin ans /= (vmax - vmin) return np.clip(ans, 0, 1)
def center_data(data, vmin, vmax): """Clips data on [vmin, vmax]; then rescales to [0,1]""" ans = data - vmin ans /= (vmax - vmin) return np.clip(ans, 0, 1)
[ "Clips", "data", "on", "[", "vmin", "vmax", "]", ";", "then", "rescales", "to", "[", "0", "1", "]" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/viz/plots.py#L615-L619
[ "def", "center_data", "(", "data", ",", "vmin", ",", "vmax", ")", ":", "ans", "=", "data", "-", "vmin", "ans", "/=", "(", "vmax", "-", "vmin", ")", "return", "np", ".", "clip", "(", "ans", ",", "0", ",", "1", ")" ]
61beed5deaaf978ab31ed716e8470d86ba639867
valid
sim_crb_diff
each element of std0 should correspond with the element of std1
peri/viz/plots.py
def sim_crb_diff(std0, std1, N=10000): """ each element of std0 should correspond with the element of std1 """ a = std0*np.random.randn(N, len(std0)) b = std1*np.random.randn(N, len(std1)) return a - b
def sim_crb_diff(std0, std1, N=10000): """ each element of std0 should correspond with the element of std1 """ a = std0*np.random.randn(N, len(std0)) b = std1*np.random.randn(N, len(std1)) return a - b
[ "each", "element", "of", "std0", "should", "correspond", "with", "the", "element", "of", "std1" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/viz/plots.py#L621-L625
[ "def", "sim_crb_diff", "(", "std0", ",", "std1", ",", "N", "=", "10000", ")", ":", "a", "=", "std0", "*", "np", ".", "random", ".", "randn", "(", "N", ",", "len", "(", "std0", ")", ")", "b", "=", "std1", "*", "np", ".", "random", ".", "randn"...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
crb_compare
To run, do: s,h = pickle... s1,h1 = pickle... i.e. /media/scratch/bamf/vacancy/vacancy_zoom-1.tif_t002.tif-featured-v2.pkl i.e. /media/scratch/bamf/frozen-particles/0.tif-featured-full.pkl crb0 = diag_crb_particles(s); crb1 = diag_crb_particles(s1) crb_compare(s,h[-25:],s1,h1[-25:], crb...
peri/viz/plots.py
def crb_compare(state0, samples0, state1, samples1, crb0=None, crb1=None, zlayer=None, xlayer=None): """ To run, do: s,h = pickle... s1,h1 = pickle... i.e. /media/scratch/bamf/vacancy/vacancy_zoom-1.tif_t002.tif-featured-v2.pkl i.e. /media/scratch/bamf/frozen-particles/0.tif-fea...
def crb_compare(state0, samples0, state1, samples1, crb0=None, crb1=None, zlayer=None, xlayer=None): """ To run, do: s,h = pickle... s1,h1 = pickle... i.e. /media/scratch/bamf/vacancy/vacancy_zoom-1.tif_t002.tif-featured-v2.pkl i.e. /media/scratch/bamf/frozen-particles/0.tif-fea...
[ "To", "run", "do", ":" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/viz/plots.py#L643-L864
[ "def", "crb_compare", "(", "state0", ",", "samples0", ",", "state1", ",", "samples1", ",", "crb0", "=", "None", ",", "crb1", "=", "None", ",", "zlayer", "=", "None", ",", "xlayer", "=", "None", ")", ":", "s0", "=", "state0", "s1", "=", "state1", "h...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
twoslice
Plot two parts of the ortho view, the two sections given by ``orientation``.
peri/viz/plots.py
def twoslice(field, center=None, size=6.0, cmap='bone_r', vmin=0, vmax=1, orientation='vertical', figpad=1.09, off=0.01): """ Plot two parts of the ortho view, the two sections given by ``orientation``. """ center = center or [i//2 for i in field.shape] slices = [] for i,c in enumerate(c...
def twoslice(field, center=None, size=6.0, cmap='bone_r', vmin=0, vmax=1, orientation='vertical', figpad=1.09, off=0.01): """ Plot two parts of the ortho view, the two sections given by ``orientation``. """ center = center or [i//2 for i in field.shape] slices = [] for i,c in enumerate(c...
[ "Plot", "two", "parts", "of", "the", "ortho", "view", "the", "two", "sections", "given", "by", "orientation", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/viz/plots.py#L939-L989
[ "def", "twoslice", "(", "field", ",", "center", "=", "None", ",", "size", "=", "6.0", ",", "cmap", "=", "'bone_r'", ",", "vmin", "=", "0", ",", "vmax", "=", "1", ",", "orientation", "=", "'vertical'", ",", "figpad", "=", "1.09", ",", "off", "=", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
circles
Plots a set of circles corresponding to a slice through the platonic structure. Copied from twoslice_overlay with comments, standaloneness. Inputs ------ pos : array of particle positions; [N,3] rad : array of particle radii; [N] ax : plt.axis instance layer : Which layer of...
peri/viz/plots.py
def circles(st, layer, axis, ax=None, talpha=1.0, cedge='white', cface='white'): """ Plots a set of circles corresponding to a slice through the platonic structure. Copied from twoslice_overlay with comments, standaloneness. Inputs ------ pos : array of particle positions; [N,3] rad...
def circles(st, layer, axis, ax=None, talpha=1.0, cedge='white', cface='white'): """ Plots a set of circles corresponding to a slice through the platonic structure. Copied from twoslice_overlay with comments, standaloneness. Inputs ------ pos : array of particle positions; [N,3] rad...
[ "Plots", "a", "set", "of", "circles", "corresponding", "to", "a", "slice", "through", "the", "platonic", "structure", ".", "Copied", "from", "twoslice_overlay", "with", "comments", "standaloneness", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/viz/plots.py#L1056-L1103
[ "def", "circles", "(", "st", ",", "layer", ",", "axis", ",", "ax", "=", "None", ",", "talpha", "=", "1.0", ",", "cedge", "=", "'white'", ",", "cface", "=", "'white'", ")", ":", "pos", "=", "st", ".", "obj_get_positions", "(", ")", "rad", "=", "st...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
missing_particle
create a two particle state and compare it to featuring using a single particle guess
scripts/does_matter/missing-particle.py
def missing_particle(separation=0.0, radius=RADIUS, SNR=20): """ create a two particle state and compare it to featuring using a single particle guess """ # create a base image of one particle s = init.create_two_particle_state(imsize=6*radius+4, axis='x', sigma=1.0/SNR, delta=separation, radius...
def missing_particle(separation=0.0, radius=RADIUS, SNR=20): """ create a two particle state and compare it to featuring using a single particle guess """ # create a base image of one particle s = init.create_two_particle_state(imsize=6*radius+4, axis='x', sigma=1.0/SNR, delta=separation, radius...
[ "create", "a", "two", "particle", "state", "and", "compare", "it", "to", "featuring", "using", "a", "single", "particle", "guess" ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/scripts/does_matter/missing-particle.py#L11-L19
[ "def", "missing_particle", "(", "separation", "=", "0.0", ",", "radius", "=", "RADIUS", ",", "SNR", "=", "20", ")", ":", "# create a base image of one particle", "s", "=", "init", ".", "create_two_particle_state", "(", "imsize", "=", "6", "*", "radius", "+", ...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
get_rand_Japprox
Calculates a random approximation to J by returning J only at a set of random pixel/voxel locations. Parameters ---------- s : :class:`peri.states.State` The state to calculate J for. params : List The list of parameter names to calculate the gradient of. num...
peri/opt/optimize.py
def get_rand_Japprox(s, params, num_inds=1000, include_cost=False, **kwargs): """ Calculates a random approximation to J by returning J only at a set of random pixel/voxel locations. Parameters ---------- s : :class:`peri.states.State` The state to calculate J for. param...
def get_rand_Japprox(s, params, num_inds=1000, include_cost=False, **kwargs): """ Calculates a random approximation to J by returning J only at a set of random pixel/voxel locations. Parameters ---------- s : :class:`peri.states.State` The state to calculate J for. param...
[ "Calculates", "a", "random", "approximation", "to", "J", "by", "returning", "J", "only", "at", "a", "set", "of", "random", "pixel", "/", "voxel", "locations", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L64-L114
[ "def", "get_rand_Japprox", "(", "s", ",", "params", ",", "num_inds", "=", "1000", ",", "include_cost", "=", "False", ",", "*", "*", "kwargs", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "tot_pix", "=", "s", ".", "residuals", ".", "siz...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
name_globals
Returns a list of the global parameter names. Parameters ---------- s : :class:`peri.states.ImageState` The state to name the globals of. remove_params : Set or None A set of unique additional parameters to remove from the globals list. Returns -----...
peri/opt/optimize.py
def name_globals(s, remove_params=None): """ Returns a list of the global parameter names. Parameters ---------- s : :class:`peri.states.ImageState` The state to name the globals of. remove_params : Set or None A set of unique additional parameters to remove from...
def name_globals(s, remove_params=None): """ Returns a list of the global parameter names. Parameters ---------- s : :class:`peri.states.ImageState` The state to name the globals of. remove_params : Set or None A set of unique additional parameters to remove from...
[ "Returns", "a", "list", "of", "the", "global", "parameter", "names", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L116-L140
[ "def", "name_globals", "(", "s", ",", "remove_params", "=", "None", ")", ":", "all_params", "=", "s", ".", "params", "for", "p", "in", "s", ".", "param_particle", "(", "np", ".", "arange", "(", "s", ".", "obj_get_positions", "(", ")", ".", "shape", "...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
get_num_px_jtj
Calculates the number of pixels to use for J at a given memory usage. Tries to pick a number of pixels as (size of image / `decimate`). However, clips this to a maximum size and minimum size to ensure that (1) too much memory isn't used and (2) J has enough elements so that the inverse of JTJ will be w...
peri/opt/optimize.py
def get_num_px_jtj(s, nparams, decimate=1, max_mem=1e9, min_redundant=20): """ Calculates the number of pixels to use for J at a given memory usage. Tries to pick a number of pixels as (size of image / `decimate`). However, clips this to a maximum size and minimum size to ensure that (1) too much m...
def get_num_px_jtj(s, nparams, decimate=1, max_mem=1e9, min_redundant=20): """ Calculates the number of pixels to use for J at a given memory usage. Tries to pick a number of pixels as (size of image / `decimate`). However, clips this to a maximum size and minimum size to ensure that (1) too much m...
[ "Calculates", "the", "number", "of", "pixels", "to", "use", "for", "J", "at", "a", "given", "memory", "usage", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L142-L183
[ "def", "get_num_px_jtj", "(", "s", ",", "nparams", ",", "decimate", "=", "1", ",", "max_mem", "=", "1e9", ",", "min_redundant", "=", "20", ")", ":", "#1. Max for a given max_mem:", "px_mem", "=", "int", "(", "max_mem", "//", "8", "//", "nparams", ")", "#...
61beed5deaaf978ab31ed716e8470d86ba639867
valid
vectorize_damping
Returns a non-constant damping vector, allowing certain parameters to be more strongly damped than others. Parameters ---------- params : List The list of parameter names, in order. damping : Float The default value of the damping. increase_list: List ...
peri/opt/optimize.py
def vectorize_damping(params, damping=1.0, increase_list=[['psf-', 1e4]]): """ Returns a non-constant damping vector, allowing certain parameters to be more strongly damped than others. Parameters ---------- params : List The list of parameter names, in order. damping : ...
def vectorize_damping(params, damping=1.0, increase_list=[['psf-', 1e4]]): """ Returns a non-constant damping vector, allowing certain parameters to be more strongly damped than others. Parameters ---------- params : List The list of parameter names, in order. damping : ...
[ "Returns", "a", "non", "-", "constant", "damping", "vector", "allowing", "certain", "parameters", "to", "be", "more", "strongly", "damped", "than", "others", "." ]
peri-source/peri
python
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L185-L210
[ "def", "vectorize_damping", "(", "params", ",", "damping", "=", "1.0", ",", "increase_list", "=", "[", "[", "'psf-'", ",", "1e4", "]", "]", ")", ":", "damp_vec", "=", "np", ".", "ones", "(", "len", "(", "params", ")", ")", "*", "damping", "for", "n...
61beed5deaaf978ab31ed716e8470d86ba639867