@@ -91,18 +91,47 @@ function define_vars(u::Union{SLArray, LArray}, t)
91
91
[_defvar (x)(t) for x in LabelledArrays. symnames (typeof (u))]
92
92
end
93
93
94
- function define_vars (u:: Tuple , t)
94
+ function define_vars (u:: NTuple{<:Number} , t)
95
95
tuple ((_defvaridx (:x , i)(ModelingToolkit. value (t)) for i in eachindex (u)). .. )
96
96
end
97
97
98
98
function define_vars (u:: NamedTuple , t)
99
99
NamedTuple (x => _defvar (x)(ModelingToolkit. value (t)) for x in keys (u))
100
100
end
101
101
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
114
+ type:: Any
115
+ end
116
+
117
+ function Base. showerror (io:: IO , e:: ModelingtoolkitizeParametersNotSupportedError )
118
+ println (io, PARAMETERS_NOT_SUPPORTED_MESSAGE)
119
+ print (io, " Parameter type: " )
120
+ println (io, e. type)
121
+ end
122
+
102
123
function define_params (p)
124
+ throw (ModelingtoolkitizeParametersNotSupportedError (typeof (p)))
125
+ end
126
+
127
+ function define_params (p:: AbstractArray )
103
128
[toparam (variable (:α , i)) for i in eachindex (p)]
104
129
end
105
130
131
+ function define_params (p:: Number )
132
+ [toparam (variable (:α ))]
133
+ end
134
+
106
135
function define_params (p:: AbstractDict )
107
136
OrderedDict (k => toparam (variable (:α , i)) for (i, k) in zip (1 : length (p), keys (p)))
108
137
end
0 commit comments