Re: [Numpy-discussion] bug in genfromtxt for python 3.2

2011-03-29 Thread Matthew Brett
Hi, On Mon, Mar 28, 2011 at 11:29 PM, wrote: > numpy/lib/test_io.py    only uses StringIO in the test, no actual csv file > > If I give the filename than I get a  TypeError: Can't convert 'bytes' > object to str implicitly > > > from the statsmodels mailing list example > > data = recfromtxt

Re: [Numpy-discussion] ANN: Numpy 1.6.0 beta 1

2011-03-29 Thread Russell E. Owen
In article , Ralf Gommers wrote: > Hi, > > I am pleased to announce the availability of the first beta of NumPy > 1.6.0. Due to the extensive changes in the Numpy core for this > release, the beta testing phase will last at least one month. Please > test this beta and report any problems on th

Re: [Numpy-discussion] loadtxt/savetxt tickets

2011-03-29 Thread Stéfan van der Walt
On Sun, Mar 27, 2011 at 12:09 PM, Paul Anton Letnes wrote: > I am sure someone has been using this functionality to convert floats to > ints. Changing will break their code. I am not sure how big a deal that would > be. Also, I am of the opinion that one should _first_ write a program that > wo

Re: [Numpy-discussion] histogram normed/density keyword (#1628)

2011-03-29 Thread Ralf Gommers
On Sun, Mar 27, 2011 at 11:56 AM, Ralf Gommers wrote: > Hi all, > > For the 1.6 release #1628 needs to be resolved. A while ago there was > a discussion about the normed keyword in histogram, which ATM has > changed behavior compared to numpy 1.5.1. The preferred fix as I read > the discussion >

Re: [Numpy-discussion] stable sort on a recarray ?

2011-03-29 Thread Peter Butterworth
np.lexsort does the job for both the single or multi-column stable sort cases, thanks. a = np.array([('a', 1, 1), ('a', 0, 1), ('a', 0, 0), ('b', 0, 2)], dtype=[('name', '|S10'), ('x', '> sortind array([1, 2, 0, 3], dtype=int64) >> a[sortind] array([('a', 0, 1), ('a', 0, 0), ('a', 1, 1), ('b', 0,

Re: [Numpy-discussion] stable sort on a recarray ?

2011-03-29 Thread Robert Kern
On Tue, Mar 29, 2011 at 13:33, wrote: > Any suggestions on how to achieve stable sort based on multiple columns with > numpy ? http://docs.scipy.org/doc/numpy/reference/generated/numpy.lexsort.html#numpy.lexsort It uses mergesort for stability. -- Robert Kern "I have come to believe that th

Re: [Numpy-discussion] stable sort on a recarray ?

2011-03-29 Thread butterw
sortind = np.argsort(x['name'], kind='mergesort'); x[sortind] The indirect sorting method that was suggested works for doing stable sort on recarrays / structured arrays based on a single-column. # It is necessary to specify kind='mergesort' because argsort is not stable: np.argsort(np.ones

Re: [Numpy-discussion] random number genration

2011-03-29 Thread Warren Weckesser
On Tue, Mar 29, 2011 at 11:59 AM, Sturla Molden wrote: > Den 29.03.2011 16:49, skrev Sturla Molden: > > > > This will not work. A boolean array is not compactly stored, but an > > array of bytes. Only the first bit 0 is 1 with probability p, bits 1 to > > 7 bits are 1 with probability 0. We thus

Re: [Numpy-discussion] random number genration

2011-03-29 Thread Sturla Molden
Den 29.03.2011 16:49, skrev Sturla Molden: > > This will not work. A boolean array is not compactly stored, but an > array of bytes. Only the first bit 0 is 1 with probability p, bits 1 to > 7 bits are 1 with probability 0. We thus have to do this 8 times for > each byte, shift left by range(8), an

Re: [Numpy-discussion] np.histogram on arrays.

2011-03-29 Thread eat
Hi, On Tue, Mar 29, 2011 at 5:13 PM, Éric Depagne wrote: > > FWIW, have you considered to use > > > http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogramdd.html# > > numpy.histogramdd > > > > Regards, > > eat > > > I tried, but I get a > /usr/lib/pymodules/python2.6/numpy/lib/funct

Re: [Numpy-discussion] random number genration

2011-03-29 Thread Robert Kern
On Tue, Mar 29, 2011 at 09:49, Sturla Molden wrote: > Den 29.03.2011 15:46, skrev Daniel Lepage: >> >> x = (np.random.random(size)<  p) > > This will not work. A boolean array is not compactly stored, but an > array of bytes. Only the first bit 0 is 1 with probability p, bits 1 to > 7 bits are 1 w

Re: [Numpy-discussion] random number genration

2011-03-29 Thread Sturla Molden
Den 29.03.2011 16:49, skrev Sturla Molden: "Only the first bit 0 is 1 with probability p, bits 1 to 7 bits are 1 with probability 0." That should read: "Only bit 0 is 1 with probability p, bits 1 to 7 are 1 with probability 0." Sorry :) Sturla __

Re: [Numpy-discussion] random number genration

2011-03-29 Thread Sturla Molden
Den 29.03.2011 15:46, skrev Daniel Lepage: > > x = (np.random.random(size)< p) This will not work. A boolean array is not compactly stored, but an array of bytes. Only the first bit 0 is 1 with probability p, bits 1 to 7 bits are 1 with probability 0. We thus have to do this 8 times for each b

Re: [Numpy-discussion] np.histogram on arrays.

2011-03-29 Thread Éric Depagne
> FWIW, have you considered to use > http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogramdd.html# > numpy.histogramdd > > Regards, > eat > I tried, but I get a /usr/lib/pymodules/python2.6/numpy/lib/function_base.pyc in histogramdd(sample, bins, range, normed, weights) 370

Re: [Numpy-discussion] random number genration

2011-03-29 Thread Daniel Lepage
On Tue, Mar 29, 2011 at 5:00 AM, Alex Ter-Sarkissov wrote: > If I want to generate a string of random bits with equal probability I run > > random.randint(0,2,size). > > What if I want a specific proportion of bits? In other words, each bit is 1 > with probability p<1/2 and 0 with probability q=1-

Re: [Numpy-discussion] np.histogram on arrays.

2011-03-29 Thread eat
Hi, On Tue, Mar 29, 2011 at 4:29 PM, Éric Depagne wrote: > Hi all. > > Sorry if this question has already been asked. I've searched the archive, > but > could not find anything related, so here is my question. > > I'm using np.histogram on a 4000x4000 array, each with 200 bins. I do that > on >

[Numpy-discussion] np.histogram on arrays.

2011-03-29 Thread Éric Depagne
Hi all. Sorry if this question has already been asked. I've searched the archive, but could not find anything related, so here is my question. I'm using np.histogram on a 4000x4000 array, each with 200 bins. I do that on both dimensions, meaning I compute 8000 histograms. It takes around 5 seco

Re: [Numpy-discussion] random number genration

2011-03-29 Thread Sturla Molden
Den 29.03.2011 14:56, skrev Sturla Molden: > import numpy as np > def randombits(n, p): > b = (np.random.rand(n*8).reshape((n,8))< p).astype(int) > return (b<< range(8)).sum(axis=1).astype(np.uint8) n is the number of bytes. If you prefer to count in bits: def randombits(n, p):

Re: [Numpy-discussion] random number genration

2011-03-29 Thread Sturla Molden
Den 29.03.2011 11:00, skrev Alex Ter-Sarkissov: > If I want to generate a string of random bits with equal probability I > run > > random.randint(0,2,size). > > What if I want a specific proportion of bits? In other words, each bit > is 1 with probability p<1/2 and 0 with probability q=1-p? Does

Re: [Numpy-discussion] random number genration

2011-03-29 Thread eat
On Tue, Mar 29, 2011 at 1:29 PM, eat wrote: > Hi, > > On Tue, Mar 29, 2011 at 12:00 PM, Alex Ter-Sarkissov > wrote: > >> If I want to generate a string of random bits with equal probability I run >> >> >> random.randint(0,2,size). >> >> What if I want a specific proportion of bits? In other word

Re: [Numpy-discussion] random number genration

2011-03-29 Thread eat
Hi, On Tue, Mar 29, 2011 at 12:00 PM, Alex Ter-Sarkissov wrote: > If I want to generate a string of random bits with equal probability I run > > random.randint(0,2,size). > > What if I want a specific proportion of bits? In other words, each bit is 1 > with probability p<1/2 and 0 with probabilit

[Numpy-discussion] random number genration

2011-03-29 Thread Alex Ter-Sarkissov
If I want to generate a string of random bits with equal probability I run random.randint(0,2,size). What if I want a specific proportion of bits? In other words, each bit is 1 with probability p<1/2 and 0 with probability q=1-p? thanks ___ NumPy-Discu

Re: [Numpy-discussion] npz load on numpy 3

2011-03-29 Thread Pauli Virtanen
Tue, 29 Mar 2011 08:27:52 +, Pauli Virtanen wrote: > Tue, 29 Mar 2011 04:16:00 -0400, josef.pktd wrote: >> Traceback (most recent call last): >> File "", line 1, in >> File "C:\Programs\Python32\lib\site-packages\numpy\lib\npyio.py", >> line 222, in __getitem__ >> return format.read_ar

Re: [Numpy-discussion] npz load on numpy 3

2011-03-29 Thread Pauli Virtanen
Tue, 29 Mar 2011 04:16:00 -0400, josef.pktd wrote: > Traceback (most recent call last): > File "", line 1, in > File "C:\Programs\Python32\lib\site-packages\numpy\lib\npyio.py", > line 222, in __getitem__ > return format.read_array(value) > File "C:\Programs\Python32\lib\site-packages\nu

[Numpy-discussion] npz load on numpy 3

2011-03-29 Thread josef . pktd
more python 3.2 fun a npz file saved with python 2.6 (I guess) that I try to read with python 3.2 I have no clue, since I never use .npz files >>> arr = >>> np.load(r"..\scikits\statsmodels\tsa\vector_ar\tests\results\vars_results.npz") >>> arr >>> dir(arr) ['__class__', '__contains__', '__de

Re: [Numpy-discussion] Array views

2011-03-29 Thread Pearu Peterson
On Tue, Mar 29, 2011 at 11:03 AM, Dag Sverre Seljebotn < d.s.seljeb...@astro.uio.no> wrote: > > I think it should be a(1:n*stride:stride) or something. > > Yes, it was my typo and I assumed that n is the length of the original array. Pearu ___ NumPy-Dis

Re: [Numpy-discussion] Array views

2011-03-29 Thread Dag Sverre Seljebotn
On 03/29/2011 09:35 AM, Pearu Peterson wrote: On Tue, Mar 29, 2011 at 8:13 AM, Pearu Peterson mailto:pearu.peter...@gmail.com>> wrote: On Mon, Mar 28, 2011 at 10:44 PM, Sturla Molden mailto:stu...@molden.no>> wrote: Den 28.03.2011 19:12, skrev Pearu Peterson: >

Re: [Numpy-discussion] Array views

2011-03-29 Thread Pearu Peterson
On Tue, Mar 29, 2011 at 8:13 AM, Pearu Peterson wrote: > > > On Mon, Mar 28, 2011 at 10:44 PM, Sturla Molden wrote: > >> Den 28.03.2011 19:12, skrev Pearu Peterson: >> > >> > FYI, f2py in numpy 1.6.x supports also assumed shape arrays. >> >> How did you do that? Chasm-interop, C bindings from F03