Skip to content

fix(vtk): transpose the vector after the point scalar expansion - #2799

Merged
jdhughes-dev merged 2 commits into
modflowpy:developfrom
jdhughes-dev:fix-vtk-vector
Aug 7, 2026
Merged

fix(vtk): transpose the vector after the point scalar expansion#2799
jdhughes-dev merged 2 commits into
modflowpy:developfrom
jdhughes-dev:fix-vtk-vector

Conversation

@jdhughes-dev

@jdhughes-dev jdhughes-dev commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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:

vector size point_scalars before after
3 * nnodes False correct correct
3 * nnodes True IndexError correct
3 * ncpl False first component written to all three correct
3 * ncpl True first component written to all three correct

The transpose is now applied once, after the expansion. The two 3 * ncpl cases wrote the wrong data without raising.

test_vtk_vector covers only the 3 * nnodes point 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 from test_vtk_vector, which loads a model and exports it but does not run one, and takes about half a second.

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

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.8%. Comparing base (556c088) to head (207f8d1).
⚠️ Report is 191 commits behind head on develop.

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     
Files with missing lines Coverage Δ
flopy/export/vtk.py 72.9% <100.0%> (-5.2%) ⬇️

... and 582 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.
@jdhughes-dev
jdhughes-dev merged commit 74d7b9e into modflowpy:develop Aug 7, 2026
20 checks passed
@jdhughes-dev
jdhughes-dev deleted the fix-vtk-vector branch August 7, 2026 18:27
@wpbonelli

Copy link
Copy Markdown
Member

Oops. Guess I only got one of the four code paths in #2733.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants