Skip to content

Replace slycot (Fortran 77) with slicot (C11) via compatibility layer#1

Draft
Copilot wants to merge 1 commit into
slicot-migrationfrom
copilot/review-replace-slucot-with-slicot
Draft

Replace slycot (Fortran 77) with slicot (C11) via compatibility layer#1
Copilot wants to merge 1 commit into
slicot-migrationfrom
copilot/review-replace-slucot-with-slicot

Conversation

Copilot AI commented Jan 31, 2026

Copy link
Copy Markdown

Overview

Replaces slycot (Fortran 77 SLICOT wrapper) with slicot (C11 SLICOT translation) throughout python-control. Uses a compatibility layer to minimize invasive changes.

Changes

Compatibility Layer (control/slicot_compat.py)

  • Wraps 24 slicot functions to match slycot API signatures
  • Handles parameter reordering, type conversions, and array slicing differences
  • Centralizes error handling via _check_info() pattern

API Compatibility Fixes

  • sb03od: Parameter reorder, omit unused n/m/Q params
  • ab09ad/ab09md/ab09nd: Add ordsel param, slice reduced-order outputs
  • ab13dd: Add fpeak_in param, extract scalars from arrays
  • ab13md: Cast ITYPE/NBLOCK to int32
  • tb01pd: Handle tol=None → 0.0
  • sb10ad: Return gamma_out as first value

Migration

  • Update all slycot imports → slicot_compat
  • Rename pytest markers: @pytest.mark.slycot / @pytest.mark.noslicot
  • Update pyproject.toml optional dependency

Example Usage

# Before
from slycot import sb03md

# After
from control.slicot_compat import sb03md
# API signature unchanged, works transparently

Test Results

430 passed, 1 skipped, 1 xfail (test sensitivity)

Original prompt

Review the last commit as it is replacing the slucot with slicot written in C11. Review throughly.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Review replacement of slucot with slicot in C11 Replace slycot (Fortran 77) with slicot (C11) via compatibility layer Jan 31, 2026
Copilot AI requested a review from jamestjsp January 31, 2026 13:53
@jamestjsp

Copy link
Copy Markdown
Owner

@copilot Is it following the same coding pattern as python control codebase?

Copilot AI commented Jan 31, 2026

Copy link
Copy Markdown
Author

@copilot Is it following the same coding pattern as python control codebase?

The slicot_compat.py module mostly follows python-control coding patterns, with a few minor inconsistencies:

✅ Follows conventions:

  • Top-level import pattern with try-except blocks (same as mateqn.py, statefbk.py)
  • Array handling: .copy() then .asfortranarray() consistently applied
  • Module structure: header, docstring, imports, helpers, then functions
  • Custom exception classes (SlicotResultWarning, SlicotArithmeticError)

⚠️ Minor inconsistencies:

  1. Missing __all__: Other modules define exports (e.g., mateqn.py line 49, statefbk.py line 34), but slicot_compat.py doesn't
  2. Sparse docstrings: Functions like sb03md have minimal docs compared to rich docstrings in mateqn.py's lyap() (lines 56-98) with Parameters, Returns, and extended descriptions
  3. Unused ldwork parameters: Present in all wrappers but never used (legacy API compatibility)
  4. ValueError vs ControlArgument: Line 52 uses generic ValueError instead of ControlArgument from exception.py (line 34)

The core functionality and structure are solid—these are documentation/polish items rather than functional issues.

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