Skip to content

Commit 70121c7

Browse files
authored
CI: Remove deprecated numpy dtype aliases (pandas-dev#49886)
1 parent c6bbda5 commit 70121c7

File tree

7 files changed

+14
-15
lines changed

7 files changed

+14
-15
lines changed

asv_bench/benchmarks/sparse.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,12 @@ def setup(self, fill_value):
219219
d = 1e-5
220220
arr = make_array(N, d, np.nan, np.float64)
221221
self.sp_arr = SparseArray(arr)
222-
b_arr = np.full(shape=N, fill_value=fill_value, dtype=np.bool8)
222+
b_arr = np.full(shape=N, fill_value=fill_value, dtype=np.bool_)
223223
fv_inds = np.unique(
224224
np.random.randint(low=0, high=N - 1, size=int(N * d), dtype=np.int32)
225225
)
226226
b_arr[fv_inds] = True if pd.isna(fill_value) else not fill_value
227-
self.sp_b_arr = SparseArray(b_arr, dtype=np.bool8, fill_value=fill_value)
227+
self.sp_b_arr = SparseArray(b_arr, dtype=np.bool_, fill_value=fill_value)
228228

229229
def time_mask(self, fill_value):
230230
self.sp_arr[self.sp_b_arr]

pandas/core/arrays/sparse/array.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ def isna(self):
716716
dtype = SparseDtype(bool, self._null_fill_value)
717717
if self._null_fill_value:
718718
return type(self)._simple_new(isna(self.sp_values), self.sp_index, dtype)
719-
mask = np.full(len(self), False, dtype=np.bool8)
719+
mask = np.full(len(self), False, dtype=np.bool_)
720720
mask[self.sp_index.indices] = isna(self.sp_values)
721721
return type(self)(mask, fill_value=False, dtype=dtype)
722722

@@ -1003,7 +1003,7 @@ def __getitem__(
10031003
if not key.fill_value:
10041004
return self.take(key.sp_index.indices)
10051005
n = len(self)
1006-
mask = np.full(n, True, dtype=np.bool8)
1006+
mask = np.full(n, True, dtype=np.bool_)
10071007
mask[key.sp_index.indices] = False
10081008
return self.take(np.arange(n)[mask])
10091009
else:

pandas/core/interchange/column.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def _get_validity_buffer(self) -> tuple[PandasBuffer, Any]:
316316
valid = invalid == 0
317317
invalid = not valid
318318

319-
mask = np.zeros(shape=(len(buf),), dtype=np.bool8)
319+
mask = np.zeros(shape=(len(buf),), dtype=np.bool_)
320320
for i, obj in enumerate(buf):
321321
mask[i] = valid if isinstance(obj, str) else invalid
322322

pandas/tests/arrays/sparse/test_indexing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_boolean_slice_empty(self):
8585

8686
def test_getitem_bool_sparse_array(self):
8787
# GH 23122
88-
spar_bool = SparseArray([False, True] * 5, dtype=np.bool8, fill_value=True)
88+
spar_bool = SparseArray([False, True] * 5, dtype=np.bool_, fill_value=True)
8989
exp = SparseArray([np.nan, 2, np.nan, 5, 6])
9090
tm.assert_sp_array_equal(arr[spar_bool], exp)
9191

@@ -95,7 +95,7 @@ def test_getitem_bool_sparse_array(self):
9595
tm.assert_sp_array_equal(res, exp)
9696

9797
spar_bool = SparseArray(
98-
[False, True, np.nan] * 3, dtype=np.bool8, fill_value=np.nan
98+
[False, True, np.nan] * 3, dtype=np.bool_, fill_value=np.nan
9999
)
100100
res = arr[spar_bool]
101101
exp = SparseArray([np.nan, 3, 5])

pandas/tests/arrays/sparse/test_reductions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def test_sum_min_count(self, arr, fill_value, min_count, expected):
142142
assert result == expected
143143

144144
def test_bool_sum_min_count(self):
145-
spar_bool = SparseArray([False, True] * 5, dtype=np.bool8, fill_value=True)
145+
spar_bool = SparseArray([False, True] * 5, dtype=np.bool_, fill_value=True)
146146
res = spar_bool.sum(min_count=1)
147147
assert res == 5
148148
res = spar_bool.sum(min_count=11)

pandas/tests/arrays/sparse/test_unary.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ def test_abs_operator(self):
5959
tm.assert_sp_array_equal(exp, res)
6060

6161
def test_invert_operator(self):
62-
arr = SparseArray([False, True, False, True], fill_value=False, dtype=np.bool8)
62+
arr = SparseArray([False, True, False, True], fill_value=False, dtype=np.bool_)
6363
exp = SparseArray(
64-
np.invert([False, True, False, True]), fill_value=True, dtype=np.bool8
64+
np.invert([False, True, False, True]), fill_value=True, dtype=np.bool_
6565
)
6666
res = ~arr
6767
tm.assert_sp_array_equal(exp, res)

pandas/tests/io/excel/test_writers.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -479,15 +479,14 @@ def test_float_types(self, np_type, path):
479479

480480
tm.assert_frame_equal(df, recons)
481481

482-
@pytest.mark.parametrize("np_type", [np.bool8, np.bool_])
483-
def test_bool_types(self, np_type, path):
484-
# Test np.bool8 and np.bool_ values read come back as float.
485-
df = DataFrame([1, 0, True, False], dtype=np_type)
482+
def test_bool_types(self, path):
483+
# Test np.bool_ values read come back as float.
484+
df = DataFrame([1, 0, True, False], dtype=np.bool_)
486485
df.to_excel(path, "test1")
487486

488487
with ExcelFile(path) as reader:
489488
recons = pd.read_excel(reader, sheet_name="test1", index_col=0).astype(
490-
np_type
489+
np.bool_
491490
)
492491

493492
tm.assert_frame_equal(df, recons)

0 commit comments

Comments
 (0)