Re: [Numpy-discussion] Matrix vs ndarray

2008-04-17 Thread Anne Archibald
On 17/04/2008, Santanu Chatterjee [EMAIL PROTECTED] wrote: Hi Numpy users, I used MATLAB to do numerical calculations for a long time. Recently I am digging into python and numpy. I am wondering about the following question : 1) What is the difference between ndarray and matrix in numpy?

Re: [Numpy-discussion] broken numpy.core.tests.test_multiarray.TestScalarIndexing.SetUp

2008-04-17 Thread Anne Archibald
On 17/04/2008, Robert Kern [EMAIL PROTECTED] wrote: On Thu, Apr 17, 2008 at 1:21 PM, Eric Firing [EMAIL PROTECTED] wrote: Arg! Cancel that! I didn't look carefully enough. How embarrassing! Sorry for the noise. Don't apologize. That is very odd code. Stefan, is there a reason to

Re: [Numpy-discussion] Release of NumPy

2008-04-16 Thread Anne Archibald
On 16/04/2008, Stéfan van der Walt [EMAIL PROTECTED] wrote: On 16/04/2008, Alan G Isaac [EMAIL PROTECTED] wrote: The whole issue occurs because a Matrix is not a proper container. Right. And *that* is the case because of the attempt to treat matrices as containers of

Re: [Numpy-discussion] Release of NumPy

2008-04-15 Thread Anne Archibald
On 15/04/2008, Jon Wright [EMAIL PROTECTED] wrote: On 15/04/2008, Alan G Isaac [EMAIL PROTECTED] wrote: ... The proposal on the table is to remove an unneeded (and unwanted) deviation of the matrix API from the ndarray API. ... How about writing up the changes needed PEP style on

Re: [Numpy-discussion] float32 is not a float ?

2008-04-11 Thread Anne Archibald
On 10/04/2008, Charles R Harris [EMAIL PROTECTED] wrote: I think you want the isreal function, but it will also return true for complex with 0 imaginary part. Hmm... the various iswhatever functions seem to be lacking in coverage. Maybe we should fix that. icomplexobj is designed to solve

Re: [Numpy-discussion] matrix multiply

2008-04-06 Thread Anne Archibald
On 06/04/2008, Alan G Isaac [EMAIL PROTECTED] wrote: Just checking: it's important to me that this won't change the behavior of boolean matrices, but I don't see a test for this. E.g., :: import numpy as N A = N.mat('1 0;1 1',dtype='bool') A**2 matrix([[ True,

Re: [Numpy-discussion] matrix multiply

2008-04-06 Thread Anne Archibald
and for negative powers some sort of floating-point inverse. That deserves discussion. Not all invertible boolean matrices have an inverse in the algebra. Just the orthogonal ones do. I guess I would special case inverses for Boolean matrices. Just test if the matrix B is

[Numpy-discussion] ma's stdu and varu

2008-04-06 Thread Anne Archibald
Hi, I was just going through tidying up the documentation for all the many functions in numpy that compute standard deviations or variances (the functions, the methods, the methods on matrices, the methods on maskedarrays, all needed their docstrings updated in approximately the same way). I

Re: [Numpy-discussion] Ticket #605 Incorrect behavior of numpy.histogram

