From 5cb1bcf551a2990dddc9bbe7e68e6081921b13b7 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:35:34 -0700 Subject: [PATCH 1/5] CI: Fix npdev failures --- pandas/_libs/hashtable_class_helper.pxi.in | 2 +- pandas/tests/arrays/test_datetimelike.py | 6 ++++-- pandas/tests/extension/base/missing.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/hashtable_class_helper.pxi.in b/pandas/_libs/hashtable_class_helper.pxi.in index 5c6254c6a1ec7..89b09bde62789 100644 --- a/pandas/_libs/hashtable_class_helper.pxi.in +++ b/pandas/_libs/hashtable_class_helper.pxi.in @@ -1020,7 +1020,7 @@ cdef class StringHashTable(HashTable): raise KeyError(key) @cython.boundscheck(False) - def get_indexer(self, ndarray[object] values) -> ndarray: + def get_indexer(self, object[:] values) -> ndarray: # -> np.ndarray[np.intp] cdef: Py_ssize_t i, n = len(values) diff --git a/pandas/tests/arrays/test_datetimelike.py b/pandas/tests/arrays/test_datetimelike.py index cfc04b5c91354..91e984965e7d1 100644 --- a/pandas/tests/arrays/test_datetimelike.py +++ b/pandas/tests/arrays/test_datetimelike.py @@ -661,7 +661,8 @@ def test_array_interface(self, datetime_index): assert result is expected tm.assert_numpy_array_equal(result, expected) result = np.array(arr, dtype="datetime64[ns]") - assert result is not expected + if not np_version_gt2: + assert result is not expected tm.assert_numpy_array_equal(result, expected) # to object dtype @@ -976,7 +977,8 @@ def test_array_interface(self, timedelta_index): assert result is expected tm.assert_numpy_array_equal(result, expected) result = np.array(arr, dtype="timedelta64[ns]") - assert result is not expected + if not np_version_gt2: + assert result is not expected tm.assert_numpy_array_equal(result, expected) # to object dtype diff --git a/pandas/tests/extension/base/missing.py b/pandas/tests/extension/base/missing.py index 4b9234a9904a2..62e019b466fa3 100644 --- a/pandas/tests/extension/base/missing.py +++ b/pandas/tests/extension/base/missing.py @@ -27,7 +27,7 @@ def test_isna_returns_copy(self, data_missing, na_func): expected = result.copy() mask = getattr(result, na_func)() if isinstance(mask.dtype, pd.SparseDtype): - mask = np.array(mask) + mask = np.array(mask, copy=True) mask[:] = True tm.assert_series_equal(result, expected) From 4e9fbacfcef2d9c0fcbf797002028601a6d317c7 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:10:08 -0700 Subject: [PATCH 2/5] Use unique index, make array writable --- pandas/tests/extension/base/missing.py | 4 +++- pandas/tests/indexes/test_base.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/tests/extension/base/missing.py b/pandas/tests/extension/base/missing.py index 62e019b466fa3..cee565d4f7c1e 100644 --- a/pandas/tests/extension/base/missing.py +++ b/pandas/tests/extension/base/missing.py @@ -27,7 +27,9 @@ def test_isna_returns_copy(self, data_missing, na_func): expected = result.copy() mask = getattr(result, na_func)() if isinstance(mask.dtype, pd.SparseDtype): - mask = np.array(mask, copy=True) + # TODO: GH 57739 + mask = np.array(mask) + mask.flags.writeable = True mask[:] = True tm.assert_series_equal(result, expected) diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 3a2d04d3ffdc2..fe225a7d20653 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -71,8 +71,8 @@ def test_constructor_casting(self, index): tm.assert_contains_all(arr, new_index) tm.assert_index_equal(index, new_index) - @pytest.mark.parametrize("index", ["string"], indirect=True) - def test_constructor_copy(self, index, using_infer_string): + def test_constructor_copy(self, using_infer_string): + index = Index(list("abc"), name="name") arr = np.array(index) new_index = Index(arr, copy=True, name="name") assert isinstance(new_index, Index) From e6fcfe7eed289442f3c916cf0204521348b7b302 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:54:42 -0700 Subject: [PATCH 3/5] Update pandas/_libs/hashtable_class_helper.pxi.in --- pandas/_libs/hashtable_class_helper.pxi.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/hashtable_class_helper.pxi.in b/pandas/_libs/hashtable_class_helper.pxi.in index 89b09bde62789..5c6254c6a1ec7 100644 --- a/pandas/_libs/hashtable_class_helper.pxi.in +++ b/pandas/_libs/hashtable_class_helper.pxi.in @@ -1020,7 +1020,7 @@ cdef class StringHashTable(HashTable): raise KeyError(key) @cython.boundscheck(False) - def get_indexer(self, object[:] values) -> ndarray: + def get_indexer(self, ndarray[object] values) -> ndarray: # -> np.ndarray[np.intp] cdef: Py_ssize_t i, n = len(values) From 1caf57b2fbcb0d0d090a663823f07b18e7fa77db Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:55:16 -0700 Subject: [PATCH 4/5] Update pandas/tests/arrays/test_datetimelike.py --- pandas/tests/arrays/test_datetimelike.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/arrays/test_datetimelike.py b/pandas/tests/arrays/test_datetimelike.py index 91e984965e7d1..e975803b0c892 100644 --- a/pandas/tests/arrays/test_datetimelike.py +++ b/pandas/tests/arrays/test_datetimelike.py @@ -978,6 +978,7 @@ def test_array_interface(self, timedelta_index): tm.assert_numpy_array_equal(result, expected) result = np.array(arr, dtype="timedelta64[ns]") if not np_version_gt2: + # TODO: GH 57739 assert result is not expected tm.assert_numpy_array_equal(result, expected) From fcfe702c7233d2c8480e858e769036c976a18c09 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:55:35 -0700 Subject: [PATCH 5/5] Update pandas/tests/arrays/test_datetimelike.py --- pandas/tests/arrays/test_datetimelike.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/arrays/test_datetimelike.py b/pandas/tests/arrays/test_datetimelike.py index e975803b0c892..6bfcc149fcee8 100644 --- a/pandas/tests/arrays/test_datetimelike.py +++ b/pandas/tests/arrays/test_datetimelike.py @@ -662,6 +662,7 @@ def test_array_interface(self, datetime_index): tm.assert_numpy_array_equal(result, expected) result = np.array(arr, dtype="datetime64[ns]") if not np_version_gt2: + # TODO: GH 57739 assert result is not expected tm.assert_numpy_array_equal(result, expected)