Skip to content

Commit 0a17f11

Browse files
Handle the p <: Number case
1 parent 0190957 commit 0a17f11

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/systems/diffeqs/modelingtoolkitize.jl

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,26 +99,25 @@ function define_vars(u::NamedTuple, t)
9999
NamedTuple(x => _defvar(x)(ModelingToolkit.value(t)) for x in keys(u))
100100
end
101101

102-
const PARAMETERS_NOT_SUPPORTED_MESSAGE =
103-
"""
104-
The chosen parameter type is currently not supported by `modelingtoolkitize`. The
105-
current supported types are:
106-
107-
- AbstractArrays
108-
- AbstractDicts
109-
- LabelledArrays (SLArray, LArray)
110-
- Flat tuples (tuples of numbers)
111-
- Flat named tuples (namedtuples of numbers)
112-
"""
113-
114-
struct ModelingtoolkitizeParametersNotSupportedError <: Exception
102+
const PARAMETERS_NOT_SUPPORTED_MESSAGE = """
103+
The chosen parameter type is currently not supported by `modelingtoolkitize`. The
104+
current supported types are:
105+
106+
- AbstractArrays
107+
- AbstractDicts
108+
- LabelledArrays (SLArray, LArray)
109+
- Flat tuples (tuples of numbers)
110+
- Flat named tuples (namedtuples of numbers)
111+
"""
112+
113+
struct ModelingtoolkitizeParametersNotSupportedError <: Exception
115114
type::Any
116115
end
117116

118117
function Base.showerror(io::IO, e::ModelingtoolkitizeParametersNotSupportedError)
119118
println(io, PARAMETERS_NOT_SUPPORTED_MESSAGE)
120119
print(io, "Parameter type: ")
121-
println(io,e.type)
120+
println(io, e.type)
122121
end
123122

124123
function define_params(p)
@@ -129,6 +128,10 @@ function define_params(p::AbstractArray)
129128
[toparam(variable(, i)) for i in eachindex(p)]
130129
end
131130

131+
function define_params(p::Number)
132+
[]
133+
end
134+
132135
function define_params(p::AbstractDict)
133136
OrderedDict(k => toparam(variable(, i)) for (i, k) in zip(1:length(p), keys(p)))
134137
end

0 commit comments

Comments
 (0)