Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
arthur-lin1027 committed May 31, 2024
1 parent 7f0746e commit 50ead3c
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 109 deletions.
1 change: 1 addition & 0 deletions anisoap/reference/projection_coefficients.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
compute_moments_diagonal_inefficient_implementation,
compute_moments_inefficient_implementation,
)

# quaternion_to_rotation_matrix no longer exists
from .radial_basis import RadialBasis

Expand Down
46 changes: 23 additions & 23 deletions anisoap/representations/ellipsoidal_density_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def pairwise_ellip_expansion(
):
r"""Computes pairwise expansion
Function to compute the pairwise expansion :math:`\langle anlm|\rho_{ij} \rangle`
Function to compute the pairwise expansion :math:`\langle anlm|\rho_{ij} \rangle`
by combining the moments and the spherical to Cartesian transformation.
Parameters
Expand All @@ -42,22 +42,22 @@ def pairwise_ellip_expansion(
Maximum angular
neighbor_list : Equistore TensorMap
Full neighborlist with keys (types_1, types_2) enumerating the possible
species pairs. Each block contains as samples, the atom indices of
(first_atom, second_atom) that correspond to the key, and block.value is
a 3D array of the form (num_samples, num_components,properties), with
num_components=3 corresponding to the (x,y,z) components of the vector
from first_atom to second_atom. Depending on the cutoff some species
pairs may not appear. Self pairs are not present but in PBC, pairs between
species pairs. Each block contains as samples, the atom indices of
(first_atom, second_atom) that correspond to the key, and block.value is
a 3D array of the form (num_samples, num_components,properties), with
num_components=3 corresponding to the (x,y,z) components of the vector
from first_atom to second_atom. Depending on the cutoff some species
pairs may not appear. Self pairs are not present but in PBC, pairs between
copies of the same atom are accounted for.
types : list of ints
List of atomic numbers present across the data frames
frame_to_global_atom_idx : list of ints
The length of the list equals the number of frames, each entry enumerating
The length of the list equals the number of frames, each entry enumerating
the number of atoms in corresponding frame
rotation_matrices : np.array of dimension ((num_atoms,3,3))
ellipsoid_lengths : np.array of dimension ((num_atoms,3))
radial_basis : Instance of the RadialBasis Class
anisoap.representations.radial_basis.RadialBasis that has been instantiated
anisoap.representations.radial_basis.RadialBasis that has been instantiated
appropriately with the cutoff radius, radial basis type.
show_progress : bool
Show progress bar for frame analysis and feature generation
Expand All @@ -67,10 +67,10 @@ def pairwise_ellip_expansion(
TensorMap
An Equistore TensorMap with keys (types_1, types_2, l) where
("types_1", "types_2") is key in the neighbor_list and "l" is the
angular channel. Each block of this tensormap has the same samples as the
corresponding block of the neighbor_list. block.value is a 3D array of
the form (num_samples, num_components, properties) where num_components
form the 2*l+1 values for the corresponding angular channel and the
angular channel. Each block of this tensormap has the same samples as the
corresponding block of the neighbor_list. block.value is a 3D array of
the form (num_samples, num_components, properties) where num_components
form the 2*l+1 values for the corresponding angular channel and the
properties dimension corresponds to the radial channel.
"""
tensorblock_list = []
Expand Down Expand Up @@ -194,11 +194,11 @@ def contract_pairwise_feat(pair_ellip_feat, types, show_progress=False):
--------------------------------------------------------
Parameters:
Function to sum over the pairwise expansion
Function to sum over the pairwise expansion
.. math::
\\sum_{j \\in a} \\langle anlm|\\rho_{ij} \\rangle
\\sum_{j \\in a} \\langle anlm|\\rho_{ij} \\rangle
= \\langle anlm|\\rho_i \\rangle
Parameters
Expand All @@ -216,12 +216,12 @@ def contract_pairwise_feat(pair_ellip_feat, types, show_progress=False):
-------
TensorMap
An Equistore TensorMap with keys (types, l) "types" takes the value
of the atomic numbers present in the dataset and "l" is the angular
of the atomic numbers present in the dataset and "l" is the angular
channel. Each block of this tensormap has as samples ("type", "center"),
yielding the indices of the frames and atoms that correspond to "species"
are present. block.value is a 3D array of the form (num_samples, num_components, properties)
where num_components take on the same values as in the pair_ellip_feat_feat.block.
block.properties now has an additional index for neighbor_species that
yielding the indices of the frames and atoms that correspond to "species"
are present. block.value is a 3D array of the form (num_samples, num_components, properties)
where num_components take on the same values as in the pair_ellip_feat_feat.block.
block.properties now has an additional index for neighbor_species that
corresponds to "a" in :math:`\\langle anlm|rho_i \\rangle`
"""
ellip_keys = list(
Expand Down Expand Up @@ -414,7 +414,7 @@ class EllipsoidalDensityProjection:
Compute the spherical projection coefficients for a system of ellipsoids
assuming a multivariate Gaussian density.
Initialize the calculator using the hyperparameters.
Parameters
Expand Down Expand Up @@ -467,7 +467,7 @@ def __init__(
max_angular : int
Number of angular functions
radial_basis_name : str
The radial basis. Currently implemented are 'GTO_primitive', 'GTO',
The radial basis. Currently implemented are 'GTO_primitive', 'GTO',
and 'monomial'.
cutoff_radius
Cutoff radius of the projection
Expand Down Expand Up @@ -564,7 +564,7 @@ def transform(self, frames, show_progress=False, normalize=True):
show_progress : bool
Show progress bar for frame analysis and feature generation
normalize: bool
Whether to perform Lowdin Symmetric Orthonormalization or not.
Whether to perform Lowdin Symmetric Orthonormalization or not.
Returns
-------
Expand Down
80 changes: 40 additions & 40 deletions anisoap/representations/radial_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def inverse_matrix_sqrt(matrix: np.array, rcond=1e-8, tol=1e-3):
r"""Returns the inverse matrix square root.
The inverse square root of the overlap matrix (or slices of the overlap matrix)
The inverse square root of the overlap matrix (or slices of the overlap matrix)
yields the orthonormalization matrix
Parameters
Expand All @@ -23,7 +23,7 @@ def inverse_matrix_sqrt(matrix: np.array, rcond=1e-8, tol=1e-3):
Returns
-------
inverse_sqrt_matrix
inverse_sqrt_matrix
:math:`S^{-1/2}`
"""
Expand Down Expand Up @@ -78,19 +78,19 @@ def gto_prefactor(n, sigma):
"""Computes the normalization prefactor of an unnormalized GTO.
This prefactor is simply :math:`\\frac{1}{\\sqrt(\\text{square_norm_area)}}`.
Scaling a GTO by this prefactor will ensure that the GTO has square norm
Scaling a GTO by this prefactor will ensure that the GTO has square norm
equal to 1.
Parameters
----------
n
n
order of GTO
sigma
sigma
width of GTO
Returns
-------
float
float
The normalization constant
"""
Expand Down Expand Up @@ -212,8 +212,8 @@ class _RadialBasis:
This helps to keep a cleaner main code by avoiding if-else clauses
related to the radial basis.
Code relating to GTO orthonormalization is heavily inspired by work done in
librascal, specifically the codebase found
Code relating to GTO orthonormalization is heavily inspired by work done in
librascal, specifically the codebase found
`here <https://github.com/lab-cosmo/librascal/blob/8405cbdc0b5c72a5f0b0c93593100dde348bb95f/bindings/rascal/utils/radial_basis.py>`_
"""
Expand Down Expand Up @@ -280,16 +280,16 @@ def get_num_radial_functions(self):
Returns
-------
array_like
The attribute `self.num_radial_functions`, which is a list containing
The attribute `self.num_radial_functions`, which is a list containing
the number of radial basis functions considered per `l`.
"""
return self.num_radial_functions

def plot_basis(self, n_r=100):
"""
Plot the normalized basis functions used in calculating the expansion
Plot the normalized basis functions used in calculating the expansion
coefficients
Parameters
----------
n_r: int
Expand All @@ -304,20 +304,20 @@ def plot_basis(self, n_r=100):

