diff --git a/example/example20.cpp b/example/example20.cpp index 2535b258b..7066e321b 100644 --- a/example/example20.cpp +++ b/example/example20.cpp @@ -57,7 +57,13 @@ py::array_t create_nested(size_t n) { ptr[i].b.x = (i + 1) % 2; ptr[i].b.y = (uint32_t) (i + 1); ptr[i].b.z = (float) (i + 1) * 1.5f; } return arr; +} + +void print_format_descriptors() { + std::cout << py::format_descriptor::value() << std::endl; + std::cout << py::format_descriptor::value() << std::endl; + std::cout << py::format_descriptor::value() << std::endl; } void init_ex20(py::module &m) { @@ -68,4 +74,5 @@ void init_ex20(py::module &m) { m.def("create_rec_simple", &create_recarray); m.def("create_rec_packed", &create_recarray); m.def("create_rec_nested", &create_nested); + m.def("print_format_descriptors", &print_format_descriptors); } diff --git a/example/example20.py b/example/example20.py index 83725b528..83a914c24 100644 --- a/example/example20.py +++ b/example/example20.py @@ -2,12 +2,16 @@ from __future__ import print_function import numpy as np -from example import create_rec_simple, create_rec_packed, create_rec_nested +from example import ( + create_rec_simple, create_rec_packed, create_rec_nested, print_format_descriptors +) def check_eq(arr, data, dtype): np.testing.assert_equal(arr, np.array(data, dtype=dtype)) +print_format_descriptors() + simple_dtype = np.dtype({'names': ['x', 'y', 'z'], 'formats': ['?', 'u4', 'f4'], 'offsets': [0, 4, 8]}) diff --git a/example/example20.ref b/example/example20.ref index e69de29bb..6023a87f2 100644 --- a/example/example20.ref +++ b/example/example20.ref @@ -0,0 +1,3 @@ +T{?:x:xxxI:y:f:z:} +T{?:x:=I:y:f:z:} +T{T{?:x:xxxI:y:f:z:}:a:T{?:x:=I:y:f:z:}:b:}