Skip to content

Commit d4c6d43

Browse files
committed
rename test_(to->as)_from_dict
google-style doc str for class Poscar
1 parent 4eb70cb commit d4c6d43

25 files changed

+119
-147
lines changed

pymatgen/io/vasp/inputs.py

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -54,48 +54,22 @@
5454
class Poscar(MSONable):
5555
"""
5656
Object for representing the data in a POSCAR or CONTCAR file.
57-
Please note that this current implementation. Most attributes can be set
58-
directly.
5957
60-
.. attribute:: structure
61-
62-
Associated Structure.
63-
64-
.. attribute:: comment
65-
66-
Optional comment string.
67-
68-
.. attribute:: true_names
69-
70-
Boolean indication whether Poscar contains actual real names parsed
71-
from either a POTCAR or the POSCAR itself.
72-
73-
.. attribute:: selective_dynamics
74-
75-
Selective dynamics attribute for each site if available. A Nx3 array of
76-
booleans.
77-
78-
.. attribute:: velocities
79-
80-
Velocities for each site (typically read in from a CONTCAR). A Nx3
81-
array of floats.
82-
83-
.. attribute:: predictor_corrector
84-
85-
Predictor corrector coordinates and derivatives for each site; i.e.
86-
a list of three 1x3 arrays for each site (typically read in from a MD
87-
CONTCAR).
88-
89-
.. attribute:: predictor_corrector_preamble
90-
91-
Predictor corrector preamble contains the predictor-corrector key,
92-
POTIM, and thermostat parameters that precede the site-specic predictor
93-
corrector data in MD CONTCAR
94-
95-
.. attribute:: temperature
96-
97-
Temperature of velocity Maxwell-Boltzmann initialization. Initialized
98-
to -1 (MB hasn"t been performed).
58+
Attributes:
59+
structure: Associated Structure.
60+
comment: Optional comment string.
61+
true_names: Boolean indication whether Poscar contains actual real names parsed
62+
from either a POTCAR or the POSCAR itself.
63+
selective_dynamics: Selective dynamics attribute for each site if available.
64+
A Nx3 array of booleans.
65+
velocities: Velocities for each site (typically read in from a CONTCAR).
66+
A Nx3 array of floats.
67+
predictor_corrector: Predictor corrector coordinates and derivatives for each site;
68+
i.e. a list of three 1x3 arrays for each site (typically read in from a MD CONTCAR).
69+
predictor_corrector_preamble: Predictor corrector preamble contains the predictor-corrector key,
70+
POTIM, and thermostat parameters that precede the site-specic predictor corrector data in MD CONTCAR.
71+
temperature: Temperature of velocity Maxwell-Boltzmann initialization.
72+
Initialized to -1 (MB hasn't been performed).
9973
"""
10074

