Add eye, zeros, zeros_like, ones, ones_like #183
Conversation
Looks like docstrings need to be spaced slightly differently. Maybe a difference in Numpy version? |
Grumble. Since
Seems to be only an issue with float arrays, just skipped those tests. |
The normal approach is to only run doctests for the latest version of numpy. With all the print changes around numpy 1.14, that's the only reasonable thing to do in CI. |
That's what we do in dask/dask. This is probably Hameer's call though.
…On Mon, Sep 17, 2018 at 5:06 PM Ralf Gommers ***@***.***> wrote:
The normal approach is to only run doctests for the latest version of
numpy. With all the print changes around numpy 1.14, that's the only
reasonable thing to do in CI.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#183 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AASszOcw813s1wbIb1umDB9WPxWt4E_6ks5ucA66gaJpZM4WsrO6>
.
|
This looks generally complete and in excellent shape. I’ve made a few comments that should increase performance generally. Also it might be nice to have If you want more visibility for your work (wink wink) a line in the change log would be nice. |
coords = np.stack([n_coords, m_coords]) | ||
data = np.ones(data_length, dtype=dtype) | ||
|
||
return COO(coords, data=data, shape=(N, M), has_duplicates=False) |
hameerabbasi
Sep 17, 2018
Collaborator
Might be nice to add sorted=True
.
Might be nice to add sorted=True
.
shape = (shape,) | ||
data = np.empty(0, dtype=dtype) | ||
coords = np.empty((len(shape), 0), dtype=np.intp) | ||
return COO(coords, data=data, shape=shape, has_duplicates=False) |
hameerabbasi
Sep 17, 2018
Collaborator
sorted=True
sorted=True
>>> zeros_like(x).todense() # doctest: +NORMALIZE_WHITESPACE | ||
array([[0, 0, 0], | ||
[0, 0, 0]]) | ||
""" |
hameerabbasi
Sep 17, 2018
Collaborator
sorted=True
.
sorted=True
.
n_coords = m_coords = np.arange(data_length, dtype=np.intp) | ||
|
||
coords = np.stack([n_coords, m_coords]) | ||
data = np.ones(data_length, dtype=dtype) |
hameerabbasi
Sep 17, 2018
Collaborator
Data as a scalar should work here. Takes less memory due to scalar broadcasting being a view.
Data as a scalar should work here. Takes less memory due to scalar broadcasting being a view.
Re the printing changes, yes, since we are highly likely to need changes in upcoming NumPy versions, it’s nice to have them with the newer versions. This has been a pain point in a PR or two, but I think being on old NumPy docstrings would be worse. |
Thanks for the review, I believe all comments have been addressed. |
Thabks for making these changes! They’re very welcome. Merging now. |
Add implementations of
eye
,zeros
, andzeros_like
, mirroring the equivalent numpy api.