Skip to content

Commit e9ea813

Browse files
authored
Return bool instead of np.bool_ (materialsproject#4074)
1 parent ea7c339 commit e9ea813

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

src/pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def is_in_plane(self, pp, dist_tolerance) -> bool:
724724
Returns:
725725
bool: True if pp is in the plane.
726726
"""
727-
return np.abs(np.dot(self.normal_vector, pp) + self._coefficients[3]) <= dist_tolerance
727+
return bool(np.abs(np.dot(self.normal_vector, pp) + self._coefficients[3]) <= dist_tolerance)
728728

729729
def is_same_plane_as(self, plane) -> bool:
730730
"""

src/pymatgen/analysis/structure_matcher.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def fit(
633633
if match1 is None or match2 is None:
634634
return False
635635

636-
return max(match1[0], match2[0]) <= self.stol
636+
return bool(max(match1[0], match2[0]) <= self.stol)
637637

638638
def get_rms_dist(self, struct1, struct2):
639639
"""

src/pymatgen/core/structure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def is_valid(self, tol: float = DISTANCE_TOLERANCE) -> bool:
500500
if len(self) == 1:
501501
return True
502502
all_dists = self.distance_matrix[np.triu_indices(len(self), 1)]
503-
return np.min(all_dists) > tol
503+
return bool(np.min(all_dists) > tol)
504504

505505
@abstractmethod
506506
def to(self, filename: str = "", fmt: FileFormats = "") -> str | None:

src/pymatgen/core/surface.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def is_symmetric(self, symprec: float = 0.1) -> bool:
299299
# to surface (b) along the [hkl]-axis, surfaces are symmetric. Or because the
300300
# two surfaces of our slabs are always parallel to the (hkl) plane,
301301
# any operation where there's an (hkl) mirror plane has surface symmetry
302-
return (
302+
return bool(
303303
spg_analyzer.is_laue()
304304
or any(op.translation_vector[2] != 0 for op in symm_ops)
305305
or any(np.all(op.rotation_matrix[2] == np.array([0, 0, -1])) for op in symm_ops)
@@ -318,7 +318,7 @@ def is_polar(self, tol_dipole_per_unit_area: float = 1e-3) -> bool:
318318
considered polar.
319319
"""
320320
dip_per_unit_area = self.dipole / self.surface_area
321-
return np.linalg.norm(dip_per_unit_area) > tol_dipole_per_unit_area
321+
return bool(np.linalg.norm(dip_per_unit_area) > tol_dipole_per_unit_area)
322322

323323
def get_surface_sites(self, tag: bool = False) -> dict[str, list]:
324324
"""Get the surface sites and their indices in a dictionary.

src/pymatgen/core/tensors.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def is_fit_to_structure(self, structure: Structure, tol: float = 1e-2) -> bool:
331331
structure (Structure): structure to be fit to
332332
tol (float): tolerance for symmetry testing
333333
"""
334-
return (self - self.fit_to_structure(structure) < tol).all()
334+
return bool((self - self.fit_to_structure(structure) < tol).all())
335335

336336
@property
337337
def voigt(self) -> NDArray:
@@ -968,7 +968,7 @@ def is_rotation(
968968
det = np.abs(np.linalg.det(self))
969969
if include_improper:
970970
det = np.abs(det)
971-
return (np.abs(self.inv - self.trans) < tol).all() and (np.abs(det - 1.0) < tol)
971+
return bool((np.abs(self.inv - self.trans) < tol).all() and (np.abs(det - 1.0) < tol))
972972

973973
def refine_rotation(self) -> Self:
974974
"""Helper method for refining rotation matrix by ensuring

src/pymatgen/phonon/bandstructure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def has_imaginary_freq(self, tol: float = 0.01) -> bool:
182182
Args:
183183
tol: Tolerance for determining if a frequency is imaginary. Defaults to 0.01.
184184
"""
185-
return self.min_freq()[1] + tol < 0
185+
return bool(self.min_freq()[1] + tol < 0)
186186

187187
def has_imaginary_gamma_freq(self, tol: float = 0.01) -> bool:
188188
"""Check if there are imaginary modes at the gamma point and all close points.

0 commit comments

Comments
 (0)