Construct an array viewing the first byte of each element of `x`
(x)
| 565 | |
| 566 | |
| 567 | def view_element_first_byte(x): |
| 568 | """Construct an array viewing the first byte of each element of `x`""" |
| 569 | from numpy.lib.stride_tricks import DummyArray |
| 570 | interface = dict(x.__array_interface__) |
| 571 | interface['typestr'] = '|b1' |
| 572 | interface['descr'] = [('', '|b1')] |
| 573 | return np.asarray(DummyArray(interface, x)) |
| 574 | |
| 575 | |
| 576 | def assert_copy_equivalent(operation, args, out, **kwargs): |