Re: [Numpy-discussion] Numpy unexpected (for me) behaviour

2009-01-22 Thread Matthew Brett
> Judging from his for loop, he does want the integer array. He's doing > something like histogramming. Yup, thanks, just goes to show that it's not good to send emails after a glass of wine late at night with slight jetlag. Matthew ___ Numpy-discussion

Re: [Numpy-discussion] Numpy unexpected (for me) behaviour

2009-01-22 Thread Robert Kern
On Fri, Jan 23, 2009 at 01:11, V. Armando Sole wrote: > Hello, > > In an effort to suppress for loops, I have arrived to the following situation. > > Through vectorial logical operations I generate a set of indices for which > the contents of an array have to be incremented. My problem can be redu

Re: [Numpy-discussion] Numpy unexpected (for me) behaviour

2009-01-22 Thread Robert Kern
On Fri, Jan 23, 2009 at 01:39, Matthew Brett wrote: > Hi, > >> #This does not work >> import numpy >> a=numpy.zeros(10) >> b=numpy.ones(4, numpy.int) >> a[b] += 1 > > The problem here is that you are setting a[1] to a[1]+1. > > I think you want: > > import numpy > a=numpy.zeros(10) > b=numpy.ones

Re: [Numpy-discussion] Numpy unexpected (for me) behaviour

2009-01-22 Thread Matthew Brett
Hi, > #This does not work > import numpy > a=numpy.zeros(10) > b=numpy.ones(4, numpy.int) > a[b] += 1 The problem here is that you are setting a[1] to a[1]+1. I think you want: import numpy a=numpy.zeros(10) b=numpy.ones(4, numpy.bool) a[b] += 1 Best, Matthew

[Numpy-discussion] Numpy unexpected (for me) behaviour

2009-01-22 Thread V. Armando Sole
Hello, In an effort to suppress for loops, I have arrived to the following situation. Through vectorial logical operations I generate a set of indices for which the contents of an array have to be incremented. My problem can be reduced to the following: #This works import numpy a=numpy.zeros(1

Re: [Numpy-discussion] numpy.array and subok kwarg

2009-01-22 Thread Scott Sinclair
> 2009/1/22 Pierre GM : > Darren, > > >> The type returned by np.array is ndarray, unless I specifically set >> subok=True, in which case I get a MyArray. The default value of >> subok is True, so I dont understand why I have to specify subok >> unless I want it to be False. Is my subclass missing

[Numpy-discussion] N-D array interface page is out of date

2009-01-22 Thread Andrew Straw
Hi, I just noticed that the N-D array interface page is outdated and doesn't mention the buffer interface that is standard with Python 2.6 and Python 3.0: http://numpy.scipy.org/array_interface.shtml This page is linked to from http://numpy.scipy.org/ I suggest, at the minimum, modifying the pag

Re: [Numpy-discussion] range in numpy where

2009-01-22 Thread Eric Firing
Ross Williamson wrote: > Hi All > > I want to get out the index of values in an array. Normally WHERE > works fine for one conditional statement but it does not work for two > - i.e. > > a = array([0,1,2,3,4,5,6,7,8,9]) > > ind, = where(a > 5) > > Works fine but if I wanted: > > ind = wher

[Numpy-discussion] range in numpy where

2009-01-22 Thread Ross Williamson
Hi All I want to get out the index of values in an array. Normally WHERE works fine for one conditional statement but it does not work for two - i.e. a = array([0,1,2,3,4,5,6,7,8,9]) ind, = where(a > 5) Works fine but if I wanted: ind = where((a > 5) and (a<8)) Then it bugs out with the f

Re: [Numpy-discussion] python numpy code many times slower than c++

2009-01-22 Thread Wes McKinney
Windows XP, Pentium D, Python 2.5.2 On Thu, Jan 22, 2009 at 6:03 PM, Robert Kern wrote: > On Thu, Jan 22, 2009 at 17:00, Wes McKinney wrote: > > import cProfile > > > > def f(): > > pass > > > > def g(): > > for i in xrange(100): > > f() > > > > cProfile.run("g()") > > > >>t

Re: [Numpy-discussion] python numpy code many times slower than c++

2009-01-22 Thread Robert Kern
On Thu, Jan 22, 2009 at 17:00, Wes McKinney wrote: > import cProfile > > def f(): > pass > > def g(): > for i in xrange(100): > f() > > cProfile.run("g()") > >>test.py > 103 function calls in 1.225 CPU seconds > >Ordered by: standard name > >ncalls tottime

Re: [Numpy-discussion] python numpy code many times slower than c++

2009-01-22 Thread Wes McKinney
import cProfile def f(): pass def g(): for i in xrange(100): f() cProfile.run("g()") >test.py 103 function calls in 1.225 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 10.0000.0

Re: [Numpy-discussion] have to use matlab: what is the equiv. to pdb.pm()

