Re: [Numpy-discussion] Should arr.diagonal() return a copy or a view? (1.7 compatibility issue)

2012-05-22 Thread Travis Oliphant
I just realized that the pull request doesn't do what I thought it did which is just add the flag to warn users who are writing to an array that is a view when it used to be a copy. It's more cautious and also "copies" the data for 1.7. Is this really a necessary step? I guess it depen

Re: [Numpy-discussion] subclassing ndarray subtleties??

2012-05-22 Thread Chris Barker
On Tue, May 22, 2012 at 1:07 PM, Dan Goodman wrote: > I think it would be useful to have an example of a completely > 'correctly' subclassed ndarray that handles all of these issues that > people could use as a template when they want to subclass ndarray. I think this is by definition impossible

Re: [Numpy-discussion] assign a float number to a member of integer array always return integer

2012-05-22 Thread Chao YUE
Thanks Chris for informative post. cheers, Chao 2012/5/22 Chris Barker > On Tue, May 22, 2012 at 6:33 AM, Chao YUE wrote: > > > Just in case some one didn't know this. Assign a float number to an > integer > > array element will always return integer. > > right -- numpy arrays are typed -- th

Re: [Numpy-discussion] subclassing ndarray subtleties??

2012-05-22 Thread Tom Aldcroft
On Tue, May 22, 2012 at 4:07 PM, Dan Goodman wrote: > On 22/05/2012 18:20, Nathaniel Smith wrote: >> I don't know of anything that the docs are lacking in particular. It's >> just that subclassing in general is basically a special form of >> monkey-patching: you have this ecosystem of cooperating

Re: [Numpy-discussion] pre-PEP for making creative forking of NumPy less destructive

2012-05-22 Thread Frédéric Bastien
Hi, The example with numpy array for small array, the speed problem is probably because NumPy have not been speed optimized for low overhead. For example, each c function should check first if the input is a NumPy array, if not jump to a function to make one. For example, currently in the c functi

Re: [Numpy-discussion] subclassing ndarray subtleties??

2012-05-22 Thread Dan Goodman
On 22/05/2012 18:20, Nathaniel Smith wrote: > I don't know of anything that the docs are lacking in particular. It's > just that subclassing in general is basically a special form of > monkey-patching: you have this ecosystem of cooperating methods, and > then you're inserting some arbitrary change

Re: [Numpy-discussion] question about in-place operations

2012-05-22 Thread Massimo Di Pierro
This problem is linear so probably Ram IO bound. I do not think I would benefit much for multiple cores. But I will give it a try. In the short term this is good enough for me. On May 22, 2012, at 1:57 PM, Francesc Alted wrote: > On 5/22/12 8:47 PM, Dag Sverre Seljebotn wrote: >> On 05/22/20

Re: [Numpy-discussion] question about in-place operations

2012-05-22 Thread Massimo Di Pierro
Thank you Dag, I will look into it. Is there any documentation about ufunc? Is this the file core/src/umath/ufunc_object.c Massimo On May 22, 2012, at 1:47 PM, Dag Sverre Seljebotn wrote: > On 05/22/2012 04:54 PM, Massimo DiPierro wrote: >> For now I will be doing this: >> >> import numpy >> i

Re: [Numpy-discussion] question about in-place operations

2012-05-22 Thread Francesc Alted
On 5/22/12 8:47 PM, Dag Sverre Seljebotn wrote: > On 05/22/2012 04:54 PM, Massimo DiPierro wrote: >> For now I will be doing this: >> >> import numpy >> import time >> >> a=numpy.zeros(200) >> b=numpy.zeros(200) >> c=1.0 >> >> # naive solution >> t0 = time.time() >> for i in xrange(len(a)):

Re: [Numpy-discussion] question about in-place operations

2012-05-22 Thread Dag Sverre Seljebotn
On 05/22/2012 04:54 PM, Massimo DiPierro wrote: > For now I will be doing this: > > import numpy > import time > > a=numpy.zeros(200) > b=numpy.zeros(200) > c=1.0 > > # naive solution > t0 = time.time() > for i in xrange(len(a)): > a[i] += c*b[i] > print time.time()-t0 > > # possible s

Re: [Numpy-discussion] Internationalization of numpy/scipy docstrings...

2012-05-22 Thread josef . pktd
On Tue, May 22, 2012 at 10:51 AM, Tim Cera wrote: >>> >> Docstrings are not stored in .rst files but in the numpy sources, so there >> are some non-trivial technical and workflow details missing here. But >> besides that, I think translating everything (even into a single language) >> is a massive

Re: [Numpy-discussion] subclassing ndarray subtleties??

2012-05-22 Thread Nathaniel Smith
On Mon, May 21, 2012 at 6:47 PM, Tom Aldcroft wrote: > Over on the scipy-user mailing list there was a question about > subclassing ndarray and I was interested to see two responses that > seemed to imply that subclassing should be avoided. > > >From Dag and Nathaniel, respectively: > > "Subclassi

