Skip to content

Commit

Permalink
Add np.abs and np.absolute to supported NumPy array functions in …
Browse files Browse the repository at this point in the history
…`Raster` (#393)

* Add np.abs and np.absolute to supported NumPy array functions

* Linting

* Add comments to describe the list structure of handled numpy functions

* Linting
  • Loading branch information
rhugonnet authored Aug 16, 2023
1 parent 3b633d0 commit 530d3c6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions geoutils/raster/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@

RasterType = TypeVar("RasterType", bound="Raster")

# List of numpy functions that are handled: nan statistics function, normal statistics function and sorting/counting
# List of NumPy "array" functions that are handled.
# Note: all universal function are supported: https://numpy.org/doc/stable/reference/ufuncs.html
# Array functions include: NaN math and stats, classic math and stats, logical, sorting/counting:
_HANDLED_FUNCTIONS_1NIN = (
# NaN math: https://numpy.org/doc/stable/reference/routines.math.html
# and NaN stats: https://numpy.org/doc/stable/reference/routines.statistics.html
[
"nansum",
"nanmax",
Expand All @@ -82,6 +86,7 @@
"nancumprod",
"nanquantile",
]
# Classic math and stats (same links as above)
+ [
"sum",
"amax",
Expand All @@ -99,10 +104,14 @@
"cumsum",
"cumprod",
"quantile",
"abs",
"absolute",
"gradient",
]
# Sorting, searching and counting: https://numpy.org/doc/stable/reference/routines.sort.html
+ ["sort", "count_nonzero", "unique"]
# Logic functions: https://numpy.org/doc/stable/reference/routines.logic.html
+ ["all", "any", "isfinite", "isinf", "isnan", "logical_not"]
+ ["gradient"]
)

_HANDLED_FUNCTIONS_2NIN = [
Expand Down

0 comments on commit 530d3c6

Please sign in to comment.