Fix: VCML writer dropped species velocity components equal to "0.0"#54
Merged
Conversation
The writer skipped any species advection-velocity component whose string was exactly "0.0", emitting e.g. <Velocity X="0.5"/> for an axis-aligned advection v = (0.5, 0). The FV reader defaults a missing component to 0, so the data-layer round trip survived — but the Moving Boundary solver reads the VCML directly and requires each needed component, failing at runtime with "Expression for VelocityY is null". Emit every component that is set, including "0.0"; the round trip is unchanged. Regression test added (verified end-to-end against pyvcell-mbsolver: velocity_y="0.0" now solves). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The quality job failed because float(reloaded_sm.velocity_x/_y) tripped mypy (velocity components are typed float | str | None). Narrow out None before float() so the assertions type-check; behavior unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
The bug
vcml_writer.pyskipped any species advection-velocity component whose string was exactly"0.0":So an axis-aligned advection
v = (0.5, 0)emitted<Velocity X="0.5"/>with noY. The FV reader defaults a missing component to 0, so the data-layer round trip survived and the bug was invisible there — but the Moving Boundary solver reads the VCML directly and requires each needed component, failing at runtime with:This surfaced while setting a species advection velocity (
v = v_b) for a moving-boundary cross-validation: any 2D velocity with a zero component was unusable.The fix
Emit every component that is set, including
"0.0". The round trip is unchanged (the reader already defaults missing → 0, so emitting"0.0"is equivalent). Regression test added (test_species_advection_velocity_emits_zero_components), and verified end-to-end againstpyvcell-mbsolver:velocity_y="0.0"now solves (previously crashed).mypy clean; the moving-boundary + velocity tests (incl. the gated end-to-end solve) pass.
🤖 Generated with Claude Code