Skip to content
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

[ArrayManager] TST: arithmetic test #39753

Merged

Conversation

jorisvandenbossche
Copy link
Member

xref #39146

@jorisvandenbossche jorisvandenbossche added Testing pandas testing functions or related to the test suite Numeric Operations Arithmetic, Comparison, and Logical operations Internals Related to non-user accessible pandas implementation labels Feb 11, 2021
# https://github.com/pandas-dev/pandas/issues/39750
# third column with all-NaT as result doesn't get preserved
# as timedelta64 dtype
expected[2] = Series([pd.NaT, pd.NaT], dtype=object)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is sub-optimal. can you add a TODO to try to retain the correct dtype

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand your comment. Of course it's sub-optimal, as it's a bug (but an existing one, and I opened an issue about it)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but an existing one

now im confused; we only get here if using_array_manager

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. if the expected isnt actually what we want, better to xfail

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now im confused; we only get here if using_array_manager

Yes, I "uncovered" the bug by adding array manager tests, but the bug itself is not related to ArrayManager, it's a bug in TimedeltaArray (and you can run into it without ArrayManager as well, just not covered by any test)

But indeed, an xfail might be more appropriate since I am now asserting the buggy behaviour. The problem is that I would then no longer test the other parts of this test (the other columns) which is actually working fine.
So I would prefer to keep it this way (but will update the comment to make it more clear this is buggy)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok can you open an issue to address this in BM. (and ideally an INFO / TODO) for future reference. I am getting increasinly worried that things are changed, but we have no idea where except for PR comments, which are not very useful forward looking.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, and already included in the comment as well, I already opened an issue (it's #39750)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and you can run into it without ArrayManager as well, just not covered by any test

OK. Can you add a non-ArrayManager test that will hit it?

Copy link
Member Author

@jorisvandenbossche jorisvandenbossche Feb 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added additional examples that don't involve ArrayManager to the issue (#39750)

@jbrockmendel
Copy link
Member

one request #39753 (comment), otherwise LGTM

pandas/tests/arithmetic/test_datetime64.py Show resolved Hide resolved
pandas/tests/arithmetic/test_numeric.py Outdated Show resolved Hide resolved
# https://github.com/pandas-dev/pandas/issues/39750
# third column with all-NaT as result doesn't get preserved
# as timedelta64 dtype
expected[2] = Series([pd.NaT, pd.NaT], dtype=object)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok can you open an issue to address this in BM. (and ideally an INFO / TODO) for future reference. I am getting increasinly worried that things are changed, but we have no idea where except for PR comments, which are not very useful forward looking.

@@ -1761,6 +1763,8 @@ def test_td64arr_floordiv_td64arr_with_nat(self, box_with_array):

expected = np.array([1.0, 1.0, np.nan], dtype=np.float64)
expected = tm.box_expected(expected, xbox)
if box is DataFrame and using_array_manager:
expected[[0, 1]] = expected[[0, 1]].astype("int64")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is expected different and is one behavior more desirable than the other?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ArrayManager performs the op column-wise, and thus can preserve dtypes (floordiv gives ints). Will add a comment about it in the line of https://github.com/pandas-dev/pandas/pull/39753/files#r576350947

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@jorisvandenbossche jorisvandenbossche merged commit 94e2982 into pandas-dev:master Feb 17, 2021
@jorisvandenbossche jorisvandenbossche deleted the am-test-arithmetic branch February 17, 2021 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internals Related to non-user accessible pandas implementation Numeric Operations Arithmetic, Comparison, and Logical operations Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants