[Numpy-discussion] Upgrade to 1.6.x: frompyfunc() ufunc casting issue

Aditya Sethi ady.sethi@gmail....
Mon Sep 19 18:18:29 CDT 2011


Hi Stefan,

The problem arises when you try to use methods of the ufunc.
So for the custom universal function previously defined, uadd:
uadd([1,2,3],[1,2,3]) works fine.

But uadd.accumulate(..) or uadd.reduce(..) fail with error:
 ValueError: could not find a matching type for add (vectorized).accumulate
( or (vectorized).reduce )

Apologies, I should have been more clear before.

Thanks,
Aditya

2011/9/19 Stéfan van der Walt <stefan@sun.ac.za>

> Hi,
>
> On Mon, Sep 19, 2011 at 2:38 PM, Aditya Sethi <ady.sethi@gmail.com> wrote:
> > I am facing an issue upgrading numpy from 1.5.1 to 1.6.1.
> > In numPy 1.6, the casting behaviour for ufunc has changed and has become
> > stricter.
> > Can someone advise how to implement the below simple example which worked
> in
> > 1.5.1 but fails in 1.6.1?
> >>>> import numpy as np
> >>>> def add(a,b):
> > ...    return (a+b)
> >>>> uadd = np.frompyfunc(add,2,1)
> >>>> uadd
> > <ufunc 'add (vectorized)'>
> >>>> uadd.accumulate([1,2,3])
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> > ValueError: could not find a matching type for add
> (vectorized).accumulate,
> > requested type has type code 'l'
>
> Seems to work ok on the latest version:
>
> In [12]: uadd([1,2,3],[1,2,3])
> Out[12]: array([2, 4, 6], dtype=object)
>
> In [13]: np.__version__
> Out[13]: '2.0.0.dev-af22fc4'
>
> Cheers
> Stéfan
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110919/f5b63b04/attachment.html 


More information about the NumPy-Discussion mailing list