Skip to content

Commit

Permalink
fix issues with unicode names
Browse files Browse the repository at this point in the history
  • Loading branch information
sumiya11 committed Mar 10, 2024
1 parent c842d57 commit f952ed1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ODE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ 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, chopsuffix(var_to_str(x), "(t)") * "'(t) = ")
# print(io, var_to_str(x)[1:(end - 3)] * "'(t) = ")
else
print(io, var_to_str(x) * "' = ")
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
29 changes: 29 additions & 0 deletions test/ode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,32 @@
y(t) = x1
)
end

@testset "ODE 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)
end

0 comments on commit f952ed1

Please sign in to comment.