|
22 | 22 |
|
23 | 23 | #include "openPMD/binding/python/Common.hpp" |
24 | 24 | #include "openPMD/binding/python/Numpy.hpp" |
| 25 | +#include "openPMD/binding/python/auxiliary.hpp" |
25 | 26 |
|
26 | 27 | #include <string> |
27 | 28 |
|
28 | 29 | void init_Dataset(py::module &m) |
29 | 30 | { |
30 | 31 | auto pyDataset = |
31 | 32 | py::class_<Dataset>(m, "Dataset") |
| 33 | + .def(py::init<Extent>(), py::arg("extent")) |
32 | 34 | .def( |
33 | | - py::init<Datatype, Extent>(), |
| 35 | + py::init<Datatype, Extent, std::string>(), |
34 | 36 | py::arg("dtype"), |
35 | | - py::arg("extent")) |
36 | | - .def(py::init<Extent>(), py::arg("extent")) |
| 37 | + py::arg("extent"), |
| 38 | + py::arg("options") = "{}") |
37 | 39 | .def( |
38 | | - py::init([](py::dtype dt, Extent const &e) { |
| 40 | + py::init([](py::dtype dt, Extent e, std::string options) { |
39 | 41 | auto const d = dtype_from_numpy(std::move(dt)); |
40 | | - return new Dataset{d, e}; |
| 42 | + return new Dataset{d, std::move(e), std::move(options)}; |
41 | 43 | }), |
42 | 44 | py::arg("dtype"), |
43 | | - py::arg("extent")) |
| 45 | + py::arg("extent"), |
| 46 | + py::arg("options") = "{}") |
44 | 47 | .def( |
45 | | - py::init<Datatype, Extent, std::string>(), |
| 48 | + py::init([](Datatype dt, Extent e, py::object const &options) { |
| 49 | + auto resolved_options = ::auxiliary::json_dumps(options); |
| 50 | + return new Dataset{ |
| 51 | + dt, std::move(e), std::move(resolved_options)}; |
| 52 | + }), |
46 | 53 | py::arg("dtype"), |
47 | 54 | py::arg("extent"), |
48 | 55 | py::arg("options")) |
49 | 56 | .def( |
50 | | - py::init([](py::dtype dt, Extent e, std::string options) { |
| 57 | + py::init([](py::dtype dt, Extent e, py::object const &options) { |
51 | 58 | auto const d = dtype_from_numpy(std::move(dt)); |
52 | | - return new Dataset{d, std::move(e), std::move(options)}; |
| 59 | + auto resolved_options = ::auxiliary::json_dumps(options); |
| 60 | + return new Dataset{ |
| 61 | + d, std::move(e), std::move(resolved_options)}; |
53 | 62 | }), |
54 | 63 | py::arg("dtype"), |
55 | 64 | py::arg("extent"), |
|
0 commit comments