[Numpy-discussion] Can't get ufunc to work for integers
Hello, I am trying to learn how to create ufuncs, and I got a ufunc to compile correctly with the signature int - double, but I can't get it to accept any arguments. My function is testfunc and I used NPY_INT as the first signature and NPY_DOUBLE as the second signature. What should I look at to figure this out? In [10]: testfunc.types Out[10]: ['i-d', '?-?'] In [11]: testfunc(x) --- TypeError Traceback (most recent call last) /Users/johnsalvatier/Documents/workspace/pymc_numexprtest/src/test/ipython console in module() TypeError: function not supported for these types, and can't coerce safely to supported types In [12]: x Out[12]: array([1, 2, 3]) In [13]: x.dtype Out[13]: dtype('int32') ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Can't get ufunc to work for integers
Thu, 22 Jul 2010 08:49:09 -0700, John Salvatier wrote: I am trying to learn how to create ufuncs, and I got a ufunc to compile correctly with the signature int - double, but I can't get it to accept any arguments. My function is testfunc and I used NPY_INT as the first signature and NPY_DOUBLE as the second signature. What should I look at to figure this out? I think you need to specify NPY_LONG instead of NPY_INT -- the NPY_INT is IIRC sort of a virtual type that you can use when creating arrays, but no array is ever of type NPY_INT, since it maps to either NPY_LONG or whatever the C int type happens to be. Maybe someone can correct me here, but AFAIK it goes like so. -- Pauli Virtanen ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Can't get ufunc to work for integers
Oh, ok. That makes sense. Thanks for the speedy help. John On Thu, Jul 22, 2010 at 9:14 AM, Pauli Virtanen p...@iki.fi wrote: Thu, 22 Jul 2010 08:49:09 -0700, John Salvatier wrote: I am trying to learn how to create ufuncs, and I got a ufunc to compile correctly with the signature int - double, but I can't get it to accept any arguments. My function is testfunc and I used NPY_INT as the first signature and NPY_DOUBLE as the second signature. What should I look at to figure this out? I think you need to specify NPY_LONG instead of NPY_INT -- the NPY_INT is IIRC sort of a virtual type that you can use when creating arrays, but no array is ever of type NPY_INT, since it maps to either NPY_LONG or whatever the C int type happens to be. Maybe someone can correct me here, but AFAIK it goes like so. -- Pauli Virtanen ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Can't get ufunc to work for integers
This did end up solving my problem. Thanks! On Thu, Jul 22, 2010 at 9:25 AM, John Salvatier jsalv...@u.washington.eduwrote: Oh, ok. That makes sense. Thanks for the speedy help. John On Thu, Jul 22, 2010 at 9:14 AM, Pauli Virtanen p...@iki.fi wrote: Thu, 22 Jul 2010 08:49:09 -0700, John Salvatier wrote: I am trying to learn how to create ufuncs, and I got a ufunc to compile correctly with the signature int - double, but I can't get it to accept any arguments. My function is testfunc and I used NPY_INT as the first signature and NPY_DOUBLE as the second signature. What should I look at to figure this out? I think you need to specify NPY_LONG instead of NPY_INT -- the NPY_INT is IIRC sort of a virtual type that you can use when creating arrays, but no array is ever of type NPY_INT, since it maps to either NPY_LONG or whatever the C int type happens to be. Maybe someone can correct me here, but AFAIK it goes like so. -- Pauli Virtanen ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion