From 6aaecdde7ecf18dd8d2a99f74f1f2d5d7e0e8b01 Mon Sep 17 00:00:00 2001 From: Matteo Becchi Date: Thu, 28 Nov 2024 13:54:51 +0100 Subject: [PATCH 1/3] Correction docstring in saponify.py --- src/dynsight/_internal/soapify/saponify.py | 31 +++++++++------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/dynsight/_internal/soapify/saponify.py b/src/dynsight/_internal/soapify/saponify.py index 1e225b5..7245a4b 100644 --- a/src/dynsight/_internal/soapify/saponify.py +++ b/src/dynsight/_internal/soapify/saponify.py @@ -37,17 +37,20 @@ def saponify_trajectory( Parameters: trajcontainer: - Container of trajectory. - trajFname (str): - The name of the hdf5 file in wich the trajectory is stored - trajectoryGroupPath (str): - the path of the group that contains the trajectory in trajFname + the name of the hdf5 file that contains the input trajectory. soapoutcontainer (str): - the name of the hdf5 file that will contain the ouput or the SOAP + the name of the hdf5 file that will contain the ouput of the SOAP analysis. - exportDatasetName (str): - the name of the dataset that will contain the SOAP results, - it will be saved in the group called "SOAP" + soaprcut (float, optional): + The cutoff for local region in angstroms. Should be bigger than 1 + angstrom (option passed to the desired SOAP engine). + Defaults to 8.0. + soapnmax (int, optional): + The number of radial basis functions (option passed to the desired + SOAP engine). Defaults to 8. + soaplmax (int, optional): + The maximum degree of spherical harmonics (option passed to the + desired SOAP engine). Defaults to 8. soapoutputchunkdim (int, optional): The dimension of the chunck of data in the SOAP results dataset. Defaults to 100. @@ -59,16 +62,6 @@ def saponify_trajectory( (option passed to the desired SOAP engine). Defaults to None. centersmask: Mask. - soaprcut (float, optional): - The cutoff for local region in angstroms. Should be bigger than 1 - angstrom (option passed to the desired SOAP engine). - Defaults to 8.0. - soapnmax (int, optional): - The number of radial basis functions (option passed to the desired - SOAP engine). Defaults to 8. - soaplmax (int, optional): - The maximum degree of spherical harmonics (option passed to the - desired SOAP engine). Defaults to 8. soap_respectpbc (bool, optional): Determines whether the system is considered to be periodic (option passed to the desired SOAP engine). Defaults to True. From 93b7234c5592809450750b8636d8e4660c303575 Mon Sep 17 00:00:00 2001 From: Matteo Becchi Date: Thu, 28 Nov 2024 14:28:09 +0100 Subject: [PATCH 2/3] Correction docstring in saponify.py --- src/dynsight/_internal/soapify/saponify.py | 78 ++++++++++----------- src/dynsight/_internal/soapify/utilities.py | 23 +++--- 2 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/dynsight/_internal/soapify/saponify.py b/src/dynsight/_internal/soapify/saponify.py index 7245a4b..2f3f889 100644 --- a/src/dynsight/_internal/soapify/saponify.py +++ b/src/dynsight/_internal/soapify/saponify.py @@ -1,10 +1,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: - from collections import abc - import h5py import SOAPify @@ -18,9 +16,9 @@ def saponify_trajectory( soapoutputchunkdim: int = 100, soapnjobs: int = 1, soapatommask: str | None = None, - centersmask: abc.Iterable | None = None, # type: ignore[type-arg] + centersmask: list[int] | None = None, soap_respectpbc: bool = True, - soapkwargs: dict | None = None, # type: ignore[type-arg] + soapkwargs: dict[Any, Any] | None = None, usesoapfrom: SOAPify.engine.KNOWNSOAPENGINES = "dscribe", dooverride: bool = False, verbose: bool = True, @@ -37,48 +35,48 @@ def saponify_trajectory( Parameters: trajcontainer: - the name of the hdf5 file that contains the input trajectory. - soapoutcontainer (str): - the name of the hdf5 file that will contain the ouput of the SOAP - analysis. - soaprcut (float, optional): + The file/group that contains the trajectory. + soapoutcontainer: + The file/group that will store the SOAP results. + soaprcut: The cutoff for local region in angstroms. Should be bigger than 1 angstrom (option passed to the desired SOAP engine). Defaults to 8.0. - soapnmax (int, optional): + soapnmax: The number of radial basis functions (option passed to the desired SOAP engine). Defaults to 8. - soaplmax (int, optional): + soaplmax: The maximum degree of spherical harmonics (option passed to the desired SOAP engine). Defaults to 8. - soapoutputchunkdim (int, optional): + soapoutputchunkdim: The dimension of the chunck of data in the SOAP results dataset. Defaults to 100. - soapnjobs (int, optional): + soapnjobs: the number of concurrent SOAP calculations (option passed to the desired SOAP engine). Defaults to 1. - soapatommask (str, optional): + soapatommask: the symbols of the atoms whose SOAP fingerprint will be calculated (option passed to the desired SOAP engine). Defaults to None. centersmask: - Mask. - soap_respectpbc (bool, optional): + the indexes of the atoms whose SOAP fingerprint will be calculated + (option passed to the desired SOAP engine). Defaults to None. + soap_respectpbc: Determines whether the system is considered to be periodic (option passed to the desired SOAP engine). Defaults to True. soapkwargs (dict, optional): additional keyword arguments to be passed to the SOAP engine. Defaults to {}. - usesoapfrom (KNOWNSOAPENGINES, optional): + usesoapfrom: This string determines the selected SOAP engine for the calculations. Defaults to "dscribe". - dooverride (bool, optional): + dooverride: if False will raise and exception if the user ask to override an already existing DataSet. Defaults to False. - verbose (bool, optional): + verbose: regulates the verbosity of the step by step operations. Defaults to True. - usetype (str,optional): + usetype: The precision used to store the data. Defaults to "float64". """ SOAPify.saponifyTrajectory( @@ -109,9 +107,9 @@ def saponify_multiple_trajectories( soapoutputchunkdim: int = 100, soapnjobs: int = 1, soapatommask: list[str] | None = None, - centersmask: abc.Iterable | None = None, # type: ignore[type-arg] + centersmask: list[int] | None = None, soap_respectpbc: bool = True, - soapkwargs: dict | None = None, # type: ignore[type-arg] + soapkwargs: dict[Any, Any] | None = None, usesoapfrom: SOAPify.engine.KNOWNSOAPENGINES = "dscribe", dooverride: bool = False, verbose: bool = True, @@ -129,50 +127,50 @@ def saponify_multiple_trajectories( :func:`SOAPify.engine.getSoapEngine`) Parameters: - trajcontainers (h5py.Group|h5py.File): - The file/group that contains the trajectories - soapoutcontainers (h5py.Group|h5py.File): - The file/group that will store the SOAP results - soaprcut (float): + trajcontainers: + The file/group that contains the trajectories. + soapoutcontainers: + The file/group that will store the SOAP results. + soaprcut: The cutoff for local region in angstroms. Should be bigger than 1 angstrom (option passed to the desired SOAP engine). Defaults to 8.0. - soapnmax (int): + soapnmax: The number of radial basis functions (option passed to the desired SOAP engine). Defaults to 8. - soaplmax (int): + soaplmax: The maximum degree of spherical harmonics (option passed to the desired SOAP engine). Defaults to 8. - soapoutputchunkdim (int, optional): + soapoutputchunkdim: The dimension of the chunck of data in the SOAP results dataset. Defaults to 100. - soapnjobs (int, optional): + soapnjobs: the number of concurrent SOAP calculations (option passed to the desired SOAP engine). Defaults to 1. - soapatommask (list[str], optional): + soapatommask: the symbols of the atoms whose SOAP fingerprint will be calculated (option passed to getSoapEngine). Defaults to None. - centersmask (Iterable, optional): + centersmask: the indexes of the atoms whose SOAP fingerprint will be calculated (option passed getSoapEngine). Defaults to None. - soap_respectpbc (bool, optional): + soap_respectpbc: Determines whether the system is considered to be periodic (option passed to the desired SOAP engine). Defaults to True. - soapkwargs (dict, optional): + soapkwargs: additional keyword arguments to be passed to the selected SOAP engine. Defaults to {}. - usesoapfrom (KNOWNSOAPENGINES, optional): + usesoapfrom: This string determines the selected SOAP engine for the calculations. Defaults to "dscribe". - dooverride (bool, optional): + dooverride: if False will raise and exception if the user ask to override an already existing DataSet. Defaults to False. - verbose (bool, optional): + verbose: regulates the verbosity of the step by step operations. Defaults to True. - usetype (str,optional): + usetype: The precision used to store the data. Defaults to "float64". """ diff --git a/src/dynsight/_internal/soapify/utilities.py b/src/dynsight/_internal/soapify/utilities.py index a40ece9..501c168 100644 --- a/src/dynsight/_internal/soapify/utilities.py +++ b/src/dynsight/_internal/soapify/utilities.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: import h5py @@ -9,18 +9,18 @@ def fill_soap_vector_from_dscribe( - soapfromdscribe: np.ndarray, # type: ignore[type-arg] + soapfromdscribe: np.ndarray[float, Any], lmax: int, nmax: int, - atomtypes: list | None = None, # type: ignore[type-arg] + atomtypes: list[str] | None = None, atomicslices: dict | None = None, # type: ignore[type-arg] -) -> np.ndarray: # type: ignore[type-arg] - """Returns the SOAP power spectrum from dsribe results. +) -> np.ndarray[float, Any]: + """Returns the SOAP power spectrum from dscribe results. With also the symmetric part explicitly stored, see the note in https://singroup.github.io/dscribe/1.2.x/tutorials/descriptors/soap.html - No controls are implemented on the shape of the soapFromdscribe vector. + No controls are implemented on the shape of the soapfromdscribe vector. Parameters: soapfromdscribe: @@ -30,13 +30,14 @@ def fill_soap_vector_from_dscribe( nmax: the n_max specified in the calculation. atomtypes: - Needs docs. + the list of atomic species. Defaults to None. atomicslices: - Needs docs. + the slices of the SOAP vector relative to the atomic species + combinations. Defaults to None. Returns: numpy.ndarray: - The full soap spectrum, with the symmetric part sored explicitly + The full soap spectrum, with the symmetric part sorted explicitly. """ return SOAPify.fillSOAPVectorFromdscribe( soapFromdscribe=soapfromdscribe, @@ -47,10 +48,10 @@ def fill_soap_vector_from_dscribe( ) -def get_soap_settings(fitsetdata: h5py.Dataset) -> dict: # type: ignore[type-arg] +def get_soap_settings(fitsetdata: h5py.Dataset) -> dict[str, Any]: """Gets the settings of the SOAP calculation. - you can feed directly this output to :func:`fillSOAPVectorFromdscribe` + You can feed directly this output to :func:`fillSOAPVectorFromdscribe` Parameters: fitsetdata: From e514d6d5873b091d23b02e2cc762c2df26834ba9 Mon Sep 17 00:00:00 2001 From: Matteo Becchi Date: Thu, 28 Nov 2024 14:40:50 +0100 Subject: [PATCH 3/3] Correction docstring in saponify.py --- src/dynsight/_internal/soapify/saponify.py | 4 ++-- src/dynsight/_internal/soapify/utilities.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dynsight/_internal/soapify/saponify.py b/src/dynsight/_internal/soapify/saponify.py index 2f3f889..d36b634 100644 --- a/src/dynsight/_internal/soapify/saponify.py +++ b/src/dynsight/_internal/soapify/saponify.py @@ -18,7 +18,7 @@ def saponify_trajectory( soapatommask: str | None = None, centersmask: list[int] | None = None, soap_respectpbc: bool = True, - soapkwargs: dict[Any, Any] | None = None, + soapkwargs: dict[str, Any] | None = None, usesoapfrom: SOAPify.engine.KNOWNSOAPENGINES = "dscribe", dooverride: bool = False, verbose: bool = True, @@ -109,7 +109,7 @@ def saponify_multiple_trajectories( soapatommask: list[str] | None = None, centersmask: list[int] | None = None, soap_respectpbc: bool = True, - soapkwargs: dict[Any, Any] | None = None, + soapkwargs: dict[str, Any] | None = None, usesoapfrom: SOAPify.engine.KNOWNSOAPENGINES = "dscribe", dooverride: bool = False, verbose: bool = True, diff --git a/src/dynsight/_internal/soapify/utilities.py b/src/dynsight/_internal/soapify/utilities.py index 501c168..e87eaac 100644 --- a/src/dynsight/_internal/soapify/utilities.py +++ b/src/dynsight/_internal/soapify/utilities.py @@ -13,7 +13,7 @@ def fill_soap_vector_from_dscribe( lmax: int, nmax: int, atomtypes: list[str] | None = None, - atomicslices: dict | None = None, # type: ignore[type-arg] + atomicslices: dict[str, Any] | None = None, ) -> np.ndarray[float, Any]: """Returns the SOAP power spectrum from dscribe results.