[Numpy-discussion] Vectorized version of numpy.linspace

Sebastian Berg sebastian at sipsolutions.net
Thu Nov 15 03:44:22 EST 2018


On Wed, 2018-11-14 at 14:46 -0800, Stephan Hoyer wrote:
> 
> 
> On Wed, Nov 14, 2018 at 2:35 PM Sebastian Berg <
> sebastian at sipsolutions.net> wrote:
> > On Wed, 2018-11-14 at 14:32 -0500, Marten van Kerkwijk wrote:
<snip>
> > some old issue or even PR somewhere.
> > I am mildly in favor, just because there is probably not much
> > reason
> > against an easy vectorization. Doesn't need to be advertised much
> > in
> > the docs anyway.
> > Although it might be good to settle the "obvious" part in case I am
> > not
> > alone in first thinking of -1 being the obvious default. I would
> > probably skip the axis argument for now, unless someone actually
> > has a
> > use case.
> 
> Indeed -- I think the best argument for adding an "axis" argument is
> that it allows people to be explicit about where the axis ends up,
> e.g., both np.linspace(start, stop, num=5, axis=0) and
> np.linspace(start, stop, num=5, axis=-1) make their intent quite
> clear.
> 
> To me, axis=0 feels like the right default, matching np.concatenate
> and np.stack. But NumPy already has split conventions for this sort
> of thing (e.g., gufuncs add axes at the end), so I like the explicit
> option.

I think that argument goes both ways. Because linspace with an array
input can be seen as stacking the linear ramps and not stacking some
interpolated intermediate values from start/stop. (Sure, it is more
then one dimension, but I would seriously argue the linear ramps are
the basic building block and not the input start/stop arrays.)

- Sebastian


> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20181115/21e19ca9/attachment.sig>


More information about the NumPy-Discussion mailing list