Ivan Smirnov | bb4015d | 2016-06-19 15:50:31 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | from __future__ import print_function |
| 3 | |
| 4 | import numpy as np |
| 5 | from example import create_rec_simple |
| 6 | |
| 7 | |
| 8 | def check_eq(arr, data, dtype): |
| 9 | np.testing.assert_equal(arr, np.array(data, dtype=dtype)) |
| 10 | |
| 11 | dtype = np.dtype({'names': ['x', 'y', 'z'], |
| 12 | 'formats': ['?', 'u4', 'f4'], |
| 13 | 'offsets': [0, 4, 8]}) |
| 14 | base_dtype = np.dtype([('x', '?'), ('y', 'u4'), ('z', 'f4')]) |
| 15 | |
| 16 | arr = create_rec_simple(3) |
| 17 | assert arr.dtype == dtype |
| 18 | check_eq(arr, [(False, 0, 0.0), (True, 1, 1.5), (False, 2, 3.0)], dtype) |
| 19 | check_eq(arr, [(False, 0, 0.0), (True, 1, 1.5), (False, 2, 3.0)], base_dtype) |