Return numpy_array from the tuple returned by rand_structure()
(items, fmt, t)
| 637 | offset=offset, flags=ND_WRITABLE|flags) |
| 638 | |
| 639 | def 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 | # ====================================================================== |
no test coverage detected