Avoid test failures with numpy 1.24
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Wed, 11 Jan 2023 07:34:28 +0000 (07:34 +0000)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Wed, 11 Jan 2023 07:34:28 +0000 (07:34 +0000)
(some tests fail on unexpected DeprecationWarnings)

Origin: mostly upstream commit 70121c75a0e2a42e31746b6c205c7bb9e4b9b930
Author: Patrick Hoefler, Rebecca N. Palmer
Forwarded: not-needed

Gbp-Pq: Name numpy1p24.patch

asv_bench/benchmarks/sparse.py
pandas/core/arrays/sparse/array.py
pandas/core/interchange/column.py
pandas/tests/arrays/sparse/test_indexing.py
pandas/tests/arrays/sparse/test_reductions.py
pandas/tests/arrays/sparse/test_unary.py
pandas/tests/io/excel/test_writers.py
pandas/tests/series/test_constructors.py

index d871f907232f5fff18caed95f13a64cb40c9204c..10390cb4493cd4bd14f18be03f06efa508f66782 100644 (file)
@@ -219,12 +219,12 @@ class GetItemMask:
         d = 1e-5
         arr = make_array(N, d, np.nan, np.float64)
         self.sp_arr = SparseArray(arr)
-        b_arr = np.full(shape=N, fill_value=fill_value, dtype=np.bool8)
+        b_arr = np.full(shape=N, fill_value=fill_value, dtype=np.bool_)
         fv_inds = np.unique(
             np.random.randint(low=0, high=N - 1, size=int(N * d), dtype=np.int32)
         )
         b_arr[fv_inds] = True if pd.isna(fill_value) else not fill_value
-        self.sp_b_arr = SparseArray(b_arr, dtype=np.bool8, fill_value=fill_value)
+        self.sp_b_arr = SparseArray(b_arr, dtype=np.bool_, fill_value=fill_value)
 
     def time_mask(self, fill_value):
         self.sp_arr[self.sp_b_arr]
index a389f1f282ee038a48a59da951ce0d832dcdb535..62ae6163a073e4fc8b429914ae972fb7411d928d 100644 (file)
@@ -728,7 +728,7 @@ class SparseArray(OpsMixin, PandasObject, ExtensionArray):
         dtype = SparseDtype(bool, self._null_fill_value)
         if self._null_fill_value:
             return type(self)._simple_new(isna(self.sp_values), self.sp_index, dtype)
-        mask = np.full(len(self), False, dtype=np.bool8)
+        mask = np.full(len(self), False, dtype=np.bool_)
         mask[self.sp_index.indices] = isna(self.sp_values)
         return type(self)(mask, fill_value=False, dtype=dtype)
 
@@ -1043,7 +1043,7 @@ class SparseArray(OpsMixin, PandasObject, ExtensionArray):
                     if not key.fill_value:
                         return self.take(key.sp_index.indices)
                     n = len(self)
-                    mask = np.full(n, True, dtype=np.bool8)
+                    mask = np.full(n, True, dtype=np.bool_)
                     mask[key.sp_index.indices] = False
                     return self.take(np.arange(n)[mask])
                 else:
index dc24c928d1f3910d5e50c1546f045ce6ce238012..359e2fa0b7ab2712b66a3bf3b40ca2e0cf6177d2 100644 (file)
@@ -315,7 +315,7 @@ class PandasColumn(Column):
             valid = invalid == 0
             invalid = not valid
 
-            mask = np.zeros(shape=(len(buf),), dtype=np.bool8)
+            mask = np.zeros(shape=(len(buf),), dtype=np.bool_)
             for i, obj in enumerate(buf):
                 mask[i] = valid if isinstance(obj, str) else invalid
 
index 7ea36ed041f443e61a71f2a15727ece738862ab0..311a8a04e5b915a2d6e79e37e689b500dd6e27e3 100644 (file)
@@ -85,7 +85,7 @@ class TestGetitem:
 
     def test_getitem_bool_sparse_array(self):
         # GH 23122
