Skip to content

Commit

Permalink
remove dtype in any and all methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jkanche committed May 24, 2024
1 parent 84bd2af commit e73c835
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
18 changes: 4 additions & 14 deletions src/delayedarray/DelayedArray.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ def var(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optiona
masked=is_masked(self),
)

def any(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optional[numpy.dtype] = numpy.bool_, buffer_size: int = 1e8) -> numpy.ndarray:
def any(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, buffer_size: int = 1e8) -> numpy.ndarray:
"""Test whether any array element along a given axis evaluates to True.
Compute this test across the ``DelayedArray``, possibly over a
Expand All @@ -920,11 +920,6 @@ def any(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optiona
for any. Alternatively, a tuple (multiple axes) or None (no
axes), see :py:func:`~numpy.any` for details.
dtype:
NumPy type for the output array. If None, this is automatically
chosen based on the type of the ``DelayedArray``, see
:py:func:`~numpy.any` for details.
buffer_size:
Buffer size in bytes to use for block processing. Larger values
generally improve speed at the cost of memory.
Expand All @@ -939,12 +934,12 @@ def any(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optiona
return array_any(
self,
axis=axis,
dtype=dtype,
dtype=numpy.bool_,
reduce_over_x=lambda x, axes, op : _reduce(x, axes, op, buffer_size),
masked=is_masked(self),
)

def all(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optional[numpy.dtype] = numpy.bool_, buffer_size: int = 1e8) -> numpy.ndarray:
def all(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, buffer_size: int = 1e8) -> numpy.ndarray:
"""Test whether all array elements along a given axis evaluate to True.
Compute this test across the ``DelayedArray``, possibly over a
Expand All @@ -957,11 +952,6 @@ def all(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optiona
for all. Alternatively, a tuple (multiple axes) or None (no
axes), see :py:func:`~numpy.all` for details.
dtype:
NumPy type for the output array. If None, this is automatically
chosen based on the type of the ``DelayedArray``, see
:py:func:`~numpy.all` for details.
buffer_size:
Buffer size in bytes to use for block processing. Larger values
generally improve speed at the cost of memory.
Expand All @@ -976,7 +966,7 @@ def all(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optiona
return array_all(
self,
axis=axis,
dtype=dtype,
dtype=numpy.bool_,
reduce_over_x=lambda x, axes, op : _reduce(x, axes, op, buffer_size),
masked=is_masked(self),
)
Expand Down
18 changes: 4 additions & 14 deletions src/delayedarray/SparseNdarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ def var(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optiona
masked=self._is_masked,
)

def any(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optional[numpy.dtype] = numpy.bool_) -> numpy.ndarray:
def any(self, axis: Optional[Union[int, Tuple[int, ...]]] = None) -> numpy.ndarray:
"""Test whether any array element along a given axis evaluates to True.
Compute this test across the ``SparseNdarray``, possibly over a
Expand All @@ -965,24 +965,19 @@ def any(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optiona
for any. Alternatively, a tuple (multiple axes) or None
(no axes), see :py:func:`~numpy.any` for details.
dtype:
NumPy type for the output array. If None, this is automatically
chosen based on the type of the ``SparseNdarray``, see
:py:func:`~numpy.any` for details.
Returns:
A NumPy array containing the variances. If ``axis = None``,
this will be a NumPy scalar instead.
"""
return array_any(
self,
axis=axis,
dtype=dtype,
dtype=numpy.bool_,
reduce_over_x=_reduce_SparseNdarray,
masked=self._is_masked,
)

def all(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optional[numpy.dtype] = numpy.bool_) -> numpy.ndarray:
def all(self, axis: Optional[Union[int, Tuple[int, ...]]] = None) -> numpy.ndarray:
"""Test whether all array elements along a given axis evaluate to True.
Compute this test across the ``SparseNdarray``, possibly over a
Expand All @@ -994,19 +989,14 @@ def all(self, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optiona
for any. Alternatively, a tuple (multiple axes) or None
(no axes), see :py:func:`~numpy.any` for details.
dtype:
NumPy type for the output array. If None, this is automatically
chosen based on the type of the ``SparseNdarray``, see
:py:func:`~numpy.any` for details.
Returns:
A NumPy array containing the variances. If ``axis = None``,
this will be a NumPy scalar instead.
"""
return array_all(
self,
axis=axis,
dtype=dtype,
dtype=numpy.bool_,
reduce_over_x=_reduce_SparseNdarray,
masked=self._is_masked,
)
Expand Down

0 comments on commit e73c835

Please sign in to comment.