Skip to content

Commit 7706d5a

Browse files
authored
Revert mp-api<0.34.0 pin (#3165)
* convert to f-string * unpin mp-api<0.34.0 added in #3056 to fix CI
1 parent 913ad94 commit 7706d5a

File tree

18 files changed

+87
-110
lines changed

18 files changed

+87
-110
lines changed

pymatgen/analysis/interface_reactions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,7 @@ def labels(self):
585585
3: 'x= 1 energy = 0 O2 -> O2'}.
586586
"""
587587
return {
588-
j: "x= " + str(round(x, 4)) + " energy in eV/atom = " + str(round(energy, 4)) + " " + str(reaction)
589-
for j, x, energy, reaction, _ in self.get_kinks()
588+
j: f"x= {x:.4} energy in eV/atom = {energy:.4} {reaction}" for j, x, energy, reaction, _ in self.get_kinks()
590589
}
591590

592591
@property
@@ -598,7 +597,7 @@ def minimum(self):
598597
Returns:
599598
Tuple (x_min, E_min).
600599
"""
601-
return min(((x, energy) for _, x, energy, _, _ in self.get_kinks()), key=lambda i: i[1])
600+
return min(((x, energy) for _, x, energy, _, _ in self.get_kinks()), key=lambda tup: tup[1])
602601

603602
@property
604603
def products(self):

pymatgen/analysis/magnetism/heisenberg.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ def _get_exchange_df(self):
253253
# Get labels of unique NN interactions
254254
for k0, v0 in nn_interactions.items():
255255
for idx, j in v0.items(): # i and j indices
256-
c = str(idx) + "-" + str(j) + "-" + str(k0)
257-
c_rev = str(j) + "-" + str(idx) + "-" + str(k0)
256+
c = f"{idx}-{j}-{k0}"
257+
c_rev = f"{j}-{idx}-{k0}"
258258
if c not in columns and c_rev not in columns:
259259
columns.append(c)
260260

@@ -311,8 +311,8 @@ def _get_exchange_df(self):
311311
order = "-nnn"
312312
elif abs(dist - dists["nnnn"]) <= tol:
313313
order = "-nnnn"
314-
j_ij = str(i_index) + "-" + str(j_index) + order
315-
j_ji = str(j_index) + "-" + str(i_index) + order
314+
j_ij = f"{i_index}-{j_index}{order}"
315+
j_ji = f"{j_index}-{i_index}{order}"
316316

317317
if j_ij in ex_mat.columns:
318318
ex_row.loc[sgraph_index, j_ij] -= s_i * s_j
@@ -611,8 +611,8 @@ def _get_j_exc(self, i, j, dist):
611611
elif abs(dist - self.dists["nnnn"]) <= self.tol:
612612
order = "-nnnn"
613613

614-
j_ij = str(i_index) + "-" + str(j_index) + order
615-
j_ji = str(j_index) + "-" + str(i_index) + order
614+
j_ij = f"{i_index}-{j_index}{order}"
615+
j_ji = f"{j_index}-{i_index}{order}"
616616

617617
if j_ij in self.ex_params:
618618
j_exc = self.ex_params[j_ij]
@@ -631,7 +631,7 @@ def get_heisenberg_model(self):
631631
"""Save results of mapping to a HeisenbergModel object.
632632
633633
Returns:
634-
hmodel (HeisenbergModel): MSONable object.
634+
HeisenbergModel: MSONable object.
635635
"""
636636
# Original formula unit with nonmagnetic ions
637637
hm_formula = str(self.ordered_structures_[0].composition.reduced_formula)
@@ -981,8 +981,8 @@ def _get_j_exc(self, i, j, dist):
981981
elif abs(dist - self.dists["nnnn"]) <= self.tol:
982982
order = "-nnnn"
983983

984-
j_ij = str(i_index) + "-" + str(j_index) + order
985-
j_ji = str(j_index) + "-" + str(i_index) + order
984+
j_ij = f"{i_index}-{j_index}{order}"
985+
j_ji = f"{j_index}-{i_index}{order}"
986986

987987
if j_ij in self.ex_params:
988988
j_exc = self.ex_params[j_ij]

pymatgen/analysis/surface_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def surface_energy(self, ucell_entry, ref_entries=None):
216216
# from each element with an existing ref_entry.
217217
bulk_energy, gbulk_eqn = 0, 0
218218
for el, ref in ref_entries_dict.items():
219-
N, delu = self.composition.as_dict()[el], Symbol("delu_" + str(el))
219+
N, delu = self.composition.as_dict()[el], Symbol(f"delu_{el}")
220220
if el in ucell_comp.as_dict():
221221
gbulk_eqn += ucell_reduced_comp[el] * (delu + ref.energy_per_atom)
222222
bulk_energy += N * (Symbol("delu_" + el) + ref.energy_per_atom)

