Proposed fix to improve pybind11 dynamic type casting#85
Conversation
|
Changed the binding interface to allow both copies and references. This makes implies extra copies of the |
|
To Do
|
michael-petersen
left a comment
There was a problem hiding this comment.
I've been working with this branch for two weeks, and no workflows have been affected. I wasn't demonstrating the problem originally, so as long as that is reported fixed, I'm happy.
| -------- | ||
| slices : generate fields in a surface slice given by the initializtion grid | ||
| slices : generate fields in a surface slice given by the | ||
| initializtion grid |
There was a problem hiding this comment.
| initializtion grid | |
| initialization grid |
| -------- | ||
| slices : generate fields in a surface slice given by the initializtion grid | ||
| slices : generate fields in a surface slice given by the | ||
| initializtion grid |
There was a problem hiding this comment.
| initializtion grid | |
| initialization grid |
| -------- | ||
| slices : generate fields in a surface slice given by the initializtion grid | ||
| slices : generate fields in a surface slice given by the | ||
| initializtion grid |
There was a problem hiding this comment.
| initializtion grid | |
| initialization grid |
There was a problem hiding this comment.
I have now added CTest pyEXP exercises for setMatrix() and createFromArray(). It seems that this bug bit Sóley while running a test notebook from Nico. Ooops.
|
Summary for this final (hopefully) commit
Probably good to go now... |
|
Great addition of tests! The tests pass locally for me, but why are they failing in CI? That nothing is getting printed in |
| exit(0) | ||
|
|
||
| print("---- createFromArray usings lists") | ||
| coef1 = basis.createFromArray(mass, [xpos, ypos, zpos], time=3.0) |
There was a problem hiding this comment.
I guess the failure in the CI tests must be coming from this line -- but I can't reproduce it.
There was a problem hiding this comment.
That was inserted to try to bisect the error. Thought I removed that.
Not sure what to do here; if we can't reproduce the error except in the runner where we can't debug it. Not really a solution, but the test seems to work fine on native Ubuntu builds, in the Docker container, and for you with Clang, right?
I'm going to label this test "long" and merge to main unless you have another idea?
There was a problem hiding this comment.
Okay, I've figured it out, and fixed the script. In short, the Python numpy array objects need to persist. Even though I got rid of the Eigen::Ref which was hosing the interface in some builds, the data is passed by reference but if the data is wiped by an assignment, the memory gets stomped on access from the C++ side. To test, I changed the script to 'hold' the instance by giving it a unique name, and the script now works in CI.
However, this could lead to Python users writing code that breaks, depending on their workflow. So now, the question is: should we eliminate pass by reference for setMatrix() and createFromAarray() and force copies? I'm sort of thinking, yes?
There was a problem hiding this comment.
I think the use case of a non-unique name is probably going to happen, so it makes sense to eliminate the pass by reference. The copies can't be that large (at least compared to RAM, I hope), so probably no harm in the copying strategy.
One more try just to make sure that this fails on all `createFromArrry` statements.
More bisection...
…emove debugging statements from createCoefs.py
to reassign `pyEXPCoefCreateTest` to `long`
|
Summary Linked the bug in the github CI runner to a Details I built the act local github runner generator with a tweaked To Do I suppose we should make sure that nothing else is broken but that does seem unlikely at this point. Then I'm hoping we can merge. |
Reverted from `Debug` to `Release`
|
Another (very minor) question is: do we leave the |
|
I think we want some sort of matrix; currently |
|
The log file from the |
test gcc and clang matrix
Another try.
Need OpenMP support for clang
Need flags for clang++ to use stdc++ lib.
Remove hardwired use of llvm's libc++
Use apt numpy package for 24.04
|
Summary of last bunch of commits
|
…dentified by Clang and Clang++. They are all minor. The result passes 'ctest -L long' but pyEXP-example notebooks have not been run.
|
Looks like we are good to go. All merged and checked. |
Problem
The
pyEXP.coefs.setMatrix()routines fail to castndarraywith complex type toEigen::MatrixXd. Not all compiles demonstrated the problem. But recent compiles in the Docker container are affected.Proposed fix
Use
Eigen::Ref<Eigen::ComplexXcd>to pass arrays insetMatrix()rather thanconst Eigen::MatrixXcd&. Tests show that this fixed the issue.To Do
The implementation has been verified on the failing case but more testing is needed.