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 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-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 to fill an

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 dani...@grinta.netwrote: 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)

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 dani...@grinta.net mailto:dani...@grinta.net 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

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 dani...@grinta.netwrote: On 18/01/2013 15:19, Benjamin Root wrote: On Fri, Jan 18, 2013 at 3:44 AM, Daniele Nicolodi dani...@grinta.net mailto:dani...@grinta.net wrote: On 17/01/2013 23:27, Mark Wiebe wrote: Would it be

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 dani...@grinta.net mailto:dani...@grinta.net wrote: On 18/01/2013 15:19, Benjamin Root wrote: On Fri, Jan 18, 2013 at 3:44 AM, Daniele Nicolodi dani...@grinta.net

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 pierre.haes...@crans.org 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,

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 matthew.br...@gmail.com 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 --

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 matthew.br...@gmail.com wrote: I personally find 'fill' OK. I'd read: a = np.empty((10, 10), fill=np.nan) as make an empty array shape (10,

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 matthew.br...@gmail.com 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

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 this use in the

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 broadcasting

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 array,

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 efir...@hawaii.edu 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

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 ben.r...@ou.edu wrote: On Thu, Jan 17, 2013 at 5:04 PM, Eric Firing efir...@hawaii.edu 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

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 ben.r...@ou.edu wrote: On Thu, Jan 17, 2013 at 5:04 PM, Eric Firing efir...@hawaii.edu 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

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 mwwi...@gmail.com wrote: On Thu, Jan 17, 2013 at 2:10 PM, Benjamin Root ben.r...@ou.edu wrote: On Thu, Jan 17, 2013 at 5:04 PM, Eric Firing efir...@hawaii.edu wrote: On 2013/01/17 4:13 AM, Pierre Haessig wrote: Hi, Le 14/01/2013

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

2013-01-17 Thread Olivier Delalleau
2013/1/17 Matthew Brett matthew.br...@gmail.com: Hi, On Thu, Jan 17, 2013 at 10:27 PM, Mark Wiebe mwwi...@gmail.com wrote: On Thu, Jan 17, 2013 at 2:10 PM, Benjamin Root ben.r...@ou.edu wrote: On Thu, Jan 17, 2013 at 5:04 PM, Eric Firing efir...@hawaii.edu wrote: On 2013/01/17 4:13 AM,

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 sh...@keba.be wrote: 2013/1/17 Matthew Brett matthew.br...@gmail.com: Hi, On Thu, Jan 17, 2013 at 10:27 PM, Mark Wiebe mwwi...@gmail.com wrote: On Thu, Jan 17, 2013 at 2:10 PM, Benjamin Root ben.r...@ou.edu wrote: On Thu, Jan 17, 2013

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

2013-01-14 Thread Dave Hirschfeld
Robert Kern robert.kern at 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 self, to avoid

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 Benjamin Root
On Mon, Jan 14, 2013 at 7:38 AM, Pierre Haessig pierre.haes...@crans.orgwrote: 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

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 ben.r...@ou.edu wrote: On Mon, Jan 14, 2013 at 7:38 AM, Pierre Haessig pierre.haes...@crans.org

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 ben.r...@ou.edu 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

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 no...@nouiz.org 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

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 dave.hirschf...@gmail.com wrote: Robert Kern robert.kern at 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 Olivier Delalleau
2013/1/14 Matthew Brett matthew.br...@gmail.com: Hi, On Mon, Jan 14, 2013 at 9:02 AM, Dave Hirschfeld dave.hirschf...@gmail.com wrote: Robert Kern robert.kern at gmail.com writes: One alternative that does not expand the API with two-liners is to let the ndarray.fill() method

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 sh...@keba.be wrote: 2013/1/14 Matthew Brett matthew.br...@gmail.com: Hi, On Mon, Jan 14, 2013 at 9:02 AM, Dave Hirschfeld dave.hirschf...@gmail.com wrote: Robert Kern robert.kern at gmail.com writes: One alternative that does not

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

2013-01-14 Thread josef . pktd
On Mon, Jan 14, 2013 at 11:22 AM, josef.p...@gmail.com wrote: On Mon, Jan 14, 2013 at 11:15 AM, Olivier Delalleau sh...@keba.be wrote: 2013/1/14 Matthew Brett matthew.br...@gmail.com: Hi, On Mon, Jan 14, 2013 at 9:02 AM, Dave Hirschfeld dave.hirschf...@gmail.com wrote: Robert Kern

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

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 efir...@hawaii.edu 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

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 robert.k...@gmail.com wrote: On Sun, Jan 13, 2013 at 6:27 PM, Nathaniel Smith n...@pobox.com wrote: Hi all, PR 2875 adds two new functions, that generalize zeros(), ones(), zeros_like(), ones_like(), by simply taking an arbitrary fill value:

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() function ? As

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 ben.r...@ou.edu wrote: On Mon, Jan 14, 2013 at 7:38 AM, Pierre Haessig pierre.haes...@crans.org 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

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 pierre.haes...@crans.org 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

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 pierre.haes...@crans.org 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

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-13 Thread josef . pktd
On Sun, Jan 13, 2013 at 12:27 PM, Nathaniel Smith n...@pobox.com 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

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 n...@pobox.com 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

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.filled((10,

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 n...@pobox.com 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 Matthew Brett
On Sun, Jan 13, 2013 at 11:24 PM, Robert Kern robert.k...@gmail.com wrote: On Sun, Jan 13, 2013 at 6:27 PM, Nathaniel Smith n...@pobox.com wrote: Hi all, PR 2875 adds two new functions, that generalize zeros(), ones(), zeros_like(), ones_like(), by simply taking an arbitrary fill value:

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 robert.k...@gmail.com wrote: On Sun, Jan 13, 2013 at 6:27 PM, Nathaniel Smith n...@pobox.com wrote: Hi all, PR 2875 adds two new functions, that generalize zeros(), ones(), zeros_like(), ones_like(), by simply taking an arbitrary fill value:

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 n...@pobox.com wrote: On Sun, Jan 13, 2013 at 11:24 PM, Robert Kern robert.k...@gmail.com wrote: On Sun, Jan 13, 2013 at 6:27 PM, Nathaniel Smith n...@pobox.com wrote: Hi all, PR 2875 adds two new functions, that generalize zeros(),

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 robert.k...@gmail.com 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

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 jsseab...@gmail.com wrote: On Sun, Jan 13, 2013 at 6:39 PM, Nathaniel Smith n...@pobox.com wrote: On Sun, Jan 13, 2013 at 11:24 PM, Robert Kern robert.k...@gmail.com wrote: On Sun, Jan 13, 2013 at 6:27 PM, Nathaniel Smith n...@pobox.com

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 n...@pobox.com wrote: On Sun, Jan 13, 2013 at 11:48 PM, Skipper Seabold jsseab...@gmail.com wrote: On Sun, Jan 13, 2013 at 6:39 PM, Nathaniel Smith n...@pobox.com wrote: On Sun, Jan 13, 2013 at 11:24 PM, Robert Kern robert.k...@gmail.com wrote: