Skip to content

Commit c5c1804

Browse files
authored
Delete commented out print statements (#3178)
* delete commented out print statements apparently used at one point for debugging * rename counters * drop useless :d f-string format
1 parent 38c8928 commit c5c1804

Some content is hidden

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

45 files changed

+145
-191
lines changed

dev_scripts/chemenv/equivalent_indices.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,5 @@
133133
i7 = 6 if i0 in [1, 4] else 7
134134
equiv_list.append([i0, i1, i2, i3, i4, i5, i6, i7])
135135

136-
print(f"Equivalent indices ({len(equiv_list):d}) for {cg_symbol} : ")
136+
print(f"Equivalent indices ({len(equiv_list)}) for {cg_symbol} : ")
137137
print(equiv_list)

dev_scripts/chemenv/explicit_permutations_plane_algorithm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636

3737
new_algos = []
3838

39-
ialgo = 1
39+
idx = 1
4040
for sep_plane_algo in cg._algorithms:
41-
print(f"In {ialgo = :d}/{len(cg._algorithms):d}")
42-
ialgo += 1
41+
print(f"In {idx = }/{len(cg._algorithms)}")
42+
idx += 1
4343
if sep_plane_algo.algorithm_type != "SEPARATION_PLANE":
4444
raise ValueError("Should all be separation plane")
4545

46-
perms_on_file = f"Permutations on file in this algorithm ({len(sep_plane_algo._permutations):d}) "
46+
perms_on_file = f"Permutations on file in this algorithm ({len(sep_plane_algo._permutations)}) "
4747
print(perms_on_file)
4848
print(sep_plane_algo._permutations)
4949
permutations = sep_plane_algo.safe_separation_permutations(
@@ -52,7 +52,7 @@
5252

5353
sep_plane_algo._permutations = permutations
5454

55-
print(f"Test permutations ({len(permutations):d}) :")
55+
print(f"Test permutations ({len(permutations)}) :")
5656
print(permutations)
5757

5858
lgf = LocalGeometryFinder()
@@ -134,7 +134,7 @@
134134
explicit_permutations.append(sep_perms[icsm])
135135

136136
print(perms_on_file)
137-
print(f"Permutations found ({len(explicit_permutations):d}) : ")
137+
print(f"Permutations found ({len(explicit_permutations)}) : ")
138138
print(explicit_permutations)
139139
sep_plane_algo.explicit_permutations = explicit_permutations
140140
new_algos.append(sep_plane_algo)

dev_scripts/chemenv/get_plane_permutations_optimized.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def random_permutations_iterator(initial_permutation, n_permutations):
175175
# 1. Check the algorithms defined for this coordination geometry and get the explicit permutations
176176
original_n_explicit_perms = []
177177
original_n_explicit_optimized_perms = []
178-
for ialgo, algo in enumerate(cg.algorithms):
178+
for idx, algo in enumerate(cg.algorithms):
179179
algo._permutations = algo.explicit_permutations
180180
algo.minimum_number_of_points = 4
181181
if algo.algorithm_type == "EXPLICIT_PERMUTATIONS":
@@ -185,7 +185,7 @@ def random_permutations_iterator(initial_permutation, n_permutations):
185185
else:
186186
eop = str(len(algo.explicit_optimized_permutations))
187187
print(
188-
f"For ialgo {ialgo,:d}, plane_points are "
188+
f"For {idx=}, plane_points are "
189189
f"[{', '.join(map(str, algo.plane_points))}], "
190190
f"side_0 is [{', '.join(map(str, algo.point_groups[0]))}] and "
191191
f"side_1 is [{', '.join(map(str, algo.point_groups[1]))}]."
@@ -194,7 +194,7 @@ def random_permutations_iterator(initial_permutation, n_permutations):
194194
original_n_explicit_optimized_perms.append(eop)
195195
print(
196196
f" For this algorithm, there are {eop} optimized permutations and "
197-
f"{len(algo.explicit_permutations):d} explicit permutations"
197+
f"{len(algo.explicit_permutations)} explicit permutations"
198198
)
199199
if algo.other_plane_points is None:
200200
input("Multiplicity and other plane points is not defined for this algorithm !")
@@ -204,7 +204,7 @@ def random_permutations_iterator(initial_permutation, n_permutations):
204204
ordered_plane=algo.ordered_plane, ordered_point_groups=algo.ordered_point_groups
205205
)
206206
algo._permutations = permutations
207-
print(f"Safe permutations found ({len(permutations):d})")
207+
print(f"Safe permutations found ({len(permutations)})")
208208

209209
# Definition of the facets
210210
all_planes_point_indices = [algo.plane_points]
@@ -213,9 +213,9 @@ def random_permutations_iterator(initial_permutation, n_permutations):
213213

214214
# Loop on the facets
215215
explicit_permutations_per_plane = []
216-
for iplane, plane_point_indices in enumerate(all_planes_point_indices):
216+
for idx_plane, plane_point_indices in enumerate(all_planes_point_indices):
217217
prt1(
218-
string=f"In plane {iplane:d} ({'-'.join(str(pp) for pp in plane_point_indices)})",
218+
string=f"In plane {idx_plane} ({'-'.join(str(pp) for pp in plane_point_indices)})",
219219
printing_volume=printing_volume,
220220
)
221221

@@ -268,7 +268,7 @@ def random_permutations_iterator(initial_permutation, n_permutations):
268268
algo.explicit_permutations = [list(perm) for perm in list(explicit_permutations_per_plane[0])]
269269
algo.explicit_permutations.sort()
270270
algo.explicit_permutations = np.array(algo.explicit_permutations)
271-
print(f"Explicit permutations found ({len(algo.explicit_permutations):d})")
271+
print(f"Explicit permutations found ({len(algo.explicit_permutations)})")
272272
print(algo.explicit_permutations)
273273
print()
274274
# Setup the permutations for the next optimization
@@ -291,10 +291,10 @@ def random_permutations_iterator(initial_permutation, n_permutations):
291291
perms_used_algos: list[dict] = [{} for _ in cg.algorithms]
292292

293293
# Loop on algorithms
294-
for ialgo, algo in enumerate(cg.algorithms):
294+
for idx, algo in enumerate(cg.algorithms):
295295
perms_used: dict[tuple, int] = {}
296296
print(
297-
f"In ialgo {ialgo:d} (plane_points : "
297+
f"In {idx=} (plane_points : "
298298
f"[{', '.join(map(str, algo.plane_points))}], "
299299
f"side_0 : [{', '.join(map(str, algo.point_groups[0]))}] and "
300300
f"side_1 : [{', '.join(map(str, algo.point_groups[1]))}])"
@@ -334,12 +334,12 @@ def random_permutations_iterator(initial_permutation, n_permutations):
334334
raise ValueError("Permutation setup not allowed ...")
335335

336336
# Loop on permutations
337-
iperm = 1
337+
idx_perm = 1
338338
t0 = time.process_time()
339339
time_left: float | str = "Unknown"
340340
for indices_perm in perms_iterator:
341341
prt1(
342-
string=f"Perm # {iperm:d}/{n_permutations:d} : "
342+
string=f"Perm # {idx_perm}/{n_permutations} : "
343343
f"{'-'.join(map(str, indices_perm))} "
344344
f"(est. rem. time : {time_left} sec)",
345345
printing_volume=printing_volume,
@@ -353,9 +353,9 @@ def random_permutations_iterator(initial_permutation, n_permutations):
353353

354354
# Loop on the facets
355355
separation_permutations = []
356-
for iplane, plane_point_indices in enumerate(all_planes_point_indices):
356+
for idx_plane, plane_point_indices in enumerate(all_planes_point_indices):
357357
prt2(
358-
string=f"In plane {iplane:d} ({'-'.join(str(pp) for pp in plane_point_indices)})",
358+
string=f"In plane {idx_plane} ({'-'.join(str(pp) for pp in plane_point_indices)})",
359359
printing_volume=printing_volume,
360360
)
361361

@@ -399,28 +399,28 @@ def random_permutations_iterator(initial_permutation, n_permutations):
399399
else:
400400
perms_used[some_perm] = 1
401401
tcurrent = time.process_time()
402-
time_left = (n_permutations - iperm) * (tcurrent - t0) / iperm # type: ignore
402+
time_left = (n_permutations - idx_perm) * (tcurrent - t0) / idx_perm # type: ignore
403403
time_left = f"{time_left:.1f}"
404-
iperm += 1
404+
idx_perm += 1
405405
print(
406-
f"Optimized permutations {len(perms_used):d}/{len(algo.permutations):d}"
407-
f"(old : {original_n_explicit_optimized_perms[ialgo]}/{original_n_explicit_perms[ialgo]}) : "
406+
f"Optimized permutations {len(perms_used)}/{len(algo.permutations)}"
407+
f"(old : {original_n_explicit_optimized_perms[idx]}/{original_n_explicit_perms[idx]}) : "
408408
)
409409
for perm, number in perms_used.items():
410-
print(f" - permutation {'-'.join(map(str, perm))} : {number:d}")
410+
print(f" - permutation {'-'.join(map(str, perm))} : {number}")
411411
print(
412-
f"For {ialgo=} (plane_points : [{', '.join(map(str, algo.plane_points))}], "
412+
f"For {idx=} (plane_points : [{', '.join(map(str, algo.plane_points))}], "
413413
f"side_0 : [{', '.join(map(str, algo.point_groups[0]))}] and "
414414
f"side_1 : [{', '.join(map(str, algo.point_groups[1]))}]),\n"
415415
f"Optimized perturbations {len(perms_used)}/{len(algo.permutations)} (old : "
416-
f"{original_n_explicit_optimized_perms[ialgo]}/{original_n_explicit_perms[ialgo]}) are :"
416+
f"{original_n_explicit_optimized_perms[idx]}/{original_n_explicit_perms[idx]}) are :"
417417
)
418-
# print(f"Optimized permutations ({len(perms_used):d}/{len(algo.permutations):d}) : ")
418+
# print(f"Optimized permutations ({len(perms_used)}/{len(algo.permutations)}) : ")
419419
explicit_optimized_permutations = [list(perm) for perm in perms_used]
420420
explicit_optimized_permutations.sort()
421421
print(explicit_optimized_permutations)
422422
print()
423-
test = input(f'Set optimized permutations for algorithm {ialgo:d} ? ("y" to confirm)')
423+
test = input(f'Set optimized permutations for algorithm {idx} ? ("y" to confirm)')
424424
if test == "y":
425425
algo.explicit_optimized_permutations = np.array(explicit_optimized_permutations)
426426

dev_scripts/chemenv/plane_multiplicity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
all_plane_points.append(tuple(equiv_plane))
3131
all_plane_points = [tuple(equiv_plane) for equiv_plane in set(all_plane_points)]
3232

33-
print(f"All plane points ({len(all_plane_points):d}) for {cg_symbol} : ")
33+
print(f"All plane points ({len(all_plane_points)}) for {cg_symbol} : ")
3434
print(all_plane_points)

dev_scripts/chemenv/strategies/multi_weights_strategy_parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def get_weights(self, weights_options):
277277
for ii in range(1, 14):
278278
self_weight_max_csms_per_cn[str(ii)] = []
279279
for jj in range(ii + 1, 14):
280-
cn_pair = f"{ii:d}_{jj:d}"
280+
cn_pair = f"{ii}_{jj}"
281281
self_weight_max_csms[cn_pair] = []
282282
delta_csm_mins[cn_pair] = []
283283
all_cn_pairs.append(cn_pair)

dev_scripts/chemenv/test_algos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
lgf.perfect_geometry = AbstractGeometry.from_cg(cg=cg)
6666
points_perfect = lgf.perfect_geometry.points_wocs_ctwocc()
6767

68-
print(f"Perm # {idx_perm:d}/{n_perms:d} : ", indices_perm)
68+
print(f"Perm # {idx_perm}/{n_perms} : ", indices_perm)
6969

7070
algos_results = []
7171
for algo in cg.algorithms:

dev_scripts/chemenv/test_algos_all_geoms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
lgf.perfect_geometry = AbstractGeometry.from_cg(cg=cg)
9999
points_perfect = lgf.perfect_geometry.points_wocs_ctwocc()
100100

101-
print(f"Perm # {i_perm:d}/{n_perms:d} : ", indices_perm)
101+
print(f"Perm # {i_perm}/{n_perms} : ", indices_perm)
102102

103103
algos_results = []
104104
for algo in cg.algorithms:

dev_scripts/chemenv/view_environment.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
print("Wrong geometry, try again ...")
4444
continue
4545
print(cg.name)
46-
for ipoint, point in enumerate(cg.points):
47-
print(f"Point #{ipoint:d} : {point[0]!r} {point[1]!r} {point[2]!r}")
46+
for idx, point in enumerate(cg.points):
47+
print(f"Point #{idx} : {point[0]!r} {point[1]!r} {point[2]!r}")
4848
print("Algorithms used :")
49-
for ialgo, algo in enumerate(cg.algorithms):
50-
print(f"Algorithm #{ialgo:d} :")
49+
for idx, algo in enumerate(cg.algorithms):
50+
print(f"Algorithm #{idx} :")
5151
print(algo)
5252
print()
5353
# Visualize the separation plane of a given algorithm
@@ -56,8 +56,8 @@
5656
test = input("Enter index of the algorithm for which you want to visualize the plane : ")
5757
if test != "":
5858
try:
59-
ialgo = int(test)
60-
algo = cg.algorithms[ialgo]
59+
idx = int(test)
60+
algo = cg.algorithms[idx]
6161
sep_plane = True
6262
except Exception:
6363
print(

pymatgen/analysis/chemenv/connectivity/connected_components.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ def periodicity(self):
651651
"""Get periodicity of this connected component."""
652652
if self._periodicity_vectors is None:
653653
self.compute_periodicity()
654-
return f"{len(self._periodicity_vectors):d}D"
654+
return f"{len(self._periodicity_vectors)}D"
655655

656656
def elastic_centered_graph(self, start_node=None):
657657
"""
@@ -681,19 +681,19 @@ def elastic_centered_graph(self, start_node=None):
681681
tree_level = 0
682682
while True:
683683
tree_level += 1
684-
logging.debug(f"In tree level {tree_level:d} ({len(current_nodes):d} nodes)")
684+
logging.debug(f"In tree level {tree_level} ({len(current_nodes)} nodes)")
685685
new_current_nodes = []
686686
# Loop on nodes in this level of the tree
687687
for node in current_nodes:
688688
inode += 1
689-
logging.debug(f" In node #{inode:d}/{len(current_nodes):d} in level {tree_level:d} ({node})")
689+
logging.debug(f" In node #{inode}/{len(current_nodes)} in level {tree_level} ({node})")
690690
node_neighbors = list(tree.neighbors(n=node))
691691
node_edges = centered_connected_subgraph.edges(nbunch=[node], data=True, keys=True)
692692
# Loop on neighbors of a node (from the tree used)
693693
for inode_neighbor, node_neighbor in enumerate(node_neighbors):
694694
logging.debug(
695-
f" Testing neighbor #{inode_neighbor:d}/{len(node_neighbors):d} ({node_neighbor}) of "
696-
f"node #{inode:d} ({node})"
695+
f" Testing neighbor #{inode_neighbor}/{len(node_neighbors)} ({node_neighbor}) of "
696+
f"node #{inode} ({node})"
697697
)
698698
already_inside = False
699699
ddeltas = []
@@ -818,7 +818,7 @@ def as_dict(self):
818818
Returns:
819819
dict: Bson-serializable dict representation of the ConnectedComponent object.
820820
"""
821-
nodes = {f"{node.isite:d}": (node, data) for node, data in self._connected_subgraph.nodes(data=True)}
821+
nodes = {f"{node.isite}": (node, data) for node, data in self._connected_subgraph.nodes(data=True)}
822822
node2stringindex = {node: strindex for strindex, (node, data) in nodes.items()}
823823
dict_of_dicts = nx.to_dict_of_dicts(self._connected_subgraph)
824824
new_dict_of_dicts = {}
@@ -899,5 +899,5 @@ def description(self, full=False):
899899
get_delta(node1=en, node2=en_neighb, edge_data=edge_data).tolist()
900900
for iedge, edge_data in self.graph[en][en_neighb].items()
901901
)
902-
out.extend([f" ({delta[0]:d} {delta[1]:d} {delta[2]:d})" for delta in all_deltas])
902+
out.extend([f" ({delta[0]} {delta[1]} {delta[2]})" for delta in all_deltas])
903903
return "\n".join(out)

pymatgen/analysis/chemenv/connectivity/connectivity_finder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def get_structure_connectivity(self, light_structure_environments):
4949
continue
5050
if len(site_neighbors_sets) > 1:
5151
if self.multiple_environments_choice is None:
52-
raise ValueError(f"Local environment of site {isite:d} is a mix and nothing is asked about it")
52+
raise ValueError(f"Local environment of site {isite} is a mix and nothing is asked about it")
5353
if self.multiple_environments_choice == "TAKE_HIGHEST_FRACTION":
5454
imax = np.argmax(
5555
[ee["ce_fraction"] for ee in light_structure_environments.coordination_environments[isite]]
5656
)
57-
print(f"IMAX {imax:d}")
57+
print(f"IMAX {imax}")
5858
site_neighbors_set = site_neighbors_sets[imax]
5959
else:
6060
raise RuntimeError("Should not be here")

0 commit comments

Comments
 (0)