[Numpy-discussion] Changing the numpy array into required shape

2014-08-22 Thread Cleo Drakos
Hello numpy users: I have 2d numpy array of 480 rows and 1440 columns as named by 'data' below: The first element belongs to (49.875S,179.875W), the second element belongs to (49.625S,179.625W),and the last element belongs to (49.875N,179.875E). import os, glob, gdal, numpy as np fname = '3B42RT

Re: [Numpy-discussion] Best way to broadcast a function from C

2014-08-22 Thread Nathaniel Smith
On Sat, Aug 23, 2014 at 12:40 AM, James Crist wrote: > I suspected as much. This is actually part of my work on numerical > evaluation in SymPy. In its current state compilation to C and autowrapping > *works*, but I think it could definitely be more versatile/efficient. Since > numpy seemed to ha

Re: [Numpy-discussion] Best way to broadcast a function from C

2014-08-22 Thread Jaime Fernández del Río
You can always write your own gufunc with signature '(),(),()->(a, a)', and write a Python wrapper that always call it with an `out=` parameter of shape (..., 3, 3), something along the lines of: def my_wrapper(a, b, c, out=None): if out is None: out = np.empty(np.broadcast(a,b,c).shap

Re: [Numpy-discussion] Best way to broadcast a function from C

2014-08-22 Thread James Crist
I suspected as much. This is actually part of my work on numerical evaluation in SymPy. In its current state compilation to C and autowrapping *works*, but I think it could definitely be more versatile/efficient. Since numpy seemed to have solved the broadcasting/datatype issues internally I hoped

Re: [Numpy-discussion] np.unique with structured arrays

2014-08-22 Thread Jaime Fernández del Río
structured arrays are of VOID dtype, but with a non-None names attribute: >>> V_.dtype.num 20 >>> V_.dtype.names ('v',) >>> V_.view(np.void).dtype.num 20 >>> V_.view(np.void).dtype.names >>> The comparison function uses the STRING comparison function if names is None, or a proper field by field c

Re: [Numpy-discussion] np.unique with structured arrays

2014-08-22 Thread Eelco Hoogendoorn
Oh yeah this could be. Floating point equality and bitwise equality are not the same thing. -Original Message- From: "Jaime Fernández del Río" Sent: ‎22-‎8-‎2014 16:22 To: "Discussion of Numerical Python" Subject: Re: [Numpy-discussion] np.unique with structured arrays I can confirm,

Re: [Numpy-discussion] np.unique with structured arrays

2014-08-22 Thread Eelco Hoogendoorn
It does not sound like an issue with unique, but rather like a matter of floating point equality and representation. Do the ' identical' elements pass an equality test? -Original Message- From: "Nicolas P. Rougier" Sent: ‎22-‎8-‎2014 15:21 To: "Discussion of Numerical Python" Subject:

Re: [Numpy-discussion] np.unique with structured arrays

2014-08-22 Thread Jaime Fernández del Río
I can confirm, the issue seems to be in sorting: >>> np.sort(V_) array([([0.5, 0.0, 1.0],), ([0.5, 0.0, -1.0],), ([0.5, -0.0, 1.0],), ([0.5, -0.0, -1.0],)], dtype=[('v', ' wrote: > > Hello, > > I've found a strange behavior or I'm missing something obvious (or > np.unique is not supp

[Numpy-discussion] np.unique with structured arrays

2014-08-22 Thread Nicolas P. Rougier
Hello, I've found a strange behavior or I'm missing something obvious (or np.unique is not supposed to work with structured arrays). I'm trying to extract unique values from a simple structured array but it does not seem to work as expected. Here is a minimal script showing the problem: impor