Re: [Numpy-discussion] assign a float number to a member of integer array always return integer

2012-05-22 Thread Chris Barker
On Tue, May 22, 2012 at 6:33 AM, Chao YUE wrote: > Just in case some one didn't know this. Assign a float number to an integer > array element will always return integer. right -- numpy arrays are typed -- that's one of the points of them -- you wouldn't want the entire array up-cast with a sing

Re: [Numpy-discussion] how to avoid re-shaping

2012-05-22 Thread Massimo DiPierro
On May 22, 2012, at 10:12 AM, Robert Kern wrote: > On Tue, May 22, 2012 at 4:09 PM, Massimo DiPierro > wrote: >> One more questions (since this list is very useful. ;-) >> >> If I have a numpy array of arbitrary shape, is there are a way to >> sequentially loop over its elements without reshap

Re: [Numpy-discussion] how to avoid re-shaping

2012-05-22 Thread Robert Kern
On Tue, May 22, 2012 at 4:09 PM, Massimo DiPierro wrote: > One more questions (since this list is very useful. ;-) > > If I have a numpy array of arbitrary shape, is there are a way to > sequentially loop over its elements without reshaping it into a 1D array? > > I am trying to simplify this: >

[Numpy-discussion] how to avoid re-shaping

2012-05-22 Thread Massimo DiPierro
One more questions (since this list is very useful. ;-) If I have a numpy array of arbitrary shape, is there are a way to sequentially loop over its elements without reshaping it into a 1D array? I am trying to simplify this: n=product(data.shape) oldshape = data.shape newshape = (n,) data.resh

Re: [Numpy-discussion] question about in-place operations

2012-05-22 Thread Massimo DiPierro
Thank you this does it. On May 22, 2012, at 9:59 AM, Robert Kern wrote: > On Tue, May 22, 2012 at 3:47 PM, Massimo DiPierro > wrote: >> Thank you. I will look into numexpr. >> >> Anyway, I do not need arbitrary expressions. If there were something like >> >> numpy.add_scaled(a,scale,b) >> >

Re: [Numpy-discussion] question about in-place operations

2012-05-22 Thread Robert Kern
On Tue, May 22, 2012 at 3:47 PM, Massimo DiPierro wrote: > Thank you. I will look into numexpr. > > Anyway, I do not need arbitrary expressions. If there were something like > > numpy.add_scaled(a,scale,b) > > with support for scale in int, float, complex, this would be sufficient for > me. BLAS

Re: [Numpy-discussion] question about in-place operations

2012-05-22 Thread Massimo DiPierro
For now I will be doing this: import numpy import time a=numpy.zeros(200) b=numpy.zeros(200) c=1.0 # naive solution t0 = time.time() for i in xrange(len(a)): a[i] += c*b[i] print time.time()-t0 # possible solution n=10 t0 = time.time() for i in xrange(0,len(a),n): a[i:i+n] +

Re: [Numpy-discussion] Internationalization of numpy/scipy docstrings...

2012-05-22 Thread Tim Cera
> > >> Docstrings are not stored in .rst files but in the numpy sources, so > there are some non-trivial technical and workflow details missing here. But > besides that, I think translating everything (even into a single language) > is a massive amount of work, and it's not at all clear if there's

Re: [Numpy-discussion] question about in-place operations

2012-05-22 Thread Massimo DiPierro
Thank you. I will look into numexpr. Anyway, I do not need arbitrary expressions. If there were something like numpy.add_scaled(a,scale,b) with support for scale in int, float, complex, this would be sufficient for me. Massimo On May 22, 2012, at 9:32 AM, Dag Sverre Seljebotn wrote: > On 05/

Re: [Numpy-discussion] un-silencing Numpy's deprecation warnings

2012-05-22 Thread Jonathan T. Niehof
On 05/22/2012 03:50 AM, Peter wrote: > We had the same discussion for Biopython two years ago, and > introduced our own warning class to avoid our deprecations being > silent (and thus almost pointless). It is just a subclass of Warning > (originally we used a subclass of UserWarning). For SpacePy

Re: [Numpy-discussion] question about in-place operations

2012-05-22 Thread Dag Sverre Seljebotn
On 05/22/2012 04:25 PM, Massimo DiPierro wrote: > hello everybody, > > first of all thanks to the developed for bumpy which is very useful. I am > building a software that uses numpy+pyopencl for lattice qcd computations. > One problem that I am facing is that I need to perform most operations on

[Numpy-discussion] question about in-place operations

2012-05-22 Thread Massimo DiPierro
hello everybody, first of all thanks to the developed for bumpy which is very useful. I am building a software that uses numpy+pyopencl for lattice qcd computations. One problem that I am facing is that I need to perform most operations on arrays in place and I must avoid creating temporary arr

[Numpy-discussion] Building error with ATLAS

