Skip to content

fix: no-ODE simulations refused, model files read as UTF-8 under any locale - #66

Merged
jcschaff merged 2 commits into
mainfrom
fix/ode-zero-equations
Oct 24, 2026
Merged

jcschaff merged 2 commits into
mainfrom
fix/ode-zero-equations

Conversation

@jcschaff

@jcschaff jcschaff commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Found while building pbsim_common's VCellUTCStep (compose-api docs/plan-vcell-ode.md).

  • A solver input with 0 equations crashed the process. pyvcell-odesolver segfaults (CVDense: A memory request failed, exit 139) when VCell's math has no state variables. Two cases:

    • every species is constant, as in BIOMD0000000241;
    • the rate rules were dropped by VCell's SBML import, as in BIOMD0000000020.

    simulate_ode_vcml now reads NUM_EQUATIONS from the input and raises a ValueError ("has no ODEs to solve") before calling the solver. The crash itself also belongs in vcell-ode, which should report an error instead.

  • Explicit output times are written as floats. numpy floats assigned after validation skip pydantic's coercion, and repr wrote them as np.float64(0.5), which VCell refuses.

  • Model files are read and written as UTF-8, whatever the process locale. COPASI and libroadrunner set the C locale when they load, which makes Python's default text encoding ASCII. Every VCML, SBML and Antimony file pyvcell reads or writes, including libvcell's intermediate files, then failed on non-ASCII names or notes ('ascii' codec can't decode byte 0xc3). open/read_text now pass encoding="utf-8". A new test switches to the C locale and loads a model with non-ASCII names: it fails on main with that error and passes here.

  • Docstring: rule-based networks are now regenerated by the BioNetGen bundled with libvcell ≥ 0.0.22, falling back to the stored math.

Tests: three new ones: the boundary-species model refused rather than crashed, numpy output times written as numbers, and loading under the C locale. tests/vcml/test_ode_simulation.py passes 20 of 20 locally, and mypy is clean.

🤖 Generated with Claude Code

jcschaff and others added 2 commits October 24, 2026 09:02
…he solver

The Sundials solver segfaults on an input with NUM_EQUATIONS 0 (every variable constant, or rate rules VCell's SBML
import did not keep: BIOMD0000000020, BIOMD0000000241), taking the Python process down. simulate_ode_vcml now raises
a ValueError first. Also: explicit output times are written as floats (numpy floats assigned after validation were
written as np.float64(...)), and the docstring says rule-based networks are regenerated by the bundled BioNetGen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
COPASI and libroadrunner set the C locale when loaded, which makes Python's default text encoding ASCII; every VCML,
SBML and Antimony file pyvcell reads or writes (libvcell's intermediate files included) then failed on non-ASCII
names and notes ('ascii' codec can't decode byte 0xc3). Found running pbsim_common's VCellUTCStep beside COPASI.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jcschaff jcschaff changed the title fix: refuse an ODE simulation with no equations instead of crashing the solver fix: no-ODE simulations refused, model files read as UTF-8 under any locale Oct 24, 2026
@jcschaff
jcschaff merged commit 7878bfe into main Oct 24, 2026
5 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.

1 participant