class MonomialBasis(_RadialBasis):
r"""
A subclass of _RadialBasis that contains attributes and methods required for
A subclass of _RadialBasis that contains attributes and methods required for
the Monomial basis.
The monomial basis of order n is defined to be :math:`R(r) = r^n`.
For monomial basis with defined :math:`n_{\text{max}}` and :math:`l_{\text{max}}`,
our radial basis set consists of monomials of order :math:`n=0` to
our radial basis set consists of monomials of order :math:`n=0` to
:math:`n=l_{\text{max}} + 2n_{\text{max}}`.
For monomial basis with coupled :math:`n_{\text{max}}` and :math:`l_{\text{max}}`,
our radial basis set consists of monomials of order :math:`n=0` to
For monomial basis with coupled :math:`n_{\text{max}}` and :math:`l_{\text{max}}`,
our radial basis set consists of monomials of order :math:`n=0` to
:math:`n=\text{max}{l_{\text{max}} + 2n_{\text{max}}}`
Monomials are not square-integrable from :math:`[0, \infty]`, so we orthonormalize
Monomials are not square-integrable from :math:`[0, \infty]`, so we orthonormalize
by integrating up to the cutoff radius
"""

Expand Down Expand Up @@ -359,7 +359,7 @@ def calc_overlap_matrix(self):
"""
Computes the overlap matrix for Monomnials over a fixed interval.
The overlap matrix is a Gram matrix whose entries are the overlap:
The overlap matrix is a Gram matrix whose entries are the overlap:
.. math::
S_{ij} = \int_{0}^{r_{cut} dr r^2 phi_i phi_j
Expand Down Expand Up @@ -397,8 +397,8 @@ def orthonormalize_basis(self, features: TensorMap):
Parameters
----------
features: TensorMap
A TensorMap whose blocks' values we wish to orthonormalize. Note that
`features` is modified in place, so a copy of `features` must be made
A TensorMap whose blocks' values we wish to orthonormalize. Note that
`features` is modified in place, so a copy of `features` must be made
before the function if you wish to retain the unnormalized values.
radial_basis: _RadialBasis
Expand Down Expand Up @@ -439,11 +439,11 @@ def orthonormalize_basis(self, features: TensorMap):
def get_basis(self, rs):
"""
Evaluate orthonormalized monomial basis functions on mesh rs.
If lmax and nmax defined, then the number of functions outputted is lmax*(nmax+1)
If lmax and nmax coupled, then the number of functions outputted is \sum_{l=0}^{lmax} (number_of_radial_functions_per_l)
Parameters
----------
rs: np.array
Expand Down Expand Up @@ -540,25 +540,25 @@ def compute_gaussian_parameters(self, r_ij, lengths, rotation_matrix):
def calc_overlap_matrix(self):
"""Computes the overlap matrix for GTOs.
The overlap matrix is a Gram matrix whose entries are the overlap:
The overlap matrix is a Gram matrix whose entries are the overlap:
.. math::
S_{ij} = \\int_0^\\infty dr \\, r^2 \\phi_i \\phi_j
The overlap has an analytic solution (see above functions).
The overlap matrix is the first step to generating an orthonormal basis
set of functions (Lodwin Symmetric Orthonormalization). The actual
The overlap matrix is the first step to generating an orthonormal basis
set of functions (Lodwin Symmetric Orthonormalization). The actual
orthonormalization matrix cannot be fully precomputed because each tensor
block uses a different set of GTOs. Hence, we precompute the full overlap
matrix of dim l_max, and while orthonormalizing each tensor block, we
block uses a different set of GTOs. Hence, we precompute the full overlap
matrix of dim l_max, and while orthonormalizing each tensor block, we
generate the respective orthonormal matrices from slices of the full
overlap matrix.
Returns
-------
2D array
2D array
The overlap matrix
"""
Expand All @@ -579,18 +579,18 @@ def calc_overlap_matrix(self):
def orthonormalize_basis(self, features: TensorMap):
"""Applies in-place orthonormalization on the features.
Apply an in-place orthonormalization on the features, using Lodwin Symmetric
Orthonormalization. Each block in the features TensorMap uses a GTO set
of l + 2n, so we must take the appropriate slices of the overlap matrix
to compute the orthonormalization matrix. An instructive example of Lodwin
Apply an in-place orthonormalization on the features, using Lodwin Symmetric
Orthonormalization. Each block in the features TensorMap uses a GTO set
of l + 2n, so we must take the appropriate slices of the overlap matrix
to compute the orthonormalization matrix. An instructive example of Lodwin
Symmetric Orthonormalization of a 2-element basis set is found here:
https://booksite.elsevier.com/9780444594365/downloads/16755_10030.pdf
Parameters
----------
features : TensorMap
contains blocks whose values we wish to orthonormalize. Note that
features is modified in place, so a copy of features must be made
features : TensorMap
contains blocks whose values we wish to orthonormalize. Note that
features is modified in place, so a copy of features must be made
before the function if you wish to retain the unnormalized values.
radial_basis : RadialBasis
Expand Down Expand Up @@ -633,12 +633,12 @@ def orthonormalize_basis(self, features: TensorMap):
def get_basis(self, rs):
r"""
Evaluate orthonormalized GTO basis functions on mesh rs.
If lmax and nmax defined, then the number of functions outputted is lmax*(nmax+1)
If lmax and nmax coupled, then the number of functions outputted is
If lmax and nmax coupled, then the number of functions outputted is
:math:`\sum_{l=0}^{\text{lmax}} (\text{number_of_radial_functions_per_l})`
Parameters
----------
rs: np.array
Expand Down
14 changes: 6 additions & 8 deletions anisoap/utils/metatensor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _real2complex(L):
.. math::
\mathbf{R} \dot \left[-L..L\right]
\mathbf{R} \dot \left[-L..L\right]
"""
result = np.zeros((2 * L + 1, 2 * L + 1), dtype=np.complex128)
Expand Down Expand Up @@ -158,9 +158,7 @@ def _remove_suffix(names, new_suffix=""):


def standardize_keys(descriptor):
"""Standardize the naming scheme of density expansion coefficient blocks (nu=1)
"""
"""Standardize the naming scheme of density expansion coefficient blocks (nu=1)"""

key_names = descriptor.keys.names
if not "angular_channel" in key_names:
Expand Down Expand Up @@ -206,10 +204,10 @@ def cg_combine(
lcut=None,
other_keys_match=None,
):
"""Performs a CG product of two sets of equivariants.
"""Performs a CG product of two sets of equivariants.
The only requirement is that sparse indices are labeled as
("inversion_sigma", "spherical_harmonics_l", "order_nu").
The only requirement is that sparse indices are labeled as
("inversion_sigma", "spherical_harmonics_l", "order_nu").
Parameters
----------
Expand All @@ -231,7 +229,7 @@ def cg_combine(
product taken, but will instead be merged into a new key. For instance,
passing `["types center"]` will combine the keys with the same type
center, yielding a single key with the same types_center in the results.
Returns
-------
TensorMap
Expand Down
Loading

0 comments on commit 50ead3c

Please sign in to comment.