Re: [Numpy-discussion] Fromfile Issue

2012-03-09 Thread Warren Weckesser
On Fri, Mar 9, 2012 at 7:26 AM, Nicola Creati ncre...@inogs.it wrote: Hello, I'm writing a library able to read LAS lidar files. I generally use it under Linux without any problems. I'm now testing my library on a Windows 7 64 bit computer and I meet some problems reading the file. I

Re: [Numpy-discussion] Possible roadmap addendum: building better text file readers

2012-03-07 Thread Warren Weckesser
On Tue, Mar 6, 2012 at 4:45 PM, Chris Barker chris.bar...@noaa.gov wrote: On Thu, Mar 1, 2012 at 10:58 PM, Jay Bourque jayv...@gmail.com wrote: 1. Loading text files using loadtxt/genfromtxt need a significant performance boost (I think at least an order of magnitude increase in

Re: [Numpy-discussion] Jaccard Hamming Problem

2012-03-01 Thread Warren Weckesser
On Thu, Mar 1, 2012 at 8:43 AM, Zayd YAKOUBI zayd.yako...@gmail.com wrote: Hello, I use the similarity measure Jaccard and Hamming of pckage Scipy.spacial.cdist (Python) in a clustering context, I applied to given typs of real and integer (0.6 0.2 1.7 May 8 ). They gave good results. But I

Re: [Numpy-discussion] Possible roadmap addendum: building better text file readers

2012-02-26 Thread Warren Weckesser
On Thu, Feb 23, 2012 at 2:19 PM, Warren Weckesser warren.weckes...@enthought.com wrote: On Thu, Feb 23, 2012 at 2:08 PM, Travis Oliphant tra...@continuum.iowrote: This is actually on my short-list as well --- it just didn't make it to the list. In fact, we have someone starting work

Re: [Numpy-discussion] Possible roadmap addendum: building better text file readers

2012-02-26 Thread Warren Weckesser
On Sun, Feb 26, 2012 at 1:00 PM, Nathaniel Smith n...@pobox.com wrote: On Sun, Feb 26, 2012 at 5:23 PM, Warren Weckesser warren.weckes...@enthought.com wrote: I haven't pushed it to the extreme, but the big example (in the examples/ directory) is a 1 gig text file with 2 million rows

Re: [Numpy-discussion] Possible roadmap addendum: building better text file readers

2012-02-26 Thread Warren Weckesser
On Sun, Feb 26, 2012 at 1:49 PM, Nathaniel Smith n...@pobox.com wrote: On Sun, Feb 26, 2012 at 7:16 PM, Warren Weckesser warren.weckes...@enthought.com wrote: On Sun, Feb 26, 2012 at 1:00 PM, Nathaniel Smith n...@pobox.com wrote: For this kind of benchmarking, you'd really rather

Re: [Numpy-discussion] Possible roadmap addendum: building better text file readers

2012-02-26 Thread Warren Weckesser
On Sun, Feb 26, 2012 at 3:00 PM, Nathaniel Smith n...@pobox.com wrote: On Sun, Feb 26, 2012 at 7:58 PM, Warren Weckesser warren.weckes...@enthought.com wrote: Right, I got that. Sorry if the placement of the notes about how to clear the cache seemed to imply otherwise. OK, cool, np

Re: [Numpy-discussion] Possible roadmap addendum: building better text file readers

2012-02-23 Thread Warren Weckesser
On Thu, Feb 23, 2012 at 2:08 PM, Travis Oliphant tra...@continuum.iowrote: This is actually on my short-list as well --- it just didn't make it to the list. In fact, we have someone starting work on it this week. It is his first project so it will take him a little time to get up to speed

Re: [Numpy-discussion] strange behavior of numpy.random.multivariate_normal, ticket:1842

2012-02-16 Thread Warren Weckesser
On Thu, Feb 16, 2012 at 10:12 AM, Pierre Haessig pierre.haes...@crans.orgwrote: Le 16/02/2012 16:20, josef.p...@gmail.com a écrit : I don't see any way to fix multivariate_normal for this case, except for dropping svd or for random perturbing a covariance matrix with multiplicity of

Re: [Numpy-discussion] repeat array along new axis without making a copy

2012-02-15 Thread Warren Weckesser
On Wed, Feb 15, 2012 at 2:25 AM, Steve Schmerler elcort...@googlemail.comwrote: Hi I'd like to repeat an array along a new axis (like broadcast): In [8]: a Out[8]: array([[0, 1, 2], [3, 4, 5]]) In [9]: b=repeat(a[None,...], 3, axis=0) In [10]: b Out[10]:

Re: [Numpy-discussion] Updated differences between 1.5.1 to 1.6.1

2012-02-14 Thread Warren Weckesser
On Tue, Feb 14, 2012 at 12:25 PM, Travis Oliphant tra...@continuum.iowrote: snip There is a mailing list for numfocus that you can sign up for if you would like to be part of those discussions. Let me know if you would like more information about that. I would like more information

Re: [Numpy-discussion] avoiding loops when downsampling arrays

2012-02-06 Thread Warren Weckesser
On Mon, Feb 6, 2012 at 2:57 PM, Sturla Molden stu...@molden.no wrote: Short answer: Create 16 view arrays, each with a stride of 4 in both dimensions. Test them against the conditions and combine the tests with an |= operator. Thus you replace the nested loop with one that has only 16

Re: [Numpy-discussion] ValueError: total size of new array must be unchanged only on Windows

2012-02-05 Thread Warren Weckesser
On Sun, Feb 5, 2012 at 12:06 PM, josef.p...@gmail.com wrote: On Sun, Feb 5, 2012 at 12:52 PM, Paolo p.zaff...@yahoo.it wrote: How I can do this? I'm not sure without trying, numpy.loadtxt might be the easier choice matrix=.join((i.strip() for i in f.readlines())) I think strip()

Re: [Numpy-discussion] fast method to to count a particular value in a large matrix

2012-02-04 Thread Warren Weckesser
On Sat, Feb 4, 2012 at 2:35 PM, Benjamin Root ben.r...@ou.edu wrote: On Saturday, February 4, 2012, Naresh Pai n...@uark.edu wrote: I am somewhat new to Python (been coding with Matlab mostly). I am trying to simplify (and expedite) a piece of code that is currently a bottleneck in a

Re: [Numpy-discussion] ufunc delegation to object method

2012-02-01 Thread Warren Weckesser
Bump... On Mon, Jan 30, 2012 at 1:17 AM, Warren Weckesser warren.weckes...@enthought.com wrote: In the following code, numpy.sin() calls the object's sin() function: In [2]: class Foo(object): ...: def sin(self): ...: return spam ...: In [3]: f = Foo() In [4

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Warren Weckesser
On Tue, Jan 31, 2012 at 4:22 PM, Robert Kern robert.k...@gmail.com wrote: On Tue, Jan 31, 2012 at 22:17, Travis Oliphant tra...@continuum.io wrote: I also agree that an exception should be raised at the very least. It might also be possible to make the NumPy any, all, and sum functions

[Numpy-discussion] ufunc delegation to object method

2012-01-29 Thread Warren Weckesser
In the following code, numpy.sin() calls the object's sin() function: In [2]: class Foo(object): ...: def sin(self): ...: return spam ...: In [3]: f = Foo() In [4]: np.sin(f) Out[4]: 'spam' Is this, in fact, guaranteed behavior for a ufunc? It does not appear to be

Re: [Numpy-discussion] Array min from argmin along an axis?

2011-12-13 Thread Warren Weckesser
On Tue, Dec 13, 2011 at 4:11 PM, Ken Basye kbas...@jhu.edu wrote: Hi folks, I need an efficient way to get both the min and argmin of a 2-d array along one axis. It seemed to me that the way to do this was to get the argmin and then use it to index into the array to get the min, but I

Re: [Numpy-discussion] Fast Reading of ASCII files

2011-12-12 Thread Warren Weckesser
On Mon, Dec 12, 2011 at 10:22 AM, Chris.Barker chris.bar...@noaa.govwrote: On 12/11/11 8:40 AM, Ralf Gommers wrote: On Wed, Dec 7, 2011 at 7:50 PM, Chris.Barker chris.bar...@noaa.gov * If we have a good, fast ascii (or unicode?) to array reader, hopefully it could be leveraged for

Re: [Numpy-discussion] Convert datetime64 to python datetime.datetime in numpy 1.6.1?

2011-12-04 Thread Warren Weckesser
On Sun, Dec 4, 2011 at 5:30 AM, Didrik Pinte dpi...@enthought.com wrote: On Sun, Dec 4, 2011 at 6:11 AM, Warren Weckesser warren.weckes...@enthought.com wrote: In numpy 1.6.1, what's the most straightforward way to convert a datetime64 to a python datetime.datetime? E.g. I have In [1

[Numpy-discussion] Convert datetime64 to python datetime.datetime in numpy 1.6.1?

2011-12-03 Thread Warren Weckesser
In numpy 1.6.1, what's the most straightforward way to convert a datetime64 to a python datetime.datetime? E.g. I have In [1]: d = datetime64(2011-12-03 12:34:56.75) In [2]: d Out[2]: 2011-12-03 12:34:56.75 I want the same time as a datetime.datetime instance. My best hack so far is to

Re: [Numpy-discussion] upsample or scale an array

2011-12-02 Thread Warren Weckesser
On Sat, Dec 3, 2011 at 12:35 AM, Robin Kraft rkra...@gmail.com wrote: I need to take an array - derived from raster GIS data - and upsample or scale it. That is, I need to repeat each value in each dimension so that, for example, a 2x2 array becomes a 4x4 array as follows: [[1, 2], [3, 4]]

Re: [Numpy-discussion] how to use the name of a ndarray as a string

2011-11-18 Thread Warren Weckesser
On Fri, Nov 18, 2011 at 10:40 AM, Chao YUE chaoyue...@gmail.com wrote: Thanks to all people for this very nice discussions. the solutions are more that what I want!! and help me to clarify some concepts, and really begin to use class as a beginner :) FYI: Just a day or so ago, I stumbled

Re: [Numpy-discussion] Memory hungry reduce ops in Numpy

2011-11-15 Thread Warren Weckesser
On Tue, Nov 15, 2011 at 10:48 AM, Andreas Müller amuel...@ais.uni-bonn.dewrote: ** On 11/15/2011 05:46 PM, Andreas Müller wrote: On 11/15/2011 04:28 PM, Bruce Southey wrote: On 11/14/2011 10:05 AM, Andreas Müller wrote: On 11/14/2011 04:23 PM, David Cournapeau wrote: On Mon, Nov 14,

Re: [Numpy-discussion] speeding up the following expression

2011-11-12 Thread Warren Weckesser
On Sat, Nov 12, 2011 at 6:43 AM, josef.p...@gmail.com wrote: On Sat, Nov 12, 2011 at 3:36 AM, Geoffrey Zhu zyzhu2...@gmail.com wrote: Hi, I am playing with multiple ways to speed up the following expression (it is in the inner loop): C[1:(M - 1)]=(a * C[2:] + b * C[1:(M-1)] + c *

Re: [Numpy-discussion] speeding up the following expression

2011-11-12 Thread Warren Weckesser
On Sat, Nov 12, 2011 at 9:59 AM, josef.p...@gmail.com wrote: On Sat, Nov 12, 2011 at 10:31 AM, Warren Weckesser warren.weckes...@enthought.com wrote: On Sat, Nov 12, 2011 at 6:43 AM, josef.p...@gmail.com wrote: On Sat, Nov 12, 2011 at 3:36 AM, Geoffrey Zhu zyzhu2...@gmail.com wrote

Re: [Numpy-discussion] speeding up the following expression

2011-11-12 Thread Warren Weckesser
On Sat, Nov 12, 2011 at 11:16 AM, josef.p...@gmail.com wrote: On Sat, Nov 12, 2011 at 11:32 AM, Warren Weckesser warren.weckes...@enthought.com wrote: On Sat, Nov 12, 2011 at 9:59 AM, josef.p...@gmail.com wrote: On Sat, Nov 12, 2011 at 10:31 AM, Warren Weckesser warren.weckes

Re: [Numpy-discussion] yet another indexing question

2011-10-14 Thread Warren Weckesser
On Fri, Oct 14, 2011 at 7:04 AM, Neal Becker ndbeck...@gmail.com wrote: suppose I have: In [10]: u Out[10]: array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) And I have a vector v: v = np.array ((0,1,0,1,0)) I want to form an output vector which selects items from u where v is the

Re: [Numpy-discussion] simple vector-matrix question

2011-10-06 Thread Warren Weckesser
On Thu, Oct 6, 2011 at 7:08 AM, Neal Becker ndbeck...@gmail.com wrote: Given a vector y, I want a matrix H whose rows are y - x0 y - x1 y - x2 ... where x_i are scalars Suggestion? In [15]: import numpy as np In [16]: y = np.array([10.0, 20.0, 30.0]) In [17]: x = np.array([0, 1,

Re: [Numpy-discussion] simple vector-matrix question

2011-10-06 Thread Warren Weckesser
, Warren Weckesser wrote: On Thu, Oct 6, 2011 at 7:08 AM, Neal Becker ndbeck...@gmail.com wrote: Given a vector y, I want a matrix H whose rows are y - x0 y - x1 y - x2 ... where x_i are scalars Suggestion? In [15]: import numpy as np In [16]: y = np.array

Re: [Numpy-discussion] Indexing by label in 3rd dimension

2011-09-16 Thread Warren Weckesser
On Fri, Sep 16, 2011 at 10:18 AM, Benjamin Landenberger benjamin.landenber...@imtek.uni-freiburg.de wrote: Hello list! I have an array *mask* of shape (a, b) and another array *intensities* of shape (N, a, b), where the values in *mask* range from 0 to N-1. It is somehow similar to label

Re: [Numpy-discussion] A question about dtype syntax

2011-08-31 Thread Warren Weckesser
On Wed, Aug 31, 2011 at 9:24 AM, Jean-Baptiste Marquette marqu...@iap.frwrote: Hi Pierre, On Aug 31, 2011, at 3:40 PM, Jean-Baptiste Marquette wrote: Traceback (most recent call last): File /Users/marquett/workspace/Distort/src/StatsSep.py, line 44, in module np.savetxt(Table,

Re: [Numpy-discussion] Issue with dtype and nx1 arrays

2011-08-30 Thread Warren Weckesser
On Tue, Aug 30, 2011 at 10:34 PM, Thomas Robitaille thomas.robitai...@gmail.com wrote: Hello, Is the following behavior normal? In [1]: import numpy as np In [2]: np.dtype([('a','f4',2)]) Out[2]: dtype([('a', 'f4', (2,))]) In [3]: np.dtype([('a','f4',1)]) Out[3]: dtype([('a', 'f4')])

Re: [Numpy-discussion] How to start at line # x when using numpy.memmap

2011-08-19 Thread Warren Weckesser
On Fri, Aug 19, 2011 at 10:09 AM, Jeremy Conlin jlcon...@gmail.com wrote: On Fri, Aug 19, 2011 at 8:01 AM, Brent Pedersen bpede...@gmail.com wrote: On Fri, Aug 19, 2011 at 7:29 AM, Jeremy Conlin jlcon...@gmail.com wrote: On Fri, Aug 19, 2011 at 7:19 AM, Pauli Virtanen p...@iki.fi wrote:

Re: [Numpy-discussion] Trim a numpy array in numpy.

2011-08-16 Thread Warren Weckesser
On Tue, Aug 16, 2011 at 4:51 PM, Hongchun Jin hongchun...@gmail.com wrote: *Thanks Derek for the quick reply. But **I am sorry, I did not make it clear in my last email. Assume I have an array like * * ['CAL_LID_L2_05kmCLay-Prov-V3-01.2008-01-01T00-37-48ZD.hdf'

Re: [Numpy-discussion] SVD does not converge on clean matrix

2011-08-12 Thread Warren Weckesser
On Fri, Aug 12, 2011 at 4:03 AM, Charanpal Dhanjal dhan...@telecom-paristech.fr wrote: Thank Nadav for testing out the matrix. I wonder if you had a chance to check if the resulting decomposition contained NaN or Inf values? As far I understood, numpy.linalg.svd uses routines in LAPACK and

Re: [Numpy-discussion] how to create a block diagonal matrix by repeating the block?

2011-08-11 Thread Warren Weckesser
On Thu, Aug 11, 2011 at 7:15 PM, Fernando Perez fperez@gmail.comwrote: On Thu, Aug 11, 2011 at 4:43 PM, Jose Borreguero borregu...@gmail.com wrote: a = random.randn(3,3) b = a.reshape(1,3,3).repeat(50,axis=0) scipy.linalg.block_diag( *b ) slightly simpler, but equivalent, code:

Re: [Numpy-discussion] fast SSD

2011-06-21 Thread Warren Weckesser
On Tue, Jun 21, 2011 at 7:09 PM, Alex Flint alex.fl...@gmail.com wrote: Is there a fast way to compute an array of sum-of-squared-differences between a (small) K x K array and all K x K sub-arrays of a larger array? (i.e. each element x,y in the output array is the SSD between the small

Re: [Numpy-discussion] reinterpret complex - float

2011-06-03 Thread Warren Weckesser
On Fri, Jun 3, 2011 at 1:46 PM, Neal Becker ndbeck...@gmail.com wrote: Can I arrange to reinterpret an array of complex of length N as an array of float of length 2N, and vice-versa? If so, how? You can use the view() method (if the data is contiguous): In [14]: z = array([1.0+1j, 2.0+3j,

Re: [Numpy-discussion] New functions.

2011-05-31 Thread Warren Weckesser
On Tue, May 31, 2011 at 8:08 PM, Charles R Harris charlesr.har...@gmail.com wrote: Hi All, I've been contemplating new functions that could be added to numpy and thought I'd run them by folks to see if there is any interest. 1) Modified sort/argsort functions that return the maximum k

Re: [Numpy-discussion] How to fix my data for visualize with Mayavi2 and to use TVTK?

2011-05-27 Thread Warren Weckesser
On Fri, May 27, 2011 at 9:07 PM, Aradenatorix Veckhom Vacelaevus arad...@gmail.com wrote: Hi again: Well, finally I solved my troubles with the importation of data from the Fortran files I've mentioned here few weeks ago... but the importation using the VTK legacy formats doesn't works... I

Re: [Numpy-discussion] bug in numpy.ndarray?

2011-05-08 Thread Warren Weckesser
On Sun, May 8, 2011 at 7:23 PM, Charles R Harris charlesr.har...@gmail.comwrote: On Sun, May 8, 2011 at 3:15 PM, Paul Anton Letnes paul.anton.let...@gmail.com wrote: Hi, it seems that I have found a bug in numpy.ndarray. numpy 1.5.1, python 2.7.1 from macports on mac os x 10.6.7. I got

Re: [Numpy-discussion] Memmap with multiprocessing

2011-04-26 Thread Warren Weckesser
On Tue, Apr 26, 2011 at 4:21 PM, Ralf Gommers ralf.gomm...@googlemail.comwrote: On Mon, Apr 25, 2011 at 1:16 PM, Thiago Franco Moraes totonixs...@gmail.com wrote: Hi, Has anyone confirmed if this is a bug? Should I post this in the bug tracker? I see the same thing with recent master.

Re: [Numpy-discussion] Arrays as nested dtype

2011-04-08 Thread Warren Weckesser
On Fri, Apr 8, 2011 at 9:23 PM, Robert Love rblove_li...@comcast.netwrote: Using np.loadtxt I can easily read my file that has columns of time, mode, 3 float64 for position and 3 for velocity like this. dt = dtype([('time', '|S12'),

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] moving window product

2011-03-21 Thread Warren Weckesser
On Mon, Mar 21, 2011 at 12:10 PM, Brent Pedersen bpede...@gmail.com wrote: hi, is there a way to take the product along a 1-d array in a moving window? -- similar to convolve, with product in place of sum? currently, i'm column_stacking the array with offsets of itself into window_size

Re: [Numpy-discussion] Suggestion about reading text file and extracting data LAS format (newbie questions)

2011-03-21 Thread Warren Weckesser
On Mon, Mar 21, 2011 at 8:00 PM, Sachin Kumar Sharma ssharm...@slb.comwrote: BB, I have picked python recently and use it for simple day to day task. I am looking a routine for loading Well Log Las format and storing information as arrays or List. Las format looks like following

Re: [Numpy-discussion] Nonzero behaving strangely?

2011-03-17 Thread Warren Weckesser
On Thu, Mar 17, 2011 at 5:17 PM, santhu kumar mesan...@gmail.com wrote: Hello all, I am new to Numpy. I used to program before in matlab and am getting used to Numpy. I have a array like: res array([[ 33.35053669, 49.4615004 , 44.27631299, 1., 2. ], [ 32.84263059,

Re: [Numpy-discussion] Where can I download numpy.i?

2011-02-27 Thread Warren Weckesser
On Sun, Feb 27, 2011 at 12:26 PM, Brandt Belson bbel...@princeton.eduwrote: Thanks, but I just downloaded the source for versions 1.5.1 and 1.4.1 and neither appear to have a swig directory in doc or numpy/doc. Are you sure that it is included with the standard download from

Re: [Numpy-discussion] help with translating some matlab

2011-02-18 Thread Warren Weckesser
On Fri, Feb 18, 2011 at 12:50 PM, Neal Becker ndbeck...@gmail.com wrote: Neal Becker wrote: My translation is: x1 = rcv[n:n-N:-1] z = np.dot (P, x1.conj().transpose()) g = z / (_lambda + np.dot (x1, z)) y = np.dot (h, x1.conj().transpose()) e = x[n-N/2]

Re: [Numpy-discussion] current numpy in python 2.5 ?

2011-02-01 Thread Warren Weckesser
On Tue, Feb 1, 2011 at 9:16 AM, Charles R Harris charlesr.har...@gmail.comwrote: On Tue, Feb 1, 2011 at 8:02 AM, Mark Sienkiewicz sienk...@stsci.eduwrote: Hi, I looked on the web site, but I couldn't find a list of python versions that numpy expects to work on. Is the trunk still

Re: [Numpy-discussion] Strange behaviour of numpy.asarray() in corner case

2011-01-31 Thread Warren Weckesser
On Mon, Jan 31, 2011 at 8:32 PM, Friedrich Romstedt friedrichromst...@gmail.com wrote: 2011/1/28 Friedrich Romstedt friedrichromst...@gmail.com: numpy.asarray([X(), numpy.asarray([1, 1])]).shape (2,) numpy.asarray([numpy.asarray([1, 1]), X()]).shape () Does noone have an opinion about

Re: [Numpy-discussion] Numexpr giving randomized results on arrays larger than 2047 elements

2011-01-24 Thread Warren Weckesser
I see the same randomness, but at a different array size: In [23]: numpy.__version__ Out[23]: '1.4.0' In [24]: import numexpr In [25]: numexpr.__version__ Out[25]: '1.4.1' In [26]: x = zeros(8192)+0.01 In [27]: print evaluate('sum(x, axis=0)') 72.97 In [28]: print evaluate('sum(x, axis=0)')

Re: [Numpy-discussion] Numexpr giving randomized results on arrays larger than 2047 elements

2011-01-24 Thread Warren Weckesser
Salvatier jsalv...@u.washington.edu wrote: I also get the same issue with prod() On Mon, Jan 24, 2011 at 10:23 AM, Warren Weckesser warren.weckes...@enthought.com wrote: I see the same randomness, but at a different array size: In [23]: numpy.__version__ Out[23]: '1.4.0' In [24]: import

Re: [Numpy-discussion] itertools.combinations to numpy

2010-12-03 Thread Warren Weckesser
On Fri, Dec 3, 2010 at 6:31 AM, Mario Moura moura.ma...@gmail.com wrote: Hi Folks I have this situation from timeit import Timer reps = 5 t = Timer('itertools.combinations(range(1,10),3)', 'import itertools') print sum(t.repeat(repeat=reps, number=1)) / reps 1.59740447998e-05 t =

Re: [Numpy-discussion] Catching and dealing with floating point errors

2010-11-08 Thread Warren Weckesser
On Mon, Nov 8, 2010 at 2:17 PM, Skipper Seabold jsseab...@gmail.com wrote: On Mon, Nov 8, 2010 at 3:14 PM, Skipper Seabold jsseab...@gmail.com wrote: I am doing some optimizations on random samples. In a small number of cases, the objective is not well-defined for a given sample (it's not

Re: [Numpy-discussion] Catching and dealing with floating point errors

2010-11-08 Thread Warren Weckesser
On Mon, Nov 8, 2010 at 2:52 PM, Skipper Seabold jsseab...@gmail.com wrote: On Mon, Nov 8, 2010 at 3:45 PM, Warren Weckesser warren.weckes...@enthought.com wrote: On Mon, Nov 8, 2010 at 2:17 PM, Skipper Seabold jsseab...@gmail.com wrote: On Mon, Nov 8, 2010 at 3:14 PM, Skipper Seabold

Re: [Numpy-discussion] Catching and dealing with floating point errors

2010-11-08 Thread Warren Weckesser
On Mon, Nov 8, 2010 at 3:20 PM, Warren Weckesser warren.weckes...@enthought.com wrote: On Mon, Nov 8, 2010 at 2:52 PM, Skipper Seabold jsseab...@gmail.comwrote: On Mon, Nov 8, 2010 at 3:45 PM, Warren Weckesser warren.weckes...@enthought.com wrote: On Mon, Nov 8, 2010 at 2:17 PM

Re: [Numpy-discussion] large float32 array issue

2010-11-03 Thread Warren Weckesser
On Wed, Nov 3, 2010 at 3:54 AM, Vincent Schut sc...@sarvision.nl wrote: Hi, I'm running in this strange issue when using some pretty large float32 arrays. In the following code I create a large array filled with ones, and calculate mean and sum, first with a float64 version, then with a

Re: [Numpy-discussion] large float32 array issue

2010-11-03 Thread Warren Weckesser
On Wed, Nov 3, 2010 at 5:59 AM, Warren Weckesser warren.weckes...@enthought.com wrote: On Wed, Nov 3, 2010 at 3:54 AM, Vincent Schut sc...@sarvision.nl wrote: Hi, I'm running in this strange issue when using some pretty large float32 arrays. In the following code I create a large array

Re: [Numpy-discussion] large float32 array issue

2010-11-03 Thread Warren Weckesser
On Wed, Nov 3, 2010 at 6:39 AM, Vincent Schut sc...@sarvision.nl wrote: On 11/03/2010 12:31 PM, Warren Weckesser wrote: On Wed, Nov 3, 2010 at 5:59 AM, Warren Weckesser warren.weckes...@enthought.com mailto:warren.weckes...@enthought.com wrote: On Wed, Nov 3, 2010 at 3:54

Re: [Numpy-discussion] Extract groups of/individual bit values from UInt16 array [SEC=UNCLASSIFIED]

2010-10-12 Thread Warren Weckesser
On Tue, Oct 12, 2010 at 11:14 PM, Pinner, Luke luke.pin...@environment.gov.au wrote: I'm working with some MODIS satellite imagery. MODIS data includes a quality flag mask. For the particular dataset I'm working with, this is a two dimensional unsigned 16 bit integer array. The quality flags

Re: [Numpy-discussion] what is the best way to do a statistical mode operation?

2010-10-03 Thread Warren Weckesser
On Sun, Oct 3, 2010 at 7:41 AM, Gordon Wrigley gor...@tolomea.com wrote: I have an array of uint8's that has a shape of X*Y*Z*8, I would like to calculate modes along the 8 axis so that I end up with an array that has the shape X*Y*Z and is full of modes. I'm having problems finding a good

Re: [Numpy-discussion] Array slices and number of dimensions

2010-09-01 Thread Warren Weckesser
Thomas Robitaille wrote: Hi, I'm trying to extract sub-sections of a multidimensional array while keeping the number of dimensions the same. If I just select a specific element along a given direction, then the number of dimensions goes down by one: snip In fact, I can get what I

Re: [Numpy-discussion] array manipulation

2010-08-17 Thread Warren Weckesser
Alex Ter-Sarkissov wrote: hi, this is probably a very silly question, but I can't get my hear around it unfortunately( I have an array (say, mat=rand(3,5)) from which I 'pull out' a row (say, s1=mat[1,]). The problem is, the shape of this row s1 is not [1,5], as I would expect, but

Re: [Numpy-discussion] Find insertion point

2010-08-17 Thread Warren Weckesser
Nikolaus Rath wrote: Hello, I want to find the first i such that x[i] y and x[i+1] = y. Is there a way to do this without using a Python loop? I can't use np.searchsorted(), because my x array crosses y several times. Best, -Nikolaus Here's one way: In [32]: x Out[32]:

Re: [Numpy-discussion] Problem with loadtxt

2010-08-17 Thread Warren Weckesser
Scott MacDonald wrote: Hi, I have a text file called 'blah' that contains only the following line: 5399354557888517312,5399354557888517312 I want to load these into a numpy array as unit64's. The following script demonstrates my problem: import numpy as np with open('blah', 'r') as

Re: [Numpy-discussion] summarizing blocks of an array using a moving window

2010-07-22 Thread Warren Weckesser
Pauli Virtanen wrote: Thu, 22 Jul 2010 00:47:20 -0400, Robin Kraft wrote: [clip] Let's say the image looks like this: np.random.randint(0,2, 16).reshape(4,4) array([[0, 0, 0, 1], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 0, 0]]) I want to use a square, non-overlapping

Re: [Numpy-discussion] summarizing blocks of an array using a moving window

2010-07-22 Thread Warren Weckesser
Keith Goodman wrote: On Thu, Jul 22, 2010 at 7:48 AM, Warren Weckesser warren.weckes...@enthought.com wrote: Actually, because of the use of reshape(3,3,4), your second example does make a copy. When does reshape return a view and when does it return a copy? According

Re: [Numpy-discussion] subtract.reduce behavior

2010-07-22 Thread Warren Weckesser
John Salvatier wrote: I get the same result on 1.4.1 On Thu, Jul 22, 2010 at 1:00 PM, Johann Hibschman jhibschman+nu...@gmail.com mailto:jhibschman%2bnu...@gmail.com wrote: I'm trying to understand numpy.subtract.reduce. The documentation doesn't seem to match the behavior. The

[Numpy-discussion] Complete and build the example from the Using Numpy C-API documentation.

2010-07-20 Thread Warren Weckesser
I would like to take the example shown here: http://docs.scipy.org/doc/numpy/user/c-info.how-to-extend.html#example and complete the code so I can build and test the extension module. Is that example currently correct? It is slightly different from the older example in the numpy book, so

Re: [Numpy-discussion] Complete and build the example from the Using Numpy C-API documentation.

2010-07-20 Thread Warren Weckesser
Warren Weckesser wrote: I would like to take the example shown here: http://docs.scipy.org/doc/numpy/user/c-info.how-to-extend.html#example and complete the code so I can build and test the extension module. Is that example currently correct? It is slightly different from the older

Re: [Numpy-discussion] arr.copy(order='F') doesn't agree with docstring: what is intended behavior?

2010-06-26 Thread Warren Weckesser
Kurt Smith wrote: I'd really like arr.copy(order='F') to work -- is it supposed to as its docstring says, or is it supposed to raise a TypeError as it does now? It works for me if I don't use the keyword. That is, b = a.copy('F') But I get the same error if I use order='F', so there

Re: [Numpy-discussion] loadtxt() behavior on single-line files

2010-06-24 Thread Warren Weckesser
Benjamin Root wrote: Hi, I was having the hardest time trying to figure out an intermittent bug in one of my programs. Essentially, in some situations, it was throwing an error saying that the array object was not an array. It took me a while, but then I figured out that my program was

Re: [Numpy-discussion] Multiplying numpy floats and python lists

2010-06-20 Thread Warren Weckesser
Tony S Yu wrote: I came across some strange behavior when multiplying numpy floats and python lists: the list is returned unchanged: In [18]: np.float64(1.2) * [1, 2] Out[18]: [1, 2] Apparently the np.float64 object is cast to an int, and python's * is used: In [7]:

Re: [Numpy-discussion] reduce array by computing min/max every n samples

2010-06-19 Thread Warren Weckesser
Benjamin Root wrote: Brad, I think you are doing it the right way, but I think what is happening is that the reshape() call on the sliced array is forcing a copy to be made first. The fact that the copy has to be made twice just worsens the issue. I would save a copy of the reshape result

Re: [Numpy-discussion] Fastest way to save a dictionary of numpy record arrays

2010-06-14 Thread Warren Weckesser
Robert Kern wrote: On Mon, Jun 14, 2010 at 19:00, Vishal Rana ranavis...@gmail.com wrote: Hi, I have dictionary of numpy record arrays, what could be fastest way to save/load to/from a disk. I tried numpy.save() but my dictionary is lost and cPickle seems to be slow. numpy.savez()

Re: [Numpy-discussion] chararray stripping trailing whitespace a bug?

2010-05-10 Thread Warren Weckesser
From the chararray docstring: Versus a regular Numpy array of type `str` or `unicode`, this class adds the following functionality: 1) values automatically have whitespace removed from the end when indexed So I guess it is a feature, not a bug. :) Warren Neil

Re: [Numpy-discussion] efficient way to manage a set of floats?

2010-05-10 Thread Warren Weckesser
Dr. Phillip M. Feldman wrote: Anne Archibald-2 wrote: on a 32-bit machine, the space overhead is roughly a 32-bit object pointer or two for each float, plus about twice the number of floats times 32-bit pointers for the table. Hello Anne, I'm a bit confused by the above. It

Re: [Numpy-discussion] Question about numpy.arange()

2010-05-02 Thread Warren Weckesser
Gökhan Sever wrote: Hello, Is b an expected value? I am suspecting another floating point arithmetic issue. Exactly. You'll see the same type of problem with float64, too: In [17]: z = np.arange(1.7, 1.8, 0.1) In [18]: z Out[18]: array([ 1.7, 1.8]) In [19]: z[1] == 1.8 Out[19]: True

Re: [Numpy-discussion] What should be the value of nansum of nan's?

2010-04-28 Thread Warren Weckesser
Travis Oliphant wrote: On Apr 26, 2010, at 12:03 PM, Charles R Harris wrote: On Mon, Apr 26, 2010 at 10:55 AM, Charles R Harris charlesr.har...@gmail.com mailto:charlesr.har...@gmail.com wrote: Hi All, We need to make a decision for ticket #1123

Re: [Numpy-discussion] how to tally the values seen

2010-04-14 Thread Warren Weckesser
Gökhan Sever wrote: On Wed, Apr 14, 2010 at 1:10 AM, Peter Shinners p...@shinners.org mailto:p...@shinners.org wrote: I have an array that represents the number of times a value has been given. I'm trying to find a direct numpy way to add into these sums without requiring a

Re: [Numpy-discussion] Proposal for new ufunc functionality

2010-04-12 Thread Warren Weckesser
Robert Kern wrote: On Mon, Apr 12, 2010 at 17:26, Travis Oliphant oliph...@enthought.com wrote: On Apr 11, 2010, at 2:56 PM, Anne Archibald wrote: 2010/4/10 Stéfan van der Walt ste...@sun.ac.za: On 10 April 2010 19:45, Pauli Virtanen p...@iki.fi wrote: Another addition to ufuncs that

Re: [Numpy-discussion] TypeError: only integer arrays with one element can be converted to an index

2010-04-03 Thread Warren Weckesser
Are you sure you wanted to make `left` and `right` tuples that contain just one element (which is a numpy array)? In your code, len(a1) will be 1. Maybe I am misinterpreting your code, but I think you want this: left = array([ 107, 594, 1082, 1569, 2057, 2545, 3033, 3520]) right = array([

Re: [Numpy-discussion] install problems

2010-04-03 Thread Warren Weckesser
Antoine Pairet wrote: Hi all! I am trying to install numpy on a computer which runs Linux and on which I have no root access. The only possibility is therefore to compile numpy from source. With the following command, the compilation seems to work fine: python setup.py install

Re: [Numpy-discussion] How do I get element on axis 1

2010-04-02 Thread Warren Weckesser
Vishal Rana wrote: Hi, I know its easy, but I am not just getting it... How do I get last element on axis=1 for: a = array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]]) Expected: array([4, 9,

Re: [Numpy-discussion] ufuncs on funny strides; also isnan, isfinite, etc on a variety of dtypes

2010-04-01 Thread Warren Weckesser
M Trumpis wrote: Hi all, snip And a last mini question, it doesn't appear that any() is doing short circuit evaluation. It runs in appx the same time whether an array is sparsely nonzero, fully zero, or fully nonzero. That's not what I see. Here's an example that shows the a linear

Re: [Numpy-discussion] Bug in logaddexp2.reduce

2010-03-31 Thread Warren Weckesser
T J wrote: On Wed, Mar 31, 2010 at 1:21 PM, Charles R Harris charlesr.har...@gmail.com wrote: Looks like roundoff error. So this is expected behavior? In [1]: np.logaddexp2(-1.5849625007211563, -53.584962500721154) Out[1]: -1.5849625007211561 In [2]:

Re: [Numpy-discussion] Column-Specific Conditions and Column-Specific Substitution Values

2010-03-23 Thread Warren Weckesser
Cristiano Fini wrote: Hi Everyone, a beginner's question on how to perform some data substitution efficiently. I have a panel dataset, or in other words x individuals observed over a certain time span. For each column or individual, I need to substitute a certain value anytime a certain

Re: [Numpy-discussion] Backwards slicing including the first element

2010-03-10 Thread Warren Weckesser
Jerome Esteve wrote: Dear all, Is there a way to give an integer value to j when using a[i:j:-1] so that the first element of the array can be included in the slice ? I would like to use some code like a[i:i-k:-1] to get a slice of length k. The numpy documentation seems to suggest

Re: [Numpy-discussion] Backwards slicing including the first element

2010-03-10 Thread Warren Weckesser
Warren Weckesser wrote: Jerome Esteve wrote: Dear all, Is there a way to give an integer value to j when using a[i:j:-1] so that the first element of the array can be included in the slice ? I would like to use some code like a[i:i-k:-1] to get a slice of length k. The numpy

Re: [Numpy-discussion] numarray iterator question

2010-03-10 Thread Warren Weckesser
Neal Becker wrote: This is a bit confusing to me: import numpy as np u = np.ones ((3,3)) for u_row in u: u_row = u_row * 2 doesn't work Try this instead: for u_row in u: u_row[:] = u_row * 2 Warren print u [[ 1. 1. 1.] [ 1. 1. 1.] [ 1. 1. 1.]] for u_row in

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread Warren Weckesser
James Bergstra wrote: On Tue, Mar 2, 2010 at 3:09 PM, Christopher Barker chris.bar...@noaa.gov wrote: James Bergstra wrote: Maybe I'm missing something... but I don't think I want to create an array. In [3]: import numpy In [4]: type(numpy.int8()) Out[4]: type 'numpy.int8' In

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread Warren Weckesser
James Bergstra wrote: On Tue, Mar 2, 2010 at 7:18 PM, Warren Weckesser warren.weckes...@enthought.com wrote: James Bergstra wrote: On Tue, Mar 2, 2010 at 3:09 PM, Christopher Barker chris.bar...@noaa.gov wrote: James Bergstra wrote: Maybe I'm missing something

Re: [Numpy-discussion] odd ascii format and genfromtxt

2010-02-26 Thread Warren Weckesser
Ralf Gommers wrote: Hi all, I'm trying to read in data from text files with genfromtxt, and have some trouble figuring out the right combination of keywords. The format is: ['0\t\t4.000e+007,0.000e+000\n', '\t9.860280631554179e-001,-1.902586503306264e-002\n',

Re: [Numpy-discussion] read ascii file with quote delimited strings

2010-02-25 Thread Warren Weckesser
Sam Tygier wrote: Hi I am trying to read an ascii file which mixes ints, floats and stings. eg. 1 2.3 'a' 'abc ' 2 3.2 'b' ' ' 3 3.4 ' ' 'hello' Within a column that data is always the same. the strings are sometimes contain with spaces. Does each column always contain the same

Re: [Numpy-discussion] int-ifying a float array

2010-02-22 Thread Warren Weckesser
Here's another way, using 'astype': In [1]: import numpy as np In [2]: x = np.array([1.0, 2.0, 3.0]) In [3]: y = x.astype(int) In [4]: y Out[4]: array([1, 2, 3]) Warren David Goldsmith wrote: Hi! Is there a less cumbersome way (e.g., one that has a cast-like syntax and/or leverages

Re: [Numpy-discussion] Request for testing

2010-02-21 Thread Warren Weckesser
Charles R Harris wrote: Hi All, I would be much obliged if some folks would run the attached script and report the output, numpy version, and python version. It just runs np.isinf(np.inf), which raises an invalid value warning with current numpy. As far as I can see the function itself

Re: [Numpy-discussion] error fromnumeric: 254 (repeat) return repeat(repeats, axis)

2010-02-06 Thread Warren Weckesser
Tom, 'mask' has 285 elements and 'delta' has 284 elements. If these are to be used as arguments of numpy.repeat(), they must be the same length. Warren Thomas Evangelidis wrote: Dear programmers, I'm not familiar with numpy therefore I need a little help to debug code which was not

Re: [Numpy-discussion] Efficiently converting numpy record array to a list of dictionary

2010-02-04 Thread Warren Weckesser
Vishal, Robert's code does the trick, but--in case you are new to numpy record arrays-I thought I'd point out that the array itself already acts like a list of dictionaries: In [6]: import numpy as np In [7]: dt = np.dtype([('name', 'S30'),('age',int),('weight',float)]) In [8]: r =

<    1   2   3   >