mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-13 17:13:53 +00:00
25 lines
724 B
Python
25 lines
724 B
Python
#!/usr/bin/env python
|
|
from __future__ import print_function
|
|
|
|
import numpy as np
|
|
from example import create_rec_simple
|
|
|
|
|
|
def check_eq(arr, data, dtype):
|
|
np.testing.assert_equal(arr, np.array(data, dtype=dtype))
|
|
|
|
dtype = np.dtype({'names': ['x', 'y', 'z'],
|
|
'formats': ['?', 'u4', 'f4'],
|
|
'offsets': [0, 4, 8]})
|
|
base_dtype = np.dtype([('x', '?'), ('y', 'u4'), ('z', 'f4')])
|
|
|
|
arr = create_rec_simple(3)
|
|
assert arr.dtype == dtype
|
|
check_eq(arr, [(False, 0, 0.0), (True, 1, 1.5), (False, 2, 3.0)], dtype)
|
|
check_eq(arr, [(False, 0, 0.0), (True, 1, 1.5), (False, 2, 3.0)], base_dtype)
|
|
|
|
arr = create_rec_simple(0)
|
|
assert arr.dtype == dtype
|
|
check_eq(arr, [], dtype)
|
|
check_eq(arr, [], base_dtype)
|