Skip to content
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

Document numpy.lib.stride_tricks.as_strided #6565

Closed
anntzer opened this issue Oct 26, 2015 · 9 comments
Closed

Document numpy.lib.stride_tricks.as_strided #6565

anntzer opened this issue Oct 26, 2015 · 9 comments

Comments

@anntzer
Copy link
Contributor

anntzer commented Oct 26, 2015

As far as I can tell as_strided (which can be rather useful, even though it is involved) is documented nowhere -- it doesn't even appear in the general index, probably because it isn't listed in stride_tricks.__all__.

@rkern
Copy link
Member

rkern commented Oct 26, 2015

Intentionally! It's dangerous! It was just low-level plumbing to help implement broadcast_arrays().

@anntzer
Copy link
Contributor Author

anntzer commented Oct 26, 2015

Fair enough. FWIW, it is mentioned as a "See also" in the docs of ndarray.strides though.

@argriffing
Copy link
Contributor

In https://github.com/numpy/numpy/blob/master/numpy/lib/stride_tricks.py the two functions in __all__ (broadcast_to and 'broadcast_arrays) are not underscored, but the helper functions have the underscore prefix. Except as_strided. Should it be changed to have an underscore prefix? Or is its absence from __all__ enough to mark it as not part of the public interface?

@insertinterestingnamehere
Copy link
Contributor

It'd be great if we could not move or deprecate that. There's plenty of code that relies on it out there (e.g. the various rolling window idioms floating around, among other things). IMHO it makes more sense to add it to the docs and say explicitly that it's dangerous and ought not to be used when another option is available.

@shoyer
Copy link
Member

shoyer commented Oct 26, 2015

I agree with @insertinterestingnamehere that it would be better to add it to the docs with lots of warnings and disclaimers. For what it's worth, it's definitely part of the implicit public API at this point -- there is plenty of code that relies on it. Note that as of NumPy 1.10 we don't even rely on as_strided for implementing broadcast_array.

@rgommers
Copy link
Member

I agree as well - add to the docs with a clear "this is dangerous" at the top of the docstring.

Or is its absence from __all__ enough to mark it as not part of the public interface?

Maybe that was the idea, but it doesn't work so well in practice. Same for stuff that's not in the docs.

@mrkwjc
Copy link

mrkwjc commented Apr 22, 2016

I'd like also vote for leaving and documenting as_strided. This is very useful function.

@mattip
Copy link
Member

mattip commented Apr 26, 2019

Documented

@mattip mattip closed this as completed Apr 26, 2019
@endolith
Copy link
Contributor

endolith commented Aug 3, 2019

There's plenty of code that relies on it out there (e.g. the various rolling window idioms floating around, among other things).

(I was going to ask about making official functions for this and then found #7753, so linking that from here for anyone else who is looking.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants