test_numpy_dtypes.cpp
Go to the documentation of this file.
1 /*
2  tests/test_numpy_dtypes.cpp -- Structured and compound NumPy dtypes
3 
4  Copyright (c) 2016 Ivan Smirnov
5 
6  All rights reserved. Use of this source code is governed by a
7  BSD-style license that can be found in the LICENSE file.
8 */
9 
10 #include <pybind11/numpy.h>
11 
12 #include "pybind11_tests.h"
13 
14 #ifdef __GNUC__
15 # define PYBIND11_PACKED(cls) cls __attribute__((__packed__))
16 #else
17 # define PYBIND11_PACKED(cls) __pragma(pack(push, 1)) cls __pragma(pack(pop))
18 #endif
19 
20 namespace py = pybind11;
21 
22 struct SimpleStruct {
23  bool bool_;
25  float float_;
26  long double ldbl_;
27 };
28 
29 std::ostream &operator<<(std::ostream &os, const SimpleStruct &v) {
30  return os << "s:" << v.bool_ << "," << v.uint_ << "," << v.float_ << "," << v.ldbl_;
31 }
32 
34  bool bool_;
35  float float_;
37  long double ldbl_;
38 };
39 
40 PYBIND11_PACKED(struct PackedStruct {
41  bool bool_;
42  uint32_t uint_;
43  float float_;
44  long double ldbl_;
45 });
46 
47 std::ostream &operator<<(std::ostream &os, const PackedStruct &v) {
48  return os << "p:" << v.bool_ << "," << v.uint_ << "," << v.float_ << "," << v.ldbl_;
49 }
50 
51 PYBIND11_PACKED(struct NestedStruct {
53  PackedStruct b;
54 });
55 
56 std::ostream &operator<<(std::ostream &os, const NestedStruct &v) {
57  return os << "n:a=" << v.a << ";b=" << v.b;
58 }
59 
60 struct PartialStruct {
61  bool bool_;
63  float float_;
65  long double ldbl_;
66 };
67 
72 };
73 
74 struct UnboundStruct {};
75 
76 struct StringStruct {
77  char a[3];
78  std::array<char, 3> b;
79 };
80 
81 struct ComplexStruct {
82  std::complex<float> cflt;
83  std::complex<double> cdbl;
84 };
85 
86 std::ostream &operator<<(std::ostream &os, const ComplexStruct &v) {
87  return os << "c:" << v.cflt << "," << v.cdbl;
88 }
89 
90 struct ArrayStruct {
91  char a[3][4];
92  int32_t b[2];
93  std::array<uint8_t, 3> c;
94  std::array<float, 2> d[4];
95 };
96 
97 PYBIND11_PACKED(struct StructWithUglyNames {
98  int8_t __x__;
99  uint64_t __y__;
100 });
101 
102 enum class E1 : int64_t { A = -1, B = 1 };
103 enum E2 : uint8_t { X = 1, Y = 2 };
104 
105 PYBIND11_PACKED(struct EnumStruct {
106  E1 e1;
107  E2 e2;
108 });
109 
110 std::ostream &operator<<(std::ostream &os, const StringStruct &v) {
111  os << "a='";
112  for (size_t i = 0; i < 3 && (v.a[i] != 0); i++) {
113  os << v.a[i];
114  }
115  os << "',b='";
116  for (size_t i = 0; i < 3 && (v.b[i] != 0); i++) {
117  os << v.b[i];
118  }
119  return os << "'";
120 }
121 
122 std::ostream &operator<<(std::ostream &os, const ArrayStruct &v) {
123  os << "a={";
124  for (int i = 0; i < 3; i++) {
125  if (i > 0) {
126  os << ',';
127  }
128  os << '{';
129  for (int j = 0; j < 3; j++) {
130  os << v.a[i][j] << ',';
131  }
132  os << v.a[i][3] << '}';
133  }
134  os << "},b={" << v.b[0] << ',' << v.b[1];
135  os << "},c={" << int(v.c[0]) << ',' << int(v.c[1]) << ',' << int(v.c[2]);
136  os << "},d={";
137  for (int i = 0; i < 4; i++) {
138  if (i > 0) {
139  os << ',';
140  }
141  os << '{' << v.d[i][0] << ',' << v.d[i][1] << '}';
142  }
143  return os << '}';
144 }
145 
146 std::ostream &operator<<(std::ostream &os, const EnumStruct &v) {
147  return os << "e1=" << (v.e1 == E1::A ? "A" : "B") << ",e2=" << (v.e2 == E2::X ? "X" : "Y");
148 }
149 
150 template <typename T>
152  return py::array(py::buffer_info(
153  nullptr, sizeof(T), py::format_descriptor<T>::format(), 1, {n}, {sizeof(T)}));
154 }
155 
156 #define SET_TEST_VALS(s, i) \
157  do { \
158  (s).bool_ = (i) % 2 != 0; \
159  (s).uint_ = (uint32_t) (i); \
160  (s).float_ = (float) (i) *1.5f; \
161  (s).ldbl_ = (long double) (i) * -2.5L; \
162  } while (0)
163 
164 template <typename S>
165 py::array_t<S, 0> create_recarray(size_t n) {
166  auto arr = mkarray_via_buffer<S>(n);
167  auto req = arr.request();
168  auto *ptr = static_cast<S *>(req.ptr);
169  for (size_t i = 0; i < n; i++) {
170  SET_TEST_VALS(ptr[i], i);
171  }
172  return arr;
173 }
174 
175 template <typename S>
176 py::list print_recarray(py::array_t<S, 0> arr) {
177  const auto req = arr.request();
178  auto *const ptr = static_cast<S *>(req.ptr);
179  auto l = py::list();
180  for (py::ssize_t i = 0; i < req.size; i++) {
181  std::stringstream ss;
182  ss << ptr[i];
183  l.append(py::str(ss.str()));
184  }
185  return l;
186 }
187 
188 py::array_t<int32_t, 0> test_array_ctors(int i) {
189  using arr_t = py::array_t<int32_t, 0>;
190 
191  std::vector<int32_t> data{1, 2, 3, 4, 5, 6};
192  std::vector<py::ssize_t> shape{3, 2};
193  std::vector<py::ssize_t> strides{8, 4};
194 
195  auto *ptr = data.data();
196  auto *vptr = (void *) ptr;
197  auto dtype = py::dtype("int32");
198 
199  py::buffer_info buf_ndim1(vptr, 4, "i", 6);
200  py::buffer_info buf_ndim1_null(nullptr, 4, "i", 6);
201  py::buffer_info buf_ndim2(vptr, 4, "i", 2, shape, strides);
202  py::buffer_info buf_ndim2_null(nullptr, 4, "i", 2, shape, strides);
203 
204  auto fill = [](py::array arr) {
205  auto req = arr.request();
206  for (int i = 0; i < 6; i++) {
207  ((int32_t *) req.ptr)[i] = i + 1;
208  }
209  return arr;
210  };
211 
212  switch (i) {
213  // shape: (3, 2)
214  case 10:
215  return arr_t(shape, strides, ptr);
216  case 11:
217  return py::array(shape, strides, ptr);
218  case 12:
219  return py::array(dtype, shape, strides, vptr);
220  case 13:
221  return arr_t(shape, ptr);
222  case 14:
223  return py::array(shape, ptr);
224  case 15:
225  return py::array(dtype, shape, vptr);
226  case 16:
227  return arr_t(buf_ndim2);
228  case 17:
229  return py::array(buf_ndim2);
230  // shape: (3, 2) - post-fill
231  case 20:
232  return fill(arr_t(shape, strides));
233  case 21:
234  return py::array(shape, strides, ptr); // can't have nullptr due to templated ctor
235  case 22:
236  return fill(py::array(dtype, shape, strides));
237  case 23:
238  return fill(arr_t(shape));
239  case 24:
240  return py::array(shape, ptr); // can't have nullptr due to templated ctor
241  case 25:
242  return fill(py::array(dtype, shape));
243  case 26:
244  return fill(arr_t(buf_ndim2_null));
245  case 27:
246  return fill(py::array(buf_ndim2_null));
247  // shape: (6, )
248  case 30:
249  return arr_t(6, ptr);
250  case 31:
251  return py::array(6, ptr);
252  case 32:
253  return py::array(dtype, 6, vptr);
254  case 33:
255  return arr_t(buf_ndim1);
256  case 34:
257  return py::array(buf_ndim1);
258  // shape: (6, )
259  case 40:
260  return fill(arr_t(6));
261  case 41:
262  return py::array(6, ptr); // can't have nullptr due to templated ctor
263  case 42:
264  return fill(py::array(dtype, 6));
265  case 43:
266  return fill(arr_t(buf_ndim1_null));
267  case 44:
268  return fill(py::array(buf_ndim1_null));
269  }
270  return arr_t();
271 }
272 
273 py::list test_dtype_ctors() {
274  py::list list;
275  list.append(py::dtype("int32"));
276  list.append(py::dtype(std::string("float64")));
277  list.append(py::dtype::from_args(py::str("bool")));
278  py::list names, offsets, formats;
279  py::dict dict;
280  names.append(py::str("a"));
281  names.append(py::str("b"));
282  dict["names"] = names;
283  offsets.append(py::int_(1));
284  offsets.append(py::int_(10));
285  dict["offsets"] = offsets;
286  formats.append(py::dtype("int32"));
287  formats.append(py::dtype("float64"));
288  dict["formats"] = formats;
289  dict["itemsize"] = py::int_(20);
290  list.append(py::dtype::from_args(dict));
291  list.append(py::dtype(names, formats, offsets, 20));
292  list.append(py::dtype(py::buffer_info((void *) nullptr, sizeof(unsigned int), "I", 1)));
293  list.append(py::dtype(py::buffer_info((void *) nullptr, 0, "T{i:a:f:b:}", 1)));
294  list.append(py::dtype(py::detail::npy_api::NPY_DOUBLE_));
295  return list;
296 }
297 
298 struct A {};
299 struct B {};
300 
301 TEST_SUBMODULE(numpy_dtypes, m) {
302  try {
303  py::module_::import("numpy");
304  } catch (const py::error_already_set &) {
305  return;
306  }
307 
308  // typeinfo may be registered before the dtype descriptor for scalar casts to work...
309  py::class_<SimpleStruct>(m, "SimpleStruct")
310  // Explicit construct to ensure zero-valued initialization.
311  .def(py::init([]() { return SimpleStruct(); }))
312  .def_readwrite("bool_", &SimpleStruct::bool_)
313  .def_readwrite("uint_", &SimpleStruct::uint_)
314  .def_readwrite("float_", &SimpleStruct::float_)
315  .def_readwrite("ldbl_", &SimpleStruct::ldbl_)
316  .def("astuple",
317  [](const SimpleStruct &self) {
318  return py::make_tuple(self.bool_, self.uint_, self.float_, self.ldbl_);
319  })
320  .def_static("fromtuple", [](const py::tuple &tup) {
321  if (py::len(tup) != 4) {
322  throw py::cast_error("Invalid size");
323  }
324  return SimpleStruct{tup[0].cast<bool>(),
325  tup[1].cast<uint32_t>(),
326  tup[2].cast<float>(),
327  tup[3].cast<long double>()};
328  });
329 
332  PYBIND11_NUMPY_DTYPE(PackedStruct, bool_, uint_, float_, ldbl_);
333  PYBIND11_NUMPY_DTYPE(NestedStruct, a, b);
338  PYBIND11_NUMPY_DTYPE(EnumStruct, e1, e2);
339  PYBIND11_NUMPY_DTYPE(ComplexStruct, cflt, cdbl);
340 
341  // ... or after
342  py::class_<PackedStruct>(m, "PackedStruct");
343 
344  PYBIND11_NUMPY_DTYPE_EX(StructWithUglyNames, __x__, "x", __y__, "y");
345 
346 #ifdef PYBIND11_NEVER_DEFINED_EVER
347  // If enabled, this should produce a static_assert failure telling the user that the struct
348  // is not a POD type
349  struct NotPOD {
350  std::string v;
351  NotPOD() : v("hi"){};
352  };
353  PYBIND11_NUMPY_DTYPE(NotPOD, v);
354 #endif
355 
356  // Check that dtypes can be registered programmatically, both from
357  // initializer lists of field descriptors and from other containers.
358  py::detail::npy_format_descriptor<A>::register_dtype({});
359  py::detail::npy_format_descriptor<B>::register_dtype(
360  std::vector<py::detail::field_descriptor>{});
361 
362  // test_recarray, test_scalar_conversion
363  m.def("create_rec_simple", &create_recarray<SimpleStruct>);
364  m.def("create_rec_packed", &create_recarray<PackedStruct>);
365  m.def("create_rec_nested", [](size_t n) { // test_signature
366  py::array_t<NestedStruct, 0> arr = mkarray_via_buffer<NestedStruct>(n);
367  auto req = arr.request();
368  auto *ptr = static_cast<NestedStruct *>(req.ptr);
369  for (size_t i = 0; i < n; i++) {
370  SET_TEST_VALS(ptr[i].a, i);
371  SET_TEST_VALS(ptr[i].b, i + 1);
372  }
373  return arr;
374  });
375  m.def("create_rec_partial", &create_recarray<PartialStruct>);
376  m.def("create_rec_partial_nested", [](size_t n) {
377  py::array_t<PartialNestedStruct, 0> arr = mkarray_via_buffer<PartialNestedStruct>(n);
378  auto req = arr.request();
379  auto *ptr = static_cast<PartialNestedStruct *>(req.ptr);
380  for (size_t i = 0; i < n; i++) {
381  SET_TEST_VALS(ptr[i].a, i);
382  }
383  return arr;
384  });
385  m.def("print_rec_simple", &print_recarray<SimpleStruct>);
386  m.def("print_rec_packed", &print_recarray<PackedStruct>);
387  m.def("print_rec_nested", &print_recarray<NestedStruct>);
388 
389  // test_format_descriptors
390  m.def("get_format_unbound", []() { return py::format_descriptor<UnboundStruct>::format(); });
391  m.def("print_format_descriptors", []() {
392  py::list l;
393  for (const auto &fmt : {py::format_descriptor<SimpleStruct>::format(),
402  l.append(py::cast(fmt));
403  }
404  return l;
405  });
406 
407  // test_dtype
408  std::vector<const char *> dtype_names{
409  "byte", "short", "intc", "int_", "longlong", "ubyte", "ushort",
410  "uintc", "uint", "ulonglong", "half", "single", "double", "longdouble",
411  "csingle", "cdouble", "clongdouble", "bool_", "datetime64", "timedelta64", "object_"};
412 
413  m.def("print_dtypes", []() {
414  py::list l;
415  for (const py::handle &d : {py::dtype::of<SimpleStruct>(),
416  py::dtype::of<PackedStruct>(),
417  py::dtype::of<NestedStruct>(),
418  py::dtype::of<PartialStruct>(),
419  py::dtype::of<PartialNestedStruct>(),
420  py::dtype::of<StringStruct>(),
421  py::dtype::of<ArrayStruct>(),
422  py::dtype::of<EnumStruct>(),
423  py::dtype::of<StructWithUglyNames>(),
424  py::dtype::of<ComplexStruct>()}) {
425  l.append(py::str(d));
426  }
427  return l;
428  });
429  m.def("test_dtype_ctors", &test_dtype_ctors);
430  m.def("test_dtype_kind", [dtype_names]() {
431  py::list list;
432  for (const auto &dt_name : dtype_names) {
433  list.append(py::dtype(dt_name).kind());
434  }
435  return list;
436  });
437  m.def("test_dtype_char_", [dtype_names]() {
438  py::list list;
439  for (const auto &dt_name : dtype_names) {
440  list.append(py::dtype(dt_name).char_());
441  }
442  return list;
443  });
444  m.def("test_dtype_num", [dtype_names]() {
445  py::list list;
446  for (const auto &dt_name : dtype_names) {
447  list.append(py::dtype(dt_name).num());
448  }
449  return list;
450  });
451  m.def("test_dtype_byteorder", [dtype_names]() {
452  py::list list;
453  for (const auto &dt_name : dtype_names) {
454  list.append(py::dtype(dt_name).byteorder());
455  }
456  return list;
457  });
458  m.def("test_dtype_alignment", [dtype_names]() {
459  py::list list;
460  for (const auto &dt_name : dtype_names) {
461  list.append(py::dtype(dt_name).alignment());
462  }
463  return list;
464  });
465  m.def("test_dtype_flags", [dtype_names]() {
466  py::list list;
467  for (const auto &dt_name : dtype_names) {
468  list.append(py::dtype(dt_name).flags());
469  }
470  return list;
471  });
472  m.def("test_dtype_methods", []() {
473  py::list list;
474  auto dt1 = py::dtype::of<int32_t>();
475  auto dt2 = py::dtype::of<SimpleStruct>();
476  list.append(dt1);
477  list.append(dt2);
478  list.append(py::bool_(dt1.has_fields()));
479  list.append(py::bool_(dt2.has_fields()));
480  list.append(py::int_(dt1.itemsize()));
481  list.append(py::int_(dt2.itemsize()));
482  return list;
483  });
484  struct TrailingPaddingStruct {
485  int32_t a;
486  char b;
487  };
488  PYBIND11_NUMPY_DTYPE(TrailingPaddingStruct, a, b);
489  m.def("trailing_padding_dtype", []() { return py::dtype::of<TrailingPaddingStruct>(); });
490 
491  // test_string_array
492  m.def("create_string_array", [](bool non_empty) {
493  py::array_t<StringStruct, 0> arr = mkarray_via_buffer<StringStruct>(non_empty ? 4 : 0);
494  if (non_empty) {
495  auto req = arr.request();
496  auto *ptr = static_cast<StringStruct *>(req.ptr);
497  for (py::ssize_t i = 0; i < req.size * req.itemsize; i++) {
498  static_cast<char *>(req.ptr)[i] = 0;
499  }
500  ptr[1].a[0] = 'a';
501  ptr[1].b[0] = 'a';
502  ptr[2].a[0] = 'a';
503  ptr[2].b[0] = 'a';
504  ptr[3].a[0] = 'a';
505  ptr[3].b[0] = 'a';
506 
507  ptr[2].a[1] = 'b';
508  ptr[2].b[1] = 'b';
509  ptr[3].a[1] = 'b';
510  ptr[3].b[1] = 'b';
511 
512  ptr[3].a[2] = 'c';
513  ptr[3].b[2] = 'c';
514  }
515  return arr;
516  });
517  m.def("print_string_array", &print_recarray<StringStruct>);
518 
519  // test_array_array
520  m.def("create_array_array", [](size_t n) {
521  py::array_t<ArrayStruct, 0> arr = mkarray_via_buffer<ArrayStruct>(n);
522  auto *ptr = (ArrayStruct *) arr.mutable_data();
523  for (size_t i = 0; i < n; i++) {
524  for (size_t j = 0; j < 3; j++) {
525  for (size_t k = 0; k < 4; k++) {
526  ptr[i].a[j][k] = char('A' + (i * 100 + j * 10 + k) % 26);
527  }
528  }
529  for (size_t j = 0; j < 2; j++) {
530  ptr[i].b[j] = int32_t(i * 1000 + j);
531  }
532  for (size_t j = 0; j < 3; j++) {
533  ptr[i].c[j] = uint8_t(i * 10 + j);
534  }
535  for (size_t j = 0; j < 4; j++) {
536  for (size_t k = 0; k < 2; k++) {
537  ptr[i].d[j][k] = float(i) * 100.0f + float(j) * 10.0f + float(k);
538  }
539  }
540  }
541  return arr;
542  });
543  m.def("print_array_array", &print_recarray<ArrayStruct>);
544 
545  // test_enum_array
546  m.def("create_enum_array", [](size_t n) {
547  py::array_t<EnumStruct, 0> arr = mkarray_via_buffer<EnumStruct>(n);
548  auto *ptr = (EnumStruct *) arr.mutable_data();
549  for (size_t i = 0; i < n; i++) {
550  ptr[i].e1 = static_cast<E1>(-1 + ((int) i % 2) * 2);
551  ptr[i].e2 = static_cast<E2>(1 + (i % 2));
552  }
553  return arr;
554  });
555  m.def("print_enum_array", &print_recarray<EnumStruct>);
556 
557  // test_complex_array
558  m.def("create_complex_array", [](size_t n) {
559  py::array_t<ComplexStruct, 0> arr = mkarray_via_buffer<ComplexStruct>(n);
560  auto *ptr = (ComplexStruct *) arr.mutable_data();
561  for (size_t i = 0; i < n; i++) {
562  ptr[i].cflt.real(float(i));
563  ptr[i].cflt.imag(float(i) + 0.25f);
564  ptr[i].cdbl.real(double(i) + 0.5);
565  ptr[i].cdbl.imag(double(i) + 0.75);
566  }
567  return arr;
568  });
569  m.def("print_complex_array", &print_recarray<ComplexStruct>);
570 
571  // test_array_constructors
572  m.def("test_array_ctors", &test_array_ctors);
573 
574  // test_compare_buffer_info
575  struct CompareStruct {
576  bool x;
577  uint32_t y;
578  float z;
579  };
580  PYBIND11_NUMPY_DTYPE(CompareStruct, x, y, z);
581  m.def("compare_buffer_info", []() {
582  py::list list;
584  py::buffer_info(nullptr, sizeof(float), "f", 1))));
586  py::buffer_info(nullptr, sizeof(int), "I", 1))));
588  py::buffer_info(nullptr, sizeof(long), "l", 1))));
590  py::buffer_info(nullptr, sizeof(long), sizeof(long) == sizeof(int) ? "i" : "q", 1))));
592  py::buffer_info(nullptr, sizeof(CompareStruct), "T{?:x:3xI:y:f:z:}", 1))));
593  return list;
594  });
595  m.def("buffer_to_dtype", [](py::buffer &buf) { return py::dtype(buf.request()); });
596 
597  // test_scalar_conversion
598  auto f_simple = [](SimpleStruct s) { return s.uint_ * 10; };
599  m.def("f_simple", f_simple);
600  m.def("f_packed", [](PackedStruct s) { return s.uint_ * 10; });
601  m.def("f_nested", [](NestedStruct s) { return s.a.uint_ * 10; });
602 
603  // test_vectorize
604  m.def("f_simple_vectorized", py::vectorize(f_simple));
605  auto f_simple_pass_thru = [](SimpleStruct s) { return s; };
606  m.def("f_simple_pass_thru_vectorized", py::vectorize(f_simple_pass_thru));
607 
608  // test_register_dtype
609  m.def("register_dtype",
610  []() { PYBIND11_NUMPY_DTYPE(SimpleStruct, bool_, uint_, float_, ldbl_); });
611 
612  // test_str_leak
613  m.def("dtype_wrapper", [](const py::object &d) { return py::dtype::from_args(d); });
614 }
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
compare
bool compare
Definition: SolverComparer.cpp:98
SimpleStructReordered::uint_
uint32_t uint_
Definition: test_numpy_dtypes.cpp:36
test_array_ctors
py::array_t< int32_t, 0 > test_array_ctors(int i)
Definition: test_numpy_dtypes.cpp:188
format
std::string format(const std::string &str, const std::vector< std::string > &find, const std::vector< std::string > &replace)
Definition: openglsupport.cpp:226
array
int array[24]
Definition: Map_general_stride.cpp:1
StringStruct::a
char a[3]
Definition: test_numpy_dtypes.cpp:77
Eigen::internal::strides
EIGEN_ALWAYS_INLINE DSizes< IndexType, NumDims > strides(const DSizes< IndexType, NumDims > &dimensions)
Definition: TensorBlock.h:26
ssize_t
Py_ssize_t ssize_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:475
X
@ X
Definition: test_numpy_dtypes.cpp:103
ArrayStruct
Definition: test_numpy_dtypes.cpp:90
s
RealScalar s
Definition: level1_cplx_impl.h:126
d
static const double d[K][N]
Definition: igam.h:11
ComplexStruct
Definition: test_numpy_dtypes.cpp:81
ArrayStruct::b
int32_t b[2]
Definition: test_numpy_dtypes.cpp:92
uint32_t
unsigned int uint32_t
Definition: ms_stdint.h:85
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
b
Scalar * b
Definition: benchVecAdd.cpp:17
ComplexStruct::cdbl
std::complex< double > cdbl
Definition: test_numpy_dtypes.cpp:83
SimpleStructReordered::ldbl_
long double ldbl_
Definition: test_numpy_dtypes.cpp:37
PartialNestedStruct
Definition: test_numpy_dtypes.cpp:68
StringStruct::b
std::array< char, 3 > b
Definition: test_numpy_dtypes.cpp:78
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
PartialStruct::dummy2
uint64_t dummy2
Definition: test_numpy_dtypes.cpp:64
E2
E2
Definition: test_numpy_dtypes.cpp:103
E1::B
@ B
T
Eigen::Triplet< double > T
Definition: Tutorial_sparse_example.cpp:6
PartialStruct::float_
float float_
Definition: test_numpy_dtypes.cpp:63
ComplexStruct::cflt
std::complex< float > cflt
Definition: test_numpy_dtypes.cpp:82
ArrayStruct::a
char a[3][4]
Definition: test_numpy_dtypes.cpp:91
Eigen::DenseBase::operator<<
std::ostream & operator<<(std::ostream &s, const DenseBase< Derived > &m)
Definition: IO.h:250
PartialNestedStruct::dummy1
uint64_t dummy1
Definition: test_numpy_dtypes.cpp:69
os
ofstream os("timeSchurFactors.csv")
uint8_t
unsigned char uint8_t
Definition: ms_stdint.h:83
ss
static std::stringstream ss
Definition: testBTree.cpp:31
bool_
Definition: pytypes.h:1756
SimpleStructReordered::bool_
bool bool_
Definition: test_numpy_dtypes.cpp:34
n
int n
Definition: BiCGSTAB_simple.cpp:1
PartialStruct
Definition: test_numpy_dtypes.cpp:60
arr_t
py::array_t< uint16_t, 0 > arr_t
Definition: test_numpy_array.cpp:78
SET_TEST_VALS
#define SET_TEST_VALS(s, i)
Definition: test_numpy_dtypes.cpp:156
dict
Definition: pytypes.h:2065
dtype
Definition: numpy.h:540
UnboundStruct
Definition: test_numpy_dtypes.cpp:74
data
int data[]
Definition: Map_placement_new.cpp:1
PartialNestedStruct::a
PartialStruct a
Definition: test_numpy_dtypes.cpp:70
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
make_tuple
tuple make_tuple()
Definition: cast.h:1248
int64_t
signed __int64 int64_t
Definition: ms_stdint.h:94
PYBIND11_NUMPY_DTYPE
#define PYBIND11_NUMPY_DTYPE(Type,...)
Definition: numpy.h:1515
SimpleStructReordered
Definition: test_numpy_dtypes.cpp:33
create_recarray
py::array_t< S, 0 > create_recarray(size_t n)
Definition: test_numpy_dtypes.cpp:165
l
static const Line3 l(Rot3(), 1, 1)
vectorize
detail::vectorize_helper< Return(*)(Args...), Return, Args... > vectorize(Return(*f)(Args...))
Definition: numpy.h:1959
numpy.h
test_dtype_ctors
py::list test_dtype_ctors()
Definition: test_numpy_dtypes.cpp:273
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
Eigen::Triplet< double >
int8_t
signed char int8_t
Definition: ms_stdint.h:80
SimpleStruct::float_
float float_
Definition: test_numpy_dtypes.cpp:25
E1::A
@ A
init
detail::initimpl::constructor< Args... > init()
Binds an existing constructor taking arguments Args...
Definition: pybind11.h:1912
y
Scalar * y
Definition: level1_cplx_impl.h:124
SimpleStruct::uint_
uint32_t uint_
Definition: test_numpy_dtypes.cpp:24
PYBIND11_PACKED
#define PYBIND11_PACKED(cls)
Definition: test_numpy_dtypes.cpp:17
process_shonan_timing_results.names
dictionary names
Definition: process_shonan_timing_results.py:175
Y
@ Y
Definition: test_numpy_dtypes.cpp:103
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
TEST_SUBMODULE
TEST_SUBMODULE(numpy_dtypes, m)
Definition: test_numpy_dtypes.cpp:301
arr
py::array arr
Definition: test_numpy_array.cpp:77
print_recarray
py::list print_recarray(py::array_t< S, 0 > arr)
Definition: test_numpy_dtypes.cpp:176
mkarray_via_buffer
py::array mkarray_via_buffer(size_t n)
Definition: test_numpy_dtypes.cpp:151
SimpleStruct::bool_
bool bool_
Definition: test_numpy_dtypes.cpp:23
pybind11_tests.h
test_eigen_tensor.dtype
dtype
Definition: test_eigen_tensor.py:24
offsets
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set offsets
Definition: gnuplot_common_settings.hh:27
SimpleStruct::ldbl_
long double ldbl_
Definition: test_numpy_dtypes.cpp:26
ArrayStruct::c
std::array< uint8_t, 3 > c
Definition: test_numpy_dtypes.cpp:93
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
float_
Definition: pytypes.h:1828
PYBIND11_NUMPY_DTYPE_EX
#define PYBIND11_NUMPY_DTYPE_EX(Type,...)
Definition: numpy.h:1537
PartialStruct::uint_
uint32_t uint_
Definition: test_numpy_dtypes.cpp:62
pybind11
Definition: wrap/pybind11/pybind11/__init__.py:1
gtsam.examples.DogLegOptimizerExample.float
float
Definition: DogLegOptimizerExample.py:113
int32_t
signed int int32_t
Definition: ms_stdint.h:82
uint64_t
unsigned __int64 uint64_t
Definition: ms_stdint.h:95
len
size_t len(handle h)
Get the length of a Python object.
Definition: pytypes.h:2399
PartialStruct::ldbl_
long double ldbl_
Definition: test_numpy_dtypes.cpp:65
ArrayStruct::d
std::array< float, 2 > d[4]
Definition: test_numpy_dtypes.cpp:94
PartialNestedStruct::dummy2
uint64_t dummy2
Definition: test_numpy_dtypes.cpp:71
gtsam.examples.ShonanAveragingCLI.str
str
Definition: ShonanAveragingCLI.py:115
SimpleStruct
Definition: test_numpy_dtypes.cpp:22
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Eigen::internal::cast
EIGEN_DEVICE_FUNC NewType cast(const OldType &x)
Definition: Eigen/src/Core/MathFunctions.h:460
SimpleStructReordered::float_
float float_
Definition: test_numpy_dtypes.cpp:35
E1
E1
Definition: test_numpy_dtypes.cpp:102
S
DiscreteKey S(1, 2)
PartialStruct::bool_
bool bool_
Definition: test_numpy_dtypes.cpp:61
StringStruct
Definition: test_numpy_dtypes.cpp:76


gtsam
Author(s):
autogenerated on Wed May 15 2024 15:24:34