[Numpy-discussion] sorting and nans, timings.

2009-07-22 Thread Charles R Harris
Hi All, I changed the sort routines to sort nans to the end and got some timings. Sorting 10 random doubles 100 times yields: current nan version quicksort 1.17 sec1.29 sec mergesort 1.37 sec1.36 sec heapsort 1.83 sec2.12 sec Curiously, mergesort doe

Re: [Numpy-discussion] ValueError: cannot convert float to NaN to integer

2009-07-22 Thread Robert Kern
On Wed, Jul 22, 2009 at 13:35, Keith Goodman wrote: > On Ubuntu 9.04, python 2.6.2, numpy 1.2.1 this gives a ValueError: > > x = np.array([1,2,3]) > x[0] = np.nan > ValueError: cannot convert float to NaN to integer > > But on Debian squeeze, python 2.5.4, numpy 1.2.1 the assignment works > (well,

Re: [Numpy-discussion] performance matrix multiplication vs. matlab

2009-07-22 Thread Jonathan Taylor
Sorry. I meant to update this thread after I had resolved my issue. This was indeed one problem. I had to set LD_LIBRARY_PATH. I also had another odd problem that I will spell out here in hopes that I save someone some trouble. Specifically, one should be very sure that the path to the blas tha

Re: [Numpy-discussion] String manipulation

2009-07-22 Thread David Goldsmith
By the way, Chris, what's it gonna take to get you contributing to the doc? ;-) DG --- On Wed, 7/22/09, Christopher Barker wrote: > From: Christopher Barker > Subject: Re: [Numpy-discussion] String manipulation > To: "Discussion of Numerical Python" > Date: Wednesday, July 22, 2009, 11:33 AM

[Numpy-discussion] ValueError: cannot convert float to NaN to integer

2009-07-22 Thread Keith Goodman
On Ubuntu 9.04, python 2.6.2, numpy 1.2.1 this gives a ValueError: x = np.array([1,2,3]) x[0] = np.nan ValueError: cannot convert float to NaN to integer But on Debian squeeze, python 2.5.4, numpy 1.2.1 the assignment works (well, the float nan is convert to the int 0): x[0] = np.nan x array(

Re: [Numpy-discussion] String manipulation

2009-07-22 Thread Christopher Barker
Stéfan van der Walt wrote: You cannot use view on an array scalar, so you'll have to convert to an array first: x = x.reshape((1,)) x.view('S1') Bingo! Thanks, Stéfan. I don't know why one can't uwe view on a scalar -- there is still a dat pointer isn't there?, and it can be reshaped. Butno

Re: [Numpy-discussion] Overloading numpy's ufuncs for better type coercion?

2009-07-22 Thread Charles R Harris
2009/7/22 Hans Meine > Hi! > > (This mail is a reply to a personal conversation with Ullrich Köthe, but is > obviously of a greater concern. This is about VIGRA's new NumPy-based > python > bindings.) Ulli considers this behaviour of NumPy to be a bug: > > In [1]: a = numpy.array([200], numpy.u

Re: [Numpy-discussion] Overloading numpy's ufuncs for better type coercion?

2009-07-22 Thread Christopher Barker
Hans Meine wrote: > In [3]: numpy.add(a, a, numpy.empty((1, ), dtype = numpy.uint32)) > Out[3]: array([144], dtype=uint32) yes, it sure would be nice to fix this... > one will often end up with uint8 arrays which cannot be passed > into many algorithms without an explicit conversion. However, i

Re: [Numpy-discussion] Getting 95%/99% margin of ndarray

2009-07-22 Thread Citi, Luca
I am afraid I misunderstand your question because I do not get the results you expected. def pdyn(a, p): a = np.sort(a) n = round((1-p) * len(a)) return a[int((n+1)/2)], a[len(a)-1-int(n/2)] # a[-int(n/2)] would not work if n<=1 >>> pdyn([0, 0, 0, 0, 1, 2, 3, 4, 5, 2000], 1) (0, 2000

Re: [Numpy-discussion] branches/datetime

2009-07-22 Thread Pierre GM
On Jul 22, 2009, at 11:34 AM, Peter Alexander wrote: > Hi all, > > I see life in a feature I've been dreaming about for years now. :-) > I'm wondering how stable this branch is and if it's ready for > playing with. I may speak out of turn here, but I don't think so. Besides Travis O. who doe

Re: [Numpy-discussion] Getting 95%/99% margin of ndarray

2009-07-22 Thread Pierre GM
On Jul 22, 2009, at 12:36 PM, Johannes Bauer wrote: > Hello list, > > is there some possibilty to get a p-dynamic of an array, i.e. if p=1 > then the result would be (arr.min(), arr.max()), but if 0 < p < 1, > then > the result is so that the pth percentile of the picture is withing the > range

Re: [Numpy-discussion] Getting 95%/99% margin of ndarray

2009-07-22 Thread Citi, Luca
You can do it "by hand" by sorting the array and taking the corresponding elements or you can use scipy.stats.scoreatpercentile that also interpolates. Best, Luca ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/l

[Numpy-discussion] Getting 95%/99% margin of ndarray

2009-07-22 Thread Johannes Bauer
Hello list, is there some possibilty to get a p-dynamic of an array, i.e. if p=1 then the result would be (arr.min(), arr.max()), but if 0 < p < 1, then the result is so that the pth percentile of the picture is withing the range given? I cannot explain this very well, so please let me illustrate

[Numpy-discussion] ANN: SciPy 2009 early registration ends today

2009-07-22 Thread Jarrod Millman
Today is the last day to register for SciPy 2009 at the early bird rates. Please register (http://conference.scipy.org/to_register ) by the end of the day to take advantage of the reduced early registration rate. The conference schedule is available here: http://conference.scipy.org/schedule The

Re: [Numpy-discussion] How to detect ndarrays pointing to the same memory?

2009-07-22 Thread Hans Meine
On Wednesday 22 July 2009 11:48:29 Gael Varoquaux wrote: > On Fri, Jul 17, 2009 at 04:30:38PM +0200, Hans Meine wrote: > > I have a simple question: How can I detect whether two arrays share the > > same data? > > np.may_share_memory Thanks a lot, that (and it's implementation, cf. byte_bounds) do

Re: [Numpy-discussion] Comparing the precision of dtypes?

2009-07-22 Thread Ralf Gommers
2009/7/22 Hans Meine > On Wednesday 22 July 2009 17:16:31 Ralf Gommers wrote: > > 2009/7/22 Hans Meine > > > type = min(float32, a.dtype.type, b.dtype.type) > > > > Are you looking for the type to cast to? In that case I guess you meant > > max() not min(). > > No, at least for integers min(..)

Re: [Numpy-discussion] Comparing the precision of dtypes?

2009-07-22 Thread Hans Meine
On Wednesday 22 July 2009 17:16:31 Ralf Gommers wrote: > 2009/7/22 Hans Meine > > type = min(float32, a.dtype.type, b.dtype.type) > > Are you looking for the type to cast to? In that case I guess you meant > max() not min(). No, at least for integers min(..) does what one would expect max(..) to

[Numpy-discussion] branches/datetime

2009-07-22 Thread Peter Alexander
Hi all, I see life in a feature I've been dreaming about for years now. :-) I'm wondering how stable this branch is and if it's ready for playing with. I ask because I'm (once again) about to write an cython extension to process vectors of epochs and records of struct tm. Naturally, I'd love to be

Re: [Numpy-discussion] Comparing the precision of dtypes?

2009-07-22 Thread Ralf Gommers
2009/7/22 Hans Meine > Hi, > > Ullrich Köthe found an interesting way to compute a promoted dtype, given > two > arrays a and b: > > type = min(float32, a.dtype.type, b.dtype.type) > Are you looking for the type to cast to? In that case I guess you meant max() not min(). > > How hackish is thi

Re: [Numpy-discussion] Overloading numpy's ufuncs for bettertypecoercion?

2009-07-22 Thread Citi, Luca
Hello Hans, > Although it should be noted that in C/C++, > the result of uint8+uint8 is int. But C/C++ works with scalars and often temporary results are kept in registers. On the contrary, numpy works with arrays. We cannot expect (a+b)*c to grow from uint8 to uint16 and then uint32 :-D > For e

Re: [Numpy-discussion] Overloading numpy's ufuncs for better typecoercion?

2009-07-22 Thread Hans Meine
On Wednesday 22 July 2009 15:14:32 Citi, Luca wrote: > In [2]: a + a > Out[2]: array([144], dtype=uint8) > > Please do not "fix" this, that IS the correct output. No, I did not mean to fix this. (Although it should be noted that in C/C++, the result of uint8+uint8 is int.) > If instead, you ref

Re: [Numpy-discussion] Overloading numpy's ufuncs for better typecoercion?

2009-07-22 Thread Citi, Luca
Hi Hans! > Ideally, I'd like numpy to be "fixed" what do you mean by "fixed"? Are you referring to Out[2] or Out[3]? In [1]: a = numpy.array([200], numpy.uint8) In [2]: a + a Out[2]: array([144], dtype=uint8) Please do not "fix" this, that IS the correct output. What should numpy do? Promote eve

Re: [Numpy-discussion] VIGRA, NumPy and Fortran-order (again)

2009-07-22 Thread Hans Meine
On Friday 17 July 2009 22:15:31 Pauli Virtanen wrote: > On 2009-07-17, Hans Meine wrote: > > If I understood Travis' comments in the above-mentioned thread [1] > > correctly, this would already fix some of the performance issues along > > the way (since it would suddenly allow the use of special,

[Numpy-discussion] Comparing the precision of dtypes?

2009-07-22 Thread Hans Meine
Hi, Ullrich Köthe found an interesting way to compute a promoted dtype, given two arrays a and b: type = min(float32, a.dtype.type, b.dtype.type) How hackish is this? Is this likely to break on other platforms/numpy versions? Is there a better API for type promotion? Have a nice day, Han

[Numpy-discussion] Overloading numpy's ufuncs for better type coercion?

2009-07-22 Thread Hans Meine
Hi! (This mail is a reply to a personal conversation with Ullrich Köthe, but is obviously of a greater concern. This is about VIGRA's new NumPy-based python bindings.) Ulli considers this behaviour of NumPy to be a bug: In [1]: a = numpy.array([200], numpy.uint8) In [2]: a + a Out[2]: array(

[Numpy-discussion] JIT ufuncs with PyPy

2009-07-22 Thread Stéfan van der Walt
Hi all, Pieter Holtzhausen sent me this interesting link: http://morepypy.blogspot.com/2009/07/pypy-numeric-experiments.html """ I have been playing recently with the idea of NumPy and PyPy integration. My idea is to integrate PyPy's JIT with NumPy or at least a very basic subset of it. Time con

Re: [Numpy-discussion] How to detect ndarrays pointing to the same memory?

2009-07-22 Thread Gael Varoquaux
On Fri, Jul 17, 2009 at 04:30:38PM +0200, Hans Meine wrote: > Hi, > I have a simple question: How can I detect whether two arrays share the same > data? np.may_share_memory G. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.sc

[Numpy-discussion] How to detect ndarrays pointing to the same memory?

2009-07-22 Thread Hans Meine
Hi, I have a simple question: How can I detect whether two arrays share the same data? >>> a = numpy.arange(10) >>> b = a.view(numpy.ndarray) >>> >>> a is not b # False, as expected True >>> a.data is b.data # I expected this to be True False >>> >>> a.data >>> b.data # even the memory address

Re: [Numpy-discussion] String manipulation

2009-07-22 Thread Stéfan van der Walt
2009/7/21 Christopher Barker : > In [35]: line > Out[35]: '-1.00E+00-1.00E+00-1.00E+00-1.00E+00 > 1.25E+00 1.25E+00' > > In [36]: a = np.array(line) > > In [37]: a > Out[37]: > array('-1.00E+00-1.00E+00-1.00E+00-1.00E+00 1.25E+00 > 1.25E+00', >