[Numpy-discussion] Vectorized version of numpy.linspace

Stephan Hoyer shoyer at gmail.com
Wed Nov 14 11:57:21 EST 2018


It recently came up on GitHub (at part of the discussion in
https://github.com/numpy/numpy/issues/12379) that numpy.linspace could, at
least in principle, be modified to support array inputs:

It looks like this has been requested on StackOverflow, too:
https://stackoverflow.com/questions/46694167/vectorized-numpy-linspace-across-multi-dimensional-arrays

My tentative proposal:
- "start" and "stop" are broadcast against each other to form start/stop
arrays. (Or we could require that start/stop have matching shape.)
- A new dimension of size "num" is inserted into the result, either along
the first or last axis.
- A new keyword argument "axis" could control where the axis is inserted in
the result.
- Vectorization support should be added in the same way to geomspace and
logspace.

Does this seem like a good idea? It's a relatively simple generalization,
and one that I, at least, would find useful (I can think of a use-case in
my own code that came up just last week).

I doubt I'll have time to implement this myself in the near future, but I
thought I would get the discussion going -- this might be a good project
for a new contributor to work on.

Cheers,
Stephan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20181114/d69f2cd5/attachment.html>


More information about the NumPy-Discussion mailing list