Re: [Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Eric Wieser
I too buy into axis=0 being the better default here for broadcasting reasons. Having it possible to specify explicitly would be handy though, for something like: x_ramped = np.linspace(x.min(axis=2), x.max(axis=2), 100, axis=2) ​ On Wed, 14 Nov 2018 at 15:20 Stephan Hoyer wrote: > On Wed, Nov

Re: [Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Stephan Hoyer
On Wed, Nov 14, 2018 at 3:16 PM Marten van Kerkwijk < m.h.vankerkw...@gmail.com> wrote: > I see the logic in having the linear space be last, but one non-negligible > advantage of the default being the first axis is that whatever is produced > broadcasts properly against start and stop. > --

Re: [Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Marten van Kerkwijk
I see the logic in having the linear space be last, but one non-negligible advantage of the default being the first axis is that whatever is produced broadcasts properly against start and stop. -- Marten ___ NumPy-Discussion mailing list

[Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Hameer Abbasi
> On Wednesday, Nov 14, 2018 at 11:46 PM, Stephan Hoyer (mailto:sho...@gmail.com)> wrote: > > > On Wed, Nov 14, 2018 at 2:35 PM Sebastian Berg (mailto:sebast...@sipsolutions.net)> wrote: > > On Wed, 2018-11-14 at 14:32 -0500, Marten van Kerkwijk wrote: > > > Code being better than words: see >

Re: [Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Stephan Hoyer
On Wed, Nov 14, 2018 at 2:35 PM Sebastian Berg wrote: > On Wed, 2018-11-14 at 14:32 -0500, Marten van Kerkwijk wrote: > > Code being better than words: see > > https://github.com/numpy/numpy/pull/12388 for an implementation. The > > change in the code proper is very small, though it is worrying

Re: [Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Marten van Kerkwijk
On Wed, Nov 14, 2018 at 1:21 PM Lars Grüter wrote: > > This reminds me of a function [1] I wrote which I think has a lot of > similarities to what Stephan describes here. It is currently part of a > PR to rewrite numpy.pad [2]. > > If we start to write the equivalent internally, then perhaps we

Re: [Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Marten van Kerkwijk
Code being better than words: see https://github.com/numpy/numpy/pull/12388 for an implementation. The change in the code proper is very small, though it is worrying that it causes two rather unrelated tests too fail (even if arguably both tests were wrong). Note that this does not give

Re: [Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Lars Grüter
On 14.11.18 17:57, Stephan Hoyer 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,

Re: [Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Marten van Kerkwijk
Just to add: nothing conceptually is strange for start and end to be arrays. Indeed, the code would work for arrays as is if it didn't check the `step == 0` case to handle denormals (arguably an even less common case than array-like inputs...), and made a trivial change to get the new axis to be

Re: [Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Matthew Harrigan
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

Re: [Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Gerrit Holl
On Wed, 14 Nov 2018 at 17:29, Ralf Gommers wrote: > On Wed, Nov 14, 2018 at 8:57 AM Stephan Hoyer 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

Re: [Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Ralf Gommers
On Wed, Nov 14, 2018 at 8:57 AM Stephan Hoyer 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

[Numpy-discussion] Vectorized version of numpy.linspace

2018-11-14 Thread Stephan Hoyer
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: