Skip to content

Commit

Permalink
hopefully num->BasicSymbolic for states
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Dec 19, 2023
1 parent 4647656 commit 9262249
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/systems/abstractsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ function namespace_expr(O, sys, n = nameof(sys); ivs = independent_variables(sys
O
end
end

_nonum(@nospecialize x) = x isa Num ? x.val : x

Check warning on line 630 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L630

Added line #L630 was not covered by tests

This comment has been minimized.

Copy link
@ChrisRackauckas

ChrisRackauckas Dec 19, 2023

Member

This is Symbolics.unwrap, but we shouldn't be unwrapping in states because then they won't act as numbers or be == to what the user defined.

This comment has been minimized.

Copy link
@chriselrod

chriselrod Dec 19, 2023

Author Contributor

Should I convert everything in the state to a Num instead?
Having mixed types in the states is causing test failures.

Where do states come from?
When/why do users == them?

function states(sys::AbstractSystem)
sts = get_states(sys)
systems = get_systems(sys)
Expand All @@ -637,9 +637,13 @@ function states(sys::AbstractSystem)
system_states = reduce(vcat, namespace_variables.(systems))
isempty(sts) ? system_states : [sts; system_states]

Check warning on line 638 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L637-L638

Added lines #L637 - L638 were not covered by tests
end
isempty(nonunique_states) && return nonunique_states

Check warning on line 640 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L640

Added line #L640 was not covered by tests
# `Vector{Any}` is incompatible with the `SymbolicIndexingInterface`, which uses
# `elsymtype = symbolic_type(eltype(_arg))`
# which inappropriately returns `NotSymbolic()`
if nonunique_states isa Vector{Any}
nonunique_states = _nonum.(nonunique_states)

Check warning on line 645 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L644-L645

Added lines #L644 - L645 were not covered by tests
end
@assert typeof(nonunique_states) !== Vector{Any}
unique(nonunique_states)

Check warning on line 648 in src/systems/abstractsystem.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/abstractsystem.jl#L647-L648

Added lines #L647 - L648 were not covered by tests
end
Expand Down
2 changes: 1 addition & 1 deletion src/systems/connectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ struct ConnectionElement
h::UInt
end
function _hash_impl(sys, v, isouter)
hashcore = hash(nameof(sys)) hash(v)
hashcore = hash(nameof(sys)) hash(getname(v))
hashouter = isouter ? hash(true) : hash(false)
hashcore hashouter

Check warning on line 155 in src/systems/connectors.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/connectors.jl#L152-L155

Added lines #L152 - L155 were not covered by tests
end
Expand Down

0 comments on commit 9262249

Please sign in to comment.