Skip to content

Commit

Permalink
Makestate_name work for arbitrary expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Datseris committed Apr 23, 2024
1 parent a3c75f5 commit 9c476c1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DynamicalSystemsBase"
uuid = "6e36e845-645a-534a-86f2-f5d4aa5a06b4"
repo = "https://github.com/JuliaDynamics/DynamicalSystemsBase.jl.git"
version = "3.8.2"
version = "3.8.3"

[deps]
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Expand Down
3 changes: 3 additions & 0 deletions src/core/dynamicalsystem_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ Return the state `u` of `ds` _observed_ at "index" `i`. Possibilities are:
such as a `Num` or `Symbol` instance with the name of the symbolic variable.
In this case, a last fourth optional positional argument `t` defaults to
`current_time(ds)` and is the time to observe the state at.
- Any symbolic expression involving variables present in the symbolic
variables tracked by the system, e.g., `i = x^2 - y` with `x, y`
symbolic variables.
For [`ProjectedDynamicalSystem`](@ref), this function assumes that the
state of the system is the full state space state, not the projected one
Expand Down
13 changes: 12 additions & 1 deletion src/core/pretty_printing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,18 @@ Return a name that matches the outcome of [`observe_state`](@ref) with `index`.
state_name(f::Int) = "u"*subscript(f)
state_name(f::Function) = string(f)
state_name(f::Union{AbstractString,Symbol}) = string(f)
state_name(f) = string(DynamicalSystemsBase.SymbolicIndexingInterface.getname(f))
function state_name(f)
# First, try a symbolic name
try
n = string(DynamicalSystemsBase.SymbolicIndexingInterface.getname(f))
return n
catch e
end
# if it failed, cast into string
n = string(f)
# and remove `(t)`
replace(n, "(t)" => "")
end

"""
parameter_name(index)::String
Expand Down

0 comments on commit 9c476c1

Please sign in to comment.