10175
def __init__(

tests/alchemy/test_filters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_filtering(self):
4747
f8 = ContainsSpecieFilter(species4, strict_compare=False, AND=True)
4848
assert not f8.test(struct), "Incorrect filter"
4949

50-
def test_to_from_dict(self):
50+
def test_as_from_dict(self):
5151
species1 = ["Si5+", "Mg2+"]
5252
f1 = ContainsSpecieFilter(species1, strict_compare=True, AND=False)
5353
d = f1.as_dict()
@@ -66,7 +66,7 @@ def test_filter(self):
6666
sf = SpecieProximityFilter({"P": 5})
6767
assert not sf.test(struct)
6868

69-
def test_to_from_dict(self):
69+
def test_as_from_dict(self):
7070
sf = SpecieProximityFilter({"Li": 1})
7171
d = sf.as_dict()
7272
assert isinstance(SpecieProximityFilter.from_dict(d), SpecieProximityFilter)
@@ -85,7 +85,7 @@ def test_filter(self):
8585
transmuter.apply_filter(dup_filter)
8686
assert len(transmuter.transformed_structures) == 11
8787

88-
def test_to_from_dict(self):
88+
def test_as_from_dict(self):
8989
fil = RemoveDuplicatesFilter()
9090
d = fil.as_dict()
9191
assert isinstance(RemoveDuplicatesFilter().from_dict(d), RemoveDuplicatesFilter)

tests/analysis/test_energy_models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_get_energy(self):
3131
s2 = Structure.from_file(f"{TEST_FILES_DIR}/Li2O.cif")
3232
assert m.get_energy(s2) == approx(-145.39050015844839, abs=1e-4)
3333

34-
def test_to_from_dict(self):
34+
def test_as_from_dict(self):
3535
m = EwaldElectrostaticModel()
3636
d = m.as_dict()
3737
assert isinstance(EwaldElectrostaticModel.from_dict(d), EwaldElectrostaticModel)
@@ -43,7 +43,7 @@ def test_get_energy(self):
4343
s2 = Structure.from_file(f"{TEST_FILES_DIR}/Li2O.cif")
4444
assert m.get_energy(s2) == approx(-225)
4545

46-
def test_to_from_dict(self):
46+
def test_as_from_dict(self):
4747
m = SymmetryModel(symprec=0.2)
4848
d = m.as_dict()
4949
o = SymmetryModel.from_dict(d)
@@ -63,7 +63,7 @@ def test_get_energy(self):
6363
struct[5] = Species("Fe", 2, spin=-4)
6464
assert m.get_energy(struct) == approx(51.97424405382921)
6565

66-
def test_to_from_dict(self):
66+
def test_as_from_dict(self):
6767
m = IsingModel(5, 4)
6868
d = m.as_dict()
6969
o = IsingModel.from_dict(d)

tests/analysis/test_graphs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def test_draw(self):
390390
}
391391
assert pdfs == expected_pdfs
392392

393-
def test_to_from_dict(self):
393+
def test_as_from_dict(self):
394394
d = self.mos2_sg.as_dict()
395395
sg = StructureGraph.from_dict(d)
396396
d2 = sg.as_dict()

tests/analysis/test_phase_diagram.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_is_element(self):
7272
assert not self.entry.is_element
7373
assert not self.gp_entry.is_element
7474

75-
def test_to_from_dict(self):
75+
def test_as_from_dict(self):
7676
d = self.entry.as_dict()
7777
gpd = self.gp_entry.as_dict()
7878
entry = PDEntry.from_dict(d)
@@ -142,7 +142,7 @@ def test_is_element(self):
142142
iron = Composition("Fe")
143143
assert TransformedPDEntry(PDEntry(iron, 0), {iron: iron}).is_element is True
144144

145-
def test_to_from_dict(self):
145+
def test_as_from_dict(self):
146146
dct = self.transformed_entry.as_dict()
147147
entry = TransformedPDEntry.from_dict(dct)
148148
assert entry.name == "LiFeO2" == self.transformed_entry.name
@@ -599,7 +599,7 @@ def test_get_all_chempots(self):
599599
def test_get_plot(self):
600600
self.pd.get_plot() # PDPlotter functionality is tested separately
601601

602-
def test_to_from_dict(self):
602+
def test_as_from_dict(self):
603603
# test round-trip for other entry types such as ComputedEntry
604604
entry = ComputedEntry("H", 0.0, 0.0, entry_id="test")
605605
pd = PhaseDiagram([entry])
@@ -768,7 +768,7 @@ def test_get_decomp_and_e_above_hull(self):
768768
def test_repr(self):
769769
assert repr(self.ppd) == str(self.ppd) == "PatchedPhaseDiagram covering 15 sub-spaces"
770770

771-
def test_to_from_dict(self):
771+
def test_as_from_dict(self):
772772
ppd_dict = self.ppd.as_dict()
773773
assert ppd_dict["@module"] == self.ppd.__class__.__module__
774774
assert ppd_dict["@class"] == self.ppd.__class__.__name__

tests/analysis/test_pourbaix_diagram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_calc_coeff_terms(self):
5151
assert self.PxSol.nPhi == -6, "Wrong nPhi!"
5252
assert self.PxSol.nH2O == 3, "Wrong nH2O!"
5353

