Skip to content

Commit

Permalink
fix missing types in doc string args
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Aug 4, 2024
1 parent e06afe9 commit 4a1522c
Show file tree
Hide file tree
Showing 28 changed files with 104 additions and 98 deletions.
4 changes: 2 additions & 2 deletions src/pymatgen/alchemy/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -157,7 +157,7 @@ def from_dict(cls, dct: dict) -> Self:
dct (dict): Dict representation.
Returns:
Filter
SpecieProximityFilter
"""
return cls(**dct["init_args"])

Expand Down
4 changes: 2 additions & 2 deletions src/pymatgen/alchemy/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
]
Expand Down
4 changes: 2 additions & 2 deletions src/pymatgen/analysis/cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/pymatgen/analysis/diffraction/xrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/pymatgen/analysis/elasticity/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/pymatgen/analysis/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pymatgen/analysis/molecule_structure_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/pymatgen/analysis/nmr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions src/pymatgen/analysis/pourbaix_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/pymatgen/analysis/reaction_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -84,22 +86,22 @@ 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
"""
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)]

Expand Down Expand Up @@ -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.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/pymatgen/core/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions src/pymatgen/core/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/pymatgen/core/periodic_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/pymatgen/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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".
Expand Down
2 changes: 1 addition & 1 deletion src/pymatgen/io/cssr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions src/pymatgen/io/feff/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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!")
Expand Down Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 4a1522c

Please sign in to comment.