|
28 | 28 | #include "py11Operator.h" |
29 | 29 | #include "py11Query.h" |
30 | 30 | #include "py11Variable.h" |
| 31 | +#include "py11VariableDerived.h" |
31 | 32 |
|
32 | 33 | #if ADIOS2_USE_MPI |
33 | 34 |
|
@@ -124,6 +125,12 @@ PYBIND11_MODULE(ADIOS2_PYTHON_MODULE_NAME, m) |
124 | 125 | .value("OtherError", adios2::StepStatus::OtherError) |
125 | 126 | .export_values(); |
126 | 127 |
|
| 128 | + pybind11::enum_<adios2::DerivedVarType>(m, "DerivedVarType") |
| 129 | + .value("MetadataOnly", adios2::DerivedVarType::MetadataOnly) |
| 130 | + .value("ExpressionString", adios2::DerivedVarType::ExpressionString) |
| 131 | + .value("StoreData", adios2::DerivedVarType::StoreData) |
| 132 | + .export_values(); |
| 133 | + |
127 | 134 | pybind11::class_<adios2::py11::ADIOS>(m, "ADIOS") |
128 | 135 | // Python 2 |
129 | 136 | .def("__nonzero__", |
@@ -218,6 +225,14 @@ PYBIND11_MODULE(ADIOS2_PYTHON_MODULE_NAME, m) |
218 | 225 | adios2::py11::IO::DefineVariable, |
219 | 226 | pybind11::return_value_policy::move, pybind11::arg("name")) |
220 | 227 |
|
| 228 | + .def("DefineDerivedVariable", |
| 229 | + (adios2::py11::VariableDerived(adios2::py11::IO::*)( |
| 230 | + const std::string &, const std::string &, const adios2::DerivedVarType)) & |
| 231 | + adios2::py11::IO::DefineDerivedVariable, |
| 232 | + pybind11::return_value_policy::move, pybind11::arg("name"), |
| 233 | + pybind11::arg("expression"), |
| 234 | + pybind11::arg("vartype") = adios2::DerivedVarType::MetadataOnly) |
| 235 | + |
221 | 236 | .def("InquireVariable", &adios2::py11::IO::InquireVariable, |
222 | 237 | pybind11::return_value_policy::move) |
223 | 238 |
|
@@ -379,6 +394,22 @@ PYBIND11_MODULE(ADIOS2_PYTHON_MODULE_NAME, m) |
379 | 394 | .def("Operations", &adios2::py11::Variable::Operations) |
380 | 395 | .def("RemoveOperations", &adios2::py11::Variable::RemoveOperations); |
381 | 396 |
|
| 397 | + pybind11::class_<adios2::py11::VariableDerived>(m, "VariableDerived") |
| 398 | + // Python 2 |
| 399 | + .def("__nonzero__", |
| 400 | + [](const adios2::py11::VariableDerived &vd) { |
| 401 | + const bool opBool = vd ? true : false; |
| 402 | + return opBool; |
| 403 | + }) |
| 404 | + // Python 3 |
| 405 | + .def("__bool__", |
| 406 | + [](const adios2::py11::VariableDerived &vd) { |
| 407 | + const bool opBool = vd ? true : false; |
| 408 | + return opBool; |
| 409 | + }) |
| 410 | + .def("Name", &adios2::py11::VariableDerived::Name) |
| 411 | + .def("Type", &adios2::py11::VariableDerived::Type); |
| 412 | + |
382 | 413 | pybind11::class_<adios2::py11::Attribute>(m, "Attribute") |
383 | 414 | // Python 2 |
384 | 415 | .def("__nonzero__", |
|
0 commit comments