From 262a6993f1980be225582a83bc3e44fd22e3cffa Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 14 Aug 2019 23:46:24 -0400 Subject: [PATCH] layout: pass short strings by value, use anonymous namespace --- bindings/Python/py11File.cpp | 6 +++--- bindings/Python/py11File.h | 8 ++++---- bindings/Python/py11File.tcc | 9 ++++++--- bindings/Python/py11glue.cpp | 25 ++++++++++++------------- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/bindings/Python/py11File.cpp b/bindings/Python/py11File.cpp index 946c575a8f..d7d46d7fe7 100644 --- a/bindings/Python/py11File.cpp +++ b/bindings/Python/py11File.cpp @@ -215,14 +215,14 @@ std::vector File::ReadString(const std::string &name, } pybind11::array File::Read(const std::string &name, const size_t blockID, - const std::string &order) + const std::string order) { return Read(name, {}, {}, blockID, order); } pybind11::array File::Read(const std::string &name, const Dims &start, const Dims &count, const size_t blockID, - const std::string &order) + const std::string order) { const std::string type = m_Stream->m_IO->InquireVariableType(name); @@ -241,7 +241,7 @@ pybind11::array File::Read(const std::string &name, const Dims &start, pybind11::array File::Read(const std::string &name, const Dims &start, const Dims &count, const size_t stepStart, const size_t stepCount, const size_t blockID, - const std::string &order) + const std::string order) { const std::string type = m_Stream->m_IO->InquireVariableType(name); diff --git a/bindings/Python/py11File.h b/bindings/Python/py11File.h index a5094e845a..0be331c7f3 100644 --- a/bindings/Python/py11File.h +++ b/bindings/Python/py11File.h @@ -95,16 +95,16 @@ class File const size_t blockID = 0); pybind11::array Read(const std::string &name, const size_t blockID, - const std::string &order); + const std::string order); pybind11::array Read(const std::string &name, const Dims &start, const Dims &count, const size_t blockID, - const std::string &order); + const std::string order); pybind11::array Read(const std::string &name, const Dims &start, const Dims &count, const size_t stepStart, const size_t stepCount, const size_t blockID, - const std::string &order); + const std::string order); pybind11::array ReadAttribute(const std::string &name, const std::string &variableName = "", @@ -132,7 +132,7 @@ class File pybind11::array DoRead(const std::string &name, const Dims &start, const Dims &count, const size_t stepStart, const size_t stepCount, const size_t blockID, - const std::string &order); + const std::string order); }; } // end namespace py11 diff --git a/bindings/Python/py11File.tcc b/bindings/Python/py11File.tcc index 98b1b1fa01..1d938c2982 100644 --- a/bindings/Python/py11File.tcc +++ b/bindings/Python/py11File.tcc @@ -18,11 +18,13 @@ namespace adios2 namespace py11 { -static Dims py_strides(const Dims &shape, ssize_t itemsize, bool has_step_dim) +namespace +{ +Dims py_strides(const Dims &shape, ssize_t itemsize, bool hasStepDim) { auto ndim = shape.size(); Dims strides(ndim, itemsize); - if (!has_step_dim) + if (!hasStepSim) { // regular column-major for (size_t i = 1; i < ndim; ++i) @@ -41,12 +43,13 @@ static Dims py_strides(const Dims &shape, ssize_t itemsize, bool has_step_dim) } return strides; } +} // end anonymous namespace template pybind11::array File::DoRead(const std::string &name, const Dims &_start, const Dims &_count, const size_t stepStart, const size_t stepCount, const size_t blockID, - const std::string &order) + const std::string order) { Layout layout = ToLayout(order); core::Variable &variable = *m_Stream->m_IO->InquireVariable(name); diff --git a/bindings/Python/py11glue.cpp b/bindings/Python/py11glue.cpp index 8b0d023668..b557f47da8 100644 --- a/bindings/Python/py11glue.cpp +++ b/bindings/Python/py11glue.cpp @@ -888,7 +888,7 @@ PYBIND11_MODULE(adios2, m) .def("read", (pybind11::array(adios2::py11::File::*)( - const std::string &, const size_t, const std::string &)) & + const std::string &, const size_t, const std::string)) & adios2::py11::File::Read, pybind11::return_value_policy::take_ownership, pybind11::arg("name"), pybind11::arg("block_id") = 0, @@ -915,17 +915,16 @@ PYBIND11_MODULE(adios2, m) Single values will have a shape={1} numpy array )md") - .def( - "read", - (pybind11::array(adios2::py11::File::*)( - const std::string &, const adios2::Dims &, const adios2::Dims &, - const size_t, const std::string &order)) & - adios2::py11::File::Read, - pybind11::return_value_policy::take_ownership, - pybind11::arg("name"), pybind11::arg("start") = adios2::Dims(), - pybind11::arg("count") = adios2::Dims(), - pybind11::arg("block_id") = 0, pybind11::arg("order") = "", - R"md( + .def("read", + (pybind11::array(adios2::py11::File::*)( + const std::string &, const adios2::Dims &, + const adios2::Dims &, const size_t, const std::string order)) & + adios2::py11::File::Read, + pybind11::return_value_policy::take_ownership, + pybind11::arg("name"), pybind11::arg("start") = adios2::Dims(), + pybind11::arg("count") = adios2::Dims(), + pybind11::arg("block_id") = 0, pybind11::arg("order") = "", + R"md( Reads a selection piece in dimension for current step (streaming mode step by step) @@ -959,7 +958,7 @@ PYBIND11_MODULE(adios2, m) (pybind11::array(adios2::py11::File::*)( const std::string &, const adios2::Dims &, const adios2::Dims &, const size_t, const size_t, const size_t, - const std::string &order)) & + const std::string order)) & adios2::py11::File::Read, pybind11::return_value_policy::take_ownership, pybind11::arg("name"), pybind11::arg("start"),