pymatgen/analysis/wulff.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,13 @@
4444

4545
def hkl_tuple_to_str(hkl):
4646
"""
47-
Prepare for display on plots
48-
"(hkl)" for surfaces
49-
Agrs:
47+
Prepare for display on plots "(hkl)" for surfaces
48+
49+
Args:
5050
hkl: in the form of [h, k, l] or (h, k, l).
5151
"""
52-
str_format = "($"
53-
for x in hkl:
54-
if x < 0:
55-
str_format += "\\overline{" + str(-x) + "}"
56-
else:
57-
str_format += str(x)
58-
str_format += "$)"
59-
return str_format
52+
out = "".join(f"\\overline{{{-x}}}" if x < 0 else str(x) for x in hkl)
53+
return f"(${out}$)"
6054

6155

6256
def get_tri_area(pts):
@@ -67,7 +61,7 @@ def get_tri_area(pts):
6761
Args:
6862
pts: [a, b, c] three points
6963
"""
70-
a, b, c = pts[0], pts[1], pts[2]
64+
a, b, c = pts
7165
v1 = np.array(b) - np.array(a)
7266
v2 = np.array(c) - np.array(a)
7367
return abs(np.linalg.norm(np.cross(v1, v2)) / 2)
@@ -218,13 +212,13 @@ def __init__(self, lattice: Lattice, miller_list, e_surf_list, symprec=1e-5):
218212

219213
miller_area = []
220214
for m, in_mill_fig in enumerate(self.input_miller_fig):
221-
miller_area.append(in_mill_fig + " : " + str(round(self.color_area[m], 4)))
215+
miller_area.append(f"{in_mill_fig} : {round(self.color_area[m], 4)}")
222216
self.miller_area = miller_area
223217

224218
def _get_all_miller_e(self):
225219
"""
226-
From self: get miller_list(unique_miller), e_surf_list and symmetry operations(symmops)
227-
according to lattice apply symmops to get all the miller index, then get normal, get
220+
From self: get miller_list(unique_miller), e_surf_list and symmetry operations(symm_ops)
221+
according to lattice apply symm_ops to get all the miller index, then get normal, get
228222
all the facets functions for Wulff shape calculation: |normal| = 1, e_surf is plane's
229223
distance to (0, 0, 0), normal[0]x + normal[1]y + normal[2]z = e_surf.
230224
@@ -422,7 +416,13 @@ def get_plot(
422416
from mpl_toolkits.mplot3d import Axes3D, art3d
423417

424418
colors = self._get_colors(color_set, alpha, off_color, custom_colors=custom_colors or {})
425-
color_list, color_proxy, color_proxy_on_wulff, miller_on_wulff, e_surf_on_wulff = colors
419+
(
420+
color_list,
421+
color_proxy,
422+
color_proxy_on_wulff,
423+
miller_on_wulff,
424+
e_surf_on_wulff,
425+
) = colors
426426

427427
if not direction:
428428
# If direction is not specified, use the miller indices of

pymatgen/command_line/gulp_caller.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def buckingham_potential(structure, val_dict=None):
445445
# Try lewis library next if element is not in bush
446446
# use_lewis = True
447447
if el != "O": # For metals the key is "Metal_OxiState+"
448-
k = el + "_" + str(int(val_dict[key])) + "+"
448+
k = f"{el}_{int(val_dict[key])}+"
449449
if k not in bpl.species_dict:
450450
# use_lewis = False
451451
raise GulpError(f"Element {k} not in library")
@@ -493,7 +493,7 @@ def tersoff_input(self, structure: Structure, periodic=False, uc=True, *keywords
493493
@staticmethod
494494
def tersoff_potential(structure):
495495
"""
496-
Generate the species, tersoff potential lines for an oxide structure.
496+
Generate the species, Tersoff potential lines for an oxide structure.
497497
498498
Args:
499499
structure: pymatgen.core.structure.Structure
@@ -504,24 +504,24 @@ def tersoff_potential(structure):
504504
el_val_dict = dict(zip(el, valences))
505505

506506
gin = "species \n"
507-
qerfstring = "qerfc\n"
507+
qerf_str = "qerfc\n"
508508

509509
for key, value in el_val_dict.items():
510510
if key != "O" and value % 1 != 0:
511511
raise SystemError("Oxide has mixed valence on metal")
512-
specie_string = key + " core " + str(value) + "\n"
513-
gin += specie_string
514-
qerfstring += key + " " + key + " 0.6000 10.0000 \n"
512+
specie_str = f"{key} core {value}\n"
513+
gin += specie_str
514+
qerf_str += f"{key} {key} 0.6000 10.0000 \n"
515515

516516
gin += "# noelectrostatics \n Morse \n"
517517
met_oxi_ters = TersoffPotential().data
518518
for key, value in el_val_dict.items():
519519
if key != "O":
520-
metal = key + "(" + str(int(value)) + ")"
520+
metal = f"{key}({int(value)})"
521521
ters_pot_str = met_oxi_ters[metal]
522522
gin += ters_pot_str
523523

524-
gin += qerfstring
524+
gin += qerf_str
525525
return gin
526526

527527
@staticmethod

pymatgen/command_line/mcsqs_caller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def run_mcsqs(
104104
# Generate clusters
105105
mcsqs_generate_clusters_cmd = ["mcsqs"]
106106
for num in clusters:
107-
mcsqs_generate_clusters_cmd.append("-" + str(num) + "=" + str(clusters[num]))
107+
mcsqs_generate_clusters_cmd.append(f"-{num}={clusters[num]}")
108108

109109
# Run mcsqs to find clusters
110110
with Popen(mcsqs_generate_clusters_cmd) as process:

pymatgen/core/periodic_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def term_symbols(self) -> list[list[str]]:
508508
L, S = min(comb_counter)
509509

510510
J = list(np.arange(abs(L - S), abs(L) + abs(S) + 1))
511-
term_symbols.append([str(int(2 * (abs(S)) + 1)) + L_symbols[abs(L)] + str(j) for j in J])
511+
term_symbols.append([f"{int(2 * (abs(S)) + 1)}{L_symbols[abs(L)]}{j}" for j in J])
512512

513513
# Delete all configurations included in this term
514514
for ML in range(-L, L - 1, -1):

pymatgen/core/structure.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,9 +2119,7 @@ def interpolate(
21192119
# Check that both structures have the same species
21202120
for i, site in enumerate(self):
21212121
if site.species != end_structure[i].species:
2122-
raise ValueError(
2123-
"Different species!\nStructure 1:\n" + str(self) + "\nStructure 2\n" + str(end_structure)
2124-
)
2122+
raise ValueError(f"Different species!\nStructure 1:\n{self}\nStructure 2\n{end_structure}")
21252123

21262124
start_coords = np.array(self.frac_coords)
21272125
end_coords = np.array(end_structure.frac_coords)

pymatgen/electronic_structure/bandstructure.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -790,12 +790,12 @@ def __init__(
790790

791791
if len(one_group) != 0:
792792
branches_tmp.append(one_group)
793-
for b in branches_tmp:
793+
for branch in branches_tmp:
794794
self.branches.append(
795795
{
796-
"start_index": b[0],
797-
"end_index": b[-1],
798-
"name": str(self.kpoints[b[0]].label) + "-" + str(self.kpoints[b[-1]].label),
796+
"start_index": branch[0],
797+
"end_index": branch[-1],
798+
"name": f"{self.kpoints[branch[0]].label}-{self.kpoints[branch[-1]].label}",
799799
}
800800
)
801801

pymatgen/electronic_structure/boltztrap2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ def plot_props(
11471147
plt.plot(
11481148
mu,
11491149
prop_out[:, i],
1150-
label="eig " + str(i) + " " + str(temp) + " K",
1150+
label=f"eig {i} {temp} K",
11511151
)
11521152

11531153
plt.xlabel(r"$\mu$ (eV)", fontsize=30)
@@ -1165,7 +1165,7 @@ def plot_props(
11651165
doping_all,
11661166
prop_out[:, i],
11671167
"s-",
1168-
label="eig " + str(i) + " " + str(temp) + " K",
1168+
label=f"eig {i} {temp} K",
11691169
)
11701170
plt.xlabel(r"Carrier conc. $cm^{-3}$", fontsize=30)
11711171
leg_title = dop_type + "-type"
@@ -1187,7 +1187,7 @@ def plot_props(
11871187
temps_all,
11881188
prop_out[:, i],
11891189
"s-",
1190-
label="eig " + str(i) + " " + str(dop) + " $cm^{-3}$",
1190+
label=f"eig {i} {dop} $cm^{{-3}}$",
11911191
)
11921192

11931193
plt.xlabel(r"Temperature (K)", fontsize=30)

0 commit comments

Comments
 (0)