I put in an issue a while ago, https://github.com/numpy/numpy/issues/8839
My use case was somwhat similar to meshgrid but with a nonrectangular domain. Not terribly hard to code, but my expectation is that numpy functions should always allow broadcasting if that operation makes sense. On Nov 14, 2018 12:42 PM, "Gerrit Holl" <gerrit.h...@gmail.com> wrote: On Wed, 14 Nov 2018 at 17:29, Ralf Gommers <ralf.gomm...@gmail.com> wrote: > On Wed, Nov 14, 2018 at 8:57 AM Stephan Hoyer <sho...@gmail.com> wrote: >> >> 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). > > > This feels a bit forced. There's not much relevance to the minor performance gain, and for code clarity it probably also wouldn't help (actually it hurts usability for 99.x% of use cases by making the doc more complicated). Not sure that it really would require a new axis argument, as Marten said on the issue. Also, the num keyword cannot be vectorized, unless one returns a list of arrays, which would actually be more natural here than a 2-D array. > > So, at best a don't care for me - I'm -0.5. For what it's worth, I had a use case for this in the past week, when I needed many simple linear interpolations between two values (thus a linspace) with only the value of boundary points varying. However, this was the first time I've ever needed it, and I found a recipe on Stack Overflow within minutes (https://stackoverflow.com/a/42617889/974555) so it wasn't a big deal that it wasn't available in core numpy. Gerrit. _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion