MCPcopy Create free account
hub / github.com/dmlc/decord / asnumpy

Method asnumpy

python/decord/_ffi/ndarray.py:245–264  ·  view source on GitHub ↗

Convert this array to numpy array Returns ------- np_arr : numpy.ndarray The corresponding numpy array.

(self)

Source from the content-addressed store, hash-verified

243 return str(self.asnumpy())
244
245 def asnumpy(self):
246 """Convert this array to numpy array
247
248 Returns
249 -------
250 np_arr : numpy.ndarray
251 The corresponding numpy array.
252 """
253 t = DECORDType(self.dtype)
254 shape, dtype = self.shape, self.dtype
255 if t.lanes > 1:
256 shape = shape + (t.lanes,)
257 t.lanes = 1
258 dtype = str(t)
259 np_arr = np.empty(shape, dtype=dtype)
260 assert np_arr.flags['C_CONTIGUOUS']
261 data = np_arr.ctypes.data_as(ctypes.c_void_p)
262 nbytes = ctypes.c_size_t(np_arr.size * np_arr.dtype.itemsize)
263 check_call(_LIB.DECORDArrayCopyToBytes(self.handle, data, nbytes))
264 return np_arr
265
266 def copyto(self, target):
267 """Copy array to target

Callers 11

__repr__Method · 0.95
__str__Method · 0.95
get_frame_timestampMethod · 0.80
get_key_indicesMethod · 0.80
__init__Method · 0.80
_get_sliceMethod · 0.80
test_bytes_ioFunction · 0.80
test_syncFunction · 0.80
test_bytes_ioFunction · 0.80
test_add_paddingFunction · 0.80
test_bytes_ioFunction · 0.80

Calls 2

DECORDTypeClass · 0.85
check_callFunction · 0.85

Tested by 5

test_bytes_ioFunction · 0.64
test_syncFunction · 0.64
test_bytes_ioFunction · 0.64
test_add_paddingFunction · 0.64
test_bytes_ioFunction · 0.64