Re: [Numpy-discussion] minor improvment to ones

2009-01-31 Thread Geoffrey Irving
On Fri, Jan 30, 2009 at 5:18 AM, Neal Becker wrote: > A nit, but it would be nice if 'ones' could fill with a value other than 1. > > Maybe an optional val= keyword? You can use the "tile" function for this. "tile(3,3)" creates an array of 3 3's. Geoffrey ___

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 16:32, Neal Becker wrote: > Robert Kern wrote: > >> On Fri, Jan 30, 2009 at 08:22, Neal Becker wrote: >>> Right now there are 2 options to create an array of constant value: >>> >>> 1) empty (size); fill (val) >>> >>> 2) ones (size) * val >>> >>> 1 has disadvantage of not

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Neal Becker
Robert Kern wrote: > On Fri, Jan 30, 2009 at 08:22, Neal Becker wrote: >> Right now there are 2 options to create an array of constant value: >> >> 1) empty (size); fill (val) >> >> 2) ones (size) * val >> >> 1 has disadvantage of not being an expression, so can't be an arg to a >> function call.

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 08:22, Neal Becker wrote: > Right now there are 2 options to create an array of constant value: > > 1) empty (size); fill (val) > > 2) ones (size) * val > > 1 has disadvantage of not being an expression, so can't be an arg to a > function call. So wrap it in a function. >

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Robert Kern
On Fri, Jan 30, 2009 at 11:26, Ryan May wrote: > Christopher Barker wrote: >>> On 1/30/2009 3:22 PM, Neal Becker wrote: >>> Now what would be _really_ cool is a special array type that would represent a constant array without wasting memory. >> >> Can't you do that with scary strid

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Ryan May
Christopher Barker wrote: >> On 1/30/2009 3:22 PM, Neal Becker wrote: >> >>> Now what would be _really_ cool is a special array type that would >>> represent >>> a constant array without wasting memory. > > Can't you do that with scary stride tricks? I think I remember some > discussion of this

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Christopher Barker
> On 1/30/2009 3:22 PM, Neal Becker wrote: > >> Now what would be _really_ cool is a special array type that would represent >> a constant array without wasting memory. Can't you do that with scary stride tricks? I think I remember some discussion of this a while back. -Chris -- Christopher

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Sturla Molden
On 1/30/2009 3:22 PM, Neal Becker wrote: > Now what would be _really_ cool is a special array type that would represent > a constant array without wasting memory. Which again is a special case of something even cooler: lazy evaluation. This would require arrays to have immutable buffers. Then a

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Ryan May
Sturla Molden wrote: > On 1/30/2009 2:18 PM, Neal Becker wrote: >> A nit, but it would be nice if 'ones' could fill with a value other than 1. >> >> Maybe an optional val= keyword? >> > > I am -1 on this. Ones should fill with ones, zeros should fill with > zeros. Anything else is counter-intuiti

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Grissiom
On Fri, Jan 30, 2009 at 22:16, Sturla Molden wrote: > On 1/30/2009 3:07 PM, Grissiom wrote: > > > Is fill function has any advantage over ones(size)*x ? > > You avoid filling with ones, all the multiplications and creating an > temporary array. It can be done like this: > > a = empty(size) > a[:]

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Gael Varoquaux
On Fri, Jan 30, 2009 at 09:22:46AM -0500, Neal Becker wrote: > Now what would be _really_ cool is a special array type that would represent > a constant array without wasting memory. boost::ublas, for example, has > this feature. What I would actually like is some kind of sparse masked array, w

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Neal Becker
Right now there are 2 options to create an array of constant value: 1) empty (size); fill (val) 2) ones (size) * val 1 has disadvantage of not being an expression, so can't be an arg to a function call. Also probably slower than create+fill @ same time 2 is probably slower than create+fill @

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Sturla Molden
On 1/30/2009 3:07 PM, Grissiom wrote: > Is fill function has any advantage over ones(size)*x ? You avoid filling with ones, all the multiplications and creating an temporary array. It can be done like this: a = empty(size) a[:] = x Which would be slightly faster and more memory efficient. S.

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Matthieu Brucher
> Is fill function has any advantage over ones(size)*x ? No intermediate array (inplace) ? Matthieu -- Information System Engineer, Ph.D. Website: http://matthieu-brucher.developpez.com/ Blogs: http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn: http://www.linkedin.com/in/m

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Sturla Molden
On 1/30/2009 2:18 PM, Neal Becker wrote: > A nit, but it would be nice if 'ones' could fill with a value other than 1. > > Maybe an optional val= keyword? > I am -1 on this. Ones should fill with ones, zeros should fill with zeros. Anything else is counter-intuitive. Calling numpy.ones to fill

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Grissiom
On Fri, Jan 30, 2009 at 21:54, Scott Sinclair wrote: > > 2009/1/30 David Cournapeau : > > Neal Becker wrote: > >> A nit, but it would be nice if 'ones' could fill with a value other than > 1. > >> > >> Maybe an optional val= keyword? > > > > What would be the advantage compared to fill ? I would g

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread Scott Sinclair
> 2009/1/30 David Cournapeau : > Neal Becker wrote: >> A nit, but it would be nice if 'ones' could fill with a value other than 1. >> >> Maybe an optional val= keyword? > > What would be the advantage compared to fill ? I would guess ones and > zeros are special because those two values are special

Re: [Numpy-discussion] minor improvment to ones

2009-01-30 Thread David Cournapeau
Neal Becker wrote: > A nit, but it would be nice if 'ones' could fill with a value other than 1. > > Maybe an optional val= keyword? > What would be the advantage compared to fill ? I would guess ones and zeros are special because those two values are special (they can be defined for many types

[Numpy-discussion] minor improvment to ones

2009-01-30 Thread Neal Becker
A nit, but it would be nice if 'ones' could fill with a value other than 1. Maybe an optional val= keyword? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion