From 39ce2229a96406edac107fc897e807251d364e2b Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 19 Aug 2024 12:27:01 -0700 Subject: [PATCH 1/9] undo numpy 2 changes? --- pandas/tests/dtypes/test_inference.py | 3 +-- pandas/tests/indexing/test_coercion.py | 6 ----- pandas/tests/series/test_constructors.py | 28 +++++------------------- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/pandas/tests/dtypes/test_inference.py b/pandas/tests/dtypes/test_inference.py index b1d7c701e1267..fbdb8eacd2f9b 100644 --- a/pandas/tests/dtypes/test_inference.py +++ b/pandas/tests/dtypes/test_inference.py @@ -34,7 +34,6 @@ missing as libmissing, ops as libops, ) -from pandas.compat.numpy import np_version_gt2 from pandas.core.dtypes import inference from pandas.core.dtypes.cast import find_result_type @@ -1989,7 +1988,7 @@ def test_ensure_int32(): # find a smaller floating dtype (300.0, np.uint16), # for integer floats, we convert them to ints (300.1, np.float64), - (np.int16(300), np.int16 if np_version_gt2 else np.uint16), + (np.int16(300), np.uint16), ], ) def test_find_result_type_uint_int(right, result): diff --git a/pandas/tests/indexing/test_coercion.py b/pandas/tests/indexing/test_coercion.py index d5002a47c3447..e47775d0d1e4e 100644 --- a/pandas/tests/indexing/test_coercion.py +++ b/pandas/tests/indexing/test_coercion.py @@ -13,7 +13,6 @@ IS64, is_platform_windows, ) -from pandas.compat.numpy import np_version_gt2 import pandas as pd import pandas._testing as tm @@ -230,11 +229,6 @@ def test_insert_float_index( dtype = float_numpy_dtype obj = pd.Index([1.0, 2.0, 3.0, 4.0], dtype=dtype) coerced_dtype = coerced_dtype if coerced_dtype is not None else dtype - - if np_version_gt2 and dtype == "float32" and coerced_val == 1.1: - # Hack, in the 2nd test case, since 1.1 can be losslessly cast to float32 - # the expected dtype will be float32 if the original dtype was float32 - coerced_dtype = np.float32 exp = pd.Index([1.0, coerced_val, 2.0, 3.0, 4.0], dtype=coerced_dtype) self._assert_insert_conversion(obj, insert, exp, coerced_dtype) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index 57b14d4b82a63..8246eff0b02de 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -770,12 +770,8 @@ def test_constructor_cast(self): def test_constructor_signed_int_overflow_raises(self): # GH#41734 disallow silent overflow, enforced in 2.0 - if np_version_gt2: - msg = "The elements provided in the data cannot all be casted to the dtype" - err = OverflowError - else: - msg = "Values are too large to be losslessly converted" - err = ValueError + msg = "Values are too large to be losslessly converted" + err = ValueError with pytest.raises(err, match=msg): Series([1, 200, 923442], dtype="int8") @@ -803,13 +799,7 @@ def test_constructor_numpy_uints(self, values): def test_constructor_unsigned_dtype_overflow(self, any_unsigned_int_numpy_dtype): # see gh-15832 - if np_version_gt2: - msg = ( - f"The elements provided in the data cannot " - f"all be casted to the dtype {any_unsigned_int_numpy_dtype}" - ) - else: - msg = "Trying to coerce negative values to unsigned integers" + msg = "Trying to coerce negative values to unsigned integers" with pytest.raises(OverflowError, match=msg): Series([-1], dtype=any_unsigned_int_numpy_dtype) @@ -1939,15 +1929,9 @@ def test_constructor_int64_dtype(self, any_int_dtype): def test_constructor_raise_on_lossy_conversion_of_strings(self): # GH#44923 - if not np_version_gt2: - raises = pytest.raises( - ValueError, match="string values cannot be losslessly cast to int8" - ) - else: - raises = pytest.raises( - OverflowError, match="The elements provided in the data" - ) - with raises: + with pytest.raises( + ValueError, match="string values cannot be losslessly cast to int8" + ): Series(["128"], dtype="int8") def test_constructor_dtype_timedelta_alternative_construct(self): From 2a751daf29813bad8ca0e335c34b4a682863407a Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 19 Aug 2024 12:28:23 -0700 Subject: [PATCH 2/9] some interval 32 bit tests working --- pandas/tests/indexes/interval/test_interval_tree.py | 1 - pandas/tests/indexing/interval/test_interval.py | 2 -- pandas/tests/indexing/interval/test_interval_new.py | 3 --- 3 files changed, 6 deletions(-) diff --git a/pandas/tests/indexes/interval/test_interval_tree.py b/pandas/tests/indexes/interval/test_interval_tree.py index 49b17f8b3d40e..7e70d2b113a6e 100644 --- a/pandas/tests/indexes/interval/test_interval_tree.py +++ b/pandas/tests/indexes/interval/test_interval_tree.py @@ -186,7 +186,6 @@ def test_construction_overflow(self): expected = (50 + np.iinfo(np.int64).max) / 2 assert result == expected - @pytest.mark.xfail(not IS64, reason="GH 23440") @pytest.mark.parametrize( "left, right, expected", [ diff --git a/pandas/tests/indexing/interval/test_interval.py b/pandas/tests/indexing/interval/test_interval.py index b72ef57475305..2d55267b88b4a 100644 --- a/pandas/tests/indexing/interval/test_interval.py +++ b/pandas/tests/indexing/interval/test_interval.py @@ -2,7 +2,6 @@ import pytest from pandas._libs import index as libindex -from pandas.compat import IS64 import pandas as pd from pandas import ( @@ -210,7 +209,6 @@ def test_mi_intervalindex_slicing_with_scalar(self): expected = Series([1, 6, 2, 8, 7], index=expected_index, name="value") tm.assert_series_equal(result, expected) - @pytest.mark.xfail(not IS64, reason="GH 23440") @pytest.mark.parametrize("base", [101, 1010]) def test_reindex_behavior_with_interval_index(self, base): # GH 51826 diff --git a/pandas/tests/indexing/interval/test_interval_new.py b/pandas/tests/indexing/interval/test_interval_new.py index 4c1efe9e4f81d..2b670cb1be6fe 100644 --- a/pandas/tests/indexing/interval/test_interval_new.py +++ b/pandas/tests/indexing/interval/test_interval_new.py @@ -3,8 +3,6 @@ import numpy as np import pytest -from pandas.compat import IS64 - from pandas import ( Index, Interval, @@ -214,7 +212,6 @@ def test_loc_getitem_missing_key_error_message( obj.loc[[4, 5, 6]] -@pytest.mark.xfail(not IS64, reason="GH 23440") @pytest.mark.parametrize( "intervals", [ From 2414bfd7cff1e0f51356a3f19f0b9e5fd99e8b30 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 19 Aug 2024 12:58:40 -0700 Subject: [PATCH 3/9] Revert "undo numpy 2 changes?" This reverts commit 39ce2229a96406edac107fc897e807251d364e2b. --- pandas/tests/dtypes/test_inference.py | 3 ++- pandas/tests/indexing/test_coercion.py | 6 +++++ pandas/tests/series/test_constructors.py | 28 +++++++++++++++++++----- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/pandas/tests/dtypes/test_inference.py b/pandas/tests/dtypes/test_inference.py index fbdb8eacd2f9b..b1d7c701e1267 100644 --- a/pandas/tests/dtypes/test_inference.py +++ b/pandas/tests/dtypes/test_inference.py @@ -34,6 +34,7 @@ missing as libmissing, ops as libops, ) +from pandas.compat.numpy import np_version_gt2 from pandas.core.dtypes import inference from pandas.core.dtypes.cast import find_result_type @@ -1988,7 +1989,7 @@ def test_ensure_int32(): # find a smaller floating dtype (300.0, np.uint16), # for integer floats, we convert them to ints (300.1, np.float64), - (np.int16(300), np.uint16), + (np.int16(300), np.int16 if np_version_gt2 else np.uint16), ], ) def test_find_result_type_uint_int(right, result): diff --git a/pandas/tests/indexing/test_coercion.py b/pandas/tests/indexing/test_coercion.py index e47775d0d1e4e..d5002a47c3447 100644 --- a/pandas/tests/indexing/test_coercion.py +++ b/pandas/tests/indexing/test_coercion.py @@ -13,6 +13,7 @@ IS64, is_platform_windows, ) +from pandas.compat.numpy import np_version_gt2 import pandas as pd import pandas._testing as tm @@ -229,6 +230,11 @@ def test_insert_float_index( dtype = float_numpy_dtype obj = pd.Index([1.0, 2.0, 3.0, 4.0], dtype=dtype) coerced_dtype = coerced_dtype if coerced_dtype is not None else dtype + + if np_version_gt2 and dtype == "float32" and coerced_val == 1.1: + # Hack, in the 2nd test case, since 1.1 can be losslessly cast to float32 + # the expected dtype will be float32 if the original dtype was float32 + coerced_dtype = np.float32 exp = pd.Index([1.0, coerced_val, 2.0, 3.0, 4.0], dtype=coerced_dtype) self._assert_insert_conversion(obj, insert, exp, coerced_dtype) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index 8246eff0b02de..57b14d4b82a63 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -770,8 +770,12 @@ def test_constructor_cast(self): def test_constructor_signed_int_overflow_raises(self): # GH#41734 disallow silent overflow, enforced in 2.0 - msg = "Values are too large to be losslessly converted" - err = ValueError + if np_version_gt2: + msg = "The elements provided in the data cannot all be casted to the dtype" + err = OverflowError + else: + msg = "Values are too large to be losslessly converted" + err = ValueError with pytest.raises(err, match=msg): Series([1, 200, 923442], dtype="int8") @@ -799,7 +803,13 @@ def test_constructor_numpy_uints(self, values): def test_constructor_unsigned_dtype_overflow(self, any_unsigned_int_numpy_dtype): # see gh-15832 - msg = "Trying to coerce negative values to unsigned integers" + if np_version_gt2: + msg = ( + f"The elements provided in the data cannot " + f"all be casted to the dtype {any_unsigned_int_numpy_dtype}" + ) + else: + msg = "Trying to coerce negative values to unsigned integers" with pytest.raises(OverflowError, match=msg): Series([-1], dtype=any_unsigned_int_numpy_dtype) @@ -1929,9 +1939,15 @@ def test_constructor_int64_dtype(self, any_int_dtype): def test_constructor_raise_on_lossy_conversion_of_strings(self): # GH#44923 - with pytest.raises( - ValueError, match="string values cannot be losslessly cast to int8" - ): + if not np_version_gt2: + raises = pytest.raises( + ValueError, match="string values cannot be losslessly cast to int8" + ) + else: + raises = pytest.raises( + OverflowError, match="The elements provided in the data" + ) + with raises: Series(["128"], dtype="int8") def test_constructor_dtype_timedelta_alternative_construct(self): From bcac38c9192fb62fb484c1e8670b6f683b9a029c Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:14:48 -0700 Subject: [PATCH 4/9] nomkl? --- .github/actions/build_pandas/action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/actions/build_pandas/action.yml b/.github/actions/build_pandas/action.yml index 460ae2f8594c0..71da6c54753e5 100644 --- a/.github/actions/build_pandas/action.yml +++ b/.github/actions/build_pandas/action.yml @@ -22,6 +22,13 @@ runs: fi shell: bash -el {0} + - name: Uninstall nomlk + run: | + if conda list nomkl 1>/dev/null; then + conda remove nomkl -yes + fi + shell: bash -el {0} + - name: Build Pandas run: | if [[ ${{ inputs.editable }} == "true" ]]; then From c961d08ca034ba3e1226db98562ffd9fe3515240 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:14:57 -0700 Subject: [PATCH 5/9] nomkl? --- .github/actions/build_pandas/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build_pandas/action.yml b/.github/actions/build_pandas/action.yml index 71da6c54753e5..5ab1954b18c15 100644 --- a/.github/actions/build_pandas/action.yml +++ b/.github/actions/build_pandas/action.yml @@ -22,7 +22,7 @@ runs: fi shell: bash -el {0} - - name: Uninstall nomlk + - name: Uninstall nomkl run: | if conda list nomkl 1>/dev/null; then conda remove nomkl -yes From c0ac1741d9797bc00ceebd98329b11eb46fa7246 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:31:52 -0700 Subject: [PATCH 6/9] Update .github/actions/build_pandas/action.yml --- .github/actions/build_pandas/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build_pandas/action.yml b/.github/actions/build_pandas/action.yml index 5ab1954b18c15..d304d8822bf83 100644 --- a/.github/actions/build_pandas/action.yml +++ b/.github/actions/build_pandas/action.yml @@ -25,7 +25,7 @@ runs: - name: Uninstall nomkl run: | if conda list nomkl 1>/dev/null; then - conda remove nomkl -yes + conda remove nomkl -y fi shell: bash -el {0} From 21ebdbaf83b35618b1c0cef157f940ff9824d393 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:25:23 -0700 Subject: [PATCH 7/9] grep for nomkl --- .github/actions/build_pandas/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build_pandas/action.yml b/.github/actions/build_pandas/action.yml index d304d8822bf83..6eac6fcf84f51 100644 --- a/.github/actions/build_pandas/action.yml +++ b/.github/actions/build_pandas/action.yml @@ -24,7 +24,7 @@ runs: - name: Uninstall nomkl run: | - if conda list nomkl 1>/dev/null; then + if conda list nomkl | grep nomkl 1>/dev/null; then conda remove nomkl -y fi shell: bash -el {0} From 50e9f4ee48bd3fd332c68d9aaae14c57019429b7 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:40:22 -0700 Subject: [PATCH 8/9] xfail WASM --- pandas/tests/indexes/interval/test_interval_tree.py | 6 +++++- pandas/tests/indexing/interval/test_interval.py | 2 ++ pandas/tests/indexing/interval/test_interval_new.py | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pandas/tests/indexes/interval/test_interval_tree.py b/pandas/tests/indexes/interval/test_interval_tree.py index 7e70d2b113a6e..d8e39372f5ae9 100644 --- a/pandas/tests/indexes/interval/test_interval_tree.py +++ b/pandas/tests/indexes/interval/test_interval_tree.py @@ -4,7 +4,10 @@ import pytest from pandas._libs.interval import IntervalTree -from pandas.compat import IS64 +from pandas.compat import ( + IS64, + WASM, +) import pandas._testing as tm @@ -186,6 +189,7 @@ def test_construction_overflow(self): expected = (50 + np.iinfo(np.int64).max) / 2 assert result == expected + @pytest.mark.xfail(not WASM, reason="GH 23440") @pytest.mark.parametrize( "left, right, expected", [ diff --git a/pandas/tests/indexing/interval/test_interval.py b/pandas/tests/indexing/interval/test_interval.py index 2d55267b88b4a..6ea17489d692e 100644 --- a/pandas/tests/indexing/interval/test_interval.py +++ b/pandas/tests/indexing/interval/test_interval.py @@ -2,6 +2,7 @@ import pytest from pandas._libs import index as libindex +from pandas.compat import WASM import pandas as pd from pandas import ( @@ -209,6 +210,7 @@ def test_mi_intervalindex_slicing_with_scalar(self): expected = Series([1, 6, 2, 8, 7], index=expected_index, name="value") tm.assert_series_equal(result, expected) + @pytest.mark.xfail(not WASM, reason="GH 23440") @pytest.mark.parametrize("base", [101, 1010]) def test_reindex_behavior_with_interval_index(self, base): # GH 51826 diff --git a/pandas/tests/indexing/interval/test_interval_new.py b/pandas/tests/indexing/interval/test_interval_new.py index 2b670cb1be6fe..4d94bed5d0a16 100644 --- a/pandas/tests/indexing/interval/test_interval_new.py +++ b/pandas/tests/indexing/interval/test_interval_new.py @@ -3,6 +3,8 @@ import numpy as np import pytest +from pandas.compat import WASM + from pandas import ( Index, Interval, @@ -212,6 +214,7 @@ def test_loc_getitem_missing_key_error_message( obj.loc[[4, 5, 6]] +@pytest.mark.xfail(not WASM, reason="GH 23440") @pytest.mark.parametrize( "intervals", [ From df7e70a68db345980ccf8f2a02cd7bbd6eab35ec Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:40:36 -0700 Subject: [PATCH 9/9] Reverse condition --- pandas/tests/indexes/interval/test_interval_tree.py | 2 +- pandas/tests/indexing/interval/test_interval.py | 2 +- pandas/tests/indexing/interval/test_interval_new.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/tests/indexes/interval/test_interval_tree.py b/pandas/tests/indexes/interval/test_interval_tree.py index d8e39372f5ae9..df9c3b390f660 100644 --- a/pandas/tests/indexes/interval/test_interval_tree.py +++ b/pandas/tests/indexes/interval/test_interval_tree.py @@ -189,7 +189,7 @@ def test_construction_overflow(self): expected = (50 + np.iinfo(np.int64).max) / 2 assert result == expected - @pytest.mark.xfail(not WASM, reason="GH 23440") + @pytest.mark.xfail(WASM, reason="GH 23440") @pytest.mark.parametrize( "left, right, expected", [ diff --git a/pandas/tests/indexing/interval/test_interval.py b/pandas/tests/indexing/interval/test_interval.py index 6ea17489d692e..6bcebefa6c696 100644 --- a/pandas/tests/indexing/interval/test_interval.py +++ b/pandas/tests/indexing/interval/test_interval.py @@ -210,7 +210,7 @@ def test_mi_intervalindex_slicing_with_scalar(self): expected = Series([1, 6, 2, 8, 7], index=expected_index, name="value") tm.assert_series_equal(result, expected) - @pytest.mark.xfail(not WASM, reason="GH 23440") + @pytest.mark.xfail(WASM, reason="GH 23440") @pytest.mark.parametrize("base", [101, 1010]) def test_reindex_behavior_with_interval_index(self, base): # GH 51826 diff --git a/pandas/tests/indexing/interval/test_interval_new.py b/pandas/tests/indexing/interval/test_interval_new.py index 4d94bed5d0a16..051dc7b98f2aa 100644 --- a/pandas/tests/indexing/interval/test_interval_new.py +++ b/pandas/tests/indexing/interval/test_interval_new.py @@ -214,7 +214,7 @@ def test_loc_getitem_missing_key_error_message( obj.loc[[4, 5, 6]] -@pytest.mark.xfail(not WASM, reason="GH 23440") +@pytest.mark.xfail(WASM, reason="GH 23440") @pytest.mark.parametrize( "intervals", [