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 ac9b2dc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 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,9 @@ 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 << std::endl;
return switchNonVectorType<SetAttributeFromObject>(
requestedDatatype, attr, key, obj);
}
Expand Down

0 comments on commit ac9b2dc

Please sign in to comment.