Use oneunit in remaining tf/ss/zpk type-promotion sites#1055
Merged
baggepinnen merged 1 commit intoMay 14, 2026
Merged
Conversation
Completes b394b96: five more `typeof(one(T)/one(T))` sites still collapsed `Measurement{Float64}` to `Float64` (since Measurements.jl defines `one(Measurement{T}) = one(T)`), breaking the tf->zpk, ss->tf, ss->zpk, minreal, and charpoly conversion paths reported in JuliaControl#1027. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1055 +/- ##
==========================================
+ Coverage 91.57% 91.61% +0.04%
==========================================
Files 42 42
Lines 5623 5653 +30
==========================================
+ Hits 5149 5179 +30
Misses 474 474 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Base.one(::Type{Measurement{T}}) = one(T), soone(Measurement{Float64}) === 1.0::Float64. Five conversion sites still inferred the result element type viatypeof(one(T0)/one(T0))/typeof(zero(T0)/one(T0)), which collapsedMeasurement{Float64}toFloat64and triggered theMethodError: no method matching Float64(::Measurement{Float64})reported in MatrixPencils - a new feature #1027 along thetf → zpk,ss → tf,ss → zpk,minreal, andcharpolypaths.typeof(oneunit(T)/oneunit(T)), matching the existing fix inconvert(::Type{StateSpace}, G::TransferFunction). Behavior forInt/Float64/BigFloat/etc. is unchanged (oneunit/oneunitreduces toone/onewhenone(T) isa T).types/conversion.jl(×3: ss→TF/SisoRational, ss→TF/SisoZpk,charpoly),types/zpk.jl(tf→zpk),types/SisoTfTypes/SisoRational.jl(minreal),matrix_comps.jl(_infnorm_two_steps_dt, for consistency).Closes #1027 to the extent it's a ControlSystems issue. (
zpkandtf(::ss{Measurement})may still fail downstream insidePolynomials.roots/LinearAlgebra.hessenberg, which need BLAS-able elements — separate upstream limitations.)Test plan
lib/ControlSystemsBasetest suite: 21146 pass, 6 broken (unchanged from master).RobustAndOptimalControl.jltest suite (extra promotion coverage): 1357 pass, 6 broken (unchanged).ss(P)now returnsStateSpace{Continuous, Measurement{Float64}}with elements preserved.🤖 Generated with Claude Code