Skip to content

Commit

Permalink
Merge pull request #303 from SciML/unicode
Browse files Browse the repository at this point in the history
Fix issues with unicode names
  • Loading branch information
pogudingleb authored Mar 10, 2024
2 parents c842d57 + 967415a commit ad17696
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ODE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ end
function Base.show(io::IO, ode::ODE)
for x in ode.x_vars
if endswith(var_to_str(x), "(t)")
print(io, var_to_str(x)[1:(end - 3)] * "'(t) = ")
print(io, chop(var_to_str(x), tail = 3) * "'(t) = ")
else
print(io, var_to_str(x) * "' = ")
end
Expand Down
2 changes: 1 addition & 1 deletion src/discrete.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ end
function Base.show(io::IO, dds::DDS)
for x in x_vars(dds)
if endswith(var_to_str(x), "(t)")
print(io, var_to_str(x)[1:(end - 3)] * "(t + 1) = ")
print(io, chop(var_to_str(x), tail = 3) * "(t + 1) = ")
else
print(io, var_to_str(x) * "(t + 1) = ")
end
Expand Down
6 changes: 3 additions & 3 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,9 @@ If yes, returns a pair (a, number), otherwise nothing
function decompose_derivative(varname::String, prefixes::Array{String})
for pr in prefixes
if startswith(varname, pr) && length(varname) > length(pr) + 1
if varname[length(pr) + 1] == '_' &&
all(map(isdigit, collect(varname[(length(pr) + 2):end])))
return (pr, parse(Int, varname[(length(pr) + 2):end]))
if varname[nextind(varname, ncodeunits(pr))] == '_' &&
all(isdigit, varname[(nextind(varname, ncodeunits(pr)) + 1):end])
return (pr, parse(Int, varname[(nextind(varname, ncodeunits(pr)) + 1):end]))
end
end
end
Expand Down
37 changes: 37 additions & 0 deletions test/ode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,40 @@
y(t) = x1
)
end

@testset "ODE/DDE unicode" begin
ode = StructuralIdentifiability.@ODEmodel(
🐁'(t) = a * 🐁 - b * 🐁 * 🦉,
🦉'(t) = c * 🦉 + d * 🐁 * 🦉,
y(t) = 🐁
)
println(ode)
res = StructuralIdentifiability.assess_identifiability(ode)
println(res)
@test res == Dict(
a => :globally,
b => :nonidentifiable,
c => :globally,
d => :globally,
🐁 => :globally,
🦉 => :nonidentifiable,
)
ode = StructuralIdentifiability.@ODEmodel(
'(t) = a⬜ ** 🐁b🦉c,
🐁b🦉c'(t) = 🐁b🦉c,
🐁y🐁(t) =
)
println(ode)
StructuralIdentifiability.assess_identifiability(ode)
StructuralIdentifiability.find_identifiable_functions(ode)
StructuralIdentifiability.reparametrize_global(ode)

dde = StructuralIdentifiability.@DDSmodel(
🐁(t + 1) = a * 🐁(t) - b * 🐁(t) * 🦉(t),
🦉(t + 1) = c * 🦉(t) + d * 🐁(t) * 🦉(t),
y(t) = 🐁(t)
)
println(dde)
StructuralIdentifiability.assess_local_identifiability(dde)
end

0 comments on commit ad17696

Please sign in to comment.