This usage of ndindex
:
>>> list(np.ndindex((3,2)))
[(0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1)]
seems to work with
>>> np.__version__
'1.18.4'
but it's not documented. Is this usage intended to be allowed? (I'd like it to be, because if shape == 5
then np.index(shape)
works while np.ndindex(*shape)
does not.) If it is, could it be added to the docs?
We may want to make that version the preferred documented one, and just briefly mention the other option as well. In most cases (e.g. also arr.reshape()
where we allow both, we prefer the tuple-version in the docs).
Just to clarify this a bit - I think there are two things that make the np.ndindex
docstring confusing:
np.ndindex
docstring is inconsistent with the Parameters listingAdditionally, the type listing in the Parameters section is incorrect: both tuples and list of ints are allowed.
This has been fixed.
The signature of the np.ndindex docstring is inconsistent with the Parameters listing
I will be raising a PR for this :)
Most helpful comment
This has been fixed.
I will be raising a PR for this :)