本文整理汇总了Python中numpy.ctypeslib方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.ctypeslib方法的具体用法?Python numpy.ctypeslib怎么用?Python numpy.ctypeslib使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy
的用法示例。
在下文中一共展示了numpy.ctypeslib方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __new__
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import ctypeslib [as 别名]
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
示例2: __new__
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import ctypeslib [as 别名]
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:
if hasattr(ctypeslib, 'prep_array'):
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