2008-04-05 Thread Anne Archibald
On 05/04/2008, Bruce Southey [EMAIL PROTECTED] wrote: 1) Should the first bin contain all values less than or equal to the value of the first limit and the last bin contain all values greater than the value of the last limit? This produced the counts as: array([3, 3, 9]) (I termed this

Re: [Numpy-discussion] Final push for NumPy 1.0.5 (I need your help!)

2008-04-05 Thread Anne Archibald
On 05/04/2008, James Philbin [EMAIL PROTECTED] wrote: I've posted patches for: #630: If float('123.45') works, so should numpy.float32('123.45') #581: random.set_state does not reset state of random.standard_normal Patches for #601, #622, #692, #696, #717 now in trac; I'd like to do

Re: [Numpy-discussion] Final push for NumPy 1.0.5 (I need your help!)

2008-04-05 Thread Anne Archibald
On 05/04/2008, Charles R Harris [EMAIL PROTECTED] wrote: On Sat, Apr 5, 2008 at 4:10 PM, Anne Archibald [EMAIL PROTECTED] wrote: More generally, my local working copy is now rater divergent from the upstream. What's the recommended way to deal with this? Make sure I have all the patches

Re: [Numpy-discussion] matrix power (was: matrix multiply)

2008-04-05 Thread Anne Archibald
On 05/04/2008, Stéfan van der Walt [EMAIL PROTECTED] wrote: Some discussion recently took place around raising a square matrices to integer powers. See ticket #601: http://scipy.org/scipy/numpy/ticket/601 Anne Archibald wrote a patch which factored 'matrix_multiply' out of defmatrix

Re: [Numpy-discussion] Final push for NumPy 1.0.5 (I need your help!)

2008-04-04 Thread Anne Archibald
On 04/04/2008, Jarrod Millman [EMAIL PROTECTED] wrote: Since I sent my email last night another 5+ tickets have been closed. If we keep going at this rate, we should be able to release 1.0.5 next Friday (4/11) with every ticket closed. Specifically, thanks to Travis Oliphant, David Huard,

Re: [Numpy-discussion] Final push for NumPy 1.0.5 (I need your help!)

2008-04-04 Thread Anne Archibald
On 04/04/2008, Travis E. Oliphant [EMAIL PROTECTED] wrote: Hey Anne, Do you currently have SVN access? Would you like it? I think the SciPy/NumPy sprint would be a good time to clean-up the committers list and add new people interested in helping. I don't have SVN access. I'd be happy

Re: [Numpy-discussion] Simple financial functions for NumPy

2008-04-04 Thread Anne Archibald
On 04/04/2008, Alan G Isaac [EMAIL PROTECTED] wrote: On Fri, 4 Apr 2008, Gael Varoquaux apparently wrote: I really thing numpy should be as thin as possible, so that you can really say that it is only an array manipulation package. This will also make it easier to sell as a core

Re: [Numpy-discussion] [SciPy-user] conforming to Python GIL...

2008-04-03 Thread Anne Archibald
On 03/04/2008, Travis E. Oliphant [EMAIL PROTECTED] wrote: fred wrote: Hi, I use a lot of ConVeX OPTimsation and fortran (via f2py) routines in my Traits app. As I want to compute the data and want to display them, I use threads. The issue I get is that data displayed

Re: [Numpy-discussion] Openmp support (was numpy's future (1.1 and beyond): which direction(s) ?)

2008-03-23 Thread Anne Archibald
On 23/03/2008, David Cournapeau [EMAIL PROTECTED] wrote: Gnata Xavier wrote: Hi, I have a very limited knowledge of openmp but please consider this testcase : Honestly, if it was that simple, it would already have been done for a long time. The problem is that your

Re: [Numpy-discussion] Openmp support (was numpy's future (1.1 and beyond): which direction(s) ?)

2008-03-22 Thread Anne Archibald
On 22/03/2008, Thomas Grill [EMAIL PROTECTED] wrote: I've experimented with branching the ufuncs into different constant strides and aligned/unaligned cases to be able to use SSE using compiler intrinsics. I expected a considerable gain as i was using float32 with stride 1 most of the

Re: [Numpy-discussion] Openmp support (was numpy's future (1.1 and beyond): which direction(s) ?)

2008-03-22 Thread Anne Archibald
On 22/03/2008, Travis E. Oliphant [EMAIL PROTECTED] wrote: James Philbin wrote: Personally, I think that the time would be better spent optimizing routines for single-threaded code and relying on BLAS and LAPACK libraries to use multiple cores for more complex calculations. In

Re: [Numpy-discussion] Improving Docs on Wiki

2008-03-21 Thread Anne Archibald
On 21/03/2008, Sebastian Haase [EMAIL PROTECTED] wrote: Comment: I have read the module- or directory-name core many times on this list, however: Who really knows where a given functions belongs ? Isn't that mostly only the numpy svn commiters ? In other words, using only the python side

Re: [Numpy-discussion] Improving Docs on Wiki

2008-03-21 Thread Anne Archibald
On 21/03/2008, Stéfan van der Walt [EMAIL PROTECTED] wrote: On Fri, Mar 21, 2008 at 2:47 PM, Anne Archibald [EMAIL PROTECTED] wrote: Is it perhaps possible to make all numpy functions accessible in submodules (in addition to in numpy, for backwards compatibility) and then promote

Re: [Numpy-discussion] Inplace index suprise

2008-03-20 Thread Anne Archibald
On 20/03/2008, Gael Varoquaux [EMAIL PROTECTED] wrote: On Thu, Mar 20, 2008 at 06:17:44PM +, James Philbin wrote: Hi, This cannot work, because the inplace operation does not take place as a for loop. Well, this would be fine if I was assigning the values to tempories as

Re: [Numpy-discussion] Numpy and OpenMP

2008-03-15 Thread Anne Archibald
On 15/03/2008, Damian Eads [EMAIL PROTECTED] wrote: Robert Kern wrote: Eric Jones tried to use multithreading to split the computation of ufuncs across CPUs. Ultimately, the overhead of locking and unlocking made it prohibitive for medium-sized arrays and only somewhat disappointing

Re: [Numpy-discussion] dimensions too large error

2008-03-14 Thread Anne Archibald
On 14/03/2008, Dinesh B Vadhia [EMAIL PROTECTED] wrote: For the following code: I = 18000 J = 33000 filename = 'ij.txt' A = scipy.asmatrix(numpy.empty((I,J), dtype=numpy.int)) for line in open(filename, 'r'): etc. The following message appears: Traceback (most recent call

Re: [Numpy-discussion] Array assignment problem

2008-03-11 Thread Anne Archibald
On 11/03/2008, Dinesh B Vadhia [EMAIL PROTECTED] wrote: Hello! I'm reading a text file with two numbers in str format on each line. The numbers are converted into integers. Each integer is then assigned to a 2-dimensional array ij (see code below). The problem is that neither of the array

Re: [Numpy-discussion] Slice and assign into new NDarray...

2008-03-08 Thread Anne Archibald
On 08/03/2008, Vince Fulco [EMAIL PROTECTED] wrote: I have an ND array with shape (10,15) and want to slice or subset(?) the data into a new 2D array with the following criteria: 1) Separate each 5 observations along axis=0 (row) and transpose them to the new array with shape (50,3)

Re: [Numpy-discussion] argmin min on ndarrays

2008-03-04 Thread Anne Archibald
On 04/03/2008, Pierre GM [EMAIL PROTECTED] wrote: All, Let a b be two ndarrays of the same shape. I'm trying to find the elements of b that correspond to the minima of a along an arbitrary axis. The problem is trivial when axis=None or when a.ndim=2, but I'm getting confused with higher

Re: [Numpy-discussion] argmin min on ndarrays

2008-03-04 Thread Anne Archibald
On 04/03/2008, Pierre GM [EMAIL PROTECTED] wrote: Anne, Thanks a lot for your suggestion. Something like if axis is None: return b.flat[a.argmin()] else: return numpy.choose(a.argmin(axis),numpy.rollaxis(b,axis,0)) seems to do the trick fairly nicely indeed. The other

Re: [Numpy-discussion] numpy.correlate with phase offset 1D data series

2008-03-03 Thread Anne Archibald
On 03/03/2008, Ray Schumacher [EMAIL PROTECTED] wrote: I'm trying to figure out what numpy.correlate does, and, what are people using to calculate the phase shift of 1D signals? I use a hand-rolled Fourier-domain cross-correlation, but then, I'm using a Fourier-domain representation of my

Re: [Numpy-discussion] numpy.correlate with phase offset 1D data series

2008-03-03 Thread Anne Archibald
On 03/03/2008, Ray Schumacher [EMAIL PROTECTED] wrote: Xie's 2D algorithm reduced to 1D works nicely for computing the relative phase, but is it the fastest way? It might be, since some correlation algorithms use FFTs as well. What does _correlateND use, in scipy? Which way will be the

Re: [Numpy-discussion] Pickling and initializing

2008-03-03 Thread Anne Archibald
On 03/03/2008, Dinesh B Vadhia [EMAIL PROTECTED] wrote: When you pickle a numpy/scipy matrix does it have to be initialized by another program? For example: Most python objects do not need to be initialized. You just call a function that makes the one you want: l = range(10) This makes a

Re: [Numpy-discussion] contiguous true

2008-02-29 Thread Anne Archibald
On 01/03/2008, Charles R Harris [EMAIL PROTECTED] wrote: On Fri, Feb 29, 2008 at 10:53 AM, John Hunter [EMAIL PROTECTED] wrote: I have a boolean array and would like to find the lowest index ind where N contiguous elements are all True. Eg, if x is [...] Oops, ind = arange(len(x)). I

Re: [Numpy-discussion] Optimize speed of for loop using numpy

2008-02-26 Thread Anne Archibald
On 25/02/2008, Trond Kristiansen [EMAIL PROTECTED] wrote: I have attached the function that the FOR loop is part of as a python file. What I am trying to do is to create a set of functions that will read the output files (NetCDF) from running the ROMS model (ocean model). The output file

Re: [Numpy-discussion] numpy 1:1.0.4: numpy.average() returns the wrong result with weights

2008-02-22 Thread Anne Archibald
On 22/02/2008, Travis E. Oliphant [EMAIL PROTECTED] wrote: Is there a ticket on the NumPy trac for this? We won't see it if there isn't. Thanks for pointing us to the bug. It appears to be fixed in SVN (that was quick!). But the Debian bug report also points out a peculiar unnecessary use

Re: [Numpy-discussion] Matching 0-d arrays and NumPy scalars

2008-02-21 Thread Anne Archibald
On 21/02/2008, Stefan van der Walt [EMAIL PROTECTED] wrote: Could I ask that we also consider implementing len() for 0-d arrays? numpy.asarray returns those as-is, and I would like to be able to handle them just as I do any other 1-dimensional array. I don't know if a length of 1 would

Re: [Numpy-discussion] Proxy array class and units

2008-02-13 Thread Anne Archibald
On 13/02/2008, Dan Goodman [EMAIL PROTECTED] wrote: Background: I'm writing a package to run simulations which make extensive use of linear algebra, for which I'm using numpy. However - it is important to my package that quantities can have dimesions, so I've written a class Quantity

Re: [Numpy-discussion] Median advice

2008-02-12 Thread Anne Archibald
On 12/02/2008, Matthew Brett [EMAIL PROTECTED] wrote: Suggestion 1: def median(a, axis=0, out=None) [...] Suggestion 2: def median(a, axis=0, scratch_input=False) No reason not to combine the two. It's a pretty straightforward modification to do the sorting in place, and it could make a lot

Re: [Numpy-discussion] sort method raises unexpected error with axis=None

2008-02-12 Thread Anne Archibald
On 12/02/2008, Matthew Brett [EMAIL PROTECTED] wrote: Is it possible, in fact, to do an inplace sort on an array with axis=None (ie flat sort)? It is, sometimes; just make an array object to point to the flattened version and sort that: In [16]: b = a[:] In [17]: b.shape = (16,) In [18]:

Re: [Numpy-discussion] sort method raises unexpected error with axis=None

2008-02-12 Thread Anne Archibald
On 12/02/2008, Anne Archibald [EMAIL PROTECTED] wrote: An efficient way to handle in-place (or out-of-place, come to think of it) median along multiple axes is actually to take medians along all axes in succession. That saves you some sorting effort, and some programming effort, and doesn't

Re: [Numpy-discussion] Setting contents of buffer for array object

2008-02-11 Thread Anne Archibald
On 11/02/2008, Matthew Brett [EMAIL PROTECTED] wrote: I can also see that this could possibly be improved by using a for loop to iterate over the output elements, so that there was no need to duplicate the large input array, or perhaps a blocked iteration that duplicated arrays of modest

Re: [Numpy-discussion] Bug in numpy all() function

2008-02-06 Thread Anne Archibald
On 06/02/2008, Robert Kern [EMAIL PROTECTED] wrote: I guess the all function doesn't know about generators? Yup. It works on arrays and things it can turn into arrays by calling the C API equivalent of numpy.asarray(). There's a ton of magic and special cases in asarray() in order to

Re: [Numpy-discussion] Stride of 2 for correlate()

2008-02-05 Thread Anne Archibald
On 05/02/2008, Chris Finley [EMAIL PROTECTED] wrote: After searching the archives, I was unable to find a good method for changing the stride of the correlate or convolve routines. I am doing a Daubechies analysis of some sample data, say data = arange(0:80). The coefficient array or four

Re: [Numpy-discussion] Can not update a submatrix

2008-01-30 Thread Anne Archibald
On 30/01/2008, Francesc Altet [EMAIL PROTECTED] wrote: A Wednesday 30 January 2008, Nadav Horesh escrigué: In the following piece of code: import numpy as N R = N.arange(9).reshape(3,3) ax = [1,2] R array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]) R[ax,:][:,ax] =

Re: [Numpy-discussion] Does float16 exist?

2008-01-08 Thread Anne Archibald
On 08/01/2008, Charles R Harris [EMAIL PROTECTED] wrote: I'm starting to get interested in implementing float16 support ;) My tentative program goes something like this: 1) Add the operators to the scalar type. This will give sorting, basic printing, addition, etc. 2) Add conversions to

Re: [Numpy-discussion] Does float16 exist?

2008-01-08 Thread Anne Archibald
On 08/01/2008, Charles R Harris [EMAIL PROTECTED] wrote: Well, at a minimum people will want to read, write, print, and promote them. That would at least let people work with the numbers, and since my understanding is that the main virtue of the format is compactness for storage and

Re: [Numpy-discussion] Nasty bug using pre-initialized arrays

2008-01-07 Thread Anne Archibald
On 07/01/2008, Charles R Harris [EMAIL PROTECTED] wrote: One place where Numpy differs from MatLab is the way memory is handled. MatLab is always generating new arrays, so for efficiency it is worth preallocating arrays and then filling in the parts. This is not the case in Numpy where lists

Re: [Numpy-discussion] CASTABLE flag

2008-01-07 Thread Anne Archibald
On 07/01/2008, Timothy Hochberg [EMAIL PROTECTED] wrote: I'm fairly dubious about assigning float to ints as is. First off it looks like a bug magnet to me due to accidentally assigning a floating point value to a target that one believes to be float but is in fact integer. Second, C-style

Re: [Numpy-discussion] fast iteration (I think I've got it)

2008-01-01 Thread Anne Archibald
On 01/01/2008, Neal Becker [EMAIL PROTECTED] wrote: This is a c-api question. I'm trying to get iterators that are both fast and reasonably general. I did confirm that iterating using just the general PyArrayIterObject protocol is not as fast as using c-style pointers for contiguous arrays.

Re: [Numpy-discussion] any better way to normalize a matrix

2007-12-28 Thread Anne Archibald
On 28/12/2007, Christopher Barker [EMAIL PROTECTED] wrote: I like the array methods a lot -- is there any particular reason there is no ndarray.abs(), or has it just not been added? Here I have to disagree with you. Numpy provides ufuncs as general powerful tools for operating on matrices.

Re: [Numpy-discussion] any better way to normalize a matrix

2007-12-28 Thread Anne Archibald
On 28/12/2007, Christopher Barker [EMAIL PROTECTED] wrote: Anne Archibald wrote: Numpy provides ufuncs as general powerful tools for operating on matrices. More can be added relatively easily, they provide not just the basic apply operation but also outer and others. Adding another way

Re: [Numpy-discussion] any better way to normalise a matrix

2007-12-27 Thread Anne Archibald
On 27/12/2007, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: in my code i am trying to normalise a matrix as below mymatrix=matrix(..# items are of double type..can be negative values) numrows,numcols=mymatrix.shape for i in range(numrows): temp=mymatrix[i].max() for j in

Re: [Numpy-discussion] RAdian -- degres conversion

2007-12-16 Thread Anne Archibald
On 16/12/2007, Hans Meine [EMAIL PROTECTED] wrote: (*: It's similar with math.hypot, which I have got to know and appreciate nowadays.) I'd like to point out that math.hypot is a nontrivial function which is easy to get wrong: In [6]: x=1e200; y=1e200; In [7]: math.hypot(x,y) Out[7]:

Re: [Numpy-discussion] OT: A Way to Approximate and Compress a 3D Surface

2007-11-20 Thread Anne Archibald
On 20/11/2007, Geoffrey Zhu [EMAIL PROTECTED] wrote: I have N tabulated data points { (x_i, y_i, z_i) } that describes a 3D surface. The surface is pretty smooth. However, the number of data points is too large to be stored and manipulated efficiently. To make it easier to deal with, I am

Re: [Numpy-discussion] numpy : your experiences?

2007-11-16 Thread Anne Archibald
On 16/11/2007, Rahul Garg [EMAIL PROTECTED] wrote: It would be awesome if you guys could respond to some of the following questions : a) Can you guys tell me briefly about the kind of problems you are tackling with numpy and scipy? b) Have you ever felt that numpy/scipy was slow and had to

Re: [Numpy-discussion] Unnecessarily bad performance of elementwise operators with Fortran-arrays

2007-11-08 Thread Anne Archibald
On 08/11/2007, David Cournapeau [EMAIL PROTECTED] wrote: For copy and array creation, I understand this, but for element-wise operations (mean, min, and max), this is not enough to explain the difference, no ? For example, I can understand a 50 % or 100 % time increase for simple operations

Re: [Numpy-discussion] numpy FFT memory accumulation

2007-10-31 Thread Anne Archibald
On 31/10/2007, Ray S [EMAIL PROTECTED] wrote: I am using fftRes = abs(fft.rfft(data_array[end-2**15:end])) to do running analysis on streaming data. The N never changes. It sucks memory up at ~1MB/sec with 70kHz data rate and 290 ffts/sec. (Interestingly, Numeric FFT accumulates much

Re: [Numpy-discussion] fortran array storage question

2007-10-26 Thread Anne Archibald
On 26/10/2007, Travis E. Oliphant [EMAIL PROTECTED] wrote: There is an optimization where-in the inner-loops are done over the dimension with the smallest stride. What other cache-coherent optimizations do you recommend? That sounds like a very good first step. I'm far from an expert on this

Re: [Numpy-discussion] appending extra items to arrays

2007-10-10 Thread Anne Archibald
On 11/10/2007, Robert Kern [EMAIL PROTECTED] wrote: Appending to a list then converting the list to an array is the most straightforward way to do it. If the performance of this isn't a problem, I recommend leaving it alone. Just a speculation: Python strings have a similar problem - they're

Re: [Numpy-discussion] Casting a float array into a string array

2007-10-05 Thread Anne Archibald
On 05/10/2007, Matthieu Brucher [EMAIL PROTECTED] wrote: I'd like to have the '2.', because if the number is negative, only '-' is returned, not the real value. For string arrays you need to specify the length of the string as part of the data type (and it defaults to length 1): In [11]:

[Numpy-discussion] bug in vectorize? (was: Re: Casting a float array into a string array)

2007-10-05 Thread Anne Archibald
On 05/10/2007, Christopher Barker [EMAIL PROTECTED] wrote: I don't know how to generalize this to n-d though -- maybe numpy.vectorize? Oops! Looks like there's a big somewhere: In [1]: from numpy import * In [2]: vectorize(lambda x: %5.3g % x)(ones((2,2,2))) Out[2]: array([[[' ', '\xc1'],

Re: [Numpy-discussion] Extended Outer Product

2007-09-20 Thread Anne Archibald
On 19/09/2007, Travis E. Oliphant [EMAIL PROTECTED] wrote: Anne Archibald wrote: vectorize, of course, is a good example of my point above: it really just loops, in python IIRC, but conceptually it's extremely handy for doing exactly what the OP wanted. Unfortunately vectorize() does

Re: [Numpy-discussion] arange and floating point arguments

2007-09-14 Thread Anne Archibald
On 15/09/2007, Christopher Barker [EMAIL PROTECTED] wrote: Oh, and could someone post an actual example of a use for which FP arange is required (with fudges to try to accommodate decimal to binary conversion errors), and linspace won't do? Well, here's one: evaluating a function we know to

Re: [Numpy-discussion] Docstring improvements for numpy.where?

2007-09-12 Thread Anne Archibald
On 12/09/2007, Robert Kern [EMAIL PROTECTED] wrote: That sentence applies to the 3-argument form, which has nothing to do with nonzero() and does not yield a tuple. But in general, yes, the docstring leaves much to be desired. Well, here's what I hope is a step in the right direction. Anne

Re: [Numpy-discussion] Accessing a numpy array in a mmap fashion

2007-08-30 Thread Anne Archibald
On 30/08/2007, Brian Donovan [EMAIL PROTECTED] wrote: Hello all, I'm wondering if there is a way to use a numpy array that uses disk as a memory store rather than ram. I'm looking for something like mmap but which can be used like a numpy array. The general idea is this. I'm simulating a

[Numpy-discussion] Bug or surprising undocumented behaviour in irfft

2007-08-29 Thread Anne Archibald
Hi, numpy's Fourier transforms have the handy feature of being able to upsample and downsample signals; for example the documentation cites irfft(rfft(A),16*len(A)) as a way to get a Fourier interpolation of A. However, there is a peculiarity with the way numpy handles the highest-frequency

Re: [Numpy-discussion] Bug or surprising undocumented behaviour in irfft

2007-08-29 Thread Anne Archibald
On 29/08/2007, Charles R Harris [EMAIL PROTECTED] wrote: What is going on is that the coefficient at the Nyquist frequency appears once in the unextended array, but twice when the array is extended with zeros because of the Hermitean symmetry. That should probably be fixed in the upsampling

Re: [Numpy-discussion] Bug or surprising undocumented behaviour in irfft

2007-08-29 Thread Anne Archibald
On 29/08/2007, Charles R Harris [EMAIL PROTECTED] wrote: Is this also appropriate for the other FFTs? (inverse real, complex, hermitian, what have you) I have written a quick hack (attached) that should do just that rescaling, but I don't know that it's a good idea, as implemented.

Re: [Numpy-discussion] Extended Outer Product

2007-08-21 Thread Anne Archibald
On 21/08/07, Timothy Hochberg [EMAIL PROTECTED] wrote: This is just a general comment on recent threads of this type and not directed specifically at Chuck or anyone else. IMO, the emphasis on avoiding FOR loops at all costs is misplaced. It is often more memory friendly and thus faster to

Re: [Numpy-discussion] .transpose() of memmap array fails to close()

2007-08-17 Thread Anne Archibald
On 16/08/07, Glen W. Mabey [EMAIL PROTECTED] wrote: On Wed, Aug 15, 2007 at 08:50:28PM -0400, Anne Archibald wrote: But to be pythonic, or numpythonic, when the original A is garbage-collected, the garbage collection should certainly close the mmap. Humm, this would be less than ideal

Re: [Numpy-discussion] .transpose() of memmap array fails to close()

2007-08-15 Thread Anne Archibald
On 15/08/07, Glen W. Mabey [EMAIL PROTECTED] wrote: On Tue, Aug 14, 2007 at 12:23:26AM -0400, Anne Archibald wrote: On 13/08/07, Glen W. Mabey [EMAIL PROTECTED] wrote: As I have tried to think through what should be the appropriate behavior for the returned value of __getitem__, I have

Re: [Numpy-discussion] .transpose() of memmap array fails to close()

2007-08-13 Thread Anne Archibald
On 13/08/07, Glen W. Mabey [EMAIL PROTECTED] wrote: As I have tried to think through what should be the appropriate behavior for the returned value of __getitem__, I have not been able to see an appropriate solution (let alone know how to implement it) to this issue. Is the problem one of

Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-08 Thread Anne Archibald
On 08/08/2007, Stefan van der Walt [EMAIL PROTECTED] wrote: On Tue, Aug 07, 2007 at 01:33:24AM -0400, Anne Archibald wrote: Well, it can be done in Python: just allocate a too-big ndarray and take a slice that's the right shape and has the right alignment. But this sucks. Could you

Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-08 Thread Anne Archibald
On 08/08/2007, Charles R Harris [EMAIL PROTECTED] wrote: On 8/8/07, Anne Archibald [EMAIL PROTECTED] wrote: Oh. Well, it's not *terrible*; it gets you an aligned array. But you have to allocate the original array as a 1D byte array (to allow for arbitrary realignments) and then align

Re: [Numpy-discussion] vectorized function inside a class

2007-08-08 Thread Anne Archibald
On 08/08/2007, mark [EMAIL PROTECTED] wrote: Thanks for the ideas to circumvent vectorization. But the real function I need to vectorize is quite a bit more complicated. So I would really like to use vectorize. Are there any reasons against vectorization? Is it slow? The way Tim suggests I

Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-06 Thread Anne Archibald
On 06/08/07, David Cournapeau [EMAIL PROTECTED] wrote: Well, when I proposed the SIMD extension, I was willing to implement the proposal, and this was for a simple goal: enabling better integration with many numeric libraries which need SIMD alignment. As nice as a custom allocator might be,

Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-06 Thread Anne Archibald
On 07/08/07, David Cournapeau [EMAIL PROTECTED] wrote: Anne, you said previously that it was easy to allocate buffers for a given alignment at runtime. Could you point me to a document which explains how ? For platforms without posix_memalign, I don't see how to implement a memory allocator

Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-04 Thread Anne Archibald
On 04/08/07, David Cournapeau [EMAIL PROTECTED] wrote: Here's a hack that google turned up: I'd avoid hacks in favour of posix_memalign (which allows arbitrary degrees of alignment. For one thing, freeing becomes a headache (you can't free a pointer you've jiggered!). - Check whether a

Re: [Numpy-discussion] expm

2007-07-20 Thread Anne Archibald
On 20/07/07, Nils Wagner [EMAIL PROTECTED] wrote: lorenzo bolla wrote: hi all. is there a function in numpy to compute the exp of a matrix, similar to expm in matlab? for example: expm([[0,0],[0,0]]) = eye(2) Numpy doesn't provide expm but scipy does. from scipy.linalg import expm,

Re: [Numpy-discussion] fancy indexing/broadcasting question

2007-07-07 Thread Anne Archibald
On 07/07/07, Mark.Miller [EMAIL PROTECTED] wrote: A quick question for the group. I'm working with some code to generate some arrays of random numbers. The random numbers, however, need to meet certain criteria. So for the moment, I have things that look like this (code is just an

Re: [Numpy-discussion] randint for long type (permutations)

2007-06-14 Thread Anne Archibald
On 14/06/07, Will Woods [EMAIL PROTECTED] wrote: I want to choose a subset of all possible permutations of a sequence of length N, with each element of the subset unique. This is then going to be scattered across multiple machines using mpi. Since there is a one-to-one mapping between the

Re: [Numpy-discussion] flatten() without copy - is this possible?

2007-06-08 Thread Anne Archibald
On 05/06/07, Charles R Harris [EMAIL PROTECTED] wrote: On 6/5/07, dmitrey [EMAIL PROTECTED] wrote: Thank you, but all your examples deal with 3-dimensional arrays. and I still misunderstood, is it possible somehow for 2-dimensional arrays or no? D. There is nothing special about the

Re: [Numpy-discussion] flatten() without copy - is this possible?

2007-06-03 Thread Anne Archibald
On 01/06/07, dmitrey [EMAIL PROTECTED] wrote: y = x.flatten(1) turn array into vector (note that this forces a copy) Is there any way to do the trick wthout copying? What are the problems here? Just other way of array elements indexing... It is sometimes possible to flatten an array

Re: [Numpy-discussion] SciPy Journal

2007-05-31 Thread Anne Archibald
On 31/05/07, Travis Oliphant [EMAIL PROTECTED] wrote: 2) I think it's scope should be limited to papers that describe algorithms and code that are in NumPy / SciPy / SciKits. Perhaps we could also accept papers that describe code that depends on NumPy / SciPy that is also easily available.

Re: [Numpy-discussion] byteswap() leaves dtype unchanged

2007-05-30 Thread Anne Archibald
On 30/05/07, Matthew Brett [EMAIL PROTECTED] wrote: I think the point is that you can have several different situations with byte ordering: 1) Your data and dtype endianess match, but you want the data swapped and the dtype to reflect this 2) Your data and dtype endianess don't match, and

Re: [Numpy-discussion] Question about flags of fancy indexed array

2007-05-23 Thread Anne Archibald
On 23/05/07, Albert Strasheim [EMAIL PROTECTED] wrote: Consider the following example: First a comment: almost nobody needs to care how the data is stored internally. Try to avoid looking at the flags unless you're interfacing with a C library. The nice feature of numpy is that it hides all

Re: [Numpy-discussion] Question about flags of fancy indexed array

2007-05-23 Thread Anne Archibald
On 23/05/07, Albert Strasheim [EMAIL PROTECTED] wrote: If you are correct that this is in fact a fresh new array, I really don't understand where the values of these flags. To recap: In [19]: x = N.zeros((3,2)) In [20]: x.flags Out[20]: C_CONTIGUOUS : True F_CONTIGUOUS : False

Re: [Numpy-discussion] best way for storing extensible data?

2007-05-18 Thread Anne Archibald
On 18/05/07, David M. Cooke [EMAIL PROTECTED] wrote: It'll act like appending to a list, where it will grow the array (by doubling, I think) when it needs to, so appending each value is amortized to O(1) time. A list though would use more memory per element as each element is a full Python

[Numpy-discussion] Unfortunate user experience with max()

2007-05-16 Thread Anne Archibald
Hi, Numpy has a max() function. It takes an array, and possibly some extra arguments (axis and default). Unfortunately, this means that numpy.max(-1.3,2,7) -1.3 This can lead to surprising bugs in code that either explicitly expects it to behave like python's max() or implicitly expects that

Re: [Numpy-discussion] Unfortunate user experience with max()

2007-05-16 Thread Anne Archibald
On 16/05/07, Alan G Isaac [EMAIL PROTECTED] wrote: On Wed, 16 May 2007, Anne Archibald apparently wrote: numpy.max(-1.3,2,7) -1.3 Is that new behavior? I get a TypeError on the last argument. (As expected.) For which version of numpy? In [2]: numpy.max(-1.3,2.7) Out[2]: -1.3 In [3

Re: [Numpy-discussion] very large matrices.

2007-05-12 Thread Anne Archibald
On 12/05/07, Dave P. Novakovic [EMAIL PROTECTED] wrote: core 2 duo with 4gb RAM. I've heard about iterative svd functions. I actually need a complete svd, with all eigenvalues (not LSI). I'm actually more interested in the individual eigenvectors. As an example, a single row could probably

Re: [Numpy-discussion] numpy version of Interactive Data Analysis tutorial available

2007-05-11 Thread Anne Archibald
On 10/05/07, Perry Greenfield [EMAIL PROTECTED] wrote: I have updated the Using Python for Interactive Data Analysis tutorial to use numpy instead of numarray (finally!). There are further improvements I would like to make in its organization and formatting (in the process including

Re: [Numpy-discussion] matlab vs. python question

2007-05-08 Thread Anne Archibald
On 08/05/07, Gael Varoquaux [EMAIL PROTECTED] wrote: On Tue, May 08, 2007 at 12:18:56PM +0200, Giorgio Luciano wrote: A good workspace (with an interactive button) just to not get figures freezed I am not sure what you mean by figures freezed but I would like to check that you are aware of

Re: [Numpy-discussion] arctan2 with complex args

2007-04-29 Thread Anne Archibald
On 29/04/07, David Goldsmith [EMAIL PROTECTED] wrote: Far be it from me to challenge the mighty Wolfram, but I'm not sure that using the *formula* for calculating the arctan of a *single* complex argument from its real and imaginary parts makes any sense if x and/or y are themselves complex

Re: [Numpy-discussion] efficient use of numpy.where() and .any()

2007-04-23 Thread Anne Archibald
On 23/04/07, Pierre GM [EMAIL PROTECTED] wrote: Note that in addition of the bitwise operators, you can use the logical_ functions. OK, you'll still end up w/ temporaries, but I wonder whether there couldn't be some tricks to bypass that... If you're really determined not to make many temps,

Re: [Numpy-discussion] Question about Optimization (Inline and Pyrex)

2007-04-17 Thread Anne Archibald
On 17/04/07, Francesc Altet [EMAIL PROTECTED] wrote: Finally, don't let benchmarks fool you. If you can, it is always better to run your own benchmarks made of your own problems. A tool that can be killer for one application can be just mediocre for another (that's somewhat extreme, but I

Re: [Numpy-discussion] Question about Optimization (Inline and Pyrex)

2007-04-17 Thread Anne Archibald
On 17/04/07, Lou Pecora [EMAIL PROTECTED] wrote: Now, I didn't know that. That's cool because I have a new dual core Intel Mac Pro. I see I have some learning to do with multithreading. Thanks. No problem. I had completely forgotten about the global interpreter lock, wrote a little

Re: [Numpy-discussion] Question about Optimization (Inline and Pyrex)

2007-04-17 Thread Anne Archibald
On 17/04/07, Lou Pecora [EMAIL PROTECTED] wrote: I get what you are saying, but I'm not even at the Stupidly Easy Parallel level, yet. Eventually. Well, it's hardly wonderful, but I wrote a little package to make idioms like: d = {} def work(f): d[f] = sum(exp(2.j*pi*f*times))

Re: [Numpy-discussion] Question about Optimization (Inline, and Pyrex)

2007-04-17 Thread Anne Archibald
On 17/04/07, James Turner [EMAIL PROTECTED] wrote: Hi Anne, Your reply to Lou raises a naive follow-up question of my own... Normally, python's multithreading is effectively cooperative, because the interpreter's data structures are all stored under the same lock, so only one thread can

Re: [Numpy-discussion] Question about Optimization (Inline, and Pyrex)

2007-04-17 Thread Anne Archibald
On 18/04/07, Robert Kern [EMAIL PROTECTED] wrote: Sebastian Haase wrote: Hi, I don't know much about ATLAS -- would there be other numpy functions that *could* or *should* be implemented using ATLAS !? Any ? Not really, no. ATLAS is a library designed to implement linear algebra

Re: [Numpy-discussion] Question about Optimization (Inline and Pyrex)

2007-04-17 Thread Anne Archibald
On 18/04/07, Sebastian Haase [EMAIL PROTECTED] wrote: Hi Anne, I'm just starting to look into your code (sound very interesting - should probably be put onto the wiki) -- quick note: you are mixing tabs and spaces :-( what editor are you using !? Agh. vim is misbehaving. Sorry about that.

<    1   2   3   4   5   >