Skip to content

Commit 59a76b5

Browse files
committed
CONSTANT_CASE module-scoped TEST_DIR
1 parent 42ebece commit 59a76b5

Some content is hidden

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

48 files changed

+580
-595
lines changed

pymatgen/analysis/wulff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def get_plotly(
530530

531531
tri_indices = np.array(list(itertools.combinations(index_list, 3))).T
532532
hkl = self.miller_list[plane.index]
533-
hkl = unicodeify_spacegroup("(" + "%s" * len(hkl) % hkl + ")")
533+
hkl = unicodeify_spacegroup(f"({'%s' * len(hkl) % hkl})")
534534
cs = tuple(np.array(plane_color) * 255)
535535
color = f"rgba({cs[0]:.5f}, {cs[1]:.5f}, {cs[2]:.5f}, {cs[3]:.5f})"
536536

pymatgen/electronic_structure/boltztrap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def write_def(self, output_file) -> None:
351351
"6,'boltztrap.outputtrans', 'unknown', "
352352
"'formatted',0\n"
353353
"20,'boltztrap.struct', 'old', 'formatted',0\n"
354-
"10,'boltztrap.energy" + so + "', 'old', "
354+
f"10,'boltztrap.energy{so}', 'old', "
355355
"'formatted',0\n48,'boltztrap.engre', 'unknown', "
356356
"'unformatted',0\n49,'boltztrap.transdos', 'unknown', "
357357
"'formatted',0\n50,'boltztrap.sigxx', 'unknown', 'formatted',"
@@ -400,7 +400,7 @@ def write_proj(self, output_file_proj, output_file_def) -> None:
400400
"6,'boltztrap.outputtrans', 'unknown', "
401401
"'formatted',0\n"
402402
"20,'boltztrap.struct', 'old', 'formatted',0\n"
403-
"10,'boltztrap.energy" + so + "', 'old', "
403+
f"10,'boltztrap.energy{so}', 'old', "
404404
"'formatted',0\n48,'boltztrap.engre', 'unknown', "
405405
"'unformatted',0\n49,'boltztrap.transdos', 'unknown', "
406406
"'formatted',0\n50,'boltztrap.sigxx', 'unknown', 'formatted',"

pymatgen/io/aims/inputs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,18 +469,18 @@ def parameters(self, parameters: dict[str, Any]) -> None:
469469
if "output" not in self._parameters:
470470
self._parameters["output"] = []
471471

472-
def get_aims_control_parameter_str(self, key: str, value: Any, format: str) -> str:
472+
def get_aims_control_parameter_str(self, key: str, value: Any, fmt: str) -> str:
473473
"""Get the string needed to add a parameter to the control.in file
474474
475475
Args:
476-
key(str): The name of the input flag
477-
value(Any): The value to be set for the flag
478-
format(str): The format string to apply to the value
476+
key (str): The name of the input flag
477+
value (Any): The value to be set for the flag
478+
fmt (str): The format string to apply to the value
479479
480480
Returns:
481481
The line to add to the control.in file
482482
"""
483-
return f"{key:35s}" + (format % value) + "\n"
483+
return f"{key:35s}{fmt % value}\n"
484484

485485
def write_file(
486486
self,

pymatgen/io/cif.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,8 @@ def get_magsymops(self, data):
808808
label = bns_name if bns_name else list(map(int, (bns_num.split("."))))
809809

810810
if data.data.get("_space_group_magn.transform_BNS_Pp_abc") != "a,b,c;0,0,0":
811-
jf = data.data.get("_space_group_magn.transform_BNS_Pp_abc")
812-
msg = MagneticSpaceGroup(label, jf)
811+
jonas_faithful = data.data.get("_space_group_magn.transform_BNS_Pp_abc")
812+
msg = MagneticSpaceGroup(label, jonas_faithful)
813813

814814
elif data.data.get("_space_group_magn.transform_BNS_Pp"):
815815
return NotImplementedError("Incomplete specification to implement.")

pymatgen/io/cp2k/inputs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def _get_str(d, indent=0):
575575
string += "\t" * (indent + 1) + v.get_str() + "\n"
576576
for v in d.subsections.values():
577577
string += v._get_str(v, indent + 1)
578-
string += "\t" * indent + "&END " + d.name + "\n"
578+
string += "\t" * indent + f"&END {d.name}\n"
579579

580580
return string
581581

@@ -764,7 +764,7 @@ def _from_lines(self, lines):
764764
self.by_path(current)[s.alias or s.name] = SectionList(sections=[tmp, s])
765765
else:
766766
self.by_path(current).insert(s)
767-
current = current + "/" + alias if alias else current + "/" + name
767+
current = f"{current}/{alias or name}"
768768
else:
769769
kwd = Keyword.from_str(line)
770770
tmp = self.by_path(current).get(kwd.name)

pymatgen/io/vasp/inputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def from_str(cls, data, default_names=None, read_velocities=True):
460460
# First line in chunk is a key in CONTCAR
461461
# Second line is POTIM
462462
# Third line is the thermostat parameters
463-
predictor_corrector_preamble = lines[0] + "\n" + lines[1] + "\n" + lines[2]
463+
predictor_corrector_preamble = f"{lines[0]}\n{lines[1]}\n{lines[2]}"
464464
# Rest is three sets of parameters, each set contains
465465
# x, y, z predictor-corrector parameters for every atom in order
466466
lines = lines[3:]

pymatgen/util/string.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def charge_string(charge, brackets=True, explicit_one=True):
140140
chg_str = chg_str.replace("1", "")
141141

142142
if chg_str != "(aq)" and brackets:
143-
chg_str = "[" + chg_str + "]"
143+
chg_str = f"[{chg_str}]"
144144

145145
return chg_str
146146

tests/analysis/ferroelectricity/test_polarization.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
from pymatgen.io.vasp.outputs import Outcar
1616
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
1717

18-
test_dir = f"{TEST_FILES_DIR}/BTO_221_99_polarization"
18+
TEST_DIR = f"{TEST_FILES_DIR}/BTO_221_99_polarization"
1919
bto_folders = ["nonpolar_polarization"]
2020
bto_folders += [f"interpolation_{i}_polarization" for i in range(1, 9)][::-1]
2121
bto_folders += ["polar_polarization"]
2222

23-
structures = [Structure.from_file(test_dir + "/" + folder + "/POSCAR") for folder in bto_folders]
23+
structures = [Structure.from_file(f"{TEST_DIR}/{folder}/POSCAR") for folder in bto_folders]
2424

2525
ions = np.array(
2626
[
@@ -40,7 +40,7 @@
4040

4141
class TestUtils(PymatgenTest):
4242
def setUp(self):
43-
self.potcar = Potcar.from_file(test_dir + "/POTCAR")
43+
self.potcar = Potcar.from_file(f"{TEST_DIR}/POTCAR")
4444
self.zval_dict = {"Ba": 10, "Ti": 10, "O": 6}
4545
self.ions = ions
4646
self.structures = structures
@@ -131,7 +131,7 @@ def setUp(self):
131131
# We do not use the p_ions values from Outcar.
132132
# We calculate using calc_ionic_from_zval because it is more reliable.
133133
self.polarization = Polarization(self.p_elecs, self.p_ions, self.structures)
134-
self.outcars = [Outcar(test_dir + "/" + folder + "/OUTCAR") for folder in bto_folders]
134+
self.outcars = [Outcar(f"{TEST_DIR}/{folder}/OUTCAR") for folder in bto_folders]
135135
self.change = np.array([[-5.79448738e-03, -4.41226597e-03, 4.62887522e01]])
136136
self.change_norm = 46.288752795325244
137137
self.max_jumps = [

tests/analysis/gb/test_grain.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
__email__ = "[email protected]"
1414
__date__ = "07/30/18"
1515

16-
test_dir = f"{TEST_FILES_DIR}/grain_boundary"
16+
TEST_DIR = f"{TEST_FILES_DIR}/grain_boundary"
1717

1818

1919
class TestGrainBoundary(PymatgenTest):
2020
@classmethod
2121
def setUpClass(cls):
22-
cls.Cu_conv = Structure.from_file(f"{test_dir}/Cu_mp-30_conventional_standard.cif")
22+
cls.Cu_conv = Structure.from_file(f"{TEST_DIR}/Cu_mp-30_conventional_standard.cif")
2323
GB_Cu_conv = GrainBoundaryGenerator(cls.Cu_conv)
2424
cls.Cu_GB1 = GB_Cu_conv.gb_from_parameters(
2525
[1, 2, 3],
@@ -107,17 +107,17 @@ def test_as_dict_and_from_dict(self):
107107
class TestGrainBoundaryGenerator(PymatgenTest):
108108
@classmethod
109109
def setUpClass(cls):
110-
cls.Cu_prim = Structure.from_file(f"{test_dir}/Cu_mp-30_primitive.cif")
110+
cls.Cu_prim = Structure.from_file(f"{TEST_DIR}/Cu_mp-30_primitive.cif")
111111
cls.GB_Cu_prim = GrainBoundaryGenerator(cls.Cu_prim)
112-
cls.Cu_conv = Structure.from_file(f"{test_dir}/Cu_mp-30_conventional_standard.cif")
112+
cls.Cu_conv = Structure.from_file(f"{TEST_DIR}/Cu_mp-30_conventional_standard.cif")
113113
cls.GB_Cu_conv = GrainBoundaryGenerator(cls.Cu_conv)
114-
cls.Be = Structure.from_file(f"{test_dir}/Be_mp-87_conventional_standard.cif")
114+
cls.Be = Structure.from_file(f"{TEST_DIR}/Be_mp-87_conventional_standard.cif")
115115
cls.GB_Be = GrainBoundaryGenerator(cls.Be)
116-
cls.Pa = Structure.from_file(f"{test_dir}/Pa_mp-62_conventional_standard.cif")
116+
cls.Pa = Structure.from_file(f"{TEST_DIR}/Pa_mp-62_conventional_standard.cif")
117117
cls.GB_Pa = GrainBoundaryGenerator(cls.Pa)
118-
cls.Br = Structure.from_file(f"{test_dir}/Br_mp-23154_conventional_standard.cif")
118+
cls.Br = Structure.from_file(f"{TEST_DIR}/Br_mp-23154_conventional_standard.cif")
119119
cls.GB_Br = GrainBoundaryGenerator(cls.Br)
120-
cls.Bi = Structure.from_file(f"{test_dir}/Bi_mp-23152_primitive.cif")
120+
cls.Bi = Structure.from_file(f"{TEST_DIR}/Bi_mp-23152_primitive.cif")
121121
cls.GB_Bi = GrainBoundaryGenerator(cls.Bi)
122122

123123
def test_gb_from_parameters(self):

tests/analysis/magnetism/test_heisenberg.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
from pymatgen.core.structure import Structure
99
from pymatgen.util.testing import TEST_FILES_DIR
1010

11-
test_dir = f"{TEST_FILES_DIR}/magnetic_orderings"
11+
TEST_DIR = f"{TEST_FILES_DIR}/magnetic_orderings"
1212

1313

1414
class TestHeisenbergMapper(unittest.TestCase):
1515
@classmethod
1616
def setUpClass(cls):
17-
cls.df = pd.read_json(f"{test_dir}/mag_orderings_test_cases.json")
17+
cls.df = pd.read_json(f"{TEST_DIR}/mag_orderings_test_cases.json")
1818

1919
# Good tests
20-
cls.Mn3Al = pd.read_json(f"{test_dir}/Mn3Al.json")
20+
cls.Mn3Al = pd.read_json(f"{TEST_DIR}/Mn3Al.json")
2121

2222
cls.compounds = [cls.Mn3Al]
2323

@@ -36,8 +36,8 @@ def setUp(self):
3636

3737
def test_graphs(self):
3838
for hm in self.hms:
39-
sgraphs = hm.sgraphs
40-
assert len(sgraphs) == 7
39+
struct_graphs = hm.sgraphs
40+
assert len(struct_graphs) == 7
4141

4242
def test_sites(self):
4343
for hm in self.hms:

0 commit comments

Comments
 (0)