-        spar_bool = SparseArray([False, True] * 5, dtype=np.bool8, fill_value=True)
+        spar_bool = SparseArray([False, True] * 5, dtype=np.bool_, fill_value=True)
         exp = SparseArray([np.nan, 2, np.nan, 5, 6])
         tm.assert_sp_array_equal(arr[spar_bool], exp)
 
@@ -95,7 +95,7 @@ class TestGetitem:
         tm.assert_sp_array_equal(res, exp)
 
         spar_bool = SparseArray(
-            [False, True, np.nan] * 3, dtype=np.bool8, fill_value=np.nan
+            [False, True, np.nan] * 3, dtype=np.bool_, fill_value=np.nan
         )
         res = arr[spar_bool]
         exp = SparseArray([np.nan, 3, 5])
index 2dd80c52f1419f4d7a5113011347007619e385ad..5d6d65dde69adbeb4eed3864f100682a3dda3ec5 100644 (file)
@@ -142,7 +142,7 @@ class TestReductions:
             assert result == expected
 
     def test_bool_sum_min_count(self):
-        spar_bool = SparseArray([False, True] * 5, dtype=np.bool8, fill_value=True)
+        spar_bool = SparseArray([False, True] * 5, dtype=np.bool_, fill_value=True)
         res = spar_bool.sum(min_count=1)
         assert res == 5
         res = spar_bool.sum(min_count=11)
index a34c3b0787753213e160cb3e4f4b7a9edec61f7e..605023a407a068ae48d3045cea6419f71145ed79 100644 (file)
@@ -59,9 +59,9 @@ class TestUnaryMethods:
         tm.assert_sp_array_equal(exp, res)
 
     def test_invert_operator(self):
-        arr = SparseArray([False, True, False, True], fill_value=False, dtype=np.bool8)
+        arr = SparseArray([False, True, False, True], fill_value=False, dtype=np.bool_)
         exp = SparseArray(
-            np.invert([False, True, False, True]), fill_value=True, dtype=np.bool8
+            np.invert([False, True, False, True]), fill_value=True, dtype=np.bool_
         )
         res = ~arr
         tm.assert_sp_array_equal(exp, res)
index d4b74ddbd66e0d52da1a15257e3176b8387b21ce..f6a77d3acb933959ccce148ccde873ca2c5feb1c 100644 (file)
@@ -496,15 +496,14 @@ class TestExcelWriter:
 
         tm.assert_frame_equal(df, recons)
 
-    @pytest.mark.parametrize("np_type", [np.bool8, np.bool_])
-    def test_bool_types(self, np_type, path):
-        # Test np.bool8 and np.bool_ values read come back as float.
-        df = DataFrame([1, 0, True, False], dtype=np_type)
+    def test_bool_types(self, path):
+        # Test np.bool_ values read come back as float.
+        df = DataFrame([1, 0, True, False], dtype=np.bool_)
         df.to_excel(path, "test1")
 
         with ExcelFile(path) as reader:
             recons = pd.read_excel(reader, sheet_name="test1", index_col=0).astype(
-                np_type
+                np.bool_
             )
 
         tm.assert_frame_equal(df, recons)
index 53b2cbedc0ae3fdaa10bc598a3be9939a1c881ce..ea680c8a38e8e5ce1d071ccf2c3c7ade46311ecd 100644 (file)
@@ -735,7 +735,7 @@ class TestSeriesConstructors:
     def test_constructor_signed_int_overflow_deprecation(self):
         # GH#41734 disallow silent overflow
         msg = "Values are too large to be losslessly cast"
-        numpy_warning = DeprecationWarning if is_numpy_dev else None
+        numpy_warning = DeprecationWarning
         with tm.assert_produces_warning(
             (FutureWarning, numpy_warning), match=msg, check_stacklevel=False
         ):