Closed
Description
In Numpy 1.5.x, we have
sage: f = 0.5
sage: f.__array_interface__
{'typestr': '=f8'}
sage: numpy.array(f)
array(0.5)
sage: numpy.array(float(f))
array(0.5)
In 1.6, we get the following,
sage: f = 0.5
sage: f.__array_interface__
{'typestr': '=f8'}
sage: numpy.array(f)
array(0.500000000000000, dtype=object)
This seems to be do to the changes in PyArray_FromAny introduced in
http://github.com/mwhansen/numpy/commit/2635398db3f26529ce2aaea4028a8118844f3c48
. In particular, _array_find_type used to be used to query our
array_interface attribute, and it no longer seems to work.
It should be reproducible with the following minimal example:
class Foo(object):
def __init__(self, value):
self.value = value
def __float__(self):
return float(self.value)
@property
def __array_interface__(self):
return {'typestr': '=f8'}
f = Foo(0.5)
import numpy
numpy.array(f)