From e73c83502f9e74252cd1df66e73ed5b67ad62d00 Mon Sep 17 00:00:00 2001 From: Jayaram Kancherla Date: Fri, 24 May 2024 11:46:14 -0700 Subject: [PATCH] remove dtype in any and all methods --- src/delayedarray/DelayedArray.py | 18 ++++-------------- src/delayedarray/SparseNdarray.py | 18 ++++-------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/delayedarray/DelayedArray.py b/src/delayedarray/DelayedArray.py index 9a90d60..8180598 100644 --- a/src/delayedarray/DelayedArray.py +++ b/src/delayedarray/DelayedArray.py @@ -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 @@ -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. @@ -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 @@ -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. @@ -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), ) diff --git a/src/delayedarray/SparseNdarray.py b/src/delayedarray/SparseNdarray.py index eca08eb..ee46c11 100644 --- a/src/delayedarray/SparseNdarray.py +++ b/src/delayedarray/SparseNdarray.py @@ -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 @@ -965,11 +965,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 ``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. @@ -977,12 +972,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=_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 @@ -994,11 +989,6 @@ 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. @@ -1006,7 +996,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=_reduce_SparseNdarray, masked=self._is_masked, )