def __new__(cls, ctypesArray, shape, dtype=float,
strides=None, offset=0, order=None):
# some magic (copied from numpy.ctypeslib) to make sure the ctypes array
# has the array interface
tp = type(ctypesArray)
try:
tp.__array_interface__
except AttributeError:
ctypeslib.prep_array(tp)
obj = numpy.ndarray.__new__(cls, shape, dtype, ctypesArray, offset, strides,
order)
# keep track of the underlying storage
# this may not be strictly necessary as the same info should be stored in .base
obj.ctypesArray = ctypesArray
return obj
评论列表
文章目录