ENH: implement any and all functions #175
Conversation
Great effort. I've left a few comments. Overall, this looks great, just needs some tweaks, namely in the tests and docs.
You will need to generate the docs once in order to produce |
@@ -811,6 +811,127 @@ def max(self, axis=None, keepdims=False, out=None): | |||
""" | |||
return np.maximum.reduce(self, out=out, axis=axis, keepdims=keepdims) | |||
|
|||
def any(self, axis=None, keepdims=False, out=None): | |||
""" | |||
Minimize along the given axes. Uses all axes by default. |
hameerabbasi
Jul 26, 2018
Collaborator
Needs to be amended.
Needs to be amended.
-------- | ||
:obj:`numpy.min` : Equivalent numpy function. | ||
scipy.sparse.coo_matrix.min : Equivalent Scipy function. | ||
:obj:`nanmin` : Function with ``NaN`` skipping. |
hameerabbasi
Jul 26, 2018
Collaborator
The See also section needs amending.
The See also section needs amending.
>>> x = np.add.outer(np.arange(5), np.arange(5)) | ||
>>> x # doctest: +NORMALIZE_WHITESPACE | ||
array([[0, 1, 2, 3, 4], |
hameerabbasi
Jul 26, 2018
Collaborator
Should ideally be a boolean array that's sometimes false and sometimes true.
Should ideally be a boolean array that's sometimes false and sometimes true.
See Also | ||
-------- | ||
:obj:`numpy.all` : Equivalent numpy function. | ||
scipy.sparse.coo_matrix.all : Equivalent Scipy function. |
hameerabbasi
Jul 26, 2018
Collaborator
This doesn't exist, I'd cite any
and all
from each other.
This doesn't exist, I'd cite any
and all
from each other.
>>> x = np.all.outer(np.arange(5), np.arange(5)) | ||
>>> x # doctest: +NORMALIZE_WHITESPACE | ||
array([[0, 1, 2, 3, 4], |
hameerabbasi
Jul 26, 2018
Collaborator
Same here. Ideally use this array for both to show the output, it's like a truth table:
x = np.array([
[False, False],
[False, True],
[True, False],
[False, False]
])
(It could be formatted better)
Same here. Ideally use this array for both to show the output, it's like a truth table:
x = np.array([
[False, False],
[False, True],
[True, False],
[False, False]
])
(It could be formatted better)
@@ -16,6 +16,8 @@ | |||
('sum', {'dtype': np.float16}, {'atol': 1e-2}), | |||
('prod', {}, {}), | |||
('min', {}, {}), | |||
('all', {}, {}), |
hameerabbasi
Jul 26, 2018
Collaborator
We'll need separate tests, input should be np.bool_
arrays. Take a look at how we've produced random arrays for binary ops and use that.
We'll need separate tests, input should be np.bool_
arrays. Take a look at how we've produced random arrays for binary ops and use that.
Oh. Apparently you're using an old NumPy version... The docstrings need to be produced with newer versions to pass the tests, unfortunately. (1.14.0 or newer I think). |
@stsievert Are you still interested in working on this? If not, is it okay if I pushed to your branch? You'd still be listed as the author of the commit. |
That's fine by me. |
Codecov Report
@@ Coverage Diff @@
## master #175 +/- ##
==========================================
+ Coverage 97.14% 97.22% +0.07%
==========================================
Files 11 11
Lines 1259 1295 +36
==========================================
+ Hits 1223 1259 +36
Misses 36 36
Continue to review full report at Codecov.
|
It seems like NumPy 1.15 changed the docstrings for bool arrays, omitting the dtype. For the tests to pass both locally and in Travis, I needed to skip these doctests. |
This PR closes #173 and adds
any
andall
methods toCOO
.