2009-01-22 Thread Matthew Brett
Did you say "matlab" ? ;-) > I have to debug a matlab program -- is there a way to do a "post > mortem" debugging ? > (I don't even know if this term even exists outside of python ;-) > ((I want to know some local variable values and find out why our > program crashes when "there are no particles

[Numpy-discussion] have to use matlab: what is the equiv. to pdb.pm()

2009-01-22 Thread Sebastian Haase
Hi, I have to debug a matlab program -- is there a way to do a "post mortem" debugging ? (I don't even know if this term even exists outside of python ;-) ((I want to know some local variable values and find out why our program crashes when "there are no particles found"...)) Thanks, Sebastian Ha

Re: [Numpy-discussion] Failures in test_recfunctions.py

2009-01-22 Thread Pierre GM
On Jan 22, 2009, at 1:31 PM, Nils Wagner wrote: >> > Hi Pierre, > > Thank you. Works for me. You're welcome, thanks for reporting! ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Failures in test_recfunctions.py

2009-01-22 Thread Nils Wagner
On Thu, 22 Jan 2009 12:53:39 -0500 Pierre GM wrote: > Interesting. > The tests pass on my machine > OS X, > Python version 2.5.4 (r254:67916, Dec 29 2008, 17:02:44) >[GCC 4.0.1 > (Apple Inc. build 5488)] > nose version 0.10.4 > >For >> File >> "/home/nwagner/local/lib64/python2.6/site-pack

Re: [Numpy-discussion] Failures in test_recfunctions.py

2009-01-22 Thread Pierre GM
Interesting. The tests pass on my machine OS X, Python version 2.5.4 (r254:67916, Dec 29 2008, 17:02:44) [GCC 4.0.1 (Apple Inc. build 5488)] nose version 0.10.4 For > File > "/home/nwagner/local/lib64/python2.6/site-packages/numpy/lib/tests/ > test_recfunctions.py", > line 34, in test_zip_des

[Numpy-discussion] Failures in test_recfunctions.py

2009-01-22 Thread Nils Wagner
>>> numpy.__version__ '1.3.0.dev6331' == FAIL: Test the ignoremask option of find_duplicates -- Traceback (most recent call last): File "/home/nwagner/local/l

Re: [Numpy-discussion] default float type of array not accepted by SWIG wrapped C functions

2009-01-22 Thread Spotz, William F
Rich, Basic python only supports double precision floats, so that is not an option. NumPy does not have, as far as I know, a way to set the default precision, although it might be a reasonable request. As for the SWIG interface file, almost anything is possible. Can you give an example of a f

[Numpy-discussion] default float type of array not accepted by SWIG wrapped C functions

2009-01-22 Thread Rich E
Hi all, I have a SWIG wrapped C library that uses 32bit floating point arrays, using the numpy.i typemapping system for passing the arrays. For every array that I make, I have to convert it using astype('float32'), else python complains that I tried to pass a double-precision array. Is there any

Re: [Numpy-discussion] numpy.array and subok kwarg

2009-01-22 Thread Pierre GM
Darren, > The type returned by np.array is ndarray, unless I specifically set > subok=True, in which case I get a MyArray. The default value of > subok is True, so I dont understand why I have to specify subok > unless I want it to be False. Is my subclass missing something > important?

[Numpy-discussion] numpy.array and subok kwarg

2009-01-22 Thread Darren Dale
Hello, I have a test script: import numpy as np class MyArray(np.ndarray): __array_priority__ = 20 def __new__(cls): return np.asarray(1).view(cls).copy() def __repr__(self): return 'my_array' __str__ = __repr__ def __mul__(self, other): return s

[Numpy-discussion] Tutorial on working with Excel files in Python (without COM and cross platform!) at PyConUS 2009

2009-01-22 Thread Chris Withers
Hi All, Too many people in the Python community think the only way to work with Excel files in Python is using COM on Windows. To try and correct this, I'm giving a tutorial at this year's PyCon in Chicago on Wednesday, 25th March that will cover working with Excel files in Python using the pur

[Numpy-discussion] header option for savetxt

2009-01-22 Thread Nils Wagner
Hi all, Is it possible to add a header option for savetxt ? Nils ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] array manipulation

2009-01-22 Thread Nils Wagner
On Thu, 22 Jan 2009 11:23:43 +0100 Robert Cimrman wrote: > Nils Wagner wrote: >> Hi all, >> >> what is the best way to check if the entries (integers) >> of an array are stored in ascending order ? > > Hi Nils, > > Try np.alltrue( ar[1:] > ar[:-1] ). > > r. Thank you ! Nils _

Re: [Numpy-discussion] array manipulation

2009-01-22 Thread Robert Cimrman
Nils Wagner wrote: > Hi all, > > what is the best way to check if the entries (integers) > of an array are stored in ascending order ? Hi Nils, Try np.alltrue( ar[1:] > ar[:-1] ). r. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://

[Numpy-discussion] array manipulation

2009-01-22 Thread Nils Wagner
Hi all, what is the best way to check if the entries (integers) of an array are stored in ascending order ? Nils ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] new incremental statistics project

2009-01-22 Thread David Cournapeau
On Mon, Jan 19, 2009 at 7:34 PM, Hans Meine wrote: > On Friday 19 December 2008 03:27:12 Bradford Cross wrote: >> This is a new project I just released. >> >> I know it is C#, but some of the design and idioms would be nice in >> numpy/scipy for working with discrete event simulators, time series,