Skip to content

Forward keyword arguments to the inner DescriptorSystems methods - #156

Merged
baggepinnen merged 2 commits into
masterfrom
fbc/descriptor-kwarg-forwarding
Sep 18, 2026
Merged

baggepinnen merged 2 commits into
masterfrom
fbc/descriptor-kwarg-forwarding

Conversation

@baggepinnen

@baggepinnen baggepinnen commented Sep 18, 2026

Copy link
Copy Markdown
Member

baltrunc_unstab splatted its keyword arguments into both DescriptorSystems.gsdec and DescriptorSystems.gbalmr, neither of which slurps keyword arguments, so any keyword argument specific to one of the two raised a MethodError. In particular smarg, which determines the stability boundary used for the additive decomposition, could not be passed at all, and neither could atolhsv and the remaining truncation tolerances. baltrunc_coprime forwarded its keyword arguments to gbalmr only, so the coprime factorization performed by factorization could not be controlled.

The keyword arguments accepted by more than one inner method are now listed explicitly in the signatures of the wrappers and forwarded to each of them:

  • baltrunc_unstab accepts smarg, which is passed to gsdec, and fast, atol, atol1, atol2, rtol, which are passed to both gsdec and gbalmr. The remaining keyword arguments are passed to gbalmr.
  • baltrunc_coprime accepts factorization_kwargs, a named tuple passed to factorization only, and fast, atol, atol1, atol2, rtol, which are passed to both factorization and gbalmr. The remaining keyword arguments are passed to gbalmr.
  • baltrunc2 is unchanged, all of its keyword arguments are passed to gbalmr.

The new keyword arguments are documented in the docstrings.

# Previously a MethodError, now selects the stability boundary of the decomposition
sysr, hs, info = baltrunc_unstab(sys; n = 12, smarg = -0.01, atolhsv = 1e-8)

# Previously ignored, now reaches the factorization
sysr, hs, info = baltrunc_coprime(sys; n = 12,
    factorization = RobustAndOptimalControl.DescriptorSystems.glcf,
    factorization_kwargs = (; smarg = -0.01))

Tests covering the forwarding and the effect of smarg on the additive decomposition are added to test/test_descriptor.jl. test_descriptor.jl, test_reduction.jl and test_glover_mcfarlane.jl pass locally.

🤖 Generated with Claude Code

`baltrunc_unstab` splatted its keyword arguments into both
`DescriptorSystems.gsdec` and `DescriptorSystems.gbalmr`, neither of which
slurps keyword arguments. Any keyword argument specific to one of the two
therefore raised a `MethodError`: `smarg`, which determines the stability
boundary used for the additive decomposition, could not be passed at all, and
neither could `atolhsv` and the other truncation tolerances. `baltrunc_coprime`
forwarded its keyword arguments to `gbalmr` only, so the factorization
performed by `factorization` could not be controlled.

Keyword arguments are now distributed over the inner methods: each inner method
receives the keyword arguments that appear in the keyword-argument list of its
own methods, so tolerances such as `atol` and `rtol` reach all of them while
`smarg` reaches `gsdec` and the coprime factorization, and `atolhsv` reaches
`gbalmr`. The keyword-argument lists are obtained from `Base.kwarg_decl`;
`glcf` and `glcfid`, which slurp their keyword arguments, are resolved through
`grcf` and `grcfid`.

A keyword argument accepted by none of the inner methods of a given wrapper now
raises an `ArgumentError` listing the supported names instead of being silently
ignored. The keyword arguments `job`, `ord` and `matchdc` are determined by the
arguments of the wrappers (`n` and `residual`) and are no longer accepted.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.78%. Comparing base (162e9b7) to head (6bfe2ee).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #156      +/-   ##
==========================================
- Coverage   91.87%   91.78%   -0.10%     
==========================================
  Files          20       20              
  Lines        3065     3078      +13     
==========================================
+ Hits         2816     2825       +9     
- Misses        249      253       +4     
Flag Coverage Δ
unittests 91.78% <100.00%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Replace the keyword-argument introspection (`_kwarg_names`, `_select_kwargs`,
`_check_kwargs` and the associated tables) with explicit keyword arguments in
the signatures of the wrappers:

- `baltrunc_unstab` accepts `smarg`, which is passed to
  `DescriptorSystems.gsdec`, and `fast, atol, atol1, atol2, rtol`, which are
  passed to both `gsdec` and `DescriptorSystems.gbalmr`. The remaining keyword
  arguments are passed to `gbalmr`.
- `baltrunc_coprime` accepts `factorization_kwargs`, a named tuple passed to
  `factorization` only, and `fast, atol, atol1, atol2, rtol`, which are passed
  to both `factorization` and `gbalmr`. The remaining keyword arguments are
  passed to `gbalmr`.
- `baltrunc2` is restored to its previous form, all of its keyword arguments
  are passed to `gbalmr`.

The new keyword arguments are documented in the docstrings.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@baggepinnen
baggepinnen merged commit b959ee6 into master Sep 18, 2026
2 checks passed
@baggepinnen
baggepinnen deleted the fbc/descriptor-kwarg-forwarding branch September 18, 2026 06:21
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.

2 participants