-
-
Notifications
You must be signed in to change notification settings - Fork 131
ENH: implement any and all functions #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great effort. I've left a few comments. Overall, this looks great, just needs some tweaks, namely in the tests and docs.
docs/generated/sparse.COO.rst needs the function names added in order to generate the docs.
You will need to generate the docs once in order to produce docs/generated/sparse.COO.all.rst and docs/generated/sparse.COO.any.rst and add those to git. See the section on adding docs in the CONTRIBUTING.
sparse/coo/core.py
Outdated
|
|
||
| def any(self, axis=None, keepdims=False, out=None): | ||
| """ | ||
| Minimize along the given axes. Uses all axes by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be amended.
sparse/coo/core.py
Outdated
| -------- | ||
| :obj:`numpy.min` : Equivalent numpy function. | ||
| scipy.sparse.coo_matrix.min : Equivalent Scipy function. | ||
| :obj:`nanmin` : Function with ``NaN`` skipping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The See also section needs amending.
sparse/coo/core.py
Outdated
| >>> x = np.add.outer(np.arange(5), np.arange(5)) | ||
| >>> x # doctest: +NORMALIZE_WHITESPACE | ||
| array([[0, 1, 2, 3, 4], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should ideally be a boolean array that's sometimes false and sometimes true.
sparse/coo/core.py
Outdated
| See Also | ||
| -------- | ||
| :obj:`numpy.all` : Equivalent numpy function. | ||
| scipy.sparse.coo_matrix.all : Equivalent Scipy function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't exist, I'd cite any and all from each other.
sparse/coo/core.py
Outdated
| >>> x = np.all.outer(np.arange(5), np.arange(5)) | ||
| >>> x # doctest: +NORMALIZE_WHITESPACE | ||
| array([[0, 1, 2, 3, 4], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
sparse/tests/test_coo.py
Outdated
| ('sum', {'dtype': np.float16}, {'atol': 1e-2}), | ||
| ('prod', {}, {}), | ||
| ('min', {}, {}), | ||
| ('all', {}, {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
anyandallmethods toCOO.