54-
def test_to_from_dict(self):
54+
def test_as_from_dict(self):
5555
d = self.PxIon.as_dict()
5656
ion_entry = self.PxIon.from_dict(d)
5757
assert ion_entry.entry.name == "MnO4[-1]", "Wrong Entry!"

tests/analysis/test_reaction_calculator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def test_products_reactants(self):
233233
assert rxn.normalized_repr == "4 Li3Fe2(PO4)3 + 2 Fe2O3 -> 3 O2 + 12 LiFePO4"
234234
assert rxn.calculate_energy(energies) == approx(-0.48333333, abs=1e-5)
235235

236-
def test_to_from_dict(self):
236+
def test_as_from_dict(self):
237237
reactants = [Composition("Fe"), Composition("O2")]
238238
products = [Composition("Fe2O3")]
239239
rxn = Reaction(reactants, products)
@@ -300,7 +300,7 @@ def test_init(self):
300300
with pytest.raises(ReactionError, match="Reaction is unbalanced"):
301301
BalancedReaction(rct, prod)
302302

303-
def test_to_from_dict(self):
303+
def test_as_from_dict(self):
304304
rct = {Composition("K2SO4"): 3, Composition("Na2S"): 1, Composition("Li"): 24}
305305
prod = {Composition("KNaS"): 2, Composition("K2S"): 2, Composition("Li2O"): 12}
306306
rxn = BalancedReaction(rct, prod)
@@ -516,7 +516,7 @@ def test_calculated_reaction_energy_uncertainty_for_nan(self):
516516
def test_init(self):
517517
assert str(self.rxn) == "2 Li + O2 -> Li2O2"
518518

519-
def test_to_from_dict(self):
519+
def test_as_from_dict(self):
520520
d = self.rxn.as_dict()
521521
new_rxn = ComputedReaction.from_dict(d)
522522
assert str(new_rxn) == "2 Li + O2 -> Li2O2"

tests/analysis/xas/test_spectrum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_add_mul(self):
5555
assert_allclose(scaled_spect2.y, 3 * self.k_xanes.y)
5656
assert approx(self.k_xanes.get_interpolated_value(7720.422), abs=1e-3) == 0.274302
5757

58-
def test_to_from_dict(self):
58+
def test_as_from_dict(self):
5959
s = XAS.from_dict(self.k_xanes.as_dict())
6060
assert_allclose(s.y, self.k_xanes.y)
6161

tests/apps/battery/test_insertion_battery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_entries(self):
7979
def test_get_all_entries(self):
8080
self.ie_LTO.get_all_entries()
8181

82-
def test_to_from_dict(self):
82+
def test_as_from_dict(self):
8383
d = self.ie_LTO.as_dict()
8484
ie = InsertionElectrode.from_dict(d)
8585
assert ie.max_voltage == approx(2.78583901)

tests/apps/borg/test_hive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_assimilate(self):
3838
assert entry.structure is not None
3939
# assert len(entry.parameters["history"]) == 2
4040

41-
def test_to_from_dict(self):
41+
def test_as_from_dict(self):
4242
d = self.structure_drone.as_dict()
4343
drone = VaspToComputedEntryDrone.from_dict(d)
4444
assert isinstance(drone, VaspToComputedEntryDrone)
@@ -54,7 +54,7 @@ def test_get_valid_paths(self):
5454
if path[0] == TEST_FILES_DIR:
5555
assert len(self.drone.get_valid_paths(path)) > 0
5656

57-
def test_to_from_dict(self):
57+
def test_as_from_dict(self):
5858
d = self.structure_drone.as_dict()
5959
drone = SimpleVaspToComputedEntryDrone.from_dict(d)
6060
assert isinstance(drone, SimpleVaspToComputedEntryDrone)
@@ -94,7 +94,7 @@ def test_assimilate(self):
9494
for p in ["properly_terminated", "stationary_type"]:
9595
assert p in entry.data
9696

97-
def test_to_from_dict(self):
97+
def test_as_from_dict(self):
9898
d = self.structure_drone.as_dict()
9999
drone = GaussianToComputedEntryDrone.from_dict(d)
100100
assert isinstance(drone, GaussianToComputedEntryDrone)

0 commit comments

Comments
 (0)