Description
I have a C++ function with the following signature:
spv_float well_path_ident(
ulong nx, ulong ny, spv_float coord, spv_float zcorn,
spv_float well_info, bool include_well_nodes, const char* strat_traits = "online_tops",
const ulong min_split_threshold = 0, spv_ulong hit_idx = nullptr
);
Here ulong
is std::size_t
, and spv_float, spv_ulong
are std::shared_ptr
pointers to my custom array type which is inherited from pybind11::array_t
. I've written custom converters for it that are very similar to Eigen
binding code. Converters are working as expected in my tests.
Next, I export the function above with the following snippet:
m.def("well_path_ident", &well_path_ident,
"nx"_a, "ny"_a, "coord"_a, "zcorn"_a, "well_info"_a, "include_well_nodes"_a = true,
"mesh_traits"_a = "online_tops", "min_split_threshold"_a = 0, "hit_idx"_a = nullptr
);
Everything compiles just fine! pybind11
correctly counts arguments of well_path_ident
-- if I make a mistake (for ex. forget one argument) it will notify me with an error at compile time.
But after module is loaded in Python here's what I get with help(my_module)
command:
well_path_ident(...)
well_path_ident(*args, **kwargs)
Overloaded function.
1. well_path_ident(nx: int, ny: int, numpy.ndarray[float64], numpy.ndarray[float64], numpy.ndarray[float64], coord: bool, zcorn: unicode, well_info: int, numpy.ndarray[uint64]) -> numpy.ndarray[float64]
(I have one more overload of this function, but it has the same issue).
As you can see, keyword arguments "skip" numpy.ndarray[float64]
(spv_float) for some reason, and starting from "coord" they bind to wrong C++ function arguments.
I feel that this is related in some way to custom type conversion code, but what really can cause such issue?
Btw, when I try to call this function from Python, I get an exception:
RuntimeError: Unknown internal error occurred
And actual C++ function isn't called, I can't get into it in debugger.