Skip to content

Commit

Permalink
tmp: printf debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Nov 10, 2023
1 parent a15a861 commit 8a14a72
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/binding/python/Attributable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,22 @@ struct char_to_explicit_char<false>
template <typename TargetType>
std::optional<TargetType> tryCast(py::object const &obj)
{
std::cout << "tryCast<" << determineDatatype<TargetType>() << ">()"
<< std::endl;
try
{
return obj.cast<TargetType>();
auto res = obj.cast<TargetType>();
std::cout << "\tSUCCESS" << std::endl;
return res;
}
catch (py::cast_error const &)
{
std::cout << "\tFAILURE 1" << std::endl;
return std::nullopt;
}
catch (py::value_error const &err)
{
std::cout << "\tFAILURE 2" << std::endl;
return std::nullopt;
}
}
Expand Down Expand Up @@ -427,6 +433,11 @@ bool setAttributeFromObject(
pybind11::dtype datatype)
{
Datatype requestedDatatype = dtype_from_numpy(datatype);
std::cout << "Setting attribute '" << key << "' with type "
<< obj.get_type() << "' and requested type " << datatype
<< ", i.e. openPMD type " << requestedDatatype << "\n\t'char' is "
<< (std::is_signed_v<char> ? "signed" : "unsigned")
<< " on the platform" << std::endl;
return switchNonVectorType<SetAttributeFromObject>(
requestedDatatype, attr, key, obj);
}
Expand Down

0 comments on commit 8a14a72

Please sign in to comment.