[Numpy-discussion] Arrays of poly1d objects, is this a bug?

Stefan van der Walt stefan at sun.ac.za
Fri Jan 26 14:07:51 CST 2007


On Fri, Jan 26, 2007 at 12:25:27PM -0700, Fernando Perez wrote:
> Hi all,
> 
> I'm puzzled by this behavior a colleague ran into:
> 
> In [38]: p1=N.poly1d([1.])
> 
> In [39]: a=N.array([p1],dtype='O')
> 
> In [40]: a
> Out[40]: array([], shape=(1, 0), dtype=object)
> 
> In [42]: print a
> []
> 
> In [43]: N.__version__
> Out[43]: '1.0.2.dev3512'
> 
> He saw it running r3520 as well.
> 
> This looks like a bug to me,  since it seems impossible to make arrays
> of poly1d objects:
> 
> In [44]: a=N.array([p1,p1],dtype='O')
> 
> In [45]: a
> Out[45]: array([], shape=(2, 0), dtype=object)
> 
> In [46]: print a
> []

I think the problem might be that an instance of poly1d can be viewed as an
array (e.g. N.asarray(p1)).

The following works:

x = N.empty((3,),object)
x[0] = p1

Cheers
Stéfan


More information about the Numpy-discussion mailing list