-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CI: fix with new numpy nightly #50129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from pandas.compat import is_numpy_dev | ||
|
||
import pandas as pd | ||
import pandas._testing as tm | ||
|
||
|
@@ -257,8 +259,13 @@ def test_compare_ea_and_np_dtype(val1, val2): | |
("b", "other"): np.nan, | ||
} | ||
) | ||
result = df1.compare(df2, keep_shape=True) | ||
tm.assert_frame_equal(result, expected) | ||
if val1 is pd.NA and is_numpy_dev: | ||
# can't compare with numpy array if it contains pd.NA | ||
with pytest.raises(TypeError, match="boolean value of NA is ambiguous"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm why wouldn't we allow this? The returned array should just be object dtype with pd.NA no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comparing with an Brock had commented here about this here, saying it'd be his inclination to say that raising is expected #50129 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could putting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this test, the column is being designed to be of dtype arr = [4.0, val1] # val1 is pd.NA from the fixture
df1 = pd.DataFrame({"a": arr, "b": [1.0, 2]}) So I think Arguably it's the test that's doing something unsupported and should be rewritten so that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our extension arrays are 1D, as soon as you have to operate on more than one column, we coerce to object dtype. Not saying this is the case here, but this is inevitable in some places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding to this: the DataFrame in the test has dtype object, eg no masked array There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, though fortunately the error's not come up in other places (yet! 😨 ). For EAs, if an error comes up as a result of this, then perhaps it's up to pandas to find a workaround But for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was mostly responding to the design flaw bit. I totally agree that users shouldn’t do this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is a problem when processing masked arrays in Dataframe methods/functions. Maybe there could be made an internal dataframe-wide na mask method, so the we can deal with NA's properly on a dataframe level, for example in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, it's inherently usupported, as |
||
result = df1.compare(df2, keep_shape=True) | ||
else: | ||
result = df1.compare(df2, keep_shape=True) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,13 @@ def test_get_indexer_non_unique_np_nats(self, np_nat_fixture, np_nat_fixture2): | |
tm.assert_numpy_array_equal(missing, expected_missing) | ||
# dt64nat vs td64nat | ||
else: | ||
try: | ||
np_nat_fixture == np_nat_fixture2 | ||
except (TypeError, OverflowError): | ||
# Numpy will raise on uncomparable types, like | ||
# np.datetime64('NaT', 'Y') and np.datetime64('NaT', 'ps') | ||
# https://github.com/numpy/numpy/issues/22762 | ||
return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this failure only on numpy dev, i.e. numpy > 1.23.x? Could this be better by having a if p_version_lte1p23:
return
np_nat_fixture == np_nat_fixture2
... ? That would make this easier to find and remove when we drop support for numpy 1.23 at some point in the future). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. true, though comparisions between maybe that can be split out - I'll do that, thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe in a followup, so we can get the CI to work again? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure! noted to self |
||
index = Index( | ||
np.array( | ||
[ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import pytest | ||
|
||
from pandas._libs.missing import is_matching_na | ||
from pandas.compat import is_numpy_dev | ||
|
||
from pandas.core.dtypes.common import is_float | ||
|
||
|
@@ -50,7 +51,7 @@ def test_equals_list_array(val): | |
|
||
cm = ( | ||
tm.assert_produces_warning(FutureWarning, check_stacklevel=False) | ||
if isinstance(val, str) | ||
if isinstance(val, str) and not is_numpy_dev | ||
Comment on lines
-53
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
else nullcontext() | ||
) | ||
with cm: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before we had:
With the new nightly: