Skip to content

Commit 3182a44

Browse files
committed
Use Bool
1 parent 037b2d4 commit 3182a44

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

adaptive/learner/triangulation.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from math import factorial, sqrt
88
from typing import Any, Iterable, Iterator, List, Sequence, Tuple, Union
99

10-
import numpy as np
1110
import scipy.spatial
1211
from numpy import abs as np_abs
1312
from numpy import (
@@ -28,6 +27,8 @@
2827
from numpy.linalg import det as ndet
2928
from numpy.linalg import matrix_rank, norm, slogdet, solve
3029

30+
from adaptive.types import Bool
31+
3132
try:
3233
from typing import TypeAlias
3334
except ImportError:
@@ -61,7 +62,7 @@ def fast_norm(v: tuple[float, ...] | ndarray) -> float:
6162

6263
def fast_2d_point_in_simplex(
6364
point: Point, simplex: SimplexPoints, eps: float = 1e-8
64-
) -> bool | np.bool_:
65+
) -> Bool:
6566
(p0x, p0y), (p1x, p1y), (p2x, p2y) = simplex
6667
px, py = point
6768

@@ -75,9 +76,7 @@ def fast_2d_point_in_simplex(
7576
return (t >= -eps) and (s + t <= 1 + eps)
7677

7778

78-
def point_in_simplex(
79-
point: Point, simplex: SimplexPoints, eps: float = 1e-8
80-
) -> bool | np.bool_:
79+
def point_in_simplex(point: Point, simplex: SimplexPoints, eps: float = 1e-8) -> Bool:
8180
if len(point) == 2:
8281
return fast_2d_point_in_simplex(point, simplex, eps)
8382

@@ -424,7 +423,7 @@ def get_reduced_simplex(
424423

425424
def point_in_simplex(
426425
self, point: Point, simplex: Simplex, eps: float = 1e-8
427-
) -> bool | np.bool_:
426+
) -> Bool:
428427
vertices = self.get_vertices(simplex)
429428
return point_in_simplex(point, vertices, eps)
430429

@@ -533,7 +532,7 @@ def circumscribed_circle(
533532

534533
def point_in_cicumcircle(
535534
self, pt_index: int, simplex: Simplex, transform: ndarray
536-
) -> bool | np.bool_:
535+
) -> Bool:
537536
# return self.fast_point_in_circumcircle(pt_index, simplex, transform)
538537
eps = 1e-8
539538

@@ -611,7 +610,7 @@ def bowyer_watson(
611610
new_triangles = self.vertex_to_simplices[pt_index]
612611
return bad_triangles - new_triangles, new_triangles - bad_triangles
613612

614-
def _simplex_is_almost_flat(self, simplex: Simplex) -> bool | np.bool_:
613+
def _simplex_is_almost_flat(self, simplex: Simplex) -> Bool:
615614
return self._relative_volume(simplex) < 1e-8
616615

617616
def _relative_volume(self, simplex: Simplex) -> float:

adaptive/types.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
Float: TypeAlias = Union[float, np.float_]
1212
Int: TypeAlias = Union[int, np.int_]
1313
Real: TypeAlias = Union[Float, Int]
14+
Bool: TypeAlias = Union[bool, np.bool_]

0 commit comments

Comments
 (0)