Conversation
- Use has(rhs, arg) from utils.jl to determine if arg appears in rhs - Generate runtime conditional code to distinguish time functions vs grids - Support multi-character time names (e.g., tau) without heuristics - Add helper functions following SRP principle - Update tests with comprehensive tau test cases - Remove heuristic-based time variable detection All 127 tests pass successfully.
Contributor
- Update version number for init branch with @init refactor - All tests passing (127/127)
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.
🎯 Objective
Refactor time handling in the
@initmacro to remove heuristic-based time variable detection and use ahas()+ runtime check approach.🔧 Key Changes
1. New Time/Grid Distinction Logic
has(rhs, arg)from utils.jl to detect ifargappears inrhshas == true→ strict validation thatarg == time_name(ocp)has == false→if Symbol(time_name(ocp)) == :arg→ constant function, else → grid2. New Helper Functions (SRP)
__gen_temporal_value(): generates runtime code for temporal specs__gen_spec_value(): dispatcher based on spec type__log_spec(): formatting for logging3. Modified Functions
_collect_init_specs(): returns taggedspecsinstead ofvals+time_symsinit_fun(): orchestration via helpers, no inline logic✅ Final Behavior
has(rhs, arg)u(s) := sin(s)(time="s")s == time_nameu(t) := t(time="s"):t != :sx(t) := 1(time="t")t == time_name→ yesx(T) := X(time="t")T != time_name→ no🧪 Testing
tau(multi-character name)🏗️ Architecture
evalin macroshas()from utils.jl (following onepass.jl pattern)📝 Notes
tau)__throw