You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
iv = b ==:t?get_t(mod, b) :generate_var(b, :variables)
288
287
prev_iv =get!(dict, :independent_variable) do
289
288
iv
290
289
end
@@ -306,6 +305,20 @@ function generate_var!(dict, a, b, varclass;
306
305
var
307
306
end
308
307
308
+
# Use the `t` defined in the `mod`. When it is unavailable, generate a new `t` with a warning.
309
+
functionget_t(mod, t)
310
+
try
311
+
get_var(mod, t)
312
+
catch e
313
+
if e isa UndefVarError
314
+
@warn("Could not find a predefined `t` in `$mod`; generating a new one within this model.\nConsider defining it or importing `t` (or `t_nounits`, `t_unitful` as `t`) from ModelingToolkit.")
315
+
variable(:t)
316
+
else
317
+
throw(e)
318
+
end
319
+
end
320
+
end
321
+
309
322
functionparse_default(mod, a)
310
323
a = Base.remove_linenums!(deepcopy(a))
311
324
MLStyle.@match a begin
@@ -393,8 +406,9 @@ function parse_constants!(exprs, dict, body, mod)
393
406
Expr(:(=), Expr(:(::), a, type), Expr(:tuple, b, metadata)) ||Expr(:(=), Expr(:(::), a, type), b) =>begin
394
407
type =getfield(mod, type)
395
408
b =_type_check!(get_var(mod, b), a, type, :constants)
0 commit comments