numpy/numpy — pull request #444 by 87 (2012-09-16 19:33:47+00:00)
Title: Fix for issue #291

Hi, I made an attempt at fixing #291, by redoing part of the array interface.

It can now accept objects that do not specify their 'data' attribute and have a shape of `()` or a shape of `(1,)`. To accept no shape information at all is a bit dangerous, because it would be prone to errors.

This now works:
```
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', 'shape' : ()}

>>> f = Foo(0.5)
>>> np.array(f)
array([ 0.5])
```
But without the shape information, it still gives the error:
`ValueError: Missing __array_interface__ shape`

I think enforcing the shape would be the best way to go, because otherwise the array interface can be interpreted wrong when someone *does* supply the 'data' attribute.