Skip to content

Commit 5c8b51c

Browse files
authored
Imperative doc strings (#3792)
* standardize first line class doc strings to imperative style np.average->np.mean * imperative doc strings * imperative doc strings * revert np.mean to np.average where passing weight kwarg * imperative doc strings * """Returns -> """Get * remove "Returns:" from property doc strings * bug fix: as_dict should not have been property on SeparationPlane and ExplicitPermutationsAlgorithm * format property doc strings with leading line break * ", e.g.," -> ", e.g." * remove leading "Get" from property doc strings * Fix TestCoordinationGeometries using as_dict as property which should have been normal method all along
1 parent 9964c4a commit 5c8b51c

File tree

145 files changed

+782
-1161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+782
-1161
lines changed

dev_scripts/chemenv/strategies/multi_weights_strategy_parameters.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ def simple_expansion(cls, initial_environment_symbol, expected_final_environment
7373
)
7474

7575
def figure_fractions(self, weights_options: dict, morphing_factors: Sequence[float] | None = None) -> None:
76-
"""
77-
Plot the fractions of the initial and final coordination environments as a function of the morphing factor.
76+
"""Plot the fractions of the initial and final coordination environments as a
77+
function of the morphing factor.
7878
7979
Args:
80-
weights_options (dict): The weights options.
81-
morphing_factors (list): The morphing factors.
80+
weights_options (dict): The weights options. morphing_factors (list): The
81+
morphing factors.
8282
"""
8383
if morphing_factors is None:
8484
morphing_factors = np.linspace(1.0, 2.0, 21)

pymatgen/alchemy/materials.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def from_cif_str(
281281
primitive (bool): Option to set if the primitive cell should be
282282
extracted. Defaults to True. However, there are certain
283283
instances where you might want to use a non-primitive cell,
284-
e.g., if you are trying to generate all possible orderings of
284+
e.g. if you are trying to generate all possible orderings of
285285
partial removals or order a disordered structure. Defaults to True.
286286
occupancy_tolerance (float): If total occupancy of a site is
287287
between 1 and occupancy_tolerance, the occupancies will be
@@ -352,8 +352,7 @@ def from_dict(cls, dct: dict) -> Self:
352352
return cls(struct, history=dct["history"], other_parameters=dct.get("other_parameters"))
353353

354354
def to_snl(self, authors: list[str], **kwargs) -> StructureNL:
355-
"""
356-
Generate a StructureNL from TransformedStructure.
355+
"""Generate a StructureNL from TransformedStructure.
357356
358357
Args:
359358
authors (List[str]): List of authors contributing to the generated StructureNL.

pymatgen/alchemy/transmuters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def add_tags(self, tags):
182182
183183
Args:
184184
tags: A sequence of tags. Note that this should be a sequence of
185-
strings, e.g., ["My awesome structures", "Project X"].
185+
strings, e.g. ["My awesome structures", "Project X"].
186186
"""
187187
self.set_parameter("tags", tags)
188188

@@ -336,7 +336,7 @@ def batch_write_vasp_input(
336336
Defaults to True.
337337
subfolder: Function to create subdirectory name from
338338
transformed_structure.
339-
e.g., lambda x: x.other_parameters["tags"][0] to use the first
339+
e.g. lambda x: x.other_parameters["tags"][0] to use the first
340340
tag.
341341
include_cif (bool): Boolean indication whether to output a CIF as
342342
well. CIF files are generally better supported in visualization

pymatgen/analysis/adsorption.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def from_bulk_and_miller(
139139
surf_props, under_coords = [], []
140140
this_mi_vec = get_mi_vec(this_slab)
141141
mi_mags = [np.dot(this_mi_vec, site.coords) for site in this_slab]
142-
average_mi_mag = np.average(mi_mags)
142+
average_mi_mag = np.mean(mi_mags)
143143
for n, site in enumerate(this_slab):
144144
bulk_coord = this_slab.site_properties["bulk_coordinations"][n]
145145
slab_coord = len(vnn_surface.get_nn(this_slab, n))
@@ -355,9 +355,9 @@ def ensemble_center(cls, site_list, indices, cartesian=True):
355355
Cartesian coordinate
356356
"""
357357
if cartesian:
358-
return np.average([site_list[idx].coords for idx in indices], axis=0)
358+
return np.mean([site_list[idx].coords for idx in indices], axis=0)
359359

360-
return np.average([site_list[idx].frac_coords for idx in indices], axis=0)
360+
return np.mean([site_list[idx].frac_coords for idx in indices], axis=0)
361361

362362
def add_adsorbate(self, molecule: Molecule, ads_coord, repeat=None, translate=True, reorient=True):
363363
"""Add an adsorbate at a particular coordinate. Adsorbate represented

pymatgen/analysis/bond_dissociation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ def __init__(
4444
allow_additional_charge_separation: bool = False,
4545
multibreak: bool = False,
4646
) -> None:
47-
"""
48-
Note that the entries passed by the user must have the following keys: formula_pretty, initial_molecule,
47+
"""The provided entries must have the following keys: formula_pretty, initial_molecule,
4948
final_molecule. If a PCM is present, all entries should also have a pcm_dielectric key.
5049
5150
Args:
@@ -327,8 +326,7 @@ def filter_fragment_entries(self, fragment_entries: list) -> None:
327326
self.filtered_entries += [entry]
328327

329328
def build_new_entry(self, frags: list, bonds: list) -> list:
330-
"""
331-
Build a new entry for bond dissociation that will be returned to the user.
329+
"""Build a new entry for bond dissociation that will be returned to the user.
332330
333331
Args:
334332
frags (list): Fragments involved in the bond dissociation.

pymatgen/analysis/bond_valence.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ def __init__(
126126
charge_neutrality_tolerance=CHARGE_NEUTRALITY_TOLERANCE,
127127
forbidden_species=None,
128128
):
129-
"""
130-
Initializes the BV analyzer, with useful defaults.
129+
"""Initialize the BV analyzer, with useful defaults.
131130
132131
Args:
133132
symm_tol:
@@ -204,16 +203,15 @@ def _calc_site_probabilities_unordered(self, site, nn):
204203
return prob
205204

206205
def get_valences(self, structure: Structure):
207-
"""
208-
Returns a list of valences for each site in the structure.
206+
"""Get a list of valences for each site in the structure.
209207
210208
Args:
211209
structure: Structure to analyze
212210
213211
Returns:
214212
A list of valences for each site in the structure (for an ordered structure),
215-
e.g., [1, 1, -2] or a list of lists with the valences for each fractional
216-
element of each site in the structure (for an unordered structure), e.g., [[2,
213+
e.g. [1, 1, -2] or a list of lists with the valences for each fractional
214+
element of each site in the structure (for an unordered structure), e.g. [[2,
217215
4], [3], [-2], [-2], [-2]]
218216
219217
Raises:
@@ -469,7 +467,7 @@ def add_oxidation_state_by_site_fraction(structure, oxidation_states):
469467
Args:
470468
oxidation_states (list): List of list of oxidation states for each
471469
site fraction for each site.
472-
E.g., [[2, 4], [3], [-2], [-2], [-2]]
470+
e.g. [[2, 4], [3], [-2], [-2], [-2]]
473471
"""
474472
try:
475473
for idx, site in enumerate(structure):

pymatgen/analysis/chemenv/connectivity/connected_components.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,14 @@ def _order_periodicity_vectors(self):
625625

626626
@property
627627
def periodicity_vectors(self):
628-
"""Get periodicity vectors of this connected component."""
628+
"""Periodicity vectors of this connected component."""
629629
if self._periodicity_vectors is None:
630630
self.compute_periodicity()
631631
return [np.array(pp) for pp in self._periodicity_vectors]
632632

633633
@property
634634
def periodicity(self):
635-
"""Get periodicity of this connected component."""
635+
"""Periodicity of this connected component."""
636636
if self._periodicity_vectors is None:
637637
self.compute_periodicity()
638638
return f"{len(self._periodicity_vectors)}D"

pymatgen/analysis/chemenv/coordination_environments/chemenv_strategies.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,8 @@ def from_dict(cls, dct: dict) -> Self:
196196

197197

198198
class AbstractChemenvStrategy(MSONable, abc.ABC):
199-
"""
200-
Class used to define a Chemenv strategy for the neighbors and coordination environment to be applied to a
201-
StructureEnvironments object.
199+
"""Base class to define a Chemenv strategy for the neighbors and coordination environment
200+
to be applied to a StructureEnvironments object.
202201
"""
203202

204203
AC = AdditionalConditions()

0 commit comments

Comments
 (0)