MCPcopy Index your code
hub / github.com/python/cpython / numpy_array_from_structure

Function numpy_array_from_structure

Lib/test/test_buffer.py:651–658  ·  view source on GitHub ↗

Return numpy_array from the tuple returned by rand_structure()

(items, fmt, t)

Source from the content-addressed store, hash-verified

649 offset=offset, flags=ND_WRITABLE|flags)
650
651def numpy_array_from_structure(items, fmt, t):
652 """Return numpy_array from the tuple returned by rand_structure()"""
653 memlen, itemsize, ndim, shape, strides, offset = t
654 buf = bytearray(memlen)
655 for j, v in enumerate(items):
656 struct.pack_into(fmt, buf, j*itemsize, v)
657 return numpy_array(buffer=buf, shape=shape, strides=strides,
658 dtype=fmt, offset=offset)
659
660
661# ======================================================================

Calls 1

enumerateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…