Suppose I have an __array_interface__
dictionary and I would like to create a numpy view of this data from the dictionary itself. For example:
buff = {'shape': (3, 3), 'data': (140546686381536, False), 'typestr': '<f8'}
view = np.array(buff, copy=False)
However, this does not work as np.array
searches for either the buffer or array interface as attributes. The simple workaround could be the following:
class numpy_holder(object):
pass
holder = numpy_holder()
holder.__array_interface__ = buff
view = np.array(holder, copy=False)
This seems a bit roundabout. Am I missing a straightforward way to do this?
Here's another approach:
Usage: