File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 1
1
struct VariableUnit end
2
2
struct VariableConnectType end
3
- struct VariabelNoiseType end
4
- struct VariabelDescriptionType end
3
+ struct VariableNoiseType end
4
+ struct VariableDescriptionType end
5
+ struct VariableInput end
6
+ struct VariableOutput end
5
7
Symbolics. option_to_metadata_type (:: Val{:unit} ) = VariableUnit
6
8
Symbolics. option_to_metadata_type (:: Val{:connect} ) = VariableConnectType
7
- Symbolics. option_to_metadata_type (:: Val{:noise} ) = VariabelNoiseType
8
- Symbolics. option_to_metadata_type (:: Val{:description} ) = VariabelDescriptionType
9
+ Symbolics. option_to_metadata_type (:: Val{:noise} ) = VariableNoiseType
10
+ Symbolics. option_to_metadata_type (:: Val{:description} ) = VariableDescriptionType
11
+ Symbolics. option_to_metadata_type (:: Val{:input} ) = VariableInput
12
+ Symbolics. option_to_metadata_type (:: Val{:output} ) = VariableOutput
9
13
10
14
"""
11
15
$(SIGNATURES)
Original file line number Diff line number Diff line change 1
- using ModelingToolkit, OrdinaryDiffEq, Test
1
+ using ModelingToolkit, OrdinaryDiffEq, Symbolics, Test
2
2
3
3
@parameters t σ ρ β
4
4
@variables x (t) y (t) z (t) F (t) u (t)
@@ -37,3 +37,16 @@ collapsed_eqs = [D(lorenz1.x) ~ (lorenz1.σ * (lorenz1.y - lorenz1.x) +
37
37
simplifyeqs (eqs) = Equation .((x-> x. lhs). (eqs), simplify .((x-> x. rhs). (eqs)))
38
38
39
39
@test isequal (simplifyeqs (equations (connected)), simplifyeqs (collapsed_eqs))
40
+
41
+ # Variables indicated to be input/output
42
+ @variables x [input= true ]
43
+ @test hasmetadata (x, Symbolics. option_to_metadata_type (Val (:input )))
44
+ @test getmetadata (x, Symbolics. option_to_metadata_type (Val (:input ))) == true
45
+ @test ! hasmetadata (x, Symbolics. option_to_metadata_type (Val (:output )))
46
+ @test_throws KeyError getmetadata (x, Symbolics. option_to_metadata_type (Val (:output )))
47
+
48
+ @variables y [output= true ]
49
+ @test hasmetadata (y, Symbolics. option_to_metadata_type (Val (:output )))
50
+ @test getmetadata (y, Symbolics. option_to_metadata_type (Val (:output ))) == true
51
+ @test ! hasmetadata (y, Symbolics. option_to_metadata_type (Val (:input )))
52
+ @test_throws KeyError getmetadata (y, Symbolics. option_to_metadata_type (Val (:input )))
You can’t perform that action at this time.
0 commit comments