Isolate model symbol namespace to prevent conflicts with package functions and constants #176
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.
Model variable and parameter names were created via
eval()in the MacroModelling module namespace, causing conflicts with built-in functions (max,min,exp) and imported constants (SymPy'ssqrt2).Changes
Core isolation mechanism
ModelSymbolssubmodule as isolated namespace for all model symbolseval_in_symbols()helper to evaluate expressions in isolated contextSymbol creation and access
create_symbols_eqs!(): Changed symbol creation fromeval(:($x = SPyPyC.symbols(...)))toCore.eval(ModelSymbols, :($x = SPyPyC.symbols(...)))simplify(): Isolated SymPy symbol creation and evaluationtransform_obc(): Isolated OBC constraint symbol handlingeval(:($x))→eval_in_symbols(:($x))Testing
test/test_namespace_isolation.jlto verify built-in functions remain accessible and models can use common function names as variablesExample
Before: Creating a model with variable named
maxwould shadow Julia'smax()function.After: Model symbols are isolated:
The isolation is transparent to users - no API changes required.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
julialang-s3.julialang.orgcurl --retry 3 -C - --proto =https --tlsv1.2 --ciphers TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384 --silent --show-error --fail --location REDACTED --output /tmp/tmp.dbWebAttcw/juliainstaller(dns block)storage.julialang.netjulia -t auto --project=. -e using Pkg Pkg.instantiate()(dns block)julia --project=. -e using Pkg; Pkg.instantiate()(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.