From d0be011a4008cca748875fdf627714371d1fe7a4 Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Fri, 18 Oct 2024 15:25:22 +0100 Subject: [PATCH] Replace use of deprecated np.bool with dtype alias np.bool_ --- src/scanspec/core.py | 6 ++---- src/scanspec/regions.py | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/scanspec/core.py b/src/scanspec/core.py index 4a4edb69..b25adca5 100644 --- a/src/scanspec/core.py +++ b/src/scanspec/core.py @@ -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( @@ -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 diff --git a/src/scanspec/regions.py b/src/scanspec/regions.py index e6fed0a7..b227039d 100644 --- a/src/scanspec/regions.py +++ b/src/scanspec/regions.py @@ -40,7 +40,7 @@ "find_regions", ] -NpMask = npt.NDArray[np.bool] +NpMask = npt.NDArray[np.bool_] @discriminated_union_of_subclasses @@ -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]]: @@ -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)