Skip to content

Say that scikit-fem probes of a vector basis are blocked by component - #73

Merged
alhermann merged 1 commit into
mainfrom
fix/skfem-vector-probe-order
Oct 15, 2026
Merged

alhermann merged 1 commit into
mainfrom
fix/skfem-vector-probe-order

Conversation

@alhermann

Copy link
Copy Markdown
Collaborator

Problem

The facts openPASO serves for scikit-fem said that basis.probes(pts) returns an interpolation operator of shape (n_points, N). That is true for a scalar basis only. On a vector basis (ElementVector, also the velocity basis that split() returns from a Taylor–Hood basis), the operator has shape (dim * n_points, N). Its product with the dof vector is blocked by component: first u_x at every point, then u_y.

The dof vector itself is interleaved per node, so reading the probed values the same way, with [0::2] and [1::2], scrambles the two components. No error is raised. Runs that did this reported a wrong field from a correct solve.

Measured

On scikit-fem 12.0.1 and 12.0.2, with exact fields:

basis probes(P).shape for 5 or 6 points blocked interleaved
P1 triangles, vector (10, 162) yes no
P2 triangles, vector (10, 162) yes no
P1 tetrahedra, vector (15, 345) yes no
velocity basis of a split Taylor–Hood basis (12, 578) yes no

basis.interpolator(x)(P) returns the (dim, n_points) array directly.

Change

  • src/tools/consolidated.py: fact 4 of the scikit-fem facts, which lead every scikit-fem reply of prepare_simulation and of a coupled side, now states the layout and the reshape (basis.probes(pts) @ x).reshape(dim, n_points).
  • src/backends/_installed_api.py: the point-evaluation note of the installed-API reference says the same.
  • tests/test_skfem_vector_probes_are_blocked.py (new): measures the layout on the installed scikit-fem and requires both served texts to state it next to the call. On the current main, the two served-text tests fail and the four measurement tests pass.

Tests

  • .venv: 105 passed, 13 skipped (tests/ without test_web_search_reports_a_block.py).
  • .venv-lg: 11 passed (test_web_search_reports_a_block.py).

🤖 Generated with Claude Code

The served facts said that basis.probes(pts) returns an operator of shape
(n_points, N). That holds for a scalar basis. On an ElementVector basis the
operator is (dim * n_points, N) and its product with the dof vector is
blocked by component: u_x at every point, then u_y. The dof vector itself is
interleaved per node, so a run that split the probed values with [0::2] and
[1::2] scrambled the components of a correct solve without any error.

Both served texts that teach probes() now state the layout and the reshape
that reads it. The new test measures the layout on the installed scikit-fem
(P1 and P2 triangles, P1 tetrahedra, the velocity basis of a split
Taylor-Hood basis) and requires both texts to state it next to the call.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused guidance corrections and regression tests are consistent, with no blocking issues identified.

0 open findings

What changed in this PR

Clarifies scikit-fem vector point-evaluation guidance to prevent incorrect component extraction from valid simulation results.

Changes:

  • Documents component-blocked probe values and the correct reshape.
  • Adds regression tests for vector bases, split Taylor–Hood velocity, and both served guidance texts.
File Description
tests/​test_skfem_vector_probes_are_blocked.py Tests probe layouts and served guidance.
src/​tools/​consolidated.py Clarifies vector probe layout in simulation facts.
src/​backends/​_installed_api.py Adds component extraction guidance to the API reference.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@alhermann
alhermann merged commit 8c382aa into main Oct 15, 2026
3 checks passed
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