MCPcopy Create free account
hub / github.com/alibaba/GraphScope / decode_numpy

Function decode_numpy

python/graphscope/framework/utils.py:426–452  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

424
425
426def decode_numpy(value):
427 if not value:
428 raise RuntimeError("Value to decode should not be empty")
429 archive = OutArchive(value)
430 shape_size = archive.get_size()
431 shape = []
432 for _ in range(shape_size):
433 shape.append(archive.get_size())
434 dtype = _context_protocol_to_numpy_dtype(archive.get_int())
435 array_size = archive.get_size()
436 check_argument(array_size == np.prod(shape))
437 if dtype is object:
438 data_copy = []
439 for _ in range(array_size):
440 data_copy.append(archive.get_string())
441 if shape and shape[0] > 1:
442 array = np.reshape(data_copy, shape)
443 else:
444 array = np.array(data_copy, dtype=dtype)
445 else:
446 array = np.ndarray(
447 shape=shape,
448 dtype=dtype,
449 buffer=archive.get_block(array_size * dtype.itemsize),
450 order="C",
451 )
452 return array
453
454
455def decode_dataframe(value):

Callers 1

wrap_resultsMethod · 0.90

Calls 8

get_sizeMethod · 0.95
get_intMethod · 0.95
get_stringMethod · 0.95
get_blockMethod · 0.95
OutArchiveClass · 0.90
check_argumentFunction · 0.90
appendMethod · 0.65

Tested by

no test coverage detected