Repository navigation
Say that scikit-fem probes of a vector basis are blocked by component - #73
Merged
Merged
Conversation
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>
There was a problem hiding this comment.
🟢 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.
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.
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 thatsplit()returns from a Taylor–Hood basis), the operator has shape(dim * n_points, N). Its product with the dof vector is blocked by component: firstu_xat every point, thenu_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:
probes(P).shapefor 5 or 6 pointsbasis.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 ofprepare_simulationand 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 currentmain, the two served-text tests fail and the four measurement tests pass.Tests
.venv: 105 passed, 13 skipped (tests/withouttest_web_search_reports_a_block.py)..venv-lg: 11 passed (test_web_search_reports_a_block.py).🤖 Generated with Claude Code