Skip to content

Commit d682909

Browse files
DanielYang59janosh
authored andcommitted
Add types for core.molecular_orbitals/operations/sites/spectrum/tensor/xcfunc (materialsproject#3829)
* fix `core.molecular_orbitals` * fix `core.operations` * add types for site, mypy errors to fix * remove no_type_check decorator * move dunder methods to the top * fix mypy errors * remove debug tag * improve `spectrum` * finish `core.tensors` * finish `xcfunc` * fix hash of `SymmOp` * add a missing type * Revert "fix hash of `SymmOp`" This reverts commit bf2a953. * fix some types in operations * "TEST": remove one unused var, relocate another * final tweak types * avoid hard-code class name * format tweaks * type tweak * fix unit test * replace all `[0:x]` with `[:x]`
1 parent ed0e8ec commit d682909

29 files changed

+813
-668
lines changed

pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def points_wcs_csc(self, permutation=None):
218218
"""
219219
if permutation is None:
220220
return self._points_wcs_csc
221-
return np.concatenate((self._points_wcs_csc[0:1], self._points_wocs_csc.take(permutation, axis=0)))
221+
return np.concatenate((self._points_wcs_csc[:1], self._points_wocs_csc.take(permutation, axis=0)))
222222

223223
def points_wocs_csc(self, permutation=None):
224224
"""
@@ -238,7 +238,7 @@ def points_wcs_ctwcc(self, permutation=None):
238238
return self._points_wcs_ctwcc
239239
return np.concatenate(
240240
(
241-
self._points_wcs_ctwcc[0:1],
241+
self._points_wcs_ctwcc[:1],
242242
self._points_wocs_ctwcc.take(permutation, axis=0),
243243
)
244244
)
@@ -261,7 +261,7 @@ def points_wcs_ctwocc(self, permutation=None):
261261
return self._points_wcs_ctwocc
262262
return np.concatenate(
263263
(
264-
self._points_wcs_ctwocc[0:1],
264+
self._points_wcs_ctwocc[:1],
265265
self._points_wocs_ctwocc.take(permutation, axis=0),
266266
)
267267
)

pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ def project_and_to2dim(self, pps, plane_center):
901901
xypps = []
902902
for pp in proj:
903903
xyzpp = np.dot(pp, PP)
904-
xypps.append(xyzpp[0:2])
904+
xypps.append(xyzpp[:2])
905905
if str(plane_center) == "mean":
906906
mean = np.zeros(2, float)
907907
for pp in xypps:
@@ -910,7 +910,7 @@ def project_and_to2dim(self, pps, plane_center):
910910
xypps = [pp - mean for pp in xypps]
911911
elif plane_center is not None:
912912
projected_plane_center = self.projectionpoints([plane_center])[0]
913-
xy_projected_plane_center = np.dot(projected_plane_center, PP)[0:2]
913+
xy_projected_plane_center = np.dot(projected_plane_center, PP)[:2]
914914
xypps = [pp - xy_projected_plane_center for pp in xypps]
915915
return xypps
916916

@@ -960,7 +960,7 @@ def coefficients(self):
960960
@property
961961
def abcd(self):
962962
"""A tuple with the plane coefficients."""
963-
return tuple(self._coefficients[0:4])
963+
return tuple(self._coefficients[:4])
964964

965965
@property
966966
def a(self):

pymatgen/analysis/ferroelectricity/polarization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def get_nearest_site(struct: Structure, coords: Sequence[float], site: PeriodicS
130130
# Sort by distance to coords
131131
ns.sort(key=lambda x: x[1])
132132
# Return PeriodicSite and distance of closest image
133-
return ns[0][0:2]
133+
return ns[0][:2]
134134

135135

136136
class Polarization:

pymatgen/analysis/magnetism/analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ def _add_structures(ordered_structures, ordered_structures_origins, structures_t
10111011

10121012
# ...and decide which ones to keep
10131013
if len(max_symmetries) > self.truncate_by_symmetry:
1014-
max_symmetries = max_symmetries[0:5]
1014+
max_symmetries = max_symmetries[:5]
10151015
structs_to_keep = [(idx, num) for idx, num in enumerate(num_sym_ops) if num in max_symmetries]
10161016

10171017
# sort so that highest symmetry structs are first

pymatgen/command_line/gulp_caller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ def get_relaxed_structure(gout: str):
585585
# read the site coordinates in the following lines
586586
idx += 6
587587
line = output_lines[idx]
588-
while line[0:2] != "--":
588+
while line[:2] != "--":
589589
structure_lines.append(line)
590590
idx += 1
591591
line = output_lines[idx]

pymatgen/command_line/mcsqs_caller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def _parse_clusters(filename):
261261
for point in range(cluster_dict["num_points_in_cluster"]):
262262
line = cluster[3 + point].split(" ")
263263
point_dict = {}
264-
point_dict["coordinates"] = [float(line) for line in line[0:3]]
264+
point_dict["coordinates"] = [float(line) for line in line[:3]]
265265
point_dict["num_possible_species"] = int(line[3]) + 2 # see ATAT manual for why +2
266266
point_dict["cluster_function"] = float(line[4]) # see ATAT manual for what "function" is
267267
points.append(point_dict)

0 commit comments

Comments
 (0)