Repository navigation
State keeps the vector field of an empty state variable - #36
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
What this changes
Statekeeps the vector field of an empty state variable._novectorfield(x) = ismissing(x) || all(ismissing, x)dropped a field wheneverall(ismissing, x)held. Over aVectorfieldVariable— anAbstractArray— that is true exactly when some extent is zero, so a state variable with a zero extent lost its field. A6 × 0particle matrix then had noq̇to fill, andintegrateraisedFieldError: type State has no field q̇on any problem whose state is empty.A field is now dropped only where
_vectorfieldreturnsmissing, 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
vectorfieldNamedTuple's type inferable from the type ofics, where it was abstract.Evidence
all(ismissing, x)over aVectorfieldVariable:6×0,0×0,(0,),0×6and3×0×2givetrue;6×3and a 0-dimensional array givefalse.test/data/state.jlasserts:q̇ ∈ keys(st)andsize(st.q̇) == size(st.q)over6×0,(0,),3×0×2and a 0-dimensional state, inFloat32andFloat64.main.VectorfieldVariablewith no zero extent and a non-missingelement type,all(ismissing, x)isfalse, 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 gainsq̇, 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.