Skip to content

Commit 32626b1

Browse files
return bools from array_function (#264)
1 parent 974cb2f commit 32626b1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pint_pandas/pint_array.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
350350
return self._convert_np_result(result)
351351

352352
def _convert_np_result(self, result):
353+
if isinstance(result, bool):
354+
return result
353355
if isinstance(result, _Quantity) and is_list_like(result.m):
354356
if hasattr(result, "ndim") and result.ndim >= 2:
355357
raise ValueError("PintArrays may only be 1D, check axis arguement")

pint_pandas/testsuite/test_issues.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def test_issue246(self):
313313
df.apply(lambda x: x * 2, axis=1)
314314

315315

316-
class TestIssue255(BaseExtensionTests):
316+
class TestArrayFunction(BaseExtensionTests):
317317
def test_issue255(self):
318318
a = np.r_[1, 2, np.nan, 4, 10]
319319
pa = PintArray.from_1darray_quantity(a * ureg.m)
@@ -324,3 +324,11 @@ def test_issue255(self):
324324
expected = PintArray.from_1darray_quantity(e * ureg.m)
325325

326326
tm.assert_equal(result, expected)
327+
328+
def test_issue108(self):
329+
pa1 = pa2 = PintArray([1, 45, -4.5], "m")
330+
331+
result = np.allclose(pa1, pa2)
332+
expected = True
333+
334+
assert result == expected

0 commit comments

Comments
 (0)