Skip to content

Commit

Permalink
Change __abs__ to return a PintArray
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgsavage authored Jun 16, 2024
1 parent 273780d commit d23b439
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
2 changes: 1 addition & 1 deletion pint_pandas/pint_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def __neg__(self):
return -1 * self

def __abs__(self):
return self._Q(np.abs(self._data), self._dtype.units)
return type(self)(self._Q(np.abs(self._data), self._dtype.units))

@property
def dtype(self):
Expand Down
5 changes: 0 additions & 5 deletions pint_pandas/testsuite/test_pandas_extensiontests.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,6 @@ def test_unstack(self, data, index, obj):
def test_invert(self, data):
base.BaseUnaryOpsTests.test_invert(self, data)

@pytest.mark.xfail(run=True, reason="np.positive requires pint 0.21")
@pytest.mark.parametrize("ufunc", [np.positive, np.negative, np.abs])
def test_unary_ufunc_dunder_equivalence(self, data, ufunc):
base.BaseUnaryOpsTests.test_unary_ufunc_dunder_equivalence(self, data, ufunc)

# Accumulate
def _supports_accumulation(self, ser: pd.Series, op_name: str) -> bool:
return True
Expand Down

0 comments on commit d23b439

Please sign in to comment.