[Numpy-discussion] load of custom .npy file fails with numpy 2.0.0

2012-08-02 Thread Geoffrey Irving
Hello, The attached .npy file was written from custom C++ code. It loads fine in Numpy 1.6.2 with Python 2.6 installed through MacPorts, but fails on a different machine with Numpy 2.0.0 installed via Superpack: box:array% which python /usr/bin/python box:array% which python box:array% python Py

Re: [Numpy-discussion] load of custom .npy file fails with numpy 2.0.0

2012-08-02 Thread Geoffrey Irving
On Thu, Aug 2, 2012 at 1:26 PM, Robert Kern wrote: > On Thu, Aug 2, 2012 at 8:46 PM, Geoffrey Irving wrote: >> Hello, >> >> The attached .npy file was written from custom C++ code. It loads >> fine in Numpy 1.6.2 with Python 2.6 installed through MacPorts, but >

Re: [Numpy-discussion] load of custom .npy file fails with numpy 2.0.0

2012-08-02 Thread Geoffrey Irving
On Thu, Aug 2, 2012 at 3:13 PM, Robert Kern wrote: > On Thu, Aug 2, 2012 at 11:41 PM, Geoffrey Irving wrote: >> On Thu, Aug 2, 2012 at 1:26 PM, Robert Kern wrote: >>> On Thu, Aug 2, 2012 at 8:46 PM, Geoffrey Irving wrote: >>>> Hello, >>>> >>>

[Numpy-discussion] PyArray_FromAny silently converts None to a singleton nan

2013-01-28 Thread Geoffrey Irving
I discovered this from C via the PyArray_FromAny function, but here it is in Python: >>> asarray(None,dtype=float) array(nan) Is this expected or documented behavior? It seems quite unintuitive and surprising that this wouldn't throw an exception. Is there a way to disable this behavior

Re: [Numpy-discussion] PyArray_FromAny silently converts None to a singleton nan

2013-01-28 Thread Geoffrey Irving
t;>>> np.double(None) > nan > > On Mon, Jan 28, 2013 at 3:48 PM, Geoffrey Irving wrote: >> >> I discovered this from C via the PyArray_FromAny function, but here it >> is in Python: >> >> &g

[Numpy-discussion] inheriting from recarray with nested dtypes

2013-03-28 Thread Geoffrey Irving
I have the following two structured dtypes: rotation (quaternion) = dtype([('s','f8'),('v','3f8')]) frame = dtype([('t','3f8'),('r',rotation)]) For various reasons, I usually store rotation arrays in a class Rotations deriving from ndarray, and frames in a class Frames deriving from ndarr

[Numpy-discussion] crash in C++ extension module on process shutdown

2011-03-05 Thread Geoffrey Irving
Hello, I have an extension module which holds on to a reference to a numpy array in a static variable. When the process shuts down, the C++ destructor triggers array_dealloc via Py_DECREF, and I get Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at

[Numpy-discussion] bug in PyArray_GetCastFunc

2011-12-03 Thread Geoffrey Irving
When attempting to cast to a user defined type, PyArray_GetCast looks up the cast function in the dictionary but doesn't check if the entry exists. This causes segfaults. Here's a patch. Geoffrey diff --git a/numpy/core/src/multiarray/convert_datatype.c b/numpy/core/src/multiarray/convert_datat

[Numpy-discussion] failure to register ufunc loops for user defined types

2011-12-03 Thread Geoffrey Irving
Hello, I'm trying to add a fixed precision rational number dtype to numpy, and am running into an issue trying to register ufunc loops. The code in question looks like int npy_rational = PyArray_RegisterDataType(&rational_descr); PyObject* equal = ... // extract equal object from the imp

Re: [Numpy-discussion] failure to register ufunc loops for user defined types

2011-12-04 Thread Geoffrey Irving
case 0: return 0; } } On Sun, Dec 4, 2011 at 9:29 AM, Charles R Harris wrote: > > > On Sat, Dec 3, 2011 at 8:14 PM, Geoffrey Irving wrote: >> >> Hello, >> >> I'm trying to add a fixed precision rational number dtype to numpy, >>

Re: [Numpy-discussion] bug in PyArray_GetCastFunc

