Skip to content

Commit

Permalink
restore usage of t in the error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Datseris committed Mar 13, 2024
1 parent 22d7d94 commit b2cb103
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
12 changes: 6 additions & 6 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ telling us exactly which variable is missing, and because of which processes it
model = processes_to_mtkmodel(processes[[1, 3]])
```
```
ERROR: ArgumentError: Variable x was introduced in process of variable z(t).
However, a process for x was not provided,
there is no default process for x, and x doesn't have a default value.
Please provide a process for variable x.
ERROR: ArgumentError: Variable x(t) was introduced in process of variable z(t).
However, a process for x(t) was not provided,
there is no default process for x(t), and (t)x doesn't have a default value.
Please provide a process for variable x(t).
```

If instead we "forgot" the ``y`` process, **PBM** will not error, but warn, and make ``y`` equal to a named parameter, since ``y`` has a default value:
Expand All @@ -129,8 +129,8 @@ parameters(model)

and the warning thrown was:
```julia
┌ Warning: Variable y was introduced in process of variable x(t).
│ However, a process for y was not provided,
┌ Warning: Variable y(t) was introduced in process of variable x(t).
│ However, a process for y(t) was not provided,
│ and there is no default process for it either.
│ Since it has a default value, we make it a parameter by adding a process:
`ParameterProcess(y)`.
Expand Down
15 changes: 7 additions & 8 deletions src/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,23 @@ function processes_to_mtkmodel(_processes, _default = [];
append_incomplete_variables!(incomplete, introduced, lhs_vars, def_proc)
else
def_val = default_value(added_var) # utilize default value (if possible)
varstr = ModelingToolkit.getname(added_var)
if !isnothing(def_val)
@warn("""
Variable $(varstr) was introduced in process of variable $(introduced[added_var]).
However, a process for $(varstr) was not provided,
Variable $(added_var) was introduced in process of variable $(introduced[added_var]).
However, a process for $(added_var) was not provided,
and there is no default process for it either.
Since it has a default value, we make it a parameter by adding a process:
`ParameterProcess($(varstr))`.
`ParameterProcess($(ModelingToolkit.getname(added_var)))`.
""")
parproc = ParameterProcess(added_var)
push!(eqs, lhs(parproc) ~ rhs(parproc))
push!(lhs_vars, added_var)
else
throw(ArgumentError("""
Variable $(varstr) was introduced in process of variable $(introduced[added_var]).
However, a process for $(varstr) was not provided,
there is no default process for $(varstr), and $(varstr) doesn't have a default value.
Please provide a process for variable $(varstr).
Variable $(added_var) was introduced in process of variable $(introduced[added_var]).
However, a process for $(added_var) was not provided,
there is no default process for $(added_var), and $(added_var) doesn't have a default value.
Please provide a process for variable $(added_var).
"""))
end
end
Expand Down

0 comments on commit b2cb103

Please sign in to comment.