Skip to content

Commit

Permalink
Merge pull request #872 from JuliaControl/colonind
Browse files Browse the repository at this point in the history
fix transfer function colon indexing
  • Loading branch information
baggepinnen committed Sep 13, 2023
2 parents 6540a25 + d8a077a commit f3848b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/ControlSystemsBase/Project.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name = "ControlSystemsBase"
uuid = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
authors = ["Dept. Automatic Control, Lund University"]
repo = "https://github.com/JuliaControl/ControlSystemsBase.jl.git"
version = "1.9.0"
repo = "https://github.com/JuliaControl/ControlSystems.jl.git"
version = "1.9.1"

[deps]
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Expand Down
6 changes: 5 additions & 1 deletion lib/ControlSystemsBase/src/types/TransferFunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ function Base.getindex(G::TransferFunction{TE,S}, inds...) where {TE,S<:SisoTf}
error("Must specify 2 indices to index TransferFunction model")
end
rows, cols = index2range(inds...)
mat = Matrix{S}(undef, length(rows), length(cols))
mat = Matrix{S}(
undef,
rows isa Colon ? noutputs(G) : length(rows),
cols isa Colon ? ninputs(G) : length(cols)
)
mat[:, :] = G.matrix[rows, cols]
return TransferFunction(mat, G.timeevol)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/ControlSystemsBase/test/test_transferfunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ M = randn(2,1)
@test C_222[1,1] == tf([1, 2, 3], [1, 8, 15])
@test C_222[1:1,1] == tf([1, 2, 3], [1, 8, 15])
@test C_222[1,1:2] == C_221
@test C_222[1,:] == C_221
@test C_222[:,:] == C_222
@test size(C_222[1,[]]) == (1,0)

# Accessing Ts through .Ts
Expand Down

2 comments on commit f3848b2

@baggepinnen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir=lib/ControlSystemsBase

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/91347

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a ControlSystemsBase-v1.9.1 -m "<description of version>" f3848b28d1163b6655047ed9465004fd1817102a
git push origin ControlSystemsBase-v1.9.1

Please sign in to comment.