Skip to content

fix(vtk): transpose before numpy_to_vtk in add_vector#2733

Open
wpbonelli wants to merge 1 commit intomodflowpy:developfrom
wpbonelli:fix-vtk-vectors
Open

fix(vtk): transpose before numpy_to_vtk in add_vector#2733
wpbonelli wants to merge 1 commit intomodflowpy:developfrom
wpbonelli:fix-vtk-vectors

Conversation

@wpbonelli
Copy link
Member

@wpbonelli wpbonelli commented Mar 19, 2026

add_vector() assigns a vector to each grid cell. The method takes an array of shape (3, nnodes) and passes it to numpy_support.numpy_to_vtk(), which due to the order of indices flattens it in column-major order, but VTK expects row-major order.

So where cell i should get

(x[i], y[i], z[i])

it instead gets

(x[3i], x[3i+1], x[3i+2])

Fixed by transposing the array passed to numpy_to_vtk() so it is (nnodes, 3) and is flattened/interpreted correctly

@wpbonelli wpbonelli added the bug label Mar 19, 2026
@wpbonelli wpbonelli added this to the 3.10.1 milestone Mar 19, 2026
@wpbonelli wpbonelli requested a review from jlarsen-usgs March 19, 2026 00:12
@wpbonelli wpbonelli marked this pull request as ready for review March 19, 2026 00:12
@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.4%. Comparing base (556c088) to head (ec740f6).
⚠️ Report is 142 commits behind head on develop.

Files with missing lines Patch % Lines
flopy/export/vtk.py 0.0% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2733      +/-   ##
===========================================
+ Coverage     55.5%    72.4%   +16.9%     
===========================================
  Files          644      674      +30     
  Lines       124135   130618    +6483     
===========================================
+ Hits         68947    94650   +25703     
+ Misses       55188    35968   -19220     
Files with missing lines Coverage Δ
flopy/export/vtk.py 69.8% <0.0%> (-8.3%) ⬇️

... and 569 files with indirect coverage changes

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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant