|
27 | 27 |
|
28 | 28 | void init_Dataset(py::module &m) |
29 | 29 | { |
30 | | - py::class_<Dataset>(m, "Dataset") |
| 30 | + auto pyDataset = |
| 31 | + py::class_<Dataset>(m, "Dataset") |
| 32 | + .def( |
| 33 | + py::init<Datatype, Extent>(), |
| 34 | + py::arg("dtype"), |
| 35 | + py::arg("extent")) |
| 36 | + .def(py::init<Extent>(), py::arg("extent")) |
| 37 | + .def( |
| 38 | + py::init([](py::dtype dt, Extent const &e) { |
| 39 | + auto const d = dtype_from_numpy(std::move(dt)); |
| 40 | + return new Dataset{d, e}; |
| 41 | + }), |
| 42 | + py::arg("dtype"), |
| 43 | + py::arg("extent")) |
| 44 | + .def( |
| 45 | + py::init<Datatype, Extent, std::string>(), |
| 46 | + py::arg("dtype"), |
| 47 | + py::arg("extent"), |
| 48 | + py::arg("options")) |
| 49 | + .def( |
| 50 | + py::init([](py::dtype dt, Extent e, std::string options) { |
| 51 | + auto const d = dtype_from_numpy(std::move(dt)); |
| 52 | + return new Dataset{d, std::move(e), std::move(options)}; |
| 53 | + }), |
| 54 | + py::arg("dtype"), |
| 55 | + py::arg("extent"), |
| 56 | + py::arg("options")) |
31 | 57 |
|
32 | | - .def(py::init<Datatype, Extent>(), py::arg("dtype"), py::arg("extent")) |
33 | | - .def(py::init<Extent>(), py::arg("extent")) |
34 | | - .def( |
35 | | - py::init([](py::dtype dt, Extent const &e) { |
36 | | - auto const d = dtype_from_numpy(std::move(dt)); |
37 | | - return new Dataset{d, e}; |
38 | | - }), |
39 | | - py::arg("dtype"), |
40 | | - py::arg("extent")) |
41 | | - .def( |
42 | | - py::init<Datatype, Extent, std::string>(), |
43 | | - py::arg("dtype"), |
44 | | - py::arg("extent"), |
45 | | - py::arg("options")) |
46 | | - .def( |
47 | | - py::init([](py::dtype dt, Extent const &e, std::string options) { |
48 | | - auto const d = dtype_from_numpy(std::move(dt)); |
49 | | - return new Dataset{d, e, std::move(options)}; |
50 | | - }), |
51 | | - py::arg("dtype"), |
52 | | - py::arg("extent"), |
53 | | - py::arg("options")) |
54 | | - |
55 | | - .def( |
56 | | - "__repr__", |
57 | | - [](const Dataset &d) { |
58 | | - std::stringstream stream; |
59 | | - stream << "<openPMD.Dataset of type '" << d.dtype |
60 | | - << "' and with extent "; |
61 | | - if (d.extent.empty()) |
62 | | - { |
63 | | - stream << "[]>"; |
64 | | - } |
65 | | - else |
66 | | - { |
67 | | - auto begin = d.extent.begin(); |
68 | | - stream << '[' << *begin++; |
69 | | - for (; begin != d.extent.end(); ++begin) |
| 58 | + .def( |
| 59 | + "__repr__", |
| 60 | + [](const Dataset &d) { |
| 61 | + std::stringstream stream; |
| 62 | + stream << "<openPMD.Dataset of type '" << d.dtype |
| 63 | + << "' and with extent "; |
| 64 | + if (d.extent.empty()) |
| 65 | + { |
| 66 | + stream << "[]>"; |
| 67 | + } |
| 68 | + else |
70 | 69 | { |
71 | | - stream << ", " << *begin; |
| 70 | + auto begin = d.extent.begin(); |
| 71 | + stream << '[' << *begin++; |
| 72 | + for (; begin != d.extent.end(); ++begin) |
| 73 | + { |
| 74 | + stream << ", " << *begin; |
| 75 | + } |
| 76 | + stream << "]>"; |
72 | 77 | } |
73 | | - stream << "]>"; |
74 | | - } |
75 | | - return stream.str(); |
76 | | - }) |
| 78 | + return stream.str(); |
| 79 | + }) |
77 | 80 |
|
78 | | - .def_readonly("extent", &Dataset::extent) |
79 | | - .def("extend", &Dataset::extend) |
80 | | - .def_readonly("rank", &Dataset::rank) |
81 | | - .def_property_readonly( |
82 | | - "dtype", [](const Dataset &d) { return dtype_to_numpy(d.dtype); }) |
83 | | - .def_readwrite("options", &Dataset::options); |
| 81 | + .def_property_readonly( |
| 82 | + "joined_dimension", &Dataset::joinedDimension) |
| 83 | + .def_readonly("extent", &Dataset::extent) |
| 84 | + .def("extend", &Dataset::extend) |
| 85 | + .def_readonly("rank", &Dataset::rank) |
| 86 | + .def_property_readonly( |
| 87 | + "dtype", |
| 88 | + [](const Dataset &d) { return dtype_to_numpy(d.dtype); }) |
| 89 | + .def_readwrite("options", &Dataset::options); |
| 90 | + pyDataset.attr("JOINED_DIMENSION") = |
| 91 | + py::int_(uint64_t(Dataset::JOINED_DIMENSION)); |
84 | 92 | } |
0 commit comments