Skip to content

Commit

Permalink
ee_array.py: User _ReducerType for Array's reduce methods.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 660623629
  • Loading branch information
schwehr authored and Google Earth Engine Authors committed Aug 8, 2024
1 parent a5ef8d3 commit 8c8fd47
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/ee/ee_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ee import ee_number
# pylint: disable-next=unused-import
from ee import ee_string
from ee import reducer as ee_reducer

_ArrayType = Union[
Any, List[Any], 'Array', 'ee_list.List', computedobject.ComputedObject
Expand All @@ -22,6 +23,7 @@
]
_NumberType = Union[float, 'ee_number.Number', computedobject.ComputedObject]
_StringType = Union[str, 'ee_string.String', computedobject.ComputedObject]
_ReducerType = Union[ee_reducer.Reducer, computedobject.ComputedObject]


class Array(computedobject.ComputedObject):
Expand Down Expand Up @@ -102,9 +104,8 @@ def abs(self) -> Array:

return apifunction.ApiFunction.call_(self.name() + '.abs', self)

# TODO: Use _ReducerType for reducer.
def accum(
self, axis: _IntegerType, reducer: Optional[_EeAnyType] = None
self, axis: _IntegerType, reducer: Optional[_ReducerType] = None
) -> Array:
"""Accumulates elements of an array along the given axis.
Expand Down Expand Up @@ -903,7 +904,7 @@ def project(self, axes: _EeAnyType) -> Array:

def reduce(
self,
reducer: _EeAnyType,
reducer: _ReducerType,
axes: _EeAnyType,
# pylint: disable-next=invalid-name
fieldAxis: Optional[_IntegerType] = None,
Expand Down

0 comments on commit 8c8fd47

Please sign in to comment.