Replies: 1 comment
-
.def("get_iomap", [](SOEM_wrapper &wrapper, uint16_t slave) -> std::tuple<BytesArray, BytesArray> {
if (slave > wrapper.maxslave) {
throw std::invalid_argument("requested slave is larger than maxslave.");
}
// when viewing master iomap (slave=0). bytecount will be accurate
if (slave == 0){
size_t shape_inputs[1] = {wrapper.slavelist[slave].Ibytes};
size_t shape_outputs[1] = {wrapper.slavelist[slave].Obytes};
return std::make_tuple(
BytesArray(wrapper.slavelist[slave].inputs, 1, shape_inputs, nb::handle()),
BytesArray(wrapper.slavelist[slave].outputs, 1, shape_outputs, nb::handle()));
}
// for slave iomaps, since bytecount can be zero for bitcount < 8,
// we will only trust bitcount
size_t shape_inputs[1] = {wrapper.slavelist[slave].Ibits / 8 + (wrapper.slavelist[slave].Ibits % 8 != 0)};
size_t shape_outputs[1] = {wrapper.slavelist[slave].Obits / 8 + (wrapper.slavelist[slave].Obits % 8 != 0)};
return std::make_tuple(
BytesArray(wrapper.slavelist[slave].inputs, 1, shape_inputs, nb::handle()),
BytesArray(wrapper.slavelist[slave].outputs, 1, shape_outputs, nb::handle()));
});
well it appears that I can return an empty array by settings shape = 0 and it doesnt matter that the pointer is null pointer |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
kj4tmp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to return None or ndarray from cpp to python?
I am returning an view of an array that may be a null pointer.
Can I return None when this array is null pointer?
Beta Was this translation helpful? Give feedback.
All reactions