-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REGR: diff_2d raising for int8, int16 #39069
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
REGR: diff_2d raising for int8, int16 #39069
Conversation
mzeitlin11
commented
Jan 9, 2021
- closes BUG: .diff() not working on int8 and int16 dtype #39050
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
pandas/core/algorithms.py
Outdated
@@ -1991,7 +1991,11 @@ def diff(arr, n: int, axis: int = 0, stacklevel=3): | |||
|
|||
elif is_integer_dtype(dtype): | |||
# We have to cast in order to be able to hold np.nan | |||
dtype = np.float64 | |||
# int8, int16 are incompatible with float64 |
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.
where exactly is the NotImplmementedError coming from. This should work as-is.
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.
Thought this change made sense because of this logic:
Lines 1270 to 1277 in 66a30bd
# Disable for unsupported dtype combinations, | |
# see https://github.com/cython/cython/issues/2646 | |
if (out_t is float32_t | |
and not (diff_t is float32_t or diff_t is int8_t or diff_t is int16_t)): | |
raise NotImplementedError | |
elif (out_t is float64_t | |
and (diff_t is float32_t or diff_t is int8_t or diff_t is int16_t)): | |
raise NotImplementedError |
Was raising in that second branch
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.
grr this is super annoying. ok can you add this reference where you are making the code change itself.
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.
e.g. here
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.
done
@@ -2409,3 +2409,10 @@ def test_diff_ea_axis(self): | |||
msg = "cannot diff DatetimeArray on axis=1" | |||
with pytest.raises(ValueError, match=msg): | |||
algos.diff(dta, 1, axis=1) | |||
|
|||
@pytest.mark.parametrize("dtype", ["int8", "int16"]) |
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.
can you also add a replica of the test from the OP in groupby tests. I don't think we actually have any :sigh:
pandas/tests/groupby//test_groupby.py near shift is fine (or actually ok with moving the shift & diff tests out to a new file).
pls add for all dtypes
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.
Added test from issue and for other dtypes
great will merge shortly. the precommit failure fixed elsewhere. |
thanks @mzeitlin11 |
@meeseeksdev backport 1.2.x |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon! If these instruction are inaccurate, feel free to suggest an improvement. |