Skip to content

Commit fbc2e32

Browse files
Merge remote-tracking branch 'upstream/master' into fstar
2 parents 634b871 + 4e25547 commit fbc2e32

File tree

81 files changed

+762
-466
lines changed

Some content is hidden

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

81 files changed

+762
-466
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ci:
88

99
repos:
1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.0.285
11+
rev: v0.0.286
1212
hooks:
1313
- id: ruff
1414
args: [--fix]

dev_scripts/chemenv/get_plane_permutations_optimized.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def random_permutations_iterator(initial_permutation, n_permutations):
256256
explicit_permutations_per_plane.append(set(explicit_permutations))
257257
prt1(string="", printing_volume=printing_volume)
258258
# Check that the explicit permutations found are the same for each plane
259-
for ip1 in range(0, len(explicit_permutations_per_plane) - 1):
259+
for ip1 in range(len(explicit_permutations_per_plane) - 1):
260260
ep_p1 = explicit_permutations_per_plane[ip1]
261261
for ip2 in range(1, len(explicit_permutations_per_plane)):
262262
ep_p2 = explicit_permutations_per_plane[ip2]

pymatgen/analysis/bond_dissociation.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def fragment_and_process(self, bonds):
184184
if not frags_done:
185185
# If we haven't, we save this pair and search for the relevant fragment entries:
186186
self.done_frag_pairs += [frags]
187-
num_entries_for_this_frag_pair = 0
187+
n_entries_for_this_frag_pair = 0
188188
frag1_entries = self.search_fragment_entries(frags[0])
189189
frag2_entries = self.search_fragment_entries(frags[1])
190190
frag1_charges_found = []
@@ -203,14 +203,14 @@ def fragment_and_process(self, bonds):
203203
smiles = pb_mol.write("smi").split()[0]
204204
for charge in self.expected_charges:
205205
if charge not in frag1_charges_found:
206-
print(f"Missing charge {charge} for fragment {smiles}")
206+
print(f"Missing {charge=} for fragment {smiles}")
207207
if len(frag2_charges_found) < len(self.expected_charges):
208208
bb = BabelMolAdaptor(frags[1].molecule)
209209
pb_mol = bb.pybel_mol
210210
smiles = pb_mol.write("smi").split()[0]
211211
for charge in self.expected_charges:
212212
if charge not in frag2_charges_found:
213-
print(f"Missing charge {charge} for fragment {smiles}")
213+
print(f"Missing {charge=} for fragment {smiles}")
214214
# Now we attempt to pair fragments with the right total charge, starting with only fragments with no
215215
# structural change:
216216
for frag1 in frag1_entries[0]: # 0 -> no structural change
@@ -220,26 +220,26 @@ def fragment_and_process(self, bonds):
220220
== self.molecule_entry["final_molecule"]["charge"]
221221
):
222222
self.bond_dissociation_energies += [self.build_new_entry([frag1, frag2], bonds)]
223-
num_entries_for_this_frag_pair += 1
223+
n_entries_for_this_frag_pair += 1
224224
# If we haven't found the number of fragment pairs that we expect, we expand our search to include
225225
# fragments that do exhibit structural change:
226-
if num_entries_for_this_frag_pair < len(self.expected_charges):
226+
if n_entries_for_this_frag_pair < len(self.expected_charges):
227227
for frag1 in frag1_entries[0]: # 0 -> no structural change
228228
for frag2 in frag2_entries[1]: # 1 -> YES structural change
229229
if (
230230
frag1["initial_molecule"]["charge"] + frag2["initial_molecule"]["charge"]
231231
== self.molecule_entry["final_molecule"]["charge"]
232232
):
233233
self.bond_dissociation_energies += [self.build_new_entry([frag1, frag2], bonds)]
234-
num_entries_for_this_frag_pair += 1
234+
n_entries_for_this_frag_pair += 1
235235
for frag1 in frag1_entries[1]: # 1 -> YES structural change
236236
for frag2 in frag2_entries[0]: # 0 -> no structural change
237237
if (
238238
frag1["initial_molecule"]["charge"] + frag2["initial_molecule"]["charge"]
239239
== self.molecule_entry["final_molecule"]["charge"]
240240
):
241241
self.bond_dissociation_energies += [self.build_new_entry([frag1, frag2], bonds)]
242-
num_entries_for_this_frag_pair += 1
242+
n_entries_for_this_frag_pair += 1
243243

