Re: [Numpy-discussion] ENH: Proposal to add atleast_nd function

2021-02-11 Thread Juan Nunez-Iglesias
both napari and scikit-image use atleast_ a few times. I don’t have many examples of where I used nd because it didn’t exist. But I have the very distinct impression of needing it repeatedly. In some places, I’ve used `np.broadcast_to` to signal the same intention, where `atleast_nd` would have

Re: [Numpy-discussion] ENH: Proposal to add atleast_nd function

2021-02-11 Thread Eric Wieser
I did a quick search of matplotlib, and found a few uses of all three functions: * https://github.com/matplotlib/matplotlib/blob/fed55c63a314351cd39a12783f385009782c06e1/lib/matplotlib/_layoutgrid.py#L441-L446 This one isn't really numpy at all, and is really just a shorthand for normalizing an

Re: [Numpy-discussion] ENH: Proposal to add atleast_nd function

2021-02-11 Thread Benjamin Root
My original usecase for these was dealing with output data from Matlab where those users would use `squeeze()` quite liberally. In addition, there was the problem of the implicit squeeze() in the numpy's loadtxt() for which I added the ndmin kwarg for in case an input CSV file had just one row or n

Re: [Numpy-discussion] ENH: Proposal to add atleast_nd function

2021-02-11 Thread Stephan Hoyer
On Thu, Feb 11, 2021 at 9:42 AM Benjamin Root wrote: > for me, I find that the at_least{1,2,3}d functions are useful for > sanitizing inputs. Having an at_leastnd() function can be viewed as a step > towards cleaning up the API, not cluttering it (although, deprecations of > the existing function

Re: [Numpy-discussion] ENH: Proposal to add atleast_nd function

2021-02-11 Thread Eric Wieser
> I find that the at_least{1,2,3}d functions are useful for sanitizing inputs IMO, this type of "sanitization" goes against "In the face of ambiguity, refuse the temptation to guess". Instead of using `at_least{n}d`, it could be argued that `if np.ndim(x) != n: raise ValueError` is a safer bet, wh

Re: [Numpy-discussion] ENH: Proposal to add atleast_nd function

2021-02-11 Thread Joseph Fox-Rabinovitz
The original functions appear to have been written for things like *stack originally, which actually goes a long way to explaining the inconsistent argument list. - Joe On Thu, Feb 11, 2021, 12:41 Benjamin Root wrote: > for me, I find that the at_least{1,2,3}d functions are useful for > saniti

Re: [Numpy-discussion] ENH: Proposal to add atleast_nd function

2021-02-11 Thread Benjamin Root
for me, I find that the at_least{1,2,3}d functions are useful for sanitizing inputs. Having an at_leastnd() function can be viewed as a step towards cleaning up the API, not cluttering it (although, deprecations of the existing functions probably should be long given how long they have existed). O