-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REGR: ufunc with DataFrame input not passing all kwargs #40878
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 3 commits
138d9d2
3b492e4
625ce36
6bf0da0
7c9a63f
cfb0bcd
58f7399
4590926
d58677e
9c0b96c
e711789
a2da4fc
5c57727
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 |
---|---|---|
|
@@ -357,7 +357,7 @@ def reconstruct(result): | |
# * len(inputs) > 1 is doable when we know that we have | ||
# aligned blocks / dtypes. | ||
inputs = tuple(np.asarray(x) for x in inputs) | ||
result = getattr(ufunc, method)(*inputs) | ||
result = getattr(ufunc, method)(*inputs, **kwargs) | ||
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. the else clause is reached for a DataFrame when not The Is it straightforward to add to the paramterised here to exercise that path. 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. Yep, I think so...will let you know if I run into any issues 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. Added a test, but had to xfail because
gives
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. |
||
elif self.ndim == 1: | ||
# ufunc(series, ...) | ||
inputs = tuple(extract_array(x, extract_numpy=True) for x in inputs) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,22 @@ def test_binary_input_dispatch_binop(dtype): | |
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
def test_ufunc_passes_args(): | ||
phofl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# GH#40662 | ||
arr = np.array([[1, 2], [3, 4]]) | ||
df = pd.DataFrame(arr) | ||
result = np.zeros_like(df) | ||
np.add(df, 1, out=result) | ||
|
||
expected = arr + 1 | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
result = np.zeros_like(df) | ||
np.add(df, 1, out=result, where=[[False, True], [True, False]]) | ||
expected = np.array([[0, 3], [4, 0]]) | ||
tm.assert_numpy_array_equal(result, expected) | ||
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. can you also test the return type/values of the operation itself. 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. done |
||
|
||
|
||
@pytest.mark.parametrize("dtype_a", dtypes) | ||
@pytest.mark.parametrize("dtype_b", dtypes) | ||
def test_binary_input_aligns_columns(request, dtype_a, dtype_b): | ||
|
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.
and maybe replace 2-dimensional input with :class:
DataFrame
?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.
Yep will do