Some cubical improvements #1295
Replies: 1 comment
I am not sure it ever comes up outside of unit tests, but if it is easy or comes as a bonus with a change that generally improves the interface, sure.
I guess the duplicated message is because some implementations used not to show the exception message, but I don't think that's the case anymore, so we could remove the cerr version.
If we change the message, it could be nice to include the actual sizes in it, something like "For sizes {x,y,z} we expect a buffer of length n1 but got one of length n2".
Indeed, adding a check shouldn't be hard.
An assertion/exception would be in order here. I don't know if disabling this constructor would cause problems or be worth it.
Failing to compile feels a bit strong. Yes, the non-periodic case would be a bit faster (probably not by a huge factor), but instantiating a single code for all cases can reduce binary code size if you care more about that than performance, keeping it allowed enables us to compare the 2 versions.
Yes. I am reluctant to do that now when we know that this code is rather slow and a new one may be written eventually, but it is a possibility. For the non-periodic case, the python sklearn interface already dispatches to different code depending on the arguments.
Or we can wrap the ndarray in a std::span (or some other range/view object) that can be constructed from pointer and size (one constructor for span checks if its argument supports .data() and .size()) and provides begin+end.
I'd rather stick to range-like interfaces, unless it causes too much trouble. |
Uh oh!
There was an error while loading. Please reload this page.
From a c++ user point of view
Here, the code to detect the exception is duplicated. The code could be factorized and the message could be more generic.
Note that this behavior is not the same for the periodic code:
If the behavior were similar it would help to fix #792
Here, we could make the compilation fails in these cases. With a level of indirection, we could make new interfaces for cubical that is using the correct class in function of the parameters given by the user.
From a Python user point of view
(cf. C++ 2.) The
std::cerrmessage also appears in Python which is not what we want IMO.Nanobind ndarray does not provide
.begin(), nor.end()methods, it only provides.data()and.size()methods, which, that if we do not want to copy data structures, cubical should provide also constructor like:All reactions