Skip to content

Commit

Permalink
Improve conversion from Python to Binary
Browse files Browse the repository at this point in the history
  • Loading branch information
lamyj committed Jan 31, 2024
1 parent 2e82a6e commit 4de2357
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions wrappers/python/opaque_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,19 @@ T convert_sequence(pybind11::sequence & source, Args && ... args)
{ \
/* Ignore */ \
}


// WARNING: Strings and DataSets are ambiguous when passing bytearray
// Skip conversion to strings if we get an sequence of bytearrays
auto const is_byte_array = std::all_of(
source.begin(), source.end(), [](auto && x) {
return PyByteArray_CheckExact(x.ptr()); });

try_convert(odil::Value::Integers);
try_convert(odil::Value::Reals);
try_convert(odil::Value::Strings);
if(!is_byte_array)
{
try_convert(odil::Value::Strings);
}
try_convert(odil::Value::DataSets);
try_convert(odil::Value::Binary);

Expand Down

0 comments on commit 4de2357

Please sign in to comment.