-
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implementation of new SymbolicIndexingInterface #2345
feat: implementation of new SymbolicIndexingInterface #2345
Conversation
dafacf2
to
d2e291d
Compare
[getfield(sys, :iv)] | ||
#Treat the result as a vector of symbols always | ||
function SymbolicIndexingInterface.is_variable(sys::AbstractSystem, sym) | ||
if unwrap(sym) isa Int # [x, 1] coerces 1 to a Num |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems really ugly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it is. It's the only way I could find to cover all the cases
- we need the
isa Int
check because[x, 1]
wraps1
in aNum
(e.g.sol(1.0, idxs=[1, x])
- The next one is necessary since
sol[x + y]
is a possibility, andgetname
errors onx+y
- The
getname
case is necessary for namespaced variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does unwrap
do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gets the value inside a Num
, which is usually either a SymbolicUtils.BasicSymbolic
for symbolic variables or a number in the case of something like Num(1)
@@ -224,8 +224,12 @@ function SymbolicIndexingInterface.variable_symbols(sys::AbstractSystem) | |||
end | |||
|
|||
function SymbolicIndexingInterface.is_parameter(sys::AbstractSystem, sym) | |||
usym = unwrap(sym) | |||
if unwrap(sym) isa Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usym
src/systems/abstractsystem.jl
Outdated
return unwrap(sym) in 1:length(parameters(sys)) | ||
return usym in 1:length(parameters(sys)) | ||
end | ||
if istree(usym) && operation(usym) != getindex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return !istree(usym) || operation(usym) == getindex
f245c52
to
11ebc18
Compare
11ebc18
to
ed2b237
Compare
ed2b237
to
d179b4f
Compare
No description provided.