Skip to content

Commit

Permalink
add propertynames for named systems
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Apr 1, 2022
1 parent 3b8a297 commit 067e87a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RobustAndOptimalControl"
uuid = "21fd56a4-db03-40ee-82ee-a87907bee541"
authors = ["Fredrik Bagge Carlson", "Marcus Greiff"]
version = "0.4.5"
version = "0.4.6"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
2 changes: 2 additions & 0 deletions src/named_systems2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ function Base.getproperty(G::NamedStateSpace, s::Symbol)
return getproperty(G.sys, s)
end

Base.propertynames(sys::NamedStateSpace) = (propertynames(sys.sys)..., :x, :u, :y)

ControlSystems.numeric_type(G::NamedStateSpace) = ControlSystems.numeric_type(G.sys)

"""
Expand Down
2 changes: 2 additions & 0 deletions test/test_named_systems2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ G2 = ss(1.0,1,1,1)
s1 = named_ss(G1, x = [:x], u = :u, y=:y) # test providing only symbol
s2 = named_ss(G2, x = [:z], u = [:u], y=[:y])
@show s1
@test :x propertynames(s1)
@test :A propertynames(s1)

s_autoname = named_ss(G1, :G)
@test s_autoname.x == [:Gx]
Expand Down

0 comments on commit 067e87a

Please sign in to comment.