[Numpy-discussion] bug in genfromtxt for python 3.2

2011-03-29 Thread josef . pktd
numpy/lib/test_io.pyonly 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(open('./star98.csv', U), delimiter=,, skip_header=1,

Re: [Numpy-discussion] Array views

2011-03-29 Thread Pearu Peterson
On Tue, Mar 29, 2011 at 8:13 AM, Pearu Peterson pearu.peter...@gmail.comwrote: On Mon, Mar 28, 2011 at 10:44 PM, Sturla Molden stu...@molden.no 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?

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 pearu.peter...@gmail.com mailto:pearu.peter...@gmail.com wrote: On Mon, Mar 28, 2011 at 10:44 PM, Sturla Molden stu...@molden.no mailto:stu...@molden.no wrote: Den 28.03.2011

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-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 numpy.lib.npyio.NpzFile object at 0x03874AC8

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 stdin, line 1, in module File C:\Programs\Python32\lib\site-packages\numpy\lib\npyio.py, line 222, in __getitem__ return format.read_array(value) File

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 stdin, line 1, in module File C:\Programs\Python32\lib\site-packages\numpy\lib\npyio.py, line 222, in __getitem__ return

[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 p1/2 and 0 with probability q=1-p? thanks ___

Re: [Numpy-discussion] random number genration

2011-03-29 Thread eat
Hi, On Tue, Mar 29, 2011 at 12:00 PM, Alex Ter-Sarkissov ater1...@gmail.comwrote: 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 p1/2 and 0

Re: [Numpy-discussion] random number genration

2011-03-29 Thread eat
On Tue, Mar 29, 2011 at 1:29 PM, eat e.antero.ta...@gmail.com wrote: Hi, On Tue, Mar 29, 2011 at 12:00 PM, Alex Ter-Sarkissov ater1...@gmail.comwrote: 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

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 p1/2 and 0 with probability q=1-p? Does this

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):

[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

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

2011-03-29 Thread eat
Hi, On Tue, Mar 29, 2011 at 4:29 PM, Éric Depagne e...@depagne.org 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

Re: [Numpy-discussion] random number genration

2011-03-29 Thread Daniel Lepage
On Tue, Mar 29, 2011 at 5:00 AM, Alex Ter-Sarkissov ater1...@gmail.com 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 p1/2 and 0 with

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 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

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 Robert Kern
On Tue, Mar 29, 2011 at 09:49, Sturla Molden stu...@molden.no 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

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

2011-03-29 Thread eat
Hi, On Tue, Mar 29, 2011 at 5:13 PM, Éric Depagne e...@depagne.org 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

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), and

Re: [Numpy-discussion] random number genration

2011-03-29 Thread Warren Weckesser
On Tue, Mar 29, 2011 at 11:59 AM, Sturla Molden stu...@molden.no 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.

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:

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

2011-03-29 Thread Robert Kern
On Tue, Mar 29, 2011 at 13:33, butt...@gmail.com 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

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', 'i4'), ('y', 'i4')]) sortind = np.lexsort([a['x'], a['name']]) sortind array([1, 2, 0, 3], dtype=int64)

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 ralf.gomm...@googlemail.com 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

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 paul.anton.let...@gmail.com 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_

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

2011-03-29 Thread Russell E. Owen
In article AANLkTi=eeg8kl7639imrtl-ihg1ncqyolddsid5tf...@mail.gmail.com, Ralf Gommers ralf.gomm...@googlemail.com 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

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, josef.p...@gmail.com 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 =