From 24e15e430bc900d30415ae7c73fd2c965f6488a9 Mon Sep 17 00:00:00 2001 From: "@jmmshn" Date: Thu, 22 Feb 2024 16:25:09 -0800 Subject: [PATCH] docs --- pyproject.toml | 3 +-- src/pyrho/charge_density.py | 32 ++++++++++++++++---------------- src/pyrho/pgrid.py | 12 ++++++------ src/pyrho/utils.py | 16 ++++++++-------- src/pyrho/vis/scatter.py | 2 +- 5 files changed, 32 insertions(+), 33 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7f2fe0b..2c03c44 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,6 @@ select = [ # "ERA001", "RUF", "D409", - "D416", "TCH", "TID251", "T20", @@ -98,7 +97,7 @@ skip-magic-trailing-comma = false line-ending = "auto" [tool.ruff.lint.pydocstyle] -convention = "google" +convention = "numpy" [tool.mypy] ignore_missing_imports = true diff --git a/src/pyrho/charge_density.py b/src/pyrho/charge_density.py index d393615..06a7a83 100644 --- a/src/pyrho/charge_density.py +++ b/src/pyrho/charge_density.py @@ -30,7 +30,7 @@ class ChargeDensity(MSONable): Defines a charge density with a PGrid object along with the atomic structure. - Attributes: + Attributes ---------- pgrids: Dict[str, PGrid] Dictionaries whose values are periodic ``PGrid`` objects @@ -67,7 +67,7 @@ def normalized_data(self) -> dict[str, npt.NDArray]: Since different codes use different normalization methods for volumetric data we should convert them to the same units (electrons / Angstrom^3) - Returns: + Returns ------- dict[str, NDArray]: The normalized data in units of (electrons / Angstrom^3) @@ -94,7 +94,7 @@ def normalized_pgrids(self) -> dict[str, PGrid]: Since different codes use different normalization methods for volumetric data we should convert them to the same units (electrons / Angstrom^3) - Returns: + Returns ------- dict[str, PGrid]: The normalized pgrids in units of (electrons / Angstrom^3) @@ -134,7 +134,7 @@ def from_pmg( - 'vasp' sum of the data / number of grid points == number of electrons - None/"none" no normalization - Returns: + Returns ------- ChargeDensity: The charge density object @@ -173,7 +173,7 @@ def get_data_in_cube(self, s: float, ngrid: int, key: str = "total") -> npt.NDAr key: The key to read from ``self.normalized_data`` - Returns: + Returns ------- NDArray: Regridded data in a ngrid x ngrid x ngrid array @@ -205,7 +205,7 @@ def get_transformed( up_sample: The factor to scale up the sampling of the grid data using Fourier interpolation - Returns: + Returns ------- ChargeDensity: The transformed ChargeDensity object @@ -256,7 +256,7 @@ def to_Chgcar(self) -> Chgcar: Scale and convert each key in the pgrids dictionary and create a ``Chgcar`` object - Returns: + Returns ------- Chgcar: The charge density object @@ -271,7 +271,7 @@ def to_VolumetricData( Scale and convert each key in the pgrids dictionary and create a ``VolumetricData`` object - Returns: + Returns ------- VolumetricData: The charge density object @@ -299,7 +299,7 @@ def from_file( The pymatgen object to read from the file (default: Chgcar). the `from_file` method from this class will be called to read the file. - Returns: + Returns ------- ChargeDensity: The ChargeDensity object @@ -320,7 +320,7 @@ def from_hdf5( The pymatgen object to read from the file (default: Chgcar). the `from_file` method from this class will be called to read the file. - Returns: + Returns ------- ChargeDensity: The ChargeDensity object @@ -342,7 +342,7 @@ def get_matched_structure_mapping( sc_struct: bigger cell sm: StructureMatcher instance - Returns: + Returns ------- sc_m : supercell matrix to apply to s1 to get s2 total_t : translation to apply on s1 * sc_m to get s2 @@ -372,7 +372,7 @@ def get_volumetric_like_sc( ): """Get the volumetric data in the supercell. - Parameters: + Parameters ---------- vd: VolumeData instance sc_struct: supercell structure. @@ -384,7 +384,7 @@ def get_volumetric_like_sc( same as VASP's CHGCAR file. If None, no normalization is done. - Returns: + Returns ------- VolumetricData: volumetric data in the supercell """ @@ -422,7 +422,7 @@ def multiply_aug(data_aug: list[str], factor: int) -> list[str]: factor: The multiplication factor (some integer number of times it gets repeated) - Returns: + Returns ------- List[str]: Each line of the augmentation data. @@ -477,7 +477,7 @@ def _normalize_data( where the second `/vol` account for the different number of electrons in different cells - Returns: + Returns ------- NDArray: The normalized grid data @@ -505,7 +505,7 @@ def _scaled_data( normalization: The normalization method defaults to vasp - Returns: + Returns ------- NDArray: The un-normalized grid data diff --git a/src/pyrho/pgrid.py b/src/pyrho/pgrid.py index 9160f40..a8f4882 100644 --- a/src/pyrho/pgrid.py +++ b/src/pyrho/pgrid.py @@ -24,7 +24,7 @@ class PGrid(MSONable): def __init__(self, grid_data: npt.NDArray, lattice: npt.NDArray): """Initialize the PGrid object. - Attributes: + Attributes ---------- grid_data: Data stored on the regular rid @@ -61,7 +61,7 @@ def _transform_data( up_sample: The factor to scale up the sampling of the grid data using Fourier interpolation - Returns: + Returns ------- NDArray: The transformed data @@ -89,7 +89,7 @@ def __mul__(self, factor: float) -> PGrid: factor: The factor to multiply the grid data by - Returns: + Returns ------- PGrid: The new PGrid object @@ -105,7 +105,7 @@ def __truediv__(self, factor: float) -> PGrid: factor: The factor to divide the grid data by - Returns: + Returns ------- PGrid: The new PGrid object @@ -133,7 +133,7 @@ def get_transformed( up_sample: The factor to scale up the sampling of the grid data using Fourier interpolation - Returns: + Returns ------- PGrid: The transformed PGrid object @@ -161,7 +161,7 @@ def lossy_smooth_compression( smear_std: standard deviation of the Gaussian smoothing - Returns: + Returns ------- NDArray: Smoothed array diff --git a/src/pyrho/utils.py b/src/pyrho/utils.py index c623895..f8f4d3e 100644 --- a/src/pyrho/utils.py +++ b/src/pyrho/utils.py @@ -51,7 +51,7 @@ def pad_arr(arr_in: NDArray, shape: List[int]) -> NDArray: shape: Desired shape of the array - Returns: + Returns ------- NDArray: padded data @@ -117,7 +117,7 @@ def interpolate_fourier(arr_in: NDArray, shape: List[int]) -> NDArray: shape: Desired shape shape of the interpolated data - Returns: + Returns ------- NDArray: Interpolated data in the desired shape @@ -144,7 +144,7 @@ def roll_array(arr: NDArray, roll_vec: List[int]) -> NDArray: roll_vec: number of indices in each direction to roll - Returns: + Returns ------- NDArray: The rolled array @@ -194,7 +194,7 @@ def get_sc_interp( origin: Shift applied to the origin in fractional coordinates - Returns: + Returns ------- NDArray: size ``(ndim x prod(grid_size))`` the cartesian coordinates of each point in the new data @@ -238,7 +238,7 @@ def get_padded_array(data_in: NDArray) -> NDArray: data_in: Array to be padded - Returns: + Returns ------- NDArray: Padded array @@ -267,7 +267,7 @@ def get_plane_spacing(lattice: NDArray) -> List[float]: lattice: List of lattice vectors in cartesian coordinates - Returns: + Returns ------- List[float]: List where the k-th element is is the spacing of planes generated by all @@ -312,7 +312,7 @@ def get_ucell_frac_fit_sphere(lattice: np.ndarray, r: float = 0.2) -> Iterable[f r: width of the sphere - Returns: + Returns ------- Iterable of floats fraction of lattice vector in each direction need to fit the sphere @@ -347,7 +347,7 @@ def gaussian_smear( multiple: ``multiple * sigma`` is the cutoff radius for the smearing - Returns: + Returns ------- NDArray: The smear data array. diff --git a/src/pyrho/vis/scatter.py b/src/pyrho/vis/scatter.py index 0c63f73..08b5266 100644 --- a/src/pyrho/vis/scatter.py +++ b/src/pyrho/vis/scatter.py @@ -48,7 +48,7 @@ def get_scatter_plot( Plotter to use, either "matplotlib" or "plotly" - Returns: + Returns ------- Figure | Axes: `Figure` object or `Axes` object from matplotlib to be rendered in a notebook