244244
def search_fragment_entries(self, frag):
245245
"""

pymatgen/analysis/chemenv/connectivity/connected_components.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,13 @@ def show_graph(
556556
plt.savefig(save_file)
557557
# nx.draw(self._connected_subgraph)
558558
elif drawing_type == "draw_graphviz":
559-
import networkx
559+
import networkx as nx
560560

561-
networkx.nx_pydot.graphviz_layout(shown_graph)
561+
nx.nx_pydot.graphviz_layout(shown_graph)
562562
elif drawing_type == "draw_random":
563-
import networkx
563+
import networkx as nx
564564

565-
networkx.draw_random(shown_graph)
565+
nx.draw_random(shown_graph)
566566

567567
@property
568568
def graph(self):

pymatgen/analysis/chemenv/utils/math_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def divisors(n):
8181
"""
8282
factors = _factor_generator(n)
8383
_divisors = []
84-
listexponents = [[k**x for x in range(0, factors[k] + 1)] for k in list(factors)]
84+
listexponents = [[k**x for x in range(factors[k] + 1)] for k in list(factors)]
8585
listfactors = _cartesian_product(listexponents)
8686
for f in listfactors:
8787
_divisors.append(reduce(lambda x, y: x * y, f, 1))

pymatgen/analysis/chempot_diagram.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
if TYPE_CHECKING:
4545
from pymatgen.entries.computed_entries import ComputedEntry
4646

47-
with open(os.path.join(os.path.dirname(__file__), "..", "util", "plotly_chempot_layouts.json")) as file:
47+
with open(f"{os.path.dirname(__file__)}/../util/plotly_chempot_layouts.json") as file:
4848
plotly_layouts = json.load(file)
4949

5050

@@ -680,7 +680,7 @@ def get_centroid_2d(vertices: np.ndarray) -> np.ndarray:
680680
cy = 0
681681
a = 0
682682

683-
for idx in range(0, len(vertices) - 1):
683+
for idx in range(len(vertices) - 1):
684684
xi = vertices[idx, 0]
685685
yi = vertices[idx, 1]
686686
xi_p = vertices[idx + 1, 0]

pymatgen/analysis/diffraction/tem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def generate_points(coord_left: int = -10, coord_right: int = 10) -> np.ndarray:
9999
points = [0, 0, 0]
100100
coord_values = np.arange(coord_left, coord_right + 1)
101101
points[0], points[1], points[2] = np.meshgrid(coord_values, coord_values, coord_values) # type: ignore
102-
points_matrix = (np.ravel(points[i]) for i in range(0, 3))
102+
points_matrix = (np.ravel(points[i]) for i in range(3))
103103
return np.vstack(list(points_matrix)).transpose()
104104

105105
def zone_axis_filter(

pymatgen/analysis/dimensionality.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,11 @@ def get_dimensionality_gorai(
535535
if not bonds:
536536
bonds = get_max_bond_lengths(structure, el_radius_updates)
537537

538-
num_surfaces = 0
538+
n_surfaces = 0
539539
for hh in range(max_hkl):
540540
for kk in range(max_hkl):
541541
for ll in range(max_hkl):
542-
if max([hh, kk, ll]) > 0 and num_surfaces < 2:
542+
if max([hh, kk, ll]) > 0 and n_surfaces < 2:
543543
sg = SlabGenerator(
544544
structure,
545545
(hh, kk, ll),
@@ -548,6 +548,6 @@ def get_dimensionality_gorai(
548548
)
549549
slabs = sg.get_slabs(bonds)
550550
for _ in slabs:
551-
num_surfaces += 1
551+
n_surfaces += 1
552552

553-
return 3 - min(num_surfaces, 2)
553+
return 3 - min(n_surfaces, 2)

pymatgen/analysis/energy_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ def __init__(self, real_space_cut=None, recip_space_cut=None, eta=None, acc_fact
5656
Args:
5757
real_space_cut (float): Real space cutoff radius dictating how
5858
many terms are used in the real space sum. Defaults to None,
59-
which means determine automagically using the formula given
59+
which means determine automatically using the formula given
6060
in gulp 3.1 documentation.
6161
recip_space_cut (float): Reciprocal space cutoff radius.
62-
Defaults to None, which means determine automagically using
62+
Defaults to None, which means determine automatically using
6363
the formula given in gulp 3.1 documentation.
6464
eta (float): Screening parameter. Defaults to None, which means
6565
determine automatically.

pymatgen/analysis/fragmenter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def open_ring(mol_graph, bond, opt_steps):
299299
self.steps, and then convert the resulting structure back into a molecule graph
300300
to be returned.
301301
"""
302-
obmol = BabelMolAdaptor.from_molecule_graph(mol_graph)
303-
obmol.remove_bond(bond[0][0] + 1, bond[0][1] + 1)
304-
obmol.localopt(steps=opt_steps, forcefield="uff")
305-
return MoleculeGraph.with_local_env_strategy(obmol.pymatgen_mol, OpenBabelNN())
302+
ob_mol = BabelMolAdaptor.from_molecule_graph(mol_graph)
303+
ob_mol.remove_bond(bond[0][0] + 1, bond[0][1] + 1)
304+
ob_mol.localopt(steps=opt_steps, forcefield="uff")
305+
return MoleculeGraph.with_local_env_strategy(ob_mol.pymatgen_mol, OpenBabelNN())

0 commit comments

Comments
 (0)