Skip to content

Commit

Permalink
Simplify hasattr at count_nonzero function from array module
Browse files Browse the repository at this point in the history
  • Loading branch information
neyberson committed Jun 6, 2024
1 parent c2ce01f commit cda1a2d
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions pozo/utils/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,7 @@ def isnan(data):
def count_nonzero(data):
if hasattr(data, "coords"): # xarray
return np.count_nonzero(data.values)
elif hasattr(data, "isnull"): # pandas
return np.count_nonzero(data.to_numpy())
elif hasattr(data, "is_null"): # polars
print(np.count_nonzero(data.to_numpy()))
elif hasattr(data, "to_numpy"): # series
return np.count_nonzero(data.to_numpy())
else:
check_numpy()
Expand Down

0 comments on commit cda1a2d

Please sign in to comment.