Skip to content

State keeps the vector field of an empty state variable - #36

Merged
michakraus merged 1 commit into
mainfrom
state/empty-vectorfield
Oct 12, 2026
Merged

michakraus merged 1 commit into
mainfrom
state/empty-vectorfield

Conversation

@michakraus

Copy link
Copy Markdown
Member

What this changes

State keeps the vector field of an empty state variable.

_novectorfield(x) = ismissing(x) || all(ismissing, x) dropped a field whenever all(ismissing, x) held. Over a VectorfieldVariable — an AbstractArray — that is true exactly when some extent is zero, so a state variable with a zero extent lost its field. A 6 × 0 particle matrix then had no q̇ to fill, and integrate raised FieldError: type State has no field q̇ on any problem whose state is empty.

A field is now dropped only where _vectorfield returns missing, so a vector field mirrors the shape of its state variable, a zero extent included.

Why

An empty particle list is a valid configuration — a vacuum run. The change also removes a crash for every other empty state, and it makes the vectorfield NamedTuple's type inferable from the type of ics, where it was abstract.

Evidence

  • all(ismissing, x) over a VectorfieldVariable: 6×0, 0×0, (0,), 0×6 and 3×0×2 give true; 6×3 and a 0-dimensional array give false.
  • The new testset in test/data/state.jl asserts :q̇ ∈ keys(st) and size(st.q̇) == size(st.q) over 6×0, (0,), 3×0×2 and a 0-dimensional state, in Float32 and Float64.
  • The suite passes with the change: States 92/92, State Variables 1738/1738, Aqua 10 pass and 1 broken, as on main.
  • No non-empty caller changes: for a VectorfieldVariable with no zero extent and a non-missing element type, all(ismissing, x) is false, so the kept keys are the same.

Compatibility

A patch release. No non-empty result changes. The one visible difference is that keys(State(…)) of an empty state gains q̇, where before any integration of such a state failed.

The branch sets version = "0.15.1", which a dependant pins; the release commit closes out the CHANGELOG.

State dropped a vector field wherever `all(ismissing, x)` held, which is true of every empty array, so a state variable with a zero extent had no `q̇` and `integrate` raised `FieldError` on any problem whose state is empty. A field is now dropped only where `_vectorfield` returns `missing`.

Version 0.15.1, so that a dependant can bound the release that carries the fix.
@codecov

codecov Bot commented Oct 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.20%. Comparing base (41c0816) to head (1d38e7a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #36      +/-   ##
==========================================
+ Coverage   77.14%   77.20%   +0.05%     
==========================================
  Files          18       18              
  Lines         442      443       +1     
==========================================
+ Hits          341      342       +1     
  Misses        101      101              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@michakraus
michakraus merged commit c479e49 into main Oct 12, 2026
13 checks passed
@michakraus
michakraus deleted the state/empty-vectorfield branch October 12, 2026 10:09
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