Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-21 Thread Pierre Haessig
Le 18/01/2013 23:22, Matthew Brett a écrit : > I personally find 'fill' OK. I'd read: > > a = np.empty((10, 10), fill=np.nan) > > as > > "make an empty array shape (10, 10) and fill with nans" +1 (and now we have *two* verbs ! ) -- Pierre signature.asc Description: OpenPGP digital signature

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-18 Thread Fernando Perez
On Fri, Jan 18, 2013 at 2:22 PM, Matthew Brett wrote: > I personally find 'fill' OK. I'd read: > > a = np.empty((10, 10), fill=np.nan) > > as > > "make an empty array shape (10, 10) and fill with nans" > > Which would indeed be what the code was doing :) So I doubt that the > semantic clash woul

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-18 Thread Ralf Gommers
On Fri, Jan 18, 2013 at 11:31 PM, Chris Barker - NOAA Federal < chris.bar...@noaa.gov> wrote: > On Fri, Jan 18, 2013 at 2:22 PM, Matthew Brett > wrote: > > > I personally find 'fill' OK. I'd read: > > > > a = np.empty((10, 10), fill=np.nan) > > > > as > > > > "make an empty array shape (10, 10)

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-18 Thread Chris Barker - NOAA Federal
On Fri, Jan 18, 2013 at 2:22 PM, Matthew Brett wrote: > I personally find 'fill' OK. I'd read: > > a = np.empty((10, 10), fill=np.nan) > > as > > "make an empty array shape (10, 10) and fill with nans" +1 simple, does the job, and doesn't bloat the API. -Chris -- Christopher Barker, Ph.D

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-18 Thread Matthew Brett
Hi, On Fri, Jan 18, 2013 at 1:48 PM, Pierre Haessig wrote: > Hi, > Le 17/01/2013 23:31, Matthew Brett a écrit : >>> Would it be too weird or clumsy to extend the empty and empty_like functions >>> >to do the filling? >>> > >>> >np.empty((10, 10), fill=np.nan) >>> >np.empty_like(my_arr, fill=np.na

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-18 Thread Daniele Nicolodi
On 18/01/2013 17:46, Benjamin Root wrote: > > > On Fri, Jan 18, 2013 at 11:36 AM, Daniele Nicolodi > wrote: > > On 18/01/2013 15:19, Benjamin Root wrote: > > > > > > On Fri, Jan 18, 2013 at 3:44 AM, Daniele Nicolodi > mailto:dani...@grinta.net> >

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-18 Thread Benjamin Root
On Fri, Jan 18, 2013 at 11:36 AM, Daniele Nicolodi wrote: > On 18/01/2013 15:19, Benjamin Root wrote: > > > > > > On Fri, Jan 18, 2013 at 3:44 AM, Daniele Nicolodi > > wrote: > > > > On 17/01/2013 23:27, Mark Wiebe wrote: > > > Would it be too weird or clumsy to

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-18 Thread Daniele Nicolodi
On 18/01/2013 15:19, Benjamin Root wrote: > > > On Fri, Jan 18, 2013 at 3:44 AM, Daniele Nicolodi > wrote: > > On 17/01/2013 23:27, Mark Wiebe wrote: > > Would it be too weird or clumsy to extend the empty and empty_like > > functions to do the filling? >

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-18 Thread Benjamin Root
On Fri, Jan 18, 2013 at 3:44 AM, Daniele Nicolodi wrote: > On 17/01/2013 23:27, Mark Wiebe wrote: > > Would it be too weird or clumsy to extend the empty and empty_like > > functions to do the filling? > > > > np.empty((10, 10), fill=np.nan) > > np.empty_like(my_arr, fill=np.nan) > > Wouldn't it b

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-18 Thread Pierre Haessig
Hi, Le 17/01/2013 23:31, Matthew Brett a écrit : >> Would it be too weird or clumsy to extend the empty and empty_like functions >> >to do the filling? >> > >> >np.empty((10, 10), fill=np.nan) >> >np.empty_like(my_arr, fill=np.nan) > That sounds like a good idea to me. Someone wanting a fast way t

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-18 Thread Daniele Nicolodi
On 17/01/2013 23:27, Mark Wiebe wrote: > Would it be too weird or clumsy to extend the empty and empty_like > functions to do the filling? > > np.empty((10, 10), fill=np.nan) > np.empty_like(my_arr, fill=np.nan) Wouldn't it be more natural to extend the ndarray constructor? np.ndarray((10, 10),

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-17 Thread Thouis (Ray) Jones
On Jan 17, 2013 8:01 PM, "Olivier Delalleau" wrote: > > 2013/1/17 Matthew Brett : > > Hi, > > > > On Thu, Jan 17, 2013 at 10:27 PM, Mark Wiebe wrote: > >> > >> On Thu, Jan 17, 2013 at 2:10 PM, Benjamin Root wrote: > >>> > >>> > >>> > >>> On Thu, Jan 17, 2013 at 5:04 PM, Eric Firing wrote: > >>>

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-17 Thread Olivier Delalleau
2013/1/17 Matthew Brett : > Hi, > > On Thu, Jan 17, 2013 at 10:27 PM, Mark Wiebe wrote: >> >> On Thu, Jan 17, 2013 at 2:10 PM, Benjamin Root wrote: >>> >>> >>> >>> On Thu, Jan 17, 2013 at 5:04 PM, Eric Firing wrote: On 2013/01/17 4:13 AM, Pierre Haessig wrote: > Hi, > >

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-17 Thread Matthew Brett
Hi, On Thu, Jan 17, 2013 at 10:27 PM, Mark Wiebe wrote: > > On Thu, Jan 17, 2013 at 2:10 PM, Benjamin Root wrote: >> >> >> >> On Thu, Jan 17, 2013 at 5:04 PM, Eric Firing wrote: >>> >>> On 2013/01/17 4:13 AM, Pierre Haessig wrote: >>> > Hi, >>> > >>> > Le 14/01/2013 20:05, Benjamin Root a écrit

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-17 Thread Mark Wiebe
On Thu, Jan 17, 2013 at 2:10 PM, Benjamin Root wrote: > > > On Thu, Jan 17, 2013 at 5:04 PM, Eric Firing wrote: > >> On 2013/01/17 4:13 AM, Pierre Haessig wrote: >> > Hi, >> > >> > Le 14/01/2013 20:05, Benjamin Root a écrit : >> >> I do like the way you are thinking in terms of the broadcasting

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-17 Thread Matthew Brett
Hi, On Thu, Jan 17, 2013 at 10:10 PM, Benjamin Root wrote: > > > On Thu, Jan 17, 2013 at 5:04 PM, Eric Firing wrote: >> >> On 2013/01/17 4:13 AM, Pierre Haessig wrote: >> > Hi, >> > >> > Le 14/01/2013 20:05, Benjamin Root a écrit : >> >> I do like the way you are thinking in terms of the broadca

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-17 Thread Benjamin Root
On Thu, Jan 17, 2013 at 5:04 PM, Eric Firing wrote: > On 2013/01/17 4:13 AM, Pierre Haessig wrote: > > Hi, > > > > Le 14/01/2013 20:05, Benjamin Root a écrit : > >> I do like the way you are thinking in terms of the broadcasting > >> semantics, but I wonder if that is a bit awkward. What I mean

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-17 Thread Eric Firing
On 2013/01/17 4:13 AM, Pierre Haessig wrote: > Hi, > > Le 14/01/2013 20:05, Benjamin Root a écrit : >> I do like the way you are thinking in terms of the broadcasting >> semantics, but I wonder if that is a bit awkward. What I mean is, if >> one were to use broadcasting semantics for creating an a

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-17 Thread Pierre Haessig
Hi, Le 14/01/2013 20:05, Benjamin Root a écrit : > I do like the way you are thinking in terms of the broadcasting > semantics, but I wonder if that is a bit awkward. What I mean is, if > one were to use broadcasting semantics for creating an array, wouldn't > one have just simply used broadcasti

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-17 Thread Pierre Haessig
Hi, Le 14/01/2013 20:17, Alan G Isaac a écrit : > >>> a = np.tile(5,(1,2,3)) > >>> a > array([[[5, 5, 5], > [5, 5, 5]]]) > >>> np.tile(1,a.shape) > array([[[1, 1, 1], > [1, 1, 1]]]) > > I had not realized a scalar first argument was possible. I didn't know either ! I discovered

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Alan G Isaac
Thanks Pierre for noting that np.tile already provides a chunk of this functionality: >>> a = np.tile(5,(1,2,3)) >>> a array([[[5, 5, 5], [5, 5, 5]]]) >>> np.tile(1,a.shape) array([[[1, 1, 1], [1, 1, 1]]]) I had not realized a scalar first argument was possible. Alan Isaac _

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Benjamin Root
On Mon, Jan 14, 2013 at 1:56 PM, David Warde-Farley < d.warde.far...@gmail.com> wrote: > On Mon, Jan 14, 2013 at 1:12 PM, Pierre Haessig > wrote: > > In [8]: tile(nan, (3,3)) # (it's a verb ! ) > > tile, in my opinion, is useful in some cases (for people who think in > terms of repmat()) but not

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread David Warde-Farley
On Mon, Jan 14, 2013 at 1:12 PM, Pierre Haessig wrote: > In [8]: tile(nan, (3,3)) # (it's a verb ! ) tile, in my opinion, is useful in some cases (for people who think in terms of repmat()) but not very NumPy-ish. What I'd like is a function that takes - an initial array_like "a" - a shape "s" -

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread David Warde-Farley
On Mon, Jan 14, 2013 at 9:57 AM, Benjamin Root wrote: > > > On Mon, Jan 14, 2013 at 7:38 AM, Pierre Haessig > wrote: >> >> Hi, >> >> Le 14/01/2013 00:39, Nathaniel Smith a écrit : >> > (The nice thing about np.filled() is that it makes np.zeros() and >> > np.ones() feel like clutter, rather than

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Pierre Haessig
Le 14/01/2013 18:33, Benjamin Root a écrit : > > > How about "initialized()"? > > > A verb! +1 from me! Shouldn't it be "initialize()" then ? I'm not so fond of it though, because initialize is pretty broad in the field of programming. What about "refurbishing" the already existing "tile()" fu

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Charles R Harris
On Sun, Jan 13, 2013 at 4:24 PM, Robert Kern wrote: > On Sun, Jan 13, 2013 at 6:27 PM, Nathaniel Smith wrote: > > Hi all, > > > > PR 2875 adds two new functions, that generalize zeros(), ones(), > > zeros_like(), ones_like(), by simply taking an arbitrary fill value: > > https://github.com/num

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Benjamin Root
On Mon, Jan 14, 2013 at 12:27 PM, Eric Firing wrote: > On 2013/01/14 6:15 AM, Olivier Delalleau wrote: > > - I agree the name collision with np.ma.filled is a problem. I have no > > better suggestion though at this point. > > How about "initialized()"? > A verb! +1 from me! For those wondering,

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Eric Firing
On 2013/01/14 6:15 AM, Olivier Delalleau wrote: > - I agree the name collision with np.ma.filled is a problem. I have no > better suggestion though at this point. How about "initialized()"? ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org htt

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread josef . pktd
On Mon, Jan 14, 2013 at 11:22 AM, wrote: > On Mon, Jan 14, 2013 at 11:15 AM, Olivier Delalleau wrote: >> 2013/1/14 Matthew Brett : >>> Hi, >>> >>> On Mon, Jan 14, 2013 at 9:02 AM, Dave Hirschfeld >>> wrote: Robert Kern gmail.com> writes: > > >>> > > >>> > One alternative

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread josef . pktd
On Mon, Jan 14, 2013 at 11:15 AM, Olivier Delalleau wrote: > 2013/1/14 Matthew Brett : >> Hi, >> >> On Mon, Jan 14, 2013 at 9:02 AM, Dave Hirschfeld >> wrote: >>> Robert Kern gmail.com> writes: >>> >>> > >>> > One alternative that does not expand the API with two-liners is to >>>

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Olivier Delalleau
2013/1/14 Matthew Brett : > Hi, > > On Mon, Jan 14, 2013 at 9:02 AM, Dave Hirschfeld > wrote: >> Robert Kern gmail.com> writes: >> >>> >>> >>> > >>> >>> > One alternative that does not expand the API with two-liners is to let >>> >>> > the ndarray.fill() method return self: >>> >>> > >>> >>> >

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Matthew Brett
Hi, On Mon, Jan 14, 2013 at 9:02 AM, Dave Hirschfeld wrote: > Robert Kern gmail.com> writes: > >> >> >>> > >> >>> > One alternative that does not expand the API with two-liners is to let >> >>> > the ndarray.fill() method return self: >> >>> > >> >>> > a = np.empty(...).fill(20.0) >> >>> >> >>

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Robert Kern
On Mon, Jan 14, 2013 at 4:12 PM, Frédéric Bastien wrote: > Why not optimize NumPy to detect a mul of an ndarray by a scalar to > call fill? That way, "np.empty * 2" will be as fast as "x=np.empty; > x.fill(2)"? In general, each element of an array will be different, so the result of the multiplic

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Robin
On Mon, Jan 14, 2013 at 2:57 PM, Benjamin Root wrote: > I am also +1 on the idea of having a filled() and filled_like() function (I > learned a long time ago to just do a = np.empty() and a.fill() rather than > the multiplication trick I learned from Matlab). However, the collision > with the mas

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Frédéric Bastien
Why not optimize NumPy to detect a mul of an ndarray by a scalar to call fill? That way, "np.empty * 2" will be as fast as "x=np.empty; x.fill(2)"? Fred On Mon, Jan 14, 2013 at 9:57 AM, Benjamin Root wrote: > > > On Mon, Jan 14, 2013 at 7:38 AM, Pierre Haessig > wrote: >> >> Hi, >> >> Le 14/01/

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Benjamin Root
On Mon, Jan 14, 2013 at 7:38 AM, Pierre Haessig wrote: > Hi, > > Le 14/01/2013 00:39, Nathaniel Smith a écrit : > > (The nice thing about np.filled() is that it makes np.zeros() and > > np.ones() feel like clutter, rather than the reverse... not that I'm > > suggesting ever getting rid of them, bu

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Pierre Haessig
Hi, Le 14/01/2013 00:39, Nathaniel Smith a écrit : > (The nice thing about np.filled() is that it makes np.zeros() and > np.ones() feel like clutter, rather than the reverse... not that I'm > suggesting ever getting rid of them, but it makes the API conceptually > feel smaller, not larger.) Coming

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-14 Thread Dave Hirschfeld
Robert Kern gmail.com> writes: > > >>> > > >>> > One alternative that does not expand the API with two-liners is to let > >>> > the ndarray.fill() method return self: > >>> > > >>> > a = np.empty(...).fill(20.0) > >>> > >>> This violates the convention that in-place operations never return > >

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-13 Thread Robert Kern
On Mon, Jan 14, 2013 at 1:04 AM, Nathaniel Smith wrote: > On Sun, Jan 13, 2013 at 11:48 PM, Skipper Seabold wrote: >> On Sun, Jan 13, 2013 at 6:39 PM, Nathaniel Smith wrote: >>> >>> On Sun, Jan 13, 2013 at 11:24 PM, Robert Kern >>> wrote: >>> > On Sun, Jan 13, 2013 at 6:27 PM, Nathaniel Smith

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-13 Thread Nathaniel Smith
On Sun, Jan 13, 2013 at 11:48 PM, Skipper Seabold wrote: > On Sun, Jan 13, 2013 at 6:39 PM, Nathaniel Smith wrote: >> >> On Sun, Jan 13, 2013 at 11:24 PM, Robert Kern >> wrote: >> > On Sun, Jan 13, 2013 at 6:27 PM, Nathaniel Smith wrote: >> >> Hi all, >> >> >> >> PR 2875 adds two new functions,

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-13 Thread Alan G Isaac
> On Sun, Jan 13, 2013 at 11:24 PM, Robert Kern wrote: >> One alternative that does not expand the API with two-liners is to let >> the ndarray.fill() method return self: >> >>a = np.empty(...).fill(20.0) > On 1/13/2013 6:39 PM, Nathaniel Smith wrote: > This violates the convention that in-p

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-13 Thread Skipper Seabold
On Sun, Jan 13, 2013 at 6:39 PM, Nathaniel Smith wrote: > On Sun, Jan 13, 2013 at 11:24 PM, Robert Kern > wrote: > > On Sun, Jan 13, 2013 at 6:27 PM, Nathaniel Smith wrote: > >> Hi all, > >> > >> PR 2875 adds two new functions, that generalize zeros(), ones(), > >> zeros_like(), ones_like(), by

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-13 Thread Nathaniel Smith
On Sun, Jan 13, 2013 at 11:24 PM, Robert Kern wrote: > On Sun, Jan 13, 2013 at 6:27 PM, Nathaniel Smith wrote: >> Hi all, >> >> PR 2875 adds two new functions, that generalize zeros(), ones(), >> zeros_like(), ones_like(), by simply taking an arbitrary fill value: >> https://github.com/numpy/nu

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-13 Thread Matthew Brett
On Sun, Jan 13, 2013 at 11:24 PM, Robert Kern wrote: > On Sun, Jan 13, 2013 at 6:27 PM, Nathaniel Smith wrote: >> Hi all, >> >> PR 2875 adds two new functions, that generalize zeros(), ones(), >> zeros_like(), ones_like(), by simply taking an arbitrary fill value: >> https://github.com/numpy/nu

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-13 Thread Robert Kern
On Sun, Jan 13, 2013 at 6:27 PM, Nathaniel Smith wrote: > Hi all, > > PR 2875 adds two new functions, that generalize zeros(), ones(), > zeros_like(), ones_like(), by simply taking an arbitrary fill value: > https://github.com/numpy/numpy/pull/2875 > So > np.ones((10, 10)) > is the same as >

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-13 Thread Eric Firing
On 2013/01/13 7:27 AM, Nathaniel Smith wrote: > Hi all, > > PR 2875 adds two new functions, that generalize zeros(), ones(), > zeros_like(), ones_like(), by simply taking an arbitrary fill value: >https://github.com/numpy/numpy/pull/2875 > So >np.ones((10, 10)) > is the same as >np.fill

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-13 Thread Matthew Brett
Hi, On Sun, Jan 13, 2013 at 5:27 PM, Nathaniel Smith wrote: > Hi all, > > PR 2875 adds two new functions, that generalize zeros(), ones(), > zeros_like(), ones_like(), by simply taking an arbitrary fill value: > https://github.com/numpy/numpy/pull/2875 > So > np.ones((10, 10)) > is the same a

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-13 Thread eat
Hi, On Sun, Jan 13, 2013 at 7:27 PM, Nathaniel Smith wrote: > Hi all, > > PR 2875 adds two new functions, that generalize zeros(), ones(), > zeros_like(), ones_like(), by simply taking an arbitrary fill value: > https://github.com/numpy/numpy/pull/2875 > So > np.ones((10, 10)) > is the same

Re: [Numpy-discussion] New numpy functions: filled, filled_like

2013-01-13 Thread josef . pktd
On Sun, Jan 13, 2013 at 12:27 PM, Nathaniel Smith wrote: > Hi all, > > PR 2875 adds two new functions, that generalize zeros(), ones(), > zeros_like(), ones_like(), by simply taking an arbitrary fill value: > https://github.com/numpy/numpy/pull/2875 > So > np.ones((10, 10)) > is the same as >

[Numpy-discussion] New numpy functions: filled, filled_like

2013-01-13 Thread Nathaniel Smith
Hi all, PR 2875 adds two new functions, that generalize zeros(), ones(), zeros_like(), ones_like(), by simply taking an arbitrary fill value: https://github.com/numpy/numpy/pull/2875 So np.ones((10, 10)) is the same as np.filled((10, 10), 1) The implementations are trivial, but the API seem