diff --git a/tests/compliance/date/test_date_compliance.py b/tests/compliance/date/test_date_compliance.py index 52b9c04..ae1ef83 100644 --- a/tests/compliance/date/test_date_compliance.py +++ b/tests/compliance/date/test_date_compliance.py @@ -51,7 +51,15 @@ class TestDtype(base.BaseDtypeTests): class TestGetitem(base.BaseGetitemTests): - pass + def test_take_pandas_style_negative_raises(self, data, na_value): + # This test was failing compliance checks because it attempted to match + # a pytest regex match using an empty string (""), which pytest version + # 8.4.0 stopped allowing. + # The test has been updated in pandas main so that it will + # no longer fail, but the fix is not expected to be released until + # at least pandas version 3.0 (current version is 2.3). + with pytest.raises(ValueError): + data.take([0, -2], fill_value=na_value, allow_fill=True) class TestGroupby(base.BaseGroupbyTests): @@ -63,7 +71,26 @@ class TestIndex(base.BaseIndexTests): class TestInterface(base.BaseInterfaceTests): - pass + def test_array_interface_copy(self, data): + # This test was failing compliance checks due to changes in how + # numpy handles processing when np.array(obj, copy=False). + # Until pandas changes the existing tests, this compliance test + # will continue to fail. + import numpy as np + from pandas.compat.numpy import np_version_gt2 + + result_copy1 = np.array(data, copy=True) + result_copy2 = np.array(data, copy=True) + assert not np.may_share_memory(result_copy1, result_copy2) + + if not np_version_gt2: + # copy=False semantics are only supported in NumPy>=2. + return + + with pytest.raises(ValueError): + result_nocopy1 = np.array(data, copy=False) + result_nocopy2 = np.array(data, copy=False) + assert np.may_share_memory(result_nocopy1, result_nocopy2) class TestMissing(base.BaseMissingTests): @@ -102,6 +129,21 @@ def test_hash_pandas_object(self): further investigation. See issues 182, 183, 185.""" ) + def test_argmax_argmin_no_skipna_notimplemented(self, data_missing_for_sorting): + # This test was failing compliance checks because it attempted to match + # a pytest regex match using an empty string (""), which pytest version + # 8.4.0 stopped allowing. + # The test has been updated in pandas main so that it will + # no longer fail, but the fix is not expected to be released until + # at least pandas version 3.0 (current version is 2.3) + data = data_missing_for_sorting + + with pytest.raises(NotImplementedError): + data.argmin(skipna=False) + + with pytest.raises(NotImplementedError): + data.argmax(skipna=False) + class TestParsing(base.BaseParsingTests): pass @@ -116,7 +158,18 @@ class TestReshaping(base.BaseReshapingTests): class TestSetitem(base.BaseSetitemTests): - pass + # This test was failing compliance checks because it attempted to match + # a pytest regex match using an empty string (""), which pytest version + # 8.4.0 stopped allowing. + # The test has been updated in pandas main so that it will + # no longer fail, but the fix is not expected to be released until + # at least pandas version 3.0 (current version is 2.3). + def test_setitem_invalid(self, data, invalid_scalar): + with pytest.raises((ValueError, TypeError)): + data[0] = invalid_scalar + + with pytest.raises((ValueError, TypeError)): + data[:] = invalid_scalar # NDArrayBacked2DTests suite added in https://github.com/pandas-dev/pandas/pull/44974 diff --git a/tests/compliance/json/test_json_compliance.py b/tests/compliance/json/test_json_compliance.py index 9a0d0ef..da5b63b 100644 --- a/tests/compliance/json/test_json_compliance.py +++ b/tests/compliance/json/test_json_compliance.py @@ -107,6 +107,16 @@ def test_getitem_scalar(self, data): """ super().test_getitem_scalar(data) + def test_take_pandas_style_negative_raises(self, data, na_value): + # This test was failing compliance checks because it attempted to match + # a pytest regex match using an empty string (""), which pytest version + # 8.4.0 stopped allowing. + # The test has been updated in pandas main so that it will + # no longer fail, but the fix is not expected to be released until + # at least pandas version 3.0 (current version is 2.3). + with pytest.raises(ValueError): + data.take([0, -2], fill_value=na_value, allow_fill=True) + class TestJSONArrayIndex(base.BaseIndexTests): pass @@ -133,6 +143,26 @@ def test_array_interface(self, data): def test_view(self, data): super().test_view(data) + def test_array_interface_copy(self, data): + # This test was failing compliance checks due to changes in how + # numpy handles processing when np.array(obj, copy=False). + # Until pandas changes the existing tests, this compliance test + # will continue to fail. + import numpy as np + from pandas.compat.numpy import np_version_gt2 + + result_copy1 = np.array(data, copy=True) + result_copy2 = np.array(data, copy=True) + assert not np.may_share_memory(result_copy1, result_copy2) + + if not np_version_gt2: + # copy=False semantics are only supported in NumPy>=2. + return + + result_nocopy1 = np.array(data, copy=False) + result_nocopy2 = np.array(data, copy=False) + assert not np.may_share_memory(result_nocopy1, result_nocopy2) + class TestJSONArrayParsing(base.BaseParsingTests): @pytest.mark.xfail(reason="data type 'json' not understood") @@ -190,6 +220,21 @@ def test_sort_values(self, data_for_sorting): def test_sort_values_frame(self, data_for_sorting): super().test_sort_values_frame(data_for_sorting) + def test_argmax_argmin_no_skipna_notimplemented(self, data_missing_for_sorting): + # This test was failing compliance checks because it attempted to match + # a pytest regex match using an empty string (""), which pytest version + # 8.4.0 stopped allowing. + # The test has been updated in pandas main so that it will + # no longer fail, but the fix is not expected to be released until + # at least pandas version 3.0 (current version is 2.3) + data = data_missing_for_sorting + + with pytest.raises(NotImplementedError): + data.argmin(skipna=False) + + with pytest.raises(NotImplementedError): + data.argmax(skipna=False) + class TestJSONArrayMissing(base.BaseMissingTests): @pytest.mark.xfail(reason="Setting a dict as a scalar") @@ -239,7 +284,20 @@ class TestJSONArrayPrinting(base.BasePrintingTests): class TestJSONArrayReduce(base.BaseReduceTests): - pass + @pytest.mark.filterwarnings("ignore::RuntimeWarning") + @pytest.mark.parametrize("skipna", [True, False]) + def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna): + op_name = all_numeric_reductions + ser = pd.Series(data) + + if not self._supports_reduction(ser, op_name): + # Sum does not raise an Error (TypeError or otherwise) + if op_name != "sum": + with pytest.raises(TypeError): + getattr(ser, op_name)(skipna=skipna) + else: + # min/max with empty produce numpy warnings + self.check_reduce(ser, op_name, skipna) class TestJSONArrayReshaping(base.BaseReshapingTests): @@ -356,6 +414,19 @@ def test_setitem_mask_boolean_array_with_na(self, data, box_in_series): def test_setitem_preserves_views(self, data): super().test_setitem_preserves_views(data) + def test_setitem_invalid(self, data, invalid_scalar): + # This test was failing compliance checks because it attempted to match + # a pytest regex match using an empty string (""), which pytest version + # 8.4.0 stopped allowing. + # The test has been updated in pandas main so that it will + # no longer fail, but the fix is not expected to be released until + # at least pandas version 3.0 (current version is 2.3) + with pytest.raises((ValueError, TypeError)): + data[0] = invalid_scalar + + with pytest.raises((ValueError, TypeError)): + data[:] = invalid_scalar + class TestJSONArrayDim2Compat(base.Dim2CompatTests): pass diff --git a/tests/compliance/time/test_time_compliance.py b/tests/compliance/time/test_time_compliance.py index 118c61d..99ac5dd 100644 --- a/tests/compliance/time/test_time_compliance.py +++ b/tests/compliance/time/test_time_compliance.py @@ -56,7 +56,15 @@ class TestDtype(base.BaseDtypeTests): class TestGetitem(base.BaseGetitemTests): - pass + def test_take_pandas_style_negative_raises(self, data, na_value): + # This test was failing compliance checks because it attempted to match + # a pytest regex match using an empty string (""), which pytest version + # 8.4.0 stopped allowing. + # The test has been updated in pandas main so that it will + # no longer fail, but the fix is not expected to be released until + # at least pandas version 3.0 (current version is 2.3). + with pytest.raises(ValueError): + data.take([0, -2], fill_value=na_value, allow_fill=True) class TestGroupby(base.BaseGroupbyTests): @@ -68,7 +76,26 @@ class TestIndex(base.BaseIndexTests): class TestInterface(base.BaseInterfaceTests): - pass + def test_array_interface_copy(self, data): + # This test was failing compliance checks due to changes in how + # numpy handles processing when np.array(obj, copy=False). + # Until pandas changes the existing tests, this compliance test + # will continue to fail. + import numpy as np + from pandas.compat.numpy import np_version_gt2 + + result_copy1 = np.array(data, copy=True) + result_copy2 = np.array(data, copy=True) + assert not np.may_share_memory(result_copy1, result_copy2) + + if not np_version_gt2: + # copy=False semantics are only supported in NumPy>=2. + return + + with pytest.raises(ValueError): + result_nocopy1 = np.array(data, copy=False) + result_nocopy2 = np.array(data, copy=False) + assert np.may_share_memory(result_nocopy1, result_nocopy2) class TestMissing(base.BaseMissingTests): @@ -95,6 +122,21 @@ def test_value_counts(self, all_data, dropna): tm.assert_series_equal(result, expected) + def test_argmax_argmin_no_skipna_notimplemented(self, data_missing_for_sorting): + # This test was failing compliance checks because it attempted to match + # a pytest regex match using an empty string (""), which pytest version + # 8.4.0 stopped allowing. + # The test has been updated in pandas main so that it will + # no longer fail, but the fix is not expected to be released until + # at least pandas version 3.0 (current version is 2.3) + data = data_missing_for_sorting + + with pytest.raises(NotImplementedError): + data.argmin(skipna=False) + + with pytest.raises(NotImplementedError): + data.argmax(skipna=False) + class TestParsing(base.BaseParsingTests): pass @@ -109,4 +151,15 @@ class TestReshaping(base.BaseReshapingTests): class TestSetitem(base.BaseSetitemTests): - pass + def test_setitem_invalid(self, data, invalid_scalar): + # This test was failing compliance checks because it attempted to match + # a pytest regex match using an empty string (""), which pytest version + # 8.4.0 stopped allowing. + # The test has been updated in pandas main so that it will + # no longer fail, but the fix is not expected to be released until + # at least pandas version 3.0 (current version is 2.3) + with pytest.raises((ValueError, TypeError)): + data[0] = invalid_scalar + + with pytest.raises((ValueError, TypeError)): + data[:] = invalid_scalar