Repository navigation
Make ParticleSystem construction trim-safe - #183
Merged
Merged
Conversation
Remove the sources of non-inferable code in the ParticleSystem constructors
that prevent compiling code using CellListMap with `juliac --trim=safe`:
- `ParticleSystemPositions.updated` is now a concrete `Base.RefValue{Bool}`
instead of the abstract `Ref{Bool}`.
- The constructor no longer reassigns `output`, which was captured by the
comprehension creating the threaded outputs (boxed variable). The
reassignment was a no-op with `reset = false`.
- `get_dim` returns the dimension from the coordinate type when coordinates
are vectors of `SVector`s, so the dimension is a compile-time constant even
when the unit cell is given as a dynamic array (unitcell size still checked).
- `output_name` accepts a `Val` in addition to a `Symbol`; defaults are now
`Val`s, so the default construction path is fully inferable. Passing a
`Symbol` still works as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Document `output_name = Val(...)` as a new feature and add a "Type-stable construction" section to the options page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #183 +/- ##
==========================================
- Coverage 98.65% 98.53% -0.12%
==========================================
Files 21 21
Lines 1632 1640 +8
==========================================
+ Hits 1610 1616 +6
- Misses 22 24 +2 ☔ 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.
Removes the non-inferable code in the
ParticleSystemconstructors that blocks compiling packages that use CellListMap withjuliac --trim=safe. Found while compiling Packmol.jl to a standalone executable. None of the changes break existing code.Changes
ParticleSystemPositions.updatedis now a concreteBase.RefValue{Bool}instead of the abstractRef{Bool}. Everyupdated[]read and write was a dynamic call (CellLists.jl,NonPeriodicCells.jl).output. That variable is captured by the comprehension that builds the threaded outputs, so it was boxed (Core.Box). Withreset = false,_reset_all_output!returnsoutputunchanged, so the assignment did nothing.get_dimmethod forSVectorcoordinates. It takes the dimension from the coordinate type, soVal(DIM)is a compile-time constant even when the unit cell is aVector/Matrix. The unit cell size is still checked at runtime.output_namenow also accepts aVal, e.g.output_name = Val(:forces). The defaults are nowVals, so constructing withoutoutput_nameis fully inferable. Passing aSymbolworks exactly as before, through a dynamic call.InPlaceNeighborListnow passesVal(:nb)internally.Changelog and docs
CHANGELOG.md: under 0.10.6-DEV, a FEATURE entry foroutput_name = Val(...)and an ENHANCEMENT entry for type-stable construction.ParticleSystem/options.md(when the constructor is inferable, with a runnable example, and why it matters forjuliac --trim), linked from the paragraph insingle_set_simple.mdthat introducesoutput_name. That paragraph's broken sentence ("the output value from thesystem.outputfield") is fixed too.examples.md.Testing
@inferredon the keyword constructor (one and two position sets; unitcell asVector,Matrix,SVector, andnothing), thatSymbolnames still work, and that a dimension mismatch still throws.juliac --trim=safe. Verifier errors raised inside CellListMap's own source dropped from 32 (v0.10.5) to 0. The remaining ones are on the Packmol side.🤖 Generated with Claude Code