Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add ADIOS1 (BP3) Python Test #1197

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[tmp] printf CI debugging
  • Loading branch information
ax3l committed Mar 8, 2022
commit 17a3063ecf3714db9c241575e040f9c8b437f05c
38 changes: 38 additions & 0 deletions include/openPMD/backend/Attribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <complex>
#include <cstdint>
#include <iterator>
#include <sstream>
#include <stdexcept>
#include <string>
#include <type_traits>
Expand Down Expand Up @@ -229,3 +230,40 @@ U Attribute::get() const
}

} // namespace openPMD

namespace std
{
inline string to_string(openPMD::Attribute const &attr)
{
return std::visit(
[](auto const &val) {
using Val_t = remove_cv_t<remove_reference_t<decltype(val)> >;

std::stringstream os;
if constexpr (
openPMD::auxiliary::IsVector_v<Val_t> ||
openPMD::auxiliary::IsArray_v<Val_t>)
{
if (val.empty())
{
os << "[]";
}
else
{
os << "[" << val[0];
for (size_t i = 1; i < val.size(); ++i)
{
os << ", " << val[i];
}
os << "]";
}
}
else
{
os << val;
}
return os.str();
},
attr.getResource());
}
} // namespace std
3 changes: 3 additions & 0 deletions src/binding/python/Attributable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ void init_Attributable(py::module &m)
"get_attribute",
[](Attributable &attr, std::string const &key) {
auto v = attr.getAttribute(key);
std::cout << "Attribute '" << key << "' has type: " << v.dtype
<< std::endl
<< " and value: " << std::to_string(v) << std::endl;
return v.getResource();
// TODO instead of returning lists, return all arrays (ndim > 0)
// as numpy arrays?
Expand Down
9 changes: 8 additions & 1 deletion src/binding/python/PatchRecordComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,14 @@ void init_PatchRecordComponent(py::module &m)
py::ssize_t numElements = 1;
if (buf.ndim > 0)
{
std::cout << "Buffer has dimensionality: " << buf.ndim
<< std::endl;
for (auto d = 0; d < buf.ndim; ++d)
{
std::cout << "Extent of dimensionality " << d << ": "
<< buf.shape.at(d) << std::endl;
numElements *= buf.shape.at(d);
}
}

// Numpy: Handling of arrays and scalars
Expand Down Expand Up @@ -177,7 +183,8 @@ void init_PatchRecordComponent(py::module &m)
{
throw std::runtime_error(
"store: "
"Only scalar values supported!");
"Only scalar values supported! (found " +
std::to_string(numElements) + "values)");
}
},
py::arg("idx"),
Expand Down
9 changes: 8 additions & 1 deletion src/binding/python/RecordComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,14 @@ void init_RecordComponent(py::module &m)
py::ssize_t numElements = 1;
if (buf.ndim > 0)
{
std::cout << "Buffer has dimensionality: " << buf.ndim
<< std::endl;
for (auto d = 0; d < buf.ndim; ++d)
{
std::cout << "Extent of dimensionality " << d << ": "
<< buf.shape.at(d) << std::endl;
numElements *= buf.shape.at(d);
}
}

// Numpy: Handling of arrays and scalars
Expand Down Expand Up @@ -867,7 +873,8 @@ void init_RecordComponent(py::module &m)
{
throw std::runtime_error(
"make_constant: "
"Only scalar values supported!");
"Only scalar values supported! (found " +
std::to_string(numElements) + "values)");
}
},
py::arg("value"))
Expand Down