-
Notifications
You must be signed in to change notification settings - Fork 4.3k
GH-51301: Fix deprecation warnings in the tests with numpy/pandas nightly #51404
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
base: main
Are you sure you want to change the base?
Changes from all commits
1ed3c25
b2d348a
180c881
43de55d
0baa242
84a8518
54feb6d
a148c13
4fa9481
1bac8c5
692fd5c
fc384ff
ed577f9
8e0342f
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 |
|---|---|---|
|
|
@@ -99,8 +99,8 @@ def _alltypes_example(size=100): | |
|
|
||
| def _check_pandas_roundtrip(df, expected=None, use_threads=False, | ||
| expected_schema=None, | ||
| check_dtype=True, schema=None, | ||
| preserve_index=False, | ||
| check_dtype=True, check_freq=False, | ||
| schema=None, preserve_index=False, | ||
| as_batch=False): | ||
| klass = pa.RecordBatch if as_batch else pa.Table | ||
| table = klass.from_pandas(df, schema=schema, | ||
|
|
@@ -125,7 +125,8 @@ def _check_pandas_roundtrip(df, expected=None, use_threads=False, | |
| "ignore", "elementwise comparison failed", DeprecationWarning) | ||
| tm.assert_frame_equal(result, expected, check_dtype=check_dtype, | ||
| check_index_type=('equiv' if preserve_index | ||
| else False)) | ||
| else False), | ||
| check_freq=check_freq) | ||
|
|
||
|
|
||
| def _check_series_roundtrip(s, type_=None, expected_pa_type=None): | ||
|
|
@@ -5002,15 +5003,15 @@ def test_threaded_pandas_import(): | |
|
|
||
|
|
||
| def test_does_not_mutate_timedelta_dtype(): | ||
| expected = np.dtype('m8') | ||
| expected = np.dtype('<m8[s]') | ||
|
|
||
| assert np.dtype(np.timedelta64) == expected | ||
| assert np.dtype(np.timedelta64(0, "s")) == expected | ||
|
|
||
| df = pd.DataFrame({"a": [np.timedelta64()]}) | ||
| df = pd.DataFrame({"a": [np.timedelta64(0, "s")]}) | ||
|
Member
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. While this makes the test run without the warning, I am not sure if then the surrounding asserts still make sense.
Member
Author
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. Ah, OK, sorry. Didn't try locally and assumed
Member
Author
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. From testing locally it seems the initial bug is not produced even if using a time unit everywhere. Will push a commit.
Member
Author
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.
Member
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. Fyi, @AlenkaF @jorisvandenbossche, running def test_does_not_mutate_timedelta_dtype():
- expected = np.dtype('<m8[s]')
+ expected = np.dtype('m8')
- assert np.dtype(np.timedelta64(0, "s")) == expected
+ assert np.dtype(np.timedelta64) == expected
df = pd.DataFrame({"a": [np.timedelta64(0, "s")]})
t = pa.Table.from_pandas(df)
t.to_pandas()
- assert np.dtype(np.timedelta64(0, "s")) == expected
+ assert np.dtype(np.timedelta64) == expectedat least second assert does (correctly) fail 🤷 |
||
| t = pa.Table.from_pandas(df) | ||
| t.to_pandas() | ||
|
|
||
| assert np.dtype(np.timedelta64) == expected | ||
| assert np.dtype(np.timedelta64(0, "s")) == expected | ||
|
|
||
|
|
||
| def test_does_not_mutate_timedelta_nested(): | ||
|
|
||
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.
Should this one be addressed?
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.
I was not sure this needs to be addressed, but you asking means it should be ;)
My thought process was:
check_freqwill be tested by default and as we do not keep freq information from pandas (AFAIU) we might default to keeping the current behavior which is not checking the frequency in any of our roundtrips. Have no problem to change this as suggested though.Uh oh!
There was an error while loading. Please reload this page.
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.
But so (AFAIK)
check_freqwas already enabled and verified in most cases, and only not in the case of eg a MultiIndex or columns Index. Thus, setting it to False here means that some cases where we were currently asserting equalfreq, will no longer be checked.To be fair, I don't know if that is much of a problem, though .. Since you noted, we typically don't do any effort to ensure there is a correct freq set.
But, I think it should also be quite easy to just update the failing test. Eg in
test_column_index_names_datetime, passcheck_freq=Falseif you pass kwargs in_check_pandas_roundtripto theassert_frame_equalcall.