fix(vtk): transpose the vector after the point scalar expansion - #2799
Merged
Conversation
add_vector builds a row per component and numpy_to_vtk flattens in row-major order, so the array has to be transposed to give a row per cell or point. The transpose was applied to the vector sized 3 * nnodes before the point scalar expansion, which left three of the four paths through the method wrong: the point scalar loop indexed a row per cell rather than a row per component and raised an IndexError, and the vector sized 3 * ncpl was never transposed at all and silently wrote the first component to all three. The transpose is now applied once, after the expansion, so a cell gets its own three components in every case. The vector sized 3 * nnodes without point scalars is the one path that was already correct and is unchanged. test_vtk_vector covers only one of the four paths and is marked slow, so the smoke test used by the test matrix skips it and only the nightly optional dependency workflow runs it. A test covering all four paths has been added without the slow mark.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2799 +/- ##
===========================================
+ Coverage 55.5% 72.8% +17.2%
===========================================
Files 644 662 +18
Lines 124135 133024 +8889
===========================================
+ Hits 68947 96877 +27930
+ Misses 55188 36147 -19041
🚀 New features to boost your workflow:
|
The smoke test used by the test matrix skips the tests marked slow, so test_vtk_vector only ran in the nightly optional dependency workflow. It loads a model and exports it but does not run one, and takes about half a second, which is below the median of the tests that carry the mark. It now runs wherever vtk is installed.
Member
|
Oops. Guess I only got one of the four code paths in #2733. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add_vectorbuilds a row per component andnumpy_to_vtkflattens in row-major order, so the array has to be transposed to give a row per cell or point. The transpose was applied to the vector sized3 * nnodesbefore the point scalar expansion, which left three of the four paths through the method wrong:point_scalars3 * nnodes3 * nnodesIndexError3 * ncpl3 * ncplThe transpose is now applied once, after the expansion. The two
3 * ncplcases wrote the wrong data without raising.test_vtk_vectorcovers only the3 * nnodespoint scalar path, and the smoke test used by the test matrix skips the tests marked slow, so it only ran in the nightly optional dependency workflow. A test covering all four paths has been added; it fails on three of the four before this change. The slow mark has also been dropped fromtest_vtk_vector, which loads a model and exports it but does not run one, and takes about half a second.