You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have recently come across strange errors (XXX undetected error) when calling overloaded methods that take as input objects that have custom type_caster instantiations. After some debugging, I found that a custom pybind11 type_caster<>::load(handle,bool) method must not only return a bool to denote its successful conversion, but must also throw a reference_cast_error() when the handle is not the expected type (to facilitate its use in pybind11's try/catch dispatch for overloaded methods). Also, the failed attempts to convert the handle likely raise a python error which, if left uncleared, will manifest in strange behavior elsewhere in the program. The readthedocs for custom type casters doesn't really cover these crucial requirements on the load method. It would have been useful for me to read about this in the documentation, so I figure it would probably be useful for someone else to read it too!
The text was updated successfully, but these errors were encountered:
`EigenConformable::stride_compatible` returns false if the strides are
negative. In this case, do not use `EigenConformable::stride`, as it
is {0,0}. We cannot write negative strides in this element, as Eigen
will throw an assertion if we do.
The `type_caster` specialization for regular, dense Eigen matrices now
does a second `array_t::ensure` to copy data in case of negative strides.
I'm not sure that this is the best way to implement this.
I have added "TODO" tags linking these changes to Eigen bug #747, which,
when fixed, will allow Eigen to accept negative strides.
I have recently come across strange errors (
XXX undetected error
) when calling overloaded methods that take as input objects that have custom type_caster instantiations. After some debugging, I found that a custom pybind11type_caster<>::load(handle,bool)
method must not only return abool
to denote its successful conversion, but must also throw areference_cast_error()
when thehandle
is not the expected type (to facilitate its use in pybind11's try/catch dispatch for overloaded methods). Also, the failed attempts to convert thehandle
likely raise a python error which, if left uncleared, will manifest in strange behavior elsewhere in the program. The readthedocs for custom type casters doesn't really cover these crucial requirements on theload
method. It would have been useful for me to read about this in the documentation, so I figure it would probably be useful for someone else to read it too!The text was updated successfully, but these errors were encountered: