asarray() with __array_interface__ doesn't set .base
Issue #52
resolved
import numpy as np
class _DummyArray(object):
""" Dummy object that just exists to hang __array_interface__ dictionaries
and possibly keep alive a reference to a base array.
"""
def __init__(self, interface, base=None):
self.__array_interface__ = interface
self.base = base
x = np.zeros(10000)
d = _DummyArray(x.__array_interface__, base=x)
y = np.asarray(d)
assert y.base is d
succeeds on numpy, fails on numpypy
Comments (3)
-
-
- changed status to resolved
Fixed in 4916eb438de5 as part of the buffer-interface branch, merged to default in 03fc4cb79e37
-
reporter Thanks!
- Log in to comment
It seems we do not call
__init__
for a class with an__array_interface__
attribute like numpy does. I linked in the test in issue#53and rewrote a bit (to allow running on a vanilla PyPy without the numpy fork)PyPy does not print
in init
like CPython does