Skip to content

Commit dbf5ad1

Browse files
Update pint_array.py
Make black happy. Signed-off-by: Michael Tiemann <[email protected]>
1 parent e1d367c commit dbf5ad1

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

pint_pandas/pint_array.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,9 @@ def isna(self):
381381
if len(self._data) == 0:
382382
# True or False doesn't matter--we just need the value for the type
383383
return np.full((0), True)
384-
return self._data.map(lambda x: pd.isna(x) or (isinstance(x, UFloat) and unp.isnan(x)))
384+
return self._data.map(
385+
lambda x: pd.isna(x) or (isinstance(x, UFloat) and unp.isnan(x))
386+
)
385387
return self._data.isna()
386388

387389
def astype(self, dtype, copy=True):
@@ -558,7 +560,12 @@ def quantify_nan(item, promote_to_ufloat):
558560
)
559561
else:
560562
promote_to_ufloat = False
561-
scalars = [item if isinstance(item, _Quantity) else quantify_nan(item, promote_to_ufloat) for item in scalars]
563+
scalars = [
564+
item
565+
if isinstance(item, _Quantity)
566+
else quantify_nan(item, promote_to_ufloat)
567+
for item in scalars
568+
]
562569
scalars = [
563570
(item.to(dtype.units).magnitude if hasattr(item, "to") else item)
564571
for item in scalars
@@ -645,7 +652,12 @@ def factorize(
645652

646653
codes = [-1] * len(self.data)
647654
# Note that item is a local variable provided in the loop below
648-
vf = np.vectorize(lambda x: True if (x_na:=pd.isna(x))*(item_na:=pd.isna(item)) else (x_na==item_na and x==item), otypes=[bool])
655+
vf = np.vectorize(
656+
lambda x: True
657+
if (x_na := pd.isna(x)) * (item_na := pd.isna(item))
658+
else (x_na == item_na and x == item),
659+
otypes=[bool],
660+
)
649661
for code, item in enumerate(arr):
650662
code_mask = vf(self._data)
651663
codes = np.where(code_mask, code, codes)

0 commit comments

Comments
 (0)