2012-05-22 Thread Magician
Hi all, I'm now trying to build NumPy with ATLAS on CentOS 6.2. I'm going to use them with SciPy. My CentOS is installed as "Software Development Workstation" on my Virtual Machine (VMware Fusion 4, Mac OS 10.7.4). I already installed Python 2.7.3 on /usr/local/python-2.7.3 from sources, and no

Re: [Numpy-discussion] un-silencing Numpy's deprecation warnings

2012-05-22 Thread Robert Kern
On Tue, May 22, 2012 at 2:45 PM, Nathaniel Smith wrote: > On Tue, May 22, 2012 at 11:06 AM, Robert Kern wrote: >> On Tue, May 22, 2012 at 9:27 AM, Nathaniel Smith wrote: >>> So starting in Python 2.7 and 3.2, the Python developers have made >>> DeprecationWarnings invisible by default: >>>  http

Re: [Numpy-discussion] un-silencing Numpy's deprecation warnings

2012-05-22 Thread Nathaniel Smith
On Tue, May 22, 2012 at 11:06 AM, Robert Kern wrote: > On Tue, May 22, 2012 at 9:27 AM, Nathaniel Smith wrote: >> So starting in Python 2.7 and 3.2, the Python developers have made >> DeprecationWarnings invisible by default: >>  http://docs.python.org/whatsnew/2.7.html#the-future-for-python-2-x

[Numpy-discussion] Problem with str.format() and np.recarray

2012-05-22 Thread Tom Aldcroft
I came across this problem which appears to be new in numpy 1.6.2 (vs. 1.6.1): In [17]: a = np.array([(1, )], dtype=[('a', 'i4')]) In [18]: ra = a.view(np.recarray) In [19]: '{}'.format(ra[0]) --- RuntimeError

[Numpy-discussion] assign a float number to a member of integer array always return integer

2012-05-22 Thread Chao YUE
Dear all, Just in case some one didn't know this. Assign a float number to an integer array element will always return integer. In [4]: a=np.arange(2,11,2) In [5]: a Out[5]: array([ 2, 4, 6, 8, 10]) In [6]: a[1]=4.5 In [7]: a Out[7]: array([ 2, 4, 6, 8, 10]) so I would always do this if

Re: [Numpy-discussion] un-silencing Numpy's deprecation warnings

2012-05-22 Thread Robert Kern
On Tue, May 22, 2012 at 11:14 AM, Dag Sverre Seljebotn wrote: > On 05/22/2012 12:06 PM, Robert Kern wrote: >> On Tue, May 22, 2012 at 9:27 AM, Nathaniel Smith  wrote: >>> So maybe we should change all our DeprecationWarnings into >>> FutureWarnings (or at least the ones that we actually plan to f

Re: [Numpy-discussion] un-silencing Numpy's deprecation warnings

2012-05-22 Thread Dag Sverre Seljebotn
On 05/22/2012 12:06 PM, Robert Kern wrote: > On Tue, May 22, 2012 at 9:27 AM, Nathaniel Smith wrote: >> So starting in Python 2.7 and 3.2, the Python developers have made >> DeprecationWarnings invisible by default: >> http://docs.python.org/whatsnew/2.7.html#the-future-for-python-2-x >> http:

Re: [Numpy-discussion] un-silencing Numpy's deprecation warnings

2012-05-22 Thread Robert Kern
On Tue, May 22, 2012 at 9:27 AM, Nathaniel Smith wrote: > So starting in Python 2.7 and 3.2, the Python developers have made > DeprecationWarnings invisible by default: >  http://docs.python.org/whatsnew/2.7.html#the-future-for-python-2-x >  http://mail.python.org/pipermail/stdlib-sig/2009-Novembe

Re: [Numpy-discussion] un-silencing Numpy's deprecation warnings

2012-05-22 Thread Peter
On Tue, May 22, 2012 at 9:27 AM, Nathaniel Smith wrote: > So starting in Python 2.7 and 3.2, the Python developers have made > DeprecationWarnings invisible by default: >  http://docs.python.org/whatsnew/2.7.html#the-future-for-python-2-x >  http://mail.python.org/pipermail/stdlib-sig/2009-Novembe

Re: [Numpy-discussion] Separating out the maskna code

2012-05-22 Thread Nathaniel Smith
On Tue, May 22, 2012 at 5:34 AM, Travis Oliphant wrote: > Just to be clear.   Are we waiting for the conclusion of the PyArray_Diagonal > PR before proceeding with this one? We can talk about this one and everyone's welcome to look at the patch, of course. (In fact it'd be useful if anyone catch

[Numpy-discussion] un-silencing Numpy's deprecation warnings

2012-05-22 Thread Nathaniel Smith
So starting in Python 2.7 and 3.2, the Python developers have made DeprecationWarnings invisible by default: http://docs.python.org/whatsnew/2.7.html#the-future-for-python-2-x http://mail.python.org/pipermail/stdlib-sig/2009-November/000789.html http://bugs.python.org/issue7319 The only way t