From 4a1522cf8be4a98b240ceb4cdd676d757cd536bf Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Sun, 4 Aug 2024 10:57:53 -0400 Subject: [PATCH] fix missing types in doc string args --- src/pymatgen/alchemy/filters.py | 4 +-- src/pymatgen/alchemy/materials.py | 4 +-- .../connectivity/connected_components.py | 10 +++--- .../connectivity/structure_connectivity.py | 8 ++--- src/pymatgen/analysis/cost.py | 4 +-- src/pymatgen/analysis/diffraction/xrd.py | 2 +- src/pymatgen/analysis/elasticity/elastic.py | 8 ++--- src/pymatgen/analysis/eos.py | 8 ++--- .../analysis/molecule_structure_comparator.py | 2 +- src/pymatgen/analysis/nmr.py | 6 ++-- src/pymatgen/analysis/pourbaix_diagram.py | 9 +++--- src/pymatgen/analysis/reaction_calculator.py | 4 +-- .../substitution_probability.py | 14 +++++---- src/pymatgen/core/composition.py | 2 +- src/pymatgen/core/interface.py | 11 +++---- src/pymatgen/core/periodic_table.py | 5 ++- src/pymatgen/core/structure.py | 6 ++-- src/pymatgen/io/cssr.py | 2 +- src/pymatgen/io/feff/inputs.py | 6 ++-- src/pymatgen/io/feff/outputs.py | 6 ++-- src/pymatgen/io/feff/sets.py | 12 +++---- src/pymatgen/io/qchem/inputs.py | 24 +++++++------- src/pymatgen/io/vasp/outputs.py | 2 +- src/pymatgen/io/vasp/sets.py | 2 +- src/pymatgen/io/xr.py | 2 +- src/pymatgen/symmetry/analyzer.py | 2 +- src/pymatgen/util/plotting.py | 6 ++-- src/pymatgen/vis/structure_vtk.py | 31 +++++++++++-------- 28 files changed, 104 insertions(+), 98 deletions(-) diff --git a/src/pymatgen/alchemy/filters.py b/src/pymatgen/alchemy/filters.py index d133c0289e3..923ca1e8056 100644 --- a/src/pymatgen/alchemy/filters.py +++ b/src/pymatgen/alchemy/filters.py @@ -43,7 +43,7 @@ class ContainsSpecieFilter(AbstractStructureFilter): def __init__(self, species, strict_compare=False, AND=True, exclude=False): """ Args: - species ([Species/Element]): list of species to look for + species (list[SpeciesLike]): species to look for AND: whether all species must be present to pass (or fail) filter. strict_compare: if true, compares objects by specie or element object if false, compares atomic number @@ -157,7 +157,7 @@ def from_dict(cls, dct: dict) -> Self: dct (dict): Dict representation. Returns: - Filter + SpecieProximityFilter """ return cls(**dct["init_args"]) diff --git a/src/pymatgen/alchemy/materials.py b/src/pymatgen/alchemy/materials.py index 848352ad8c5..c5bded7c26b 100644 --- a/src/pymatgen/alchemy/materials.py +++ b/src/pymatgen/alchemy/materials.py @@ -366,13 +366,13 @@ def to_snl(self, authors: list[str], **kwargs) -> StructureNL: history = [] for hist in self.history: snl_metadata = hist.pop("_snl", {}) - history.append( + history += [ { "name": snl_metadata.pop("name", "pymatgen"), "url": snl_metadata.pop("url", "http://pypi.python.org/pypi/pymatgen"), "description": hist, } - ) + ] return StructureNL(self.final_structure, authors, history=history, **kwargs) diff --git a/src/pymatgen/analysis/chemenv/connectivity/connected_components.py b/src/pymatgen/analysis/chemenv/connectivity/connected_components.py index 3e75f758bc8..6acb98df505 100644 --- a/src/pymatgen/analysis/chemenv/connectivity/connected_components.py +++ b/src/pymatgen/analysis/chemenv/connectivity/connected_components.py @@ -373,14 +373,15 @@ def __len__(self): def compute_periodicity(self, algorithm="all_simple_paths") -> None: """ Args: - algorithm (): + algorithm (str): Algorithm to use to compute the periodicity vectors. Can be + either "all_simple_paths" or "cycle_basis". """ if algorithm == "all_simple_paths": self.compute_periodicity_all_simple_paths_algorithm() elif algorithm == "cycle_basis": self.compute_periodicity_cycle_basis() else: - raise ValueError(f"Algorithm {algorithm!r} is not allowed to compute periodicity") + raise ValueError(f"{algorithm=} is not allowed to compute periodicity") self._order_periodicity_vectors() def compute_periodicity_all_simple_paths_algorithm(self): @@ -513,7 +514,7 @@ def compute_periodicity_cycle_basis(self) -> None: def make_supergraph(self, multiplicity): """ Args: - multiplicity (): + multiplicity (int): Multiplicity of the super graph. Returns: nx.MultiGraph: Super graph of the connected component. @@ -636,7 +637,8 @@ def periodicity(self): def elastic_centered_graph(self, start_node=None): """ Args: - start_node (): + start_node (Node, optional): Node to start the elastic centering from. + If not provided, the first node in the graph is used. Returns: nx.MultiGraph: Elastic centered subgraph. diff --git a/src/pymatgen/analysis/chemenv/connectivity/structure_connectivity.py b/src/pymatgen/analysis/chemenv/connectivity/structure_connectivity.py index 7258be9baf4..8159a6095fa 100644 --- a/src/pymatgen/analysis/chemenv/connectivity/structure_connectivity.py +++ b/src/pymatgen/analysis/chemenv/connectivity/structure_connectivity.py @@ -76,8 +76,8 @@ def __init__( def environment_subgraph(self, environments_symbols=None, only_atoms=None): """ Args: - environments_symbols (): - only_atoms (): + environments_symbols (list[str]): symbols of the environments to consider. + only_atoms (list[str]): atoms to consider. Returns: nx.MultiGraph: The subgraph of the structure connectivity graph @@ -187,8 +187,8 @@ def setup_environment_subgraph(self, environments_symbols, only_atoms=None): ) self._environment_subgraph.add_node(env_node) else: - # TODO: add the possibility of a "constraint" on the minimum percentage - # of the atoms on the site + # TODO add the possibility of a "constraint" on the minimum percentage + # of the atoms on the site this_site_elements = [ sp.symbol for sp in self.light_structure_environments.structure[isite].species_and_occu ] diff --git a/src/pymatgen/analysis/cost.py b/src/pymatgen/analysis/cost.py index 458fea711e6..e5b34ed623c 100644 --- a/src/pymatgen/analysis/cost.py +++ b/src/pymatgen/analysis/cost.py @@ -118,10 +118,10 @@ def __init__(self): class CostAnalyzer: """Given a CostDB, figures out the minimum cost solutions via convex hull.""" - def __init__(self, costdb): + def __init__(self, costdb: CostDB) -> None: """ Args: - costdb (): Cost database. + costdb (CostDB): Cost database to use. """ self.costdb = costdb diff --git a/src/pymatgen/analysis/diffraction/xrd.py b/src/pymatgen/analysis/diffraction/xrd.py index 49eb07e05a0..31ad7e98017 100644 --- a/src/pymatgen/analysis/diffraction/xrd.py +++ b/src/pymatgen/analysis/diffraction/xrd.py @@ -101,7 +101,7 @@ def __init__(self, wavelength="CuKa", symprec: float = 0, debye_waller_factors=N """Initialize the XRD calculator with a given radiation. Args: - wavelength (str/float): The wavelength can be specified as either a + wavelength (str | float): The wavelength can be specified as either a float or a string. If it is a string, it must be one of the supported definitions in the AVAILABLE_RADIATION class variable, which provides useful commonly used wavelengths. diff --git a/src/pymatgen/analysis/elasticity/elastic.py b/src/pymatgen/analysis/elasticity/elastic.py index 7ac2ef19015..ef931a6dabf 100644 --- a/src/pymatgen/analysis/elasticity/elastic.py +++ b/src/pymatgen/analysis/elasticity/elastic.py @@ -55,9 +55,9 @@ class NthOrderElasticTensor(Tensor): def __new__(cls, input_array, check_rank=None, tol: float = 1e-4) -> Self: """ Args: - input_array (): - check_rank (): - tol (): + input_array (np.ndarray): input array for tensor + check_rank (int): rank of tensor to check + tol (float): tolerance for initial symmetry test of tensor """ obj = super().__new__(cls, input_array, check_rank=check_rank) if obj.rank % 2 != 0: @@ -524,7 +524,7 @@ class ComplianceTensor(Tensor): def __new__(cls, s_array) -> Self: """ Args: - s_array (): + s_array (np.ndarray): input array for tensor """ vscale = np.ones((6, 6)) vscale[3:] *= 2 diff --git a/src/pymatgen/analysis/eos.py b/src/pymatgen/analysis/eos.py index b5f49e472fa..ebb5bcbc2db 100644 --- a/src/pymatgen/analysis/eos.py +++ b/src/pymatgen/analysis/eos.py @@ -38,8 +38,8 @@ class EOSBase(ABC): def __init__(self, volumes, energies): """ Args: - volumes (list/numpy.array): volumes in Ang^3 - energies (list/numpy.array): energy in eV. + volumes (Sequence[float]): in Ang^3. + energies (Sequence[float]): in eV. """ self.volumes = np.array(volumes) self.energies = np.array(energies) @@ -561,8 +561,8 @@ def fit(self, volumes, energies): """Fit energies as function of volumes. Args: - volumes (list/np.array) - energies (list/np.array) + volumes (Sequence[float]): in Ang^3 + energies (Sequence[float]): in eV Returns: EOSBase: EOSBase object diff --git a/src/pymatgen/analysis/molecule_structure_comparator.py b/src/pymatgen/analysis/molecule_structure_comparator.py index 32d603abd28..b52ed667042 100644 --- a/src/pymatgen/analysis/molecule_structure_comparator.py +++ b/src/pymatgen/analysis/molecule_structure_comparator.py @@ -194,7 +194,7 @@ def are_equal(self, mol1, mol2) -> bool: def get_13_bonds(priority_bonds): """ Args: - priority_bonds (): + priority_bonds (list[tuple]): 12 bonds Returns: tuple: 13 bonds diff --git a/src/pymatgen/analysis/nmr.py b/src/pymatgen/analysis/nmr.py index bf16031f028..288309513f8 100644 --- a/src/pymatgen/analysis/nmr.py +++ b/src/pymatgen/analysis/nmr.py @@ -122,9 +122,9 @@ def from_maryland_notation(cls, sigma_iso, omega, kappa) -> Self: Initialize from Maryland notation. Args: - sigma_iso (): - omega (): - kappa (): + sigma_iso (float): isotropic chemical shielding + omega (float): anisotropy + kappa (float): asymmetry parameter Returns: ChemicalShielding diff --git a/src/pymatgen/analysis/pourbaix_diagram.py b/src/pymatgen/analysis/pourbaix_diagram.py index c850855564e..135f2abbabf 100644 --- a/src/pymatgen/analysis/pourbaix_diagram.py +++ b/src/pymatgen/analysis/pourbaix_diagram.py @@ -85,10 +85,9 @@ class PourbaixEntry(MSONable, Stringify): def __init__(self, entry, entry_id=None, concentration=1e-6): """ Args: - entry (ComputedEntry/ComputedStructureEntry/PDEntry/IonEntry): An - entry object - entry_id (): - concentration (): + entry (ComputedEntry | ComputedStructureEntry | PDEntry | IonEntry): An entry object + entry_id (str): A string id for the entry + concentration (float): Concentration of the entry in M. Defaults to 1e-6. """ self.entry = entry if isinstance(entry, IonEntry): @@ -102,7 +101,7 @@ def __init__(self, entry, entry_id=None, concentration=1e-6): self.uncorrected_energy = entry.energy if entry_id is not None: self.entry_id = entry_id - elif hasattr(entry, "entry_id") and entry.entry_id: + elif getattr(entry, "entry_id", None): self.entry_id = entry.entry_id else: self.entry_id = None diff --git a/src/pymatgen/analysis/reaction_calculator.py b/src/pymatgen/analysis/reaction_calculator.py index c76ed0889df..26f5766dd36 100644 --- a/src/pymatgen/analysis/reaction_calculator.py +++ b/src/pymatgen/analysis/reaction_calculator.py @@ -139,7 +139,7 @@ def normalize_to_element(self, element: Species | Element, factor: float = 1) -> Another factor can be specified. Args: - element (Element/Species): Element to normalize to. + element (SpeciesLike): Element to normalize to. factor (float): Factor to normalize to. Defaults to 1. """ all_comp = self._all_comp @@ -152,7 +152,7 @@ def get_el_amount(self, element: Element | Species) -> float: """Get the amount of the element in the reaction. Args: - element (Element/Species): Element in the reaction + element (SpeciesLike): Element in the reaction Returns: Amount of that element in the reaction. diff --git a/src/pymatgen/analysis/structure_prediction/substitution_probability.py b/src/pymatgen/analysis/structure_prediction/substitution_probability.py index 210e218d2b1..01a6d32cb2e 100644 --- a/src/pymatgen/analysis/structure_prediction/substitution_probability.py +++ b/src/pymatgen/analysis/structure_prediction/substitution_probability.py @@ -20,6 +20,8 @@ if TYPE_CHECKING: from typing_extensions import Self + from pymatgen.util.typing import SpeciesLike + __author__ = "Will Richards, Geoffroy Hautier" __copyright__ = "Copyright 2012, The Materials Project" __version__ = "1.2" @@ -84,8 +86,8 @@ def __init__(self, lambda_table=None, alpha=-5): def get_lambda(self, s1, s2): """ Args: - s1 (Element/Species/str/int): Describes Ion in 1st Structure - s2 (Element/Species/str/int): Describes Ion in 2nd Structure. + s1 (SpeciesLike): Ion in 1st structure. + s2 (SpeciesLike): Ion in 2nd structure. Returns: Lambda values @@ -93,13 +95,13 @@ def get_lambda(self, s1, s2): key = frozenset([get_el_sp(s1), get_el_sp(s2)]) return self._l.get(key, self.alpha) - def get_px(self, sp): + def get_px(self, sp: SpeciesLike) -> float: """ Args: - sp (Species/Element): Species. + sp (SpeciesLike): Species. Returns: - Probability + float: Probability """ return self._px[get_el_sp(sp)] @@ -185,7 +187,7 @@ class SubstitutionPredictor: def __init__(self, lambda_table=None, alpha=-5, threshold=1e-3): """ Args: - lambda_table (): Input lambda table. + lambda_table (dict): Input lambda table. alpha (float): weight function for never observed substitutions threshold (float): Threshold to use to identify high probability structures. """ diff --git a/src/pymatgen/core/composition.py b/src/pymatgen/core/composition.py index ba29e686a44..168591cbff4 100644 --- a/src/pymatgen/core/composition.py +++ b/src/pymatgen/core/composition.py @@ -507,7 +507,7 @@ def get_atomic_fraction(self, el: SpeciesLike) -> float: """Calculate atomic fraction of an Element or Species. Args: - el (Element/Species): Element or Species to get fraction for. + el (SpeciesLike): Element or Species to get fraction for. Returns: Atomic fraction for element el in Composition diff --git a/src/pymatgen/core/interface.py b/src/pymatgen/core/interface.py index 14421832b34..a7a49004409 100644 --- a/src/pymatgen/core/interface.py +++ b/src/pymatgen/core/interface.py @@ -83,8 +83,8 @@ def __init__( """A Structure with additional information and methods pertaining to GBs. Args: - lattice (Lattice/3x3 array): The lattice, either as an instance or - any 2D array. Each row should correspond to a lattice vector. + lattice (Lattice | np.ndarray): The lattice, either as an instance or + a 3x3 array. Each row should correspond to a lattice vector. species ([Species]): Sequence of species on each site. Can take in flexible input, including: @@ -2390,7 +2390,7 @@ def symm_group_cubic(mat: NDArray) -> list: """Obtain cubic symmetric equivalents of the list of vectors. Args: - mat (n by 3 array/matrix): lattice matrix + mat (np.ndarray): n x 3 lattice matrix Returns: @@ -2451,9 +2451,8 @@ def __init__( and methods pertaining to interfaces. Args: - lattice (Lattice/3x3 array): The lattice, either as a - pymatgen.core.Lattice or - simply as any 2D array. Each row should correspond to a lattice + lattice (Lattice | np.ndarray): The lattice, either as a pymatgen.core.Lattice + or a 3x3 array. Each row should correspond to a lattice vector. e.g. [[10,0,0], [20,10,0], [0,0,30]] specifies a lattice with lattice vectors [10,0,0], [20,10,0] and [0,0,30]. species ([Species]): Sequence of species on each site. Can take in diff --git a/src/pymatgen/core/periodic_table.py b/src/pymatgen/core/periodic_table.py index 2a7abad65c2..d6992dc3c15 100644 --- a/src/pymatgen/core/periodic_table.py +++ b/src/pymatgen/core/periodic_table.py @@ -1609,9 +1609,8 @@ def get_el_sp(obj: int | SpeciesLike) -> Element | Species | DummySpecies: will be attempted. Args: - obj (Element/Species/str/int): An arbitrary object. Supported objects - are actual Element/Species objects, integers (representing atomic - numbers) or strings (element symbols or species strings). + obj (SpeciesLike): An arbitrary object. Supported objects are actual Element/Species, + integers (representing atomic numbers) or strings (element symbols or species strings). Raises: ValueError: if obj cannot be converted into an Element or Species. diff --git a/src/pymatgen/core/structure.py b/src/pymatgen/core/structure.py index 5b9b2fba660..14aa7c19866 100644 --- a/src/pymatgen/core/structure.py +++ b/src/pymatgen/core/structure.py @@ -1256,7 +1256,7 @@ def from_spacegroup( are generated from the spacegroup operations. Args: - sg (str/int): The spacegroup. If a string, it will be interpreted + sg (str | int): The spacegroup. If a string, it will be interpreted as one of the notations supported by pymatgen.symmetry.groups.Spacegroup. e.g. "R-3c" or "Fm-3m". If an int, it will be interpreted as an international number. @@ -1545,7 +1545,7 @@ def matches( Basically a convenience method to call structure matching. Args: - other (IStructure/Structure): Another structure. + other (IStructure | Structure): Another structure. anonymous (bool): Whether to use anonymous structure matching which allows distinct species in one structure to map to another. **kwargs: Same **kwargs as in @@ -1816,7 +1816,7 @@ def get_symmetric_neighbor_list( Args: r (float): Radius of sphere - sg (str/int): The spacegroup the symmetry operations of which will be + sg (str | int): The spacegroup the symmetry operations of which will be used to classify the neighbors. If a string, it will be interpreted as one of the notations supported by pymatgen.symmetry.groups.Spacegroup. e.g. "R-3c" or "Fm-3m". diff --git a/src/pymatgen/io/cssr.py b/src/pymatgen/io/cssr.py index 97631f3bf28..112292cf6b8 100644 --- a/src/pymatgen/io/cssr.py +++ b/src/pymatgen/io/cssr.py @@ -32,7 +32,7 @@ class Cssr: def __init__(self, structure: Structure): """ Args: - structure (Structure/IStructure): A structure to create the Cssr object. + structure (Structure | IStructure): A structure to create the Cssr object. """ if not structure.is_ordered: raise ValueError("Cssr file can only be constructed from ordered structure") diff --git a/src/pymatgen/io/feff/inputs.py b/src/pymatgen/io/feff/inputs.py index 5a3ed16ac35..f4316fe121c 100644 --- a/src/pymatgen/io/feff/inputs.py +++ b/src/pymatgen/io/feff/inputs.py @@ -375,7 +375,7 @@ def __init__(self, struct, absorbing_atom, radius): """ Args: struct (Structure): input structure - absorbing_atom (str/int): Symbol for absorbing atom or site index + absorbing_atom (str | int): Symbol for absorbing atom or site index radius (float): radius of the atom cluster in Angstroms. """ if not struct.is_ordered: @@ -778,7 +778,7 @@ def __init__(self, struct, absorbing_atom): """ Args: struct (Structure): Structure object. - absorbing_atom (str/int): Absorbing atom symbol or site index. + absorbing_atom (str | int): Absorbing atom symbol or site index. """ if not struct.is_ordered: raise ValueError("Structure with partial occupancies cannot be converted into atomic coordinates!") @@ -984,7 +984,7 @@ def get_absorbing_atom_symbol_index(absorbing_atom, structure): """Get the absorbing atom symbol and site index in the given structure. Args: - absorbing_atom (str/int): symbol or site index + absorbing_atom (str | int): symbol or site index structure (Structure) Returns: diff --git a/src/pymatgen/io/feff/outputs.py b/src/pymatgen/io/feff/outputs.py index 133a28c7821..9d5d00137d9 100644 --- a/src/pymatgen/io/feff/outputs.py +++ b/src/pymatgen/io/feff/outputs.py @@ -281,7 +281,7 @@ def __init__(self, header, parameters, absorbing_atom, data): Args: header: Header object parameters: Tags object - absorbing_atom (str/int): absorbing atom symbol or index + absorbing_atom (str | int): absorbing atom symbol or index data (numpy.ndarray, Nx6): cross_sections. """ self.header = header @@ -380,12 +380,12 @@ def as_dict(self): class Eels(MSONable): - """Parse'eels.dat' file.""" + """Parse eels.dat file.""" def __init__(self, data): """ Args: - data (): Eels data. + data (numpy.ndarray): data from eels.dat file """ self.data = np.array(data) diff --git a/src/pymatgen/io/feff/sets.py b/src/pymatgen/io/feff/sets.py index 6dca1577562..83a3945fd65 100644 --- a/src/pymatgen/io/feff/sets.py +++ b/src/pymatgen/io/feff/sets.py @@ -134,7 +134,7 @@ def __init__( ): """ Args: - absorbing_atom (str/int): absorbing atom symbol or site index + absorbing_atom (str | int): absorbing atom symbol or site index structure: Structure or Molecule object. If a Structure, SpaceGroupAnalyzer is used to determine symmetrically-equivalent sites. If a Molecule, there is no symmetry checking. @@ -366,7 +366,7 @@ def __init__( ): r""" Args: - absorbing_atom (str/int): absorbing atom symbol or site index + absorbing_atom (str | int): absorbing atom symbol or site index structure (Structure): input edge (str): absorption edge radius (float): cluster radius in Angstroms. @@ -405,7 +405,7 @@ def __init__( ): r""" Args: - absorbing_atom (str/int): absorbing atom symbol or site index + absorbing_atom (str | int): absorbing atom symbol or site index structure (Structure): input structure edge (str): absorption edge radius (float): cluster radius in Angstroms. @@ -449,7 +449,7 @@ def __init__( ): """ Args: - absorbing_atom (str/int): absorbing atom symbol or site index + absorbing_atom (str | int): absorbing atom symbol or site index structure (Structure): input structure edge (str): absorption edge spectrum (str): ELNES or EXELFS @@ -520,7 +520,7 @@ def __init__( ): r""" Args: - absorbing_atom (str/int): absorbing atom symbol or site index + absorbing_atom (str | int): absorbing atom symbol or site index structure (Structure): input structure edge (str): absorption edge radius (float): cluster radius in Angstroms. @@ -576,7 +576,7 @@ def __init__( ): r""" Args: - absorbing_atom (str/int): absorbing atom symbol or site index + absorbing_atom (str | int): absorbing atom symbol or site index structure (Structure): input structure edge (str): absorption edge radius (float): cluster radius in Angstroms. diff --git a/src/pymatgen/io/qchem/inputs.py b/src/pymatgen/io/qchem/inputs.py index 27f2816103e..7776940c27d 100644 --- a/src/pymatgen/io/qchem/inputs.py +++ b/src/pymatgen/io/qchem/inputs.py @@ -292,7 +292,7 @@ def get_str(self) -> str: def multi_job_string(job_list: list[QCInput]) -> str: """ Args: - job_list (): List of jobs. + job_list (list[QCInput]): List of QChem jobs. Returns: str: String representation of a multi-job input file. @@ -373,8 +373,8 @@ def write_multi_job_file(job_list: list[QCInput], filename: str): """Write a multijob file. Args: - job_list (): List of jobs. - filename (): Filename + job_list (list[QCInput]): List of QChem jobs. + filename (str): Name of the file to write. """ with zopen(filename, mode="wt") as file: file.write(QCInput.multi_job_string(job_list)) @@ -452,10 +452,10 @@ def molecule_template(molecule: Molecule | list[Molecule] | Literal["read"]) -> return "\n".join(mol_list) @staticmethod - def rem_template(rem: dict) -> str: + def rem_template(rem: dict[str, Any]) -> str: """ Args: - rem (): + rem (dict[str, Any]): REM section. Returns: str: REM template. @@ -473,7 +473,7 @@ def opt_template(opt: dict[str, list]) -> str: Optimization template. Args: - opt (): + opt (dict[str, list]): Optimization section. Returns: str: Optimization template. @@ -498,7 +498,7 @@ def pcm_template(pcm: dict) -> str: PCM run template. Args: - pcm (): + pcm (dict): PCM section. Returns: str: PCM template. @@ -515,7 +515,7 @@ def solvent_template(solvent: dict) -> str: """Solvent template. Args: - solvent (): + solvent (dict): Solvent section. Returns: str: Solvent section. @@ -531,7 +531,7 @@ def solvent_template(solvent: dict) -> str: def smx_template(smx: dict) -> str: """ Args: - smx (): + smx (dict): Solvation model with short-range corrections. Returns: str: Solvation model with short-range corrections. @@ -604,7 +604,7 @@ def van_der_waals_template(radii: dict[str, float], mode: str = "atomic") -> str def plots_template(plots: dict) -> str: """ Args: - plots (): + plots (dict): Plots section. Returns: str: Plots section. @@ -619,7 +619,7 @@ def plots_template(plots: dict) -> str: def nbo_template(nbo: dict) -> str: """ Args: - nbo (): + nbo (dict): NBO section. Returns: str: NBO section. @@ -655,7 +655,7 @@ def svp_template(svp: dict) -> str: def geom_opt_template(geom_opt: dict) -> str: """ Args: - geom_opt (): + geom_opt (dict): Geometry optimization section. Returns: str: Geometry optimization section. diff --git a/src/pymatgen/io/vasp/outputs.py b/src/pymatgen/io/vasp/outputs.py index d44f0f894ba..40634973a1f 100644 --- a/src/pymatgen/io/vasp/outputs.py +++ b/src/pymatgen/io/vasp/outputs.py @@ -281,7 +281,7 @@ def __init__( eigenvalues and magnetization. Defaults to False. Set to True to obtain projected eigenvalues and magnetization. **Note that this can take an extreme amount of time and memory.** So use this wisely. - parse_potcar_file (PathLike/bool): Whether to parse the potcar file to read + parse_potcar_file (bool | PathLike): Whether to parse the potcar file to read the potcar hashes for the potcar_spec attribute. Defaults to True, where no hashes will be determined and the potcar_spec dictionaries will read {"symbol": ElSymbol, "hash": None}. By Default, looks in diff --git a/src/pymatgen/io/vasp/sets.py b/src/pymatgen/io/vasp/sets.py index d333056b4ce..5467c2cec68 100644 --- a/src/pymatgen/io/vasp/sets.py +++ b/src/pymatgen/io/vasp/sets.py @@ -148,7 +148,7 @@ class VaspInputSet(InputGenerator, abc.ABC): force_gamma (bool): Force gamma centered kpoint generation. Default (False) is to use the Automatic Density kpoint scheme, which will use the Gamma centered generation scheme for hexagonal cells, and Monkhorst-Pack otherwise. - reduce_structure (None/str): Before generating the input files, generate the + reduce_structure (str | None): Before generating the input files, generate the reduced structure. Default (None), does not alter the structure. Valid values: None, "niggli", "LLL". vdw: Adds default parameters for van-der-Waals functionals supported by VASP to diff --git a/src/pymatgen/io/xr.py b/src/pymatgen/io/xr.py index 645c8a6910c..4ad17556412 100644 --- a/src/pymatgen/io/xr.py +++ b/src/pymatgen/io/xr.py @@ -38,7 +38,7 @@ class Xr: def __init__(self, structure: Structure): """ Args: - structure (Structure/IStructure): Structure object to create the Xr object. + structure (Structure | IStructure): Structure object to create the Xr object. """ if not structure.is_ordered: raise ValueError("Xr file can only be constructed from ordered structure") diff --git a/src/pymatgen/symmetry/analyzer.py b/src/pymatgen/symmetry/analyzer.py index 375a9214a98..5a06a9c4b48 100644 --- a/src/pymatgen/symmetry/analyzer.py +++ b/src/pymatgen/symmetry/analyzer.py @@ -87,7 +87,7 @@ def __init__( ) -> None: """ Args: - structure (Structure/IStructure): Structure to find symmetry + structure (Structure | IStructure): Structure to find symmetry symprec (float): Tolerance for symmetry finding. Defaults to 0.01, which is fairly strict and works well for properly refined structures with atoms in the proper symmetry coordinates. For diff --git a/src/pymatgen/util/plotting.py b/src/pymatgen/util/plotting.py index 5cf33601c21..068d1c2a064 100644 --- a/src/pymatgen/util/plotting.py +++ b/src/pymatgen/util/plotting.py @@ -93,10 +93,10 @@ def pretty_plot_two_axis( examples. Makes it easier to create plots with different axes. Args: - x (np.ndarray/list): Data for x-axis. - y1 (dict/np.ndarray/list): Data for y1 axis (left). If a dict, it will + x (Sequence[float]): Data for x-axis. + y1 (Sequence[float] | dict[str, Sequence[float]]): Data for y1 axis (left). If a dict, it will be interpreted as a {label: sequence}. - y2 (dict/np.ndarray/list): Data for y2 axis (right). If a dict, it will + y2 (Sequence[float] | dict[str, Sequence[float]]): Data for y2 axis (right). If a dict, it will be interpreted as a {label: sequence}. xlabel (str): If not None, this will be the label for the x-axis. y1label (str): If not None, this will be the label for the y1-axis. diff --git a/src/pymatgen/vis/structure_vtk.py b/src/pymatgen/vis/structure_vtk.py index 86ed42265e5..2bc4293e2e1 100644 --- a/src/pymatgen/vis/structure_vtk.py +++ b/src/pymatgen/vis/structure_vtk.py @@ -361,7 +361,7 @@ def add_partial_sphere(self, coords, radius, color, start=0, end=360, opacity=1. Args: coords (nd.array): Coordinates radius (float): Radius of sphere - color (): Color of sphere. + color (tuple): RGB color of sphere start (float): Starting angle. end (float): Ending angle. opacity (float): Opacity. @@ -569,8 +569,8 @@ def add_faces(self, faces, color, opacity=0.35): Adding face of polygon. Args: - faces (): Coordinates of the faces. - color (): Color. + faces (list): Coordinates of the faces. + color (tuple): RGB color. opacity (float): Opacity """ for face in faces: @@ -629,13 +629,19 @@ def add_faces(self, faces, color, opacity=0.35): else: raise ValueError("Number of points for a face should be >= 3") - def add_edges(self, edges, type="line", linewidth=2, color=(0.0, 0.0, 0.0)): # noqa: A002 + def add_edges( + self, + edges: Sequence[Sequence[Sequence[float]]], + type: str = "line", # noqa: A002 + linewidth: float = 2, + color: tuple[float, float, float] = (0.0, 0.0, 0.0), + ) -> None: """ Args: - edges (): List of edges - type (): placeholder - linewidth (): Width of line - color (nd.array/tuple): RGB color. + edges (Sequence): List of edges. Each edge is a list of two points. + type (str): Type of the edge. Defaults to "line". Unused. + linewidth (float): Width of the line. + color (tuple[float, float, float]): RGB color. """ points = vtk.vtkPoints() lines = vtk.vtkCellArray() @@ -922,7 +928,7 @@ def __init__( bonding determination. Defaults to an empty list. Useful when trying to visualize a certain atom type in the framework (e.g., Li in a Li-ion battery cathode material). - animated_movie_options (): Used for moving. + animated_movie_options (dict): Options for animated movie. """ super().__init__( element_color_mapping=element_color_mapping, @@ -942,12 +948,11 @@ def __init__( self.set_animated_movie_options(animated_movie_options=animated_movie_options) def set_structures(self, structures: Sequence[Structure], tags=None): - """ - Add list of structures to the visualizer. + """Add list of structures to the visualizer. Args: structures (list[Structures]): structures to be visualized. - tags (): List of tags. + tags (list[dict]): List of tags to be applied to the structures. """ self.structures = structures self.istruct = 0 @@ -1054,7 +1059,7 @@ def apply_tags(self): def set_animated_movie_options(self, animated_movie_options=None): """ Args: - animated_movie_options (): animated movie options. + animated_movie_options (dict): Options for animated movie. """ if animated_movie_options is None: self.animated_movie_options = self.DEFAULT_ANIMATED_MOVIE_OPTIONS.copy()