Skip to content

Commit

Permalink
Replace use of deprecated np.bool with dtype alias np.bool_
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Oct 18, 2024
1 parent 6291ec7 commit d0be011
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/scanspec/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
C = TypeVar("C")
T = TypeVar("T")

GapArray = npt.NDArray[np.bool]
GapArray = npt.NDArray[np.bool_]


def discriminated_union_of_subclasses(
Expand Down Expand Up @@ -586,9 +586,7 @@ def consume(self, num: int | None = None) -> Frames[Axis]:
end_index = min(self.index + num, self.end_index)
indices = np.arange(self.index, end_index)
self.index = end_index
stack: Frames[Axis] = Frames(
{}, {}, {}, np.zeros(indices.shape, dtype=np.bool_)
)
stack: Frames[Axis] = Frames({}, {}, {}, np.zeros(indices.shape, dtype=bool_))
# Example numbers below from a 2x3x4 ZxYxX scan
for i, frames in enumerate(self.stack):
# Number of times each frame will repeat: Z:12, Y:4, X:1
Expand Down
8 changes: 4 additions & 4 deletions src/scanspec/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"find_regions",
]

NpMask = npt.NDArray[np.bool]
NpMask = npt.NDArray[np.bool_]


@discriminated_union_of_subclasses
Expand Down Expand Up @@ -96,7 +96,7 @@ def get_mask(region: Region[Axis], points: AxesPoints[Axis]) -> NpMask:
if needs_mask:
return region.mask(points)
else:
return np.ones(len(list(points.values())[0]), dtype=np.bool)
return np.ones(len(list(points.values())[0]), dtype=np.bool_)


def _merge_axis_sets(axis_sets: list[set[Axis]]) -> Iterator[set[Axis]]:
Expand Down Expand Up @@ -287,11 +287,11 @@ def mask(self, points: AxesPoints[Axis]) -> NpMask: # noqa: D102
x = points[self.x_axis]
y = points[self.y_axis]
v1x, v1y = self.x_verts[-1], self.y_verts[-1]
mask = np.full(len(x), False, dtype=np.bool)
mask = np.full(len(x), False, dtype=np.bool_)
for v2x, v2y in zip(self.x_verts, self.y_verts, strict=False):
# skip horizontal edges
if v2y != v1y:
vmask = np.full(len(x), False, dtype=np.bool)
vmask = np.full(len(x), False, dtype=np.bool_)
vmask |= (y < v2y) & (y >= v1y)
vmask |= (y < v1y) & (y >= v2y)
t = (y - v1y) / (v2y - v1y)
Expand Down

0 comments on commit d0be011

Please sign in to comment.