IERR size should be M x IR?
gillette7 opened this issue · comments
DelaunaySparse/python/delsparse.py
Line 86 in 6a80558
When trying to use the python wrapper on a case with output dimension (IR) larger than 1, I got error code 21: The size of the error array IERR does not match the number of interpolation points M. When I changed the size of IERR to M x IR, it worked. I think the readme has to be changed (in two spots) to reflect this.
@gillette7 I'm not following where the readme is wrong. I believe IERR
should always be a vector of size M
, never relating to the value IR
.
The reason your change worked is that the code only checks the first dimension of any array you pass for IERR
because it assumes it will be a 1D input (maybe it shouldn't?). Regardless of input array shape, the only values touched by the Fortran source will be IERR(...,1:M)
, the first M
contiguous memory elements of the given IERR
array.
The issue was I had declared ierr = np.zeros([1,m])
but it should have been ierr = np.zeros([m,1])
; once I changed it, the error went away. Seems like just a different convention between python and Fortran. Thanks for checking on this!
This is a good point. Instead of checking the first shape dimension, the code could instead check the last (since that is really what matters from a Fortran perspective). That would make more sense, mathematically speaking, and it wouldn't change the behavior when an array with shape (M,)
gets passed.
@thchang do you think this is a good idea? @gillette7 would it bother you if I make that change and you have to revert your code to be ierr = np.zeros([1,m])
after the update?
No problem for me if you want to change it - just let me know if you do!
@tchlux I think the documentation should reflect the expectation that users will pass a shape of (M,), but if checking the last dimension will make this more intuitive for Python users, then I support the change Thanks all for raising/solving this issue
@gillette7 this newly merged pull request now causes the code to check the last dimension of incoming vectors. If you are going to send in a vector with len(*.shape) > 1
then only the last dimension size needs to match.
For your purposes, this will require you to revert to using ierr = np.zeros([1,m])
.