Skip to content

Commit

Permalink
Merge pull request #704 from ComputationalCryoEM/docs_fix_702
Browse files Browse the repository at this point in the history
Fix Docstrings Formatting
  • Loading branch information
garrettwrong authored Oct 26, 2022
2 parents 9571203 + ec73eaf commit 0bd790b
Show file tree
Hide file tree
Showing 33 changed files with 204 additions and 118 deletions.
6 changes: 3 additions & 3 deletions src/aspire/apple/apple.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(
Journal of Structural Biology, Vol. 204, No. 2, 11.2018, p. 215-227.
:param particle_size: Particle size (pixels) is required.
Remaining parameters generally have defaults based on particle size.
Remaining parameters generally have defaults based on particle size.
:param min_particle_size:
:param max_particle_size:
:param query_image_size:
Expand All @@ -59,8 +59,8 @@ def __init__(
:param model: One of svm/gaussian_mixture/gaussian_naive_bayes/xgboost/thunder_svm
:param model_opts: Optional dictionary of svm model options. Defaults to None.
:param n_processes: Concurrent processes to spawn.
May improve performance on very large machines.
Otherwise use default of 1.
May improve performance on very large machines.
Otherwise use default of 1.
"""

self.particle_size = particle_size
Expand Down
2 changes: 1 addition & 1 deletion src/aspire/apple/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def extract_references(cls, img, query_size, container_size):
img: Micrograph image.
query_size: Reference images must be of the same size of query images, i.e. (query_size x query_size).
container_size: Containers are large regions used to select reference images. The size of each
region is (container_size x container_size)
region is (container_size x container_size)
Returns:
3D Matrix of reference images. windows[0] is the first reference window.
Expand Down
4 changes: 2 additions & 2 deletions src/aspire/basis/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, size, ell_max=None, dtype=np.float32):
:param size: The size of the vectors for which to define the basis.
Currently only square images and cubic volumes are supported.
:ell_max: The maximum order ell of the basis elements. If no input
:param ell_max: The maximum order ell of the basis elements. If no input
(= None), it will be set to np.Inf and the basis includes all
ell such that the resulting basis vectors are concentrated
below the Nyquist frequency (default Inf).
Expand Down Expand Up @@ -162,7 +162,7 @@ def expand(self, x):
:param x: An array whose last two or three dimensions are to be expanded
the desired basis. These dimensions must equal `self.sz`.
:return : The coefficients of `v` expanded in the desired basis.
:return: The coefficients of `v` expanded in the desired basis.
The last dimension of `v` is with size of `count` and the
first dimensions of the return value correspond to
those first dimensions of `x`.
Expand Down
6 changes: 4 additions & 2 deletions src/aspire/basis/basis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
def check_besselj_zeros(nu, z):
"""
Sanity-check a sequence of estimated zeros of the Bessel function with order `nu`.
:param nu: The real number order of the Bessel function.
:param z: (Array-like) A sequence of postulated zeros.
:return result: True or False.
Expand Down Expand Up @@ -54,7 +55,7 @@ def besselj_newton(nu, z0, max_iter=10):
:param nu: The real number order of the Bessel function.
:param z0: (Array-like) The initial guess(es) for the root-finding algorithm.
:param max_iter: Maximum number of iterations for Newton-Raphson
(default: 10).
(default: 10).
:return z: (Array-like) The estimated root(s).
"""
z = z0
Expand Down Expand Up @@ -254,7 +255,7 @@ def all_besselj_zeros(ell, r):
:param ell: The real number order of the Bessel function.
:param r: The upper bound for zeros returned.
:return n, r0: The number of zeros and the zeros themselves
as a NumPy array.
as a NumPy array.
"""
k = 4
# get the first 4 zeros
Expand All @@ -272,6 +273,7 @@ def all_besselj_zeros(ell, r):
def unique_coords_nd(N, ndim, shifted=False, normalized=True, dtype=np.float32):
"""
Generate unique polar coordinates from 2D or 3D rectangular coordinates.
:param N: length size of a square or cube.
:param ndim: number of dimension, 2 or 3.
:param shifted: shifted half pixel or not for odd N.
Expand Down
4 changes: 2 additions & 2 deletions src/aspire/basis/fb_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ def _evaluate_t(self, v):
must equal `self.sz`.
:return: The evaluation of the coefficient array `v` in the dual basis
of `basis`. This is an array of vectors whose last dimension equals
`self.count` and whose first dimensions correspond to
first dimensions of `v`.
`self.count` and whose first dimensions correspond to
first dimensions of `v`.
"""
v = v.asnumpy().T # RCOPT

Expand Down
3 changes: 2 additions & 1 deletion src/aspire/basis/fb_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, size, ell_max=None, dtype=np.float32):
:param size: The size of the vectors for which to define the basis.
May be a 3-tuple or an integer, in which case a cubic basis is assumed.
Currently only cubic images are supported.
:ell_max: The maximum order ell of the basis elements. If no input
:param ell_max: The maximum order ell of the basis elements. If no input
(= None), it will be set to np.Inf and the basis includes all
ell such that the resulting basis vectors are concentrated
below the Nyquist frequency (default Inf).
Expand Down Expand Up @@ -144,6 +144,7 @@ def basis_norm_3d(self, ell, k):
def _evaluate(self, v):
"""
Evaluate coefficients in standard 3D coordinate basis from those in FB basis
:param v: A coefficient vector (or an array of coefficient vectors) to
be evaluated. The first dimension must equal `self.count`.
:return: The evaluation of the coefficient vector(s) `v` for this basis.
Expand Down
2 changes: 1 addition & 1 deletion src/aspire/basis/ffb_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def _evaluate_t(self, x):
Evaluate coefficient in FB basis from those in standard 2D coordinate basis
:param x: The Image instance representing coefficient array in the
standard 2D coordinate basis to be evaluated.
standard 2D coordinate basis to be evaluated.
:return v: The evaluation of the coefficient array `v` in the FB basis.
This is an array of vectors whose last dimension equals `self.count`
and whose first dimension correspond to `x.n_images`.
Expand Down
2 changes: 1 addition & 1 deletion src/aspire/basis/fpswf_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def evaluate_t(self, images):
Evaluate coefficient vectors in PSWF basis using the fast method.
:param images: Image stack in the standard 2D coordinate basis.
:return : Coefficient array in the PSWF basis.
:return: Coefficient array in the PSWF basis.
"""

if not isinstance(images, Image):
Expand Down
14 changes: 7 additions & 7 deletions src/aspire/basis/fspca.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def __init__(
:param src: Source instance
:param basis: Optional Fourier Bessel Basis (usually FFBBasis2D)
:param components: Optionally assign number of principal components
to use for the FSPCA basis.
Default value of `None` will use `self.basis.count`.
to use for the FSPCA basis.
Default value of `None` will use `self.basis.count`.
:param noise_var: Optionally assign noise variance.
Default value of `None` will estimate noise with WhiteNoiseEstimator.
Use 0 when using clean images so cov2d skips applying noisy covar coeffs..
Default value of `None` will estimate noise with WhiteNoiseEstimator.
Use 0 when using clean images so cov2d skips applying noisy covar coeffs..
:param batch_size: Batch size for computing basis coefficients.
`batch_size` is also passed to BatchedRotCov2D.
"""
Expand Down Expand Up @@ -311,7 +311,7 @@ def expand_from_image_basis(self, x):
basis vectors, described by an eigenvector in FSPCA.
:param x: The Image instance representing a stack of images in the
standard 2D coordinate basis to be evaluated.
standard 2D coordinate basis to be evaluated.
:return: Stack of coefs in the FSPCABasis.
"""
fb_coefs = self.basis.evaluate_t(x)
Expand All @@ -325,7 +325,7 @@ def expand(self, x):
basis vectors, described by an eigenvector in FSPCA.
:param x: Coefs representing a stack in the
Fourier Bessel basis.
Fourier Bessel basis.
:return: Stack of coefs in the FSPCABasis.
"""

Expand All @@ -342,7 +342,7 @@ def evaluate_to_image_basis(self, c):
:param c: Stack of coefs in the FSPCABasis to be evaluated.
:return: The Image instance representing a stack of images in the
standard 2D coordinate basis..
standard 2D coordinate basis..
"""
c_fb = self.evaluate(c)

Expand Down
6 changes: 3 additions & 3 deletions src/aspire/basis/polar_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ def _evaluate_t(self, x):
Evaluate coefficient in polar Fourier grid from those in standard 2D coordinate basis
:param x: The Image instance representing coefficient array in the
standard 2D coordinate basis to be evaluated.
standard 2D coordinate basis to be evaluated.
:return v: The evaluation of the coefficient array `v` in the polar
Fourier grid. This is an array of vectors whose first dimension
corresponds to x.n_images, and last dimension equals `self.count`.
Fourier grid. This is an array of vectors whose first dimension
corresponds to x.n_images, and last dimension equals `self.count`.
"""
nimgs = x.n_images

Expand Down
4 changes: 2 additions & 2 deletions src/aspire/basis/pswf_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def evaluate_t(self, images):
:param images: coefficient array in the standard 2D coordinate basis
to be evaluated.
:return : The evaluation of the coefficient array in the PSWF basis.
:return: The evaluation of the coefficient array in the PSWF basis.
"""

if not isinstance(images, Image):
Expand All @@ -174,7 +174,7 @@ def evaluate(self, coefficients):
Evaluate coefficients in standard 2D coordinate basis from those in PSWF basis
:param coeffcients: A coefficient vector (or an array of coefficient
vectors) in PSWF basis to be evaluated. (n_image, count)
vectors) in PSWF basis to be evaluated. (n_image, count)
:return : Image in standard 2D coordinate basis.
"""
Expand Down
34 changes: 17 additions & 17 deletions src/aspire/classification/averager2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def __init__(self, composite_basis, src, num_procs=1, dtype=None):
:param composite_basis: Basis to be used during class average composition (eg FFB2D)
:param src: Source of original images.
:param num_procs: Number of processes to use.
`None` will attempt computing a suggestion based on machine resources.
Note some underlying code may already use threading.
`None` will attempt computing a suggestion based on machine resources.
Note some underlying code may already use threading.
:param dtype: Numpy dtype to be used during alignment.
"""

Expand Down Expand Up @@ -83,9 +83,9 @@ def average(
:param classes: class indices, refering to src. (n_classes, n_nbor).
:param reflections: Bool representing whether to reflect image in `classes`.
(n_clases, n_nbor)
(n_clases, n_nbor)
:param coefs: Optional basis coefs (could avoid recomputing).
(n_classes, coef_count)
(n_classes, coef_count)
:return: Stack of synthetic class average images as Image instance.
"""

Expand All @@ -95,9 +95,9 @@ def _cls_images(self, cls, src=None):
preserving the class/nbor order.
:param cls: An iterable (0/1-D array or list) that holds the indices of images to align.
In class averaging, this would be a class.
In class averaging, this would be a class.
:param src: Optionally override the src, for example, if you want to use a different
source for a certain operation (ie alignment).
source for a certain operation (ie alignment).
"""
src = src or self.src

Expand All @@ -124,7 +124,7 @@ def __init__(
:param src: Source of original images.
:param alignment_basis: Optional, basis to be used only during alignment (eg FSPCA).
:param num_procs: Number of processes to use.
Note some underlying code may already use threading.
Note some underlying code may already use threading.
:param dtype: Numpy dtype to be used during alignment.
"""

Expand Down Expand Up @@ -258,7 +258,7 @@ def __init__(
"""
See AligningAverager2D, adds:
:params n_angles: Number of brute force rotations to attempt, defaults 360.
:param n_angles: Number of brute force rotations to attempt, defaults 360.
"""
super().__init__(
composite_basis, src, alignment_basis, num_procs=num_procs, dtype=dtype
Expand Down Expand Up @@ -488,10 +488,10 @@ def __init__(
:param composite_basis: Basis to be used during class average composition.
:param src: Source of original images.
:param alignment_src: Optional, source to be used during class average alignment.
Must be the same resolution as `src`.
Must be the same resolution as `src`.
:param num_procs: Number of processes to use.
`None` will attempt computing a suggestion based on machine resources.
Note some underlying code may already use threading.
`None` will attempt computing a suggestion based on machine resources.
Note some underlying code may already use threading.
:param dtype: Numpy dtype to be used during alignment.
"""

Expand Down Expand Up @@ -644,19 +644,19 @@ def __init__(
):
"""
:param alignment_basis: Basis to be used during alignment.
For current implementation of ReddyChatterjiAverager2D this should be `None`.
Instead see `alignment_src`.
For current implementation of ReddyChatterjiAverager2D this should be `None`.
Instead see `alignment_src`.
:param src: Source of original images.
:param composite_basis: Basis to be used during class average composition.
:param alignment_src: Optional, source to be used during class average alignment.
Must be the same resolution as `src`.
Must be the same resolution as `src`.
:param radius: Brute force translation search radius.
Defaults to src.L//8.
Defaults to src.L//8.
:param dtype: Numpy dtype to be used during alignment.
:param num_procs: Number of processes to use.
`None` will attempt computing a suggestion based on machine resources.
Note some underlying code may already use threading.
`None` will attempt computing a suggestion based on machine resources.
Note some underlying code may already use threading.
:param dtype: Numpy dtype to be used during alignment.
"""

Expand Down
14 changes: 7 additions & 7 deletions src/aspire/classification/rir_class2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ def __init__(
for Viewing Direction Classification in Cryo-EM. (2014)
:param src: Source instance. Note it is possible to use one `source` for classification (ie CWF),
and a different `source` for stacking in the `averager`.
and a different `source` for stacking in the `averager`.
:param pca_basis: Optional FSPCA Basis instance
:param fspca_components: Optinally set number of components (top eigvals) to keep from full FSCPA.
Default value of None will infer from `pca_basis` when provided, otherwise defaults to 400.
Default value of None will infer from `pca_basis` when provided, otherwise defaults to 400.
:param alpha: Amplitude Power Scale, default 1/3 (eq 20 from RIIR paper).
:param sample_n: Threshold for random sampling of bispectrum coefs. Default 4000,
high values such as 50000 reduce random sampling.
high values such as 50000 reduce random sampling.
:param n_nbor: Number of nearest neighbors to compute.
:param n_classes: Number of class averages to return.
:param bispectrum_freq_cutoff: Truncate (zero) high k frequecies above (int) value, defaults off (None).
Expand All @@ -70,7 +70,7 @@ def __init__(
:param bispectrum_implementation: See `bispectrum`.
:param selector: A ClassSelector subclass. Defaults to RandomClassSelector.
:param num_procs: Number of processes to use.
`None` will attempt computing a suggestion based on machine resources.
`None` will attempt computing a suggestion based on machine resources.
:param batch_size: Chunk size (typically number of images) for batched methods.
:param averager: An Averager2D subclass. Defaults to BFSReddyChatterjiAverager2D.
:param dtype: Optional dtype, otherwise taken from src.
Expand Down Expand Up @@ -281,9 +281,9 @@ def nn_classification(self, coef_b, coef_b_r):
:param coef_b:
:param coef_b_r:
:returns: Tuple of classes, refl, dists where
classes is an integer array of indices representing image ids,
refl is a bool array representing reflections (True is refl),
and distances is an array of distances as returned by NN implementation.
classes is an integer array of indices representing image ids,
refl is a bool array representing reflections (True is refl),
and distances is an array of distances as returned by NN implementation.
"""
# _nn_classification is assigned during initialization.
return self._nn_classification(coef_b, coef_b_r)
Expand Down
4 changes: 3 additions & 1 deletion src/aspire/covariance/covar.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def cb(xk):
def apply_kernel(self, coeff, kernel=None, packed=False):
"""
Applies the kernel represented by convolution
:param coeff: The volume matrix (6 dimensions) to be convolved (but see the `packed` argument below).
:param kernel: a Kernel object. If None, the kernel for this Estimator is used.
:param packed: whether the `coeff` matrix represents an isometrically mapped packed vector,
Expand All @@ -165,7 +166,7 @@ def src_backward(self, mean_vol, noise_variance, shrink_method=None):
Apply adjoint mapping to source
:return: The sum of the outer products of the mean-subtracted images in `src`, corrected by the expected noise
contribution and expressed as coefficients of `basis`.
contribution and expressed as coefficients of `basis`.
"""
covar_b = np.zeros(
(self.src.L, self.src.L, self.src.L, self.src.L, self.src.L, self.src.L),
Expand All @@ -192,6 +193,7 @@ def src_backward(self, mean_vol, noise_variance, shrink_method=None):
def _shrink(self, covar_b_coeff, noise_variance, method=None):
"""
Shrink covariance matrix
:param covar_b_coeff: Outer products of the mean-subtracted images
:param noise_variance: Noise variance
:param method: One of None/'frobenius_norm'/'operator_norm'/'soft_threshold'
Expand Down
Loading

0 comments on commit 0bd790b

Please sign in to comment.