MCPcopy
hub / github.com/dmlc/dgl / asnumpy

Method asnumpy

python/dgl/_ffi/ndarray.py:325–344  ·  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

323 return str(self.asnumpy())
324
325 def asnumpy(self):
326 """Convert this array to numpy array
327
328 Returns
329 -------
330 np_arr : numpy.ndarray
331 The corresponding numpy array.
332 """
333 t = DGLDataType(self.dtype)
334 shape, dtype = self.shape, self.dtype
335 if t.lanes > 1:
336 shape = shape + (t.lanes,)
337 t.lanes = 1
338 dtype = str(t)
339 np_arr = np.empty(shape, dtype=dtype)
340 assert np_arr.flags["C_CONTIGUOUS"]
341 data = np_arr.ctypes.data_as(ctypes.c_void_p)
342 nbytes = ctypes.c_size_t(np_arr.size * np_arr.dtype.itemsize)
343 check_call(_LIB.DGLArrayCopyToBytes(self.handle, data, nbytes))
344 return np_arr
345
346 def copyto(self, target):
347 """Copy array to target

Callers 15

__repr__Method · 0.95
__str__Method · 0.95
_bucketingFunction · 0.80
_topk_onFunction · 0.80
unbatchFunction · 0.80
reorder_nodesFunction · 0.80
reshuffle_graphFunction · 0.80
__getitem__Method · 0.80
to_heterogeneousFunction · 0.80
_to_networkx_homogeneousFunction · 0.80

Calls 2

DGLDataTypeClass · 0.85
check_callFunction · 0.85

Tested by 15

test_redditFunction · 0.64
check_closeFunction · 0.64
test_topkFunction · 0.64
test_csrmmFunction · 0.64
test_csrmm_backwardFunction · 0.64
test_csrsumFunction · 0.64
test_csrsum_backwardFunction · 0.64
test_csrmaskFunction · 0.64
test_csrmask_backwardFunction · 0.64
_print_errorFunction · 0.64
test_heterograph_mergeFunction · 0.64
_print_errorFunction · 0.64