2011-12-04 Thread Geoffrey Irving
On Sun, Dec 4, 2011 at 10:02 AM, Charles R Harris wrote: > > > On Sat, Dec 3, 2011 at 5:28 PM, Geoffrey Irving wrote: >> >> When attempting to cast to a user defined type, PyArray_GetCast looks >> up the cast function in the dictionary but doesn't check if t

Re: [Numpy-discussion] failure to register ufunc loops for user defined types

2011-12-04 Thread Geoffrey Irving
On Sun, Dec 4, 2011 at 5:18 PM, Charles R Harris wrote: > > > On Sun, Dec 4, 2011 at 5:41 PM, Geoffrey Irving wrote: >> >> This may be the problem.  Simple diffs are pleasant.  I'm guessing >> this code doesn't get a lot of testing.  Glad it's there,

Re: [Numpy-discussion] failure to register ufunc loops for user defined types

2011-12-04 Thread Geoffrey Irving
On Sun, Dec 4, 2011 at 6:45 PM, Charles R Harris wrote: > > > On Sun, Dec 4, 2011 at 6:59 PM, Geoffrey Irving wrote: >> >> On Sun, Dec 4, 2011 at 5:18 PM, Charles R Harris >> wrote: >> > >> > >> > On Sun, Dec 4, 2011 at 5:41 PM, Geoff

Re: [Numpy-discussion] failure to register ufunc loops for user defined types

2011-12-05 Thread Geoffrey Irving
On Mon, Dec 5, 2011 at 6:59 AM, Charles R Harris wrote: > Hi Geoffrey, > > On Mon, Dec 5, 2011 at 12:37 AM, Geoffrey Irving wrote: >> >> On Sun, Dec 4, 2011 at 6:45 PM, Charles R Harris >> wrote: >> > >> > >> > On Sun, Dec 4, 2011 at 6:59

[Numpy-discussion] test code for user defined types in numpy

2011-12-20 Thread Geoffrey Irving
Hello, As a followup to the prior thread on bugs in user defined types in numpy, I converted my rational number class from C++ to C and switched to 32 bits to remove the need for unportable 128 bit numbers. It should be usable as a fairly thorough test case for user defined types now. It does ra

Re: [Numpy-discussion] test code for user defined types in numpy

2011-12-21 Thread Geoffrey Irving
On Wed, Dec 21, 2011 at 3:56 AM, Charles R Harris wrote: > Hi Geoffrey, > > On Tue, Dec 20, 2011 at 7:24 PM, Geoffrey Irving wrote: >> >> Hello, >> >> As a followup to the prior thread on bugs in user defined types in >> numpy, I converted my rational

[Numpy-discussion] restricting object arrays to a single Python type

2013-07-16 Thread Geoffrey Irving
Is there a standard way of creating an object array restricted to a particular python type? I want a safe way of sending arrays of objects back and forth between Python and C++, and it'd be great if I could use numpy arrays on the Python side instead of creating a new type. For example, I might h

Re: [Numpy-discussion] restricting object arrays to a single Python type

2013-07-16 Thread Geoffrey Irving
On Tue, Jul 16, 2013 at 4:51 PM, Anthony Scopatz wrote: > Hi Geoffrey, > > Not to toot my own horn here too much, but you really should have a look at > xdress (http://xdress.org/ and https://github.com/xdress/xdress). XDress > will generate a wrapper of the Force class for you and then also crea

[Numpy-discussion] char with native integer signedness

2013-10-30 Thread Geoffrey Irving
Is there a standard way in numpy of getting a char with C-native integer signedness? I.e., boost::is_signed::value ? numpy.byte : numpy.ubyte but without nonsensical mixing of languages? Thanks, Geoffrey ___ NumPy-Discussion mailing list NumPy-Dis

Re: [Numpy-discussion] char with native integer signedness

2013-10-31 Thread Geoffrey Irving
On Thu, Oct 31, 2013 at 2:08 AM, Robert Kern wrote: > On Thu, Oct 31, 2013 at 12:52 AM, Geoffrey Irving wrote: >> >> Is there a standard way in numpy of getting a char with C-native >> integer signedness? I.e., >> >> boost::is_signed::value ? numpy.byt

[Numpy-discussion] mmap bug

2010-06-10 Thread Geoffrey Irving
Hello, If I create an mmap'ed array, and then generate another array referencing only its base, destruction of the original mmap'ed array closes the mmap. The second array is then prone to segfaults. I think the best fix is to put the responsibility for flushing the mmap onto the actual mmap obj

[Numpy-discussion] constant shaded triangle mesh in mayavi2

2010-09-30 Thread Geoffrey Irving
Hello, I'm not sure where the correct place to ask questions about Mayavi, so feel free to redirect me elsewhere. I have a triangle mesh with a bunch of data on each face. The only color-relevant argument to triangular_mesh I know about is scalars, which is one value per vertex. Is there a way

Re: [Numpy-discussion] constant shaded triangle mesh in mayavi2

2010-09-30 Thread Geoffrey Irving
On Fri, Oct 1, 2010 at 9:38 AM, Robert Kern wrote: > On Thu, Sep 30, 2010 at 15:30, Geoffrey Irving wrote: >> Hello, >> >> I'm not sure where the correct place to ask questions about Mayavi, so >> feel free to redirect me elsewhere. > > https://mail.enthou

Re: [Numpy-discussion] constant shaded triangle mesh in mayavi2

2010-09-30 Thread Geoffrey Irving
On Fri, Oct 1, 2010 at 10:18 AM, Robert Kern wrote: > On Thu, Sep 30, 2010 at 16:00, Geoffrey Irving wrote: >> On Fri, Oct 1, 2010 at 9:38 AM, Robert Kern wrote: >>> On Thu, Sep 30, 2010 at 15:30, Geoffrey Irving wrote: >>>> Hello, >>>> >&g

Re: [Numpy-discussion] constant shaded triangle mesh in mayavi2

2010-09-30 Thread Geoffrey Irving
On Fri, Oct 1, 2010 at 11:39 AM, Robert Kern wrote: > On Thu, Sep 30, 2010 at 16:26, Geoffrey Irving wrote: >> On Fri, Oct 1, 2010 at 10:18 AM, Robert Kern wrote: >>> On Thu, Sep 30, 2010 at 16:00, Geoffrey Irving wrote: >>>> On Fri, Oct 1, 2010 at 9:38 AM, Ro

Re: [Numpy-discussion] minor improvment to ones

2009-01-31 Thread Geoffrey Irving
On Fri, Jan 30, 2009 at 5:18 AM, Neal Becker wrote: > A nit, but it would be nice if 'ones' could fill with a value other than 1. > > Maybe an optional val= keyword? You can use the "tile" function for this. "tile(3,3)" creates an array of 3 3's. Geoffrey ___

Re: [Numpy-discussion] array of matrices

2009-03-28 Thread Geoffrey Irving
On Sat, Mar 28, 2009 at 12:47 AM, Robert Kern wrote: > 2009/3/27 Charles R Harris : >> >> On Fri, Mar 27, 2009 at 4:43 PM, Robert Kern wrote: >>> >>> On Fri, Mar 27, 2009 at 17:38, Bryan Cole wrote: >>> > I have a number of arrays of shape (N,4,4). I need to perform a >>> > vectorised matrix-mul

[Numpy-discussion] nonuniform scatter operations

2008-09-27 Thread Geoffrey Irving
Hello, Is there an efficient way to implement a nonuniform gather operation in numpy? Specifically, I want to do something like n,m = 100,1000 X = random.uniform(size=n) K = random.randint(n, size=m) Y = random.uniform(size=m) for k,y in zip(K,Y): X[k] += y but I want it to be fast. The n

Re: [Numpy-discussion] nonuniform scatter operations

2008-09-28 Thread Geoffrey Irving
On Sat, Sep 27, 2008 at 10:01 PM, Nathan Bell <[EMAIL PROTECTED]> wrote: > On Sun, Sep 28, 2008 at 12:34 AM, Geoffrey Irving <[EMAIL PROTECTED]> wrote: >> >> Is there an efficient way to implement a nonuniform gather operation >> in numpy? Specifically, I wa

[Numpy-discussion] dtype comparison and hashing

2008-10-15 Thread Geoffrey Irving
Hello, Currently in numpy comparing dtypes for equality with == does an internal PyArray_EquivTypes check, which means that the dtypes NPY_INT and NPY_LONG compare as equal in python. However, the hash function for dtypes reduces id(), which is therefore inconsistent with ==. Unfortunately I can'

Re: [Numpy-discussion] dtype comparison and hashing

2008-10-18 Thread Geoffrey Irving
On Wed, Oct 15, 2008 at 12:56 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > On Wed, Oct 15, 2008 at 02:20, Geoffrey Irving <[EMAIL PROTECTED]> wrote: >> Hello, >> >> Currently in numpy comparing dtypes for equality with == does an >> internal PyArray_EquivT

[Numpy-discussion] immutable numpy arrays

2008-12-17 Thread Geoffrey Irving
Currently numpy arrays are either writable or unwritable, but unwritable arrays can still be changed through other copies. This means that when a numpy array is passed into an interface that requires immutability for safety reasons, a copy always has to be made. One way around this would be to ad

Re: [Numpy-discussion] immutable numpy arrays

2008-12-17 Thread Geoffrey Irving
On Wed, Dec 17, 2008 at 2:24 PM, Robert Kern wrote: > On Wed, Dec 17, 2008 at 15:52, Geoffrey Irving wrote: >> Currently numpy arrays are either writable or unwritable, but >> unwritable arrays can still be changed through other copies. This >> means that when a numpy ar

Re: [Numpy-discussion] immutable numpy arrays

2008-12-17 Thread Geoffrey Irving
On Wed, Dec 17, 2008 at 3:34 PM, Robert Kern wrote: > On Wed, Dec 17, 2008 at 16:51, Geoffrey Irving wrote: >> On Wed, Dec 17, 2008 at 2:24 PM, Robert Kern wrote: >>> On Wed, Dec 17, 2008 at 15:52, Geoffrey Irving wrote: >>>> Currently numpy arrays are eith

Re: [Numpy-discussion] immutable numpy arrays

2008-12-18 Thread Geoffrey Irving
On Wed, Dec 17, 2008 at 4:28 PM, Robert Kern wrote: > On Wed, Dec 17, 2008 at 17:45, Geoffrey Irving wrote: >> On Wed, Dec 17, 2008 at 3:34 PM, Robert Kern wrote: >>> On Wed, Dec 17, 2008 at 16:51, Geoffrey Irving wrote: >>>> On Wed, Dec 17, 2008 at 2:24 PM, Ro

Re: [Numpy-discussion] immutable numpy arrays

2008-12-19 Thread Geoffrey Irving
On Thu, Dec 18, 2008 at 1:00 PM, Robert Kern wrote: > On Thu, Dec 18, 2008 at 10:01, Geoffrey Irving wrote: >> On Wed, Dec 17, 2008 at 4:28 PM, Robert Kern wrote: > >>> It just seems to me to be another complication that does not provide >>> any guarantees. You s

[Numpy-discussion] arrays of matrices

2008-02-28 Thread Geoffrey Irving
Hello, I have a large number of points (shape (n,3)), and a matching number of 3x3 matrices (shape (n,3,3)), and I want to compute the product of each matrix times the corresponding point. I can't see a way to do this operation with dot or tensordot, since these routines either sum across an inde

Re: [Numpy-discussion] arrays of matrices

2008-02-28 Thread Geoffrey Irving
On Thu, Feb 28, 2008 at 05:57:29PM -0600, Robert Kern wrote: > On Thu, Feb 28, 2008 at 4:34 PM, Geoffrey Irving <[EMAIL PROTECTED]> wrote: > > Hello, > > > > I have a large number of points (shape (n,3)), and a matching > > number of 3x3 matrices (shape (n,3,3)

Re: [Numpy-discussion] arrays of matrices

2008-02-28 Thread Geoffrey Irving
On Thu, Feb 28, 2008 at 06:55:11PM -0600, Robert Kern wrote: > On Thu, Feb 28, 2008 at 6:43 PM, Geoffrey Irving <[EMAIL PROTECTED]> wrote: > > > The magic is in In[27]. We reshape the array of vectors to be > > > compatible with the shape of the array of matrices. When