Skip to content

Commit

Permalink
layout: pass short strings by value, use anonymous namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
germasch committed Aug 15, 2019
1 parent cb3a3f4 commit 262a699
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
6 changes: 3 additions & 3 deletions bindings/Python/py11File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ std::vector<std::string> 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);

Expand All @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions bindings/Python/py11File.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions bindings/Python/py11File.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -41,12 +43,13 @@ static Dims py_strides(const Dims &shape, ssize_t itemsize, bool has_step_dim)
}
return strides;
}
} // end anonymous namespace

template <class T>
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<T> &variable = *m_Stream->m_IO->InquireVariable<T>(name);
Expand Down
25 changes: 12 additions & 13 deletions bindings/Python/py11glue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 262a699

Please sign in to comment.