Skip to content

Commit d3f63c1

Browse files
committed
BUG: Fixed IntegerArray.__array_ufunc__ with nout
We forgot to return.
1 parent 8f6ec1e commit d3f63c1

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

doc/source/whatsnew/v1.2.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ ExtensionArray
367367

368368
- Fixed Bug where :class:`DataFrame` column set to scalar extension type via a dict instantion was considered an object type rather than the extension type (:issue:`35965`)
369369
- Fixed bug where ``astype()`` with equal dtype and ``copy=False`` would return a new object (:issue:`284881`)
370-
-
370+
- Fixed bug when applying a NumPy ufunc with multiple outputs to a :class:`pandas.arrays.IntegerArray` returning None (:issue:`36913`)
371371

372372

373373
Other

pandas/core/arrays/integer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def reconstruct(x):
427427

428428
result = getattr(ufunc, method)(*inputs2, **kwargs)
429429
if isinstance(result, tuple):
430-
tuple(reconstruct(x) for x in result)
430+
return tuple(reconstruct(x) for x in result)
431431
else:
432432
return reconstruct(result)
433433

pandas/tests/arrays/integer/test_function.py

+14
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ def test_ufuncs_binary_int(ufunc):
6464
tm.assert_extension_array_equal(result, expected)
6565

6666

67+
def test_ufunc_binary_output():
68+
a = integer_array([1, 2, np.nan])
69+
result = np.modf(a)
70+
expected = np.modf(a.to_numpy(na_value=np.nan, dtype="float"))
71+
72+
assert isinstance(result, tuple)
73+
assert len(result) == 2
74+
75+
for x, y in zip(result, expected):
76+
# TODO(FloatArray): This will return an extension array.
77+
# y = integer_array(y)
78+
tm.assert_numpy_array_equal(x, y)
79+
80+
6781
@pytest.mark.parametrize("values", [[0, 1], [0, None]])
6882
def test_ufunc_reduce_raises(values):
6983
a = integer_array(values)

0 commit comments

Comments
 (0)