Skip to content

Conversation

@baggepinnen
Copy link
Member

the division might change the type, causing the ST constructor to fail.

Closes #299

the division might change the type, causing the `ST` constructor to fail

Base.inv(sys::AbstractStateSpace) = 1/sys
/(sys::ST, n::Number) where ST <: AbstractStateSpace = ST(sys.A, sys.B, sys.C/n, sys.D/n, sys.timeevol)
/(sys::ST, n::Number) where ST <: AbstractStateSpace = ss(sys.A, sys.B, sys.C/n, sys.D/n, sys.timeevol)
Copy link
Member

Choose a reason for hiding this comment

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

Does this work with heterostatespace then?

Copy link
Member Author

Choose a reason for hiding this comment

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

nope, hss needs it's own overload. For Int it didn't work before either since hss is even stricter with the types, but this actually breaks hss for float types :/, good catch. It's a bit unfortunate that we can't use ST here, perhaps something like constructor(ST) that strips the type parameters would be nice to have to make it generic

Copy link
Member Author

Choose a reason for hiding this comment

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

or, hss will still work, but "demote" to standard ss

Copy link
Member

Choose a reason for hiding this comment

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

perhaps something like constructor(ST) that strips the type parameters

Is this easy to do? Remember I tried to do something similar with maybe c2d for tf, and we wanted to return a tf of same type as in zpk/rational but the number types could change and timeevol would change. I think I ended up just dispatching differently because I only found some internal methods to access that data which didn't seems stable, but might have changed (or I might not have found the best method).

Copy link
Member Author

Choose a reason for hiding this comment

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

This

julia> tG = typeof(G)
TransferFunction{Continuous, ControlSystems.SisoRational{Int64}}

julia> tG.name.wrapper
TransferFunction

is probably one of the most used internals of julia since there is no "supported" way of doing it, but it's often very useful to do. The alternative would be that every type of LTISystem implements a method like

constructor(::StateSpace) = StateSpace

(without the type parameters). This also works, but it's a bit unfortunate that it's required. There's an issue about exposing .name.wrapper as an API and the consensus appears to be that it should be done, but no one has done it yet.
JuliaLang/julia#35543
I think we could introduce our own basetype function until one exists in Base.

@JuliaControlBot
Copy link

This is an automated message.
Plots were compared to references. 9/11 images have changed, see differences below.
After pulling this PR, please update the reference images by creating a PR to ControlExamplePlots.jl here.

Difference Reference Image New Image
✔️ 0.003 Reference New
✔️ 0.003 Reference New
✔️ 0.0 Reference New
✔️ 0.001 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New
❌ 0.042 Reference New
✔️ 0.006 Reference New
✔️ 0.011 Reference New

@codecov
Copy link

codecov bot commented Jan 28, 2022

Codecov Report

Merging #625 (fdc547f) into master (9455a54) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #625   +/-   ##
=======================================
  Coverage   86.75%   86.75%           
=======================================
  Files          31       31           
  Lines        3253     3217   -36     
=======================================
- Hits         2822     2791   -31     
+ Misses        431      426    -5     
Impacted Files Coverage Δ
src/types/StateSpace.jl 87.19% <100.00%> (-0.15%) ⬇️
src/types/conversion.jl 97.79% <100.00%> (+1.49%) ⬆️
src/types/promotion.jl 33.33% <100.00%> (+3.33%) ⬆️
src/utilities.jl 85.71% <100.00%> (+0.29%) ⬆️
src/connections.jl 92.68% <0.00%> (-0.58%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9455a54...fdc547f. Read the comment docs.

@baggepinnen baggepinnen requested a review from albheim January 29, 2022 14:00
Copy link
Member

@albheim albheim left a comment

Choose a reason for hiding this comment

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

LGTM

@baggepinnen baggepinnen merged commit 6b8e2d0 into master Jan 30, 2022
@baggepinnen baggepinnen deleted the ss_type branch January 30, 2022 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conversion problem for ss(1,1,1,0)/3

4 participants