MCPcopy Index your code
hub / github.com/RustPython/RustPython / numpy_array_from_structure

Function numpy_array_from_structure

Lib/test/test_buffer.py:639–646  ·  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

637 offset=offset, flags=ND_WRITABLE|flags)
638
639def numpy_array_from_structure(items, fmt, t):
640 """Return numpy_array from the tuple returned by rand_structure()"""
641 memlen, itemsize, ndim, shape, strides, offset = t
642 buf = bytearray(memlen)
643 for j, v in enumerate(items):
644 struct.pack_into(fmt, buf, j*itemsize, v)
645 return numpy_array(buffer=buf, shape=shape, strides=strides,
646 dtype=fmt, offset=offset)
647
648
649# ======================================================================

Calls 2

enumerateFunction · 0.85
pack_intoMethod · 0.45

Tested by

no test coverage detected