Skip to content

Commit fa0f07d

Browse files
authored
Merge pull request #254 from roryyorke/lint-fixes-small
Minimum lint fixes and suppressions to pass CI
2 parents 4c28f87 + ef11c49 commit fa0f07d

23 files changed

Lines changed: 83 additions & 18 deletions

‎BUILD.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ The test command is the same as when building from the sdist::
6262
Non-isolated, editable build
6363
----------------------------
6464

65-
When doing development one builds over and over; in that case it's faster to do a non-isolated editable build. Run or adapt developer script `inplace-editable-build.bash`_ for that.
65+
When doing development one builds over and over; in that case it's faster to do a non-isolated editable build. Run or adapt developer script `inplace-editable-build.bash`_ for that. CMake variables can be set to configure the build; for example, in the command below, ``BLA_VENDOR`` is set to tell CMake to use the Netlib BLAS/LAPACK libraries. This example is not merely illustrative: on Debian 13 *not* specifying ``BLA_VENDOR`` can cause test failures.
6666

67-
.. _`inplace-editable-build.bash`: ./dev-tools/inplace-editable-build.bash
67+
.. _`inplace-editable-build.bash`: BLA_VENDOR=Generic ./dev-tools/inplace-editable-build.bash
6868

6969

7070
Customizing the build

‎dev-tools/inplace-editable-build.bash‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
# - BLAS and LAPACK libraries
2121
#
2222
# Tested on Debian 13.
23+
#
24+
# Select a BLAS/LAPACK provider with environment variable BLA_VENDOR; see
25+
# https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors
2326

2427
set -euo pipefail
2528

@@ -28,6 +31,10 @@ if [ ! -f ./dev-tools/inplace-editable-build.bash ]; then
2831
exit 1;
2932
fi
3033

34+
if [ ! -v BLA_VENDOR ]; then
35+
echo "BLA_VENDOR is not set. This is known to sometimes cause test failures";
36+
fi
37+
3138
echo "--Build"
3239
python -m venv venv-build
3340
source venv-build/bin/activate

‎pyproject.toml‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["scikit-build-core", "numpy"]
2+
requires = ["scikit-build-core>=1.0", "numpy"]
33
build-backend = "scikit_build_core.build"
44

55
[project]
@@ -43,16 +43,21 @@ test = ["pytest", "scipy"]
4343
[project.urls]
4444
homepage = "https://github.com/python-control/Slycot"
4545

46+
[[tool.dynamic-metadata]]
47+
field = "version"
48+
provider = "scikit_build_core.metadata.setuptools_scm"
49+
4650
[tool.scikit-build]
47-
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
4851
wheel.exclude = ["slycot/src/", "slycot/CMakeLists.txt", "slycot/slicot-source.cmake", "slycot/scipy-openblas-symbols"]
4952

5053
[tool.pytest.ini_options]
5154
# run the tests with compiled and installed package
5255
addopts = "--pyargs slycot"
5356

5457
[tool.ruff.lint]
55-
ignore = [ "E741" ]
58+
ignore = [
59+
"I001", # import order & formatting
60+
]
5661

5762
[tool.cibuildwheel]
5863
# scipy-openblas32 version specified here

‎slycot/__init__.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@
7272

7373

7474
__all__ = [
75-
ab01nd, ab04md, ab05md, ab05nd, ab07nd, ab08nd, ab08nz,
76-
ab09ad, ab09ax, ab09bd, ab09md, ab09nd, ab13bd, ab13dd,
77-
ab13ed, ab13fd, ab13md, ag08bd, mb02ed, mb03rd, mb03vd,
78-
mb03vy, mb03wd, mb05md, mb05nd, mc01td, sb01bd, sb02md,
79-
sb02mt, sb02od, sb03md, sb03md57, sb03od, sb04md, sb04qd,
80-
sb10ad, sb10dd, sb10fd, sb10hd, sb10jd, sb10yd, sg02ad,
81-
sg03ad, sg03bd, tb01id, tb01pd, tb03ad, tb04ad, tb05ad,
82-
tc01od, tc04ad, td04ad, tf01md, tf01rd, tg01ad, tg01fd,
83-
__version__
75+
'__version__',
76+
'ab01nd', 'ab04md', 'ab05md', 'ab05nd', 'ab07nd', 'ab08nd', 'ab08nz',
77+
'ab09ad', 'ab09ax', 'ab09bd', 'ab09md', 'ab09nd', 'ab13bd', 'ab13dd',
78+
'ab13ed', 'ab13fd', 'ab13md', 'ag08bd', 'mb02ed', 'mb03rd', 'mb03vd',
79+
'mb03vy', 'mb03wd', 'mb05md', 'mb05nd', 'mc01td', 'sb01bd', 'sb02md',
80+
'sb02mt', 'sb02od', 'sb03md', 'sb03md57', 'sb03od', 'sb04md', 'sb04qd',
81+
'sb10ad', 'sb10dd', 'sb10fd', 'sb10hd', 'sb10jd', 'sb10yd', 'sg02ad',
82+
'sg03ad', 'sg03bd', 'tb01id', 'tb01pd', 'tb03ad', 'tb04ad', 'tb05ad',
83+
'tc01od', 'tc04ad', 'td04ad', 'tf01md', 'tf01rd', 'tg01ad', 'tg01fd',
8484
]
8585

8686
def test():

‎slycot/examples.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,13 @@ def tb03ad_example():
190190
print('is the following:' )
191191
print('index', out[4])
192192
k_max = max(out[4]) + 1
193+
# ruff: disable[PIE808]
193194
for k in range(0,k_max):
195+
# ruff: disable[UP031]
194196
print('P_%d =' %(k))
195197
print(out[5][0:m,0:m,k])
196198
for k in range(0,k_max):
199+
# ruff: disable[UP031]
197200
print('Q_%d =' %(k))
198201
print(out[6][0:m,0:p,k])
199202

@@ -254,13 +257,15 @@ def tb05ad_example():
254257
p = np.shape(C)[0]
255258

256259
jw_s = [1j*11, 1j*15]
260+
# ruff: disable[RUF059]
257261
at, bt, ct, g_1, hinvb,info = slycot.tb05ad(n, m, p, jw_s[0],
258262
A, B, C, job='NG')
259263
g_2, hinv2, info = slycot.tb05ad(n, m, p, jw_s[1], at, bt, ct, job='NH')
260264
print('--- Example for tb05ad...')
261265
print('Frequency response for (A, B, C)')
262266
print('-------------------------')
263267
print('Frequency | Response')
268+
# ruff: disable[UP031]
264269
print('%s | %s '%(jw_s[0], g_1[0, 0]))
265270
print('%s | %s '%(jw_s[1], g_2[0, 0]))
266271

‎slycot/exceptions.py‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class SlycotError(RuntimeError):
2727
"""Slycot exception base class"""
2828

2929
def __init__(self, message, info):
30+
# ruff: disable[UP008]
3031
super(SlycotError, self).__init__(message)
3132
self.info = info
3233

@@ -37,20 +38,21 @@ class SlycotParameterError(SlycotError, ValueError):
3738
In case of a wrong input value, the SLICOT routines return a negative
3839
info parameter indicating which parameter was illegal.
3940
"""
40-
41+
# ruff: disable[PIE790]
4142
pass
4243

4344

4445
class SlycotArithmeticError(SlycotError, ArithmeticError):
4546
"""A Slycot computation failed"""
46-
47+
# ruff: disable[PIE790]
4748
pass
4849

4950

5051
class SlycotWarning(UserWarning):
5152
"""Slycot Warning"""
5253

5354
def __init__(self, message, iwarn, info):
55+
# ruff: disable[UP008]
5456
super(SlycotWarning, self).__init__(message)
5557
self.info = info
5658
self.iwarn = iwarn
@@ -62,7 +64,7 @@ class SlycotResultWarning(SlycotWarning):
6264
A Slycot routine returned a nonzero info parameter that warns about the
6365
returned results, but the results might still be usable.
6466
"""
65-
67+
# ruff: disable[PIE790]
6668
pass
6769

6870

@@ -101,7 +103,9 @@ def _parse_docsection(section_name, docstring, checkvars):
101103
infospec_indent = len(imatch.group(1))
102104
infospec = imatch.group(2)
103105
# Don't handle the standard case unless we have i
106+
# ruff: disable[SIM102]
104107
if infospec == "info = -i":
108+
# ruff: disable[SIM118]
105109
if 'i' not in checkvars.keys():
106110
continue
107111
infospec_ = infospec.replace(" = ", " == ")
@@ -242,18 +246,21 @@ def raise_if_slycot_error(info, arg_list=None, docstring=None, checkvars=None):
242246
return
243247

244248
if info < 0 and arg_list:
249+
# ruff: disable[UP032]
245250
message = ("The following argument had an illegal value: {}"
246251
"".format(arg_list[-info-1]))
247252
raise SlycotParameterError(message, info)
248253

249254
# catch all
250255
if info > 0:
256+
# ruff: disable[UP032]
251257
raise SlycotError("Caught unhandled nonzero INFO value {}"
252258
"".format(info),
253259
info)
254260
if iwarn is None and 'iwarn' in checkvars:
255261
iwarn = checkvars['iwarn']
256262
if iwarn:
263+
# ruff: disable[UP032]
257264
warn(SlycotWarning("Caught unhandled nonzero IWARN value {}"
258265
"".format(iwarn),
259266
iwarn, info))

‎slycot/scipy-openblas-symbols/generate_def.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def main():
9595
)
9696

9797
with open("scipy-openblas-symbols.def", "wt") as outfile:
98+
# ruff: disable[FURB122]
9899
for symbol in blas + lapack + own_symbols + lapack_exclusions:
99100
outfile.write(f"-D{symbol.upper()}=SCIPY_{symbol.upper()}\n")
100101

‎slycot/synthesis.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ def sb04qd(n,m,A,B,C,ldwork=None):
10871087
for the ({info}-{m})-th column of matrix X.
10881088
"""
10891089
hidden = ' (hidden by the wrapper)'
1090+
# ruff: disable[PLW0127, PLW0128]
10901091
arg_list = arg_list = ['n', 'm', 'A', 'LDA' + hidden, 'B', 'LDB' + hidden,
10911092
'C', 'LDC' + hidden, 'Z', 'LDZ' + hidden,
10921093
'IWORK' + hidden, 'DWORK' + hidden, 'ldwork', 'INFO' + hidden]
@@ -2378,6 +2379,7 @@ def sg02ad(dico,jobb,fact,uplo,jobl,scal,sort,acc,N,M,P,A,E,B,Q,R,L,ldwork=None,
23782379
elif (jobb == 'B'):
23792380
if (fact == 'N'):
23802381
out = _wrapper.sg02ad_bn(dico,uplo,jobl,scal,sort,acc,N,M,A,E,B,Q,R,L,tol,ldwork)
2382+
#ruff: disable[SIM114]
23812383
elif (fact == 'C'):
23822384
out = _wrapper.sg02ad_bc(dico,jobl,scal,sort,acc,N,M,P,A,E,B,Q,R,L,tol,ldwork)
23832385
elif (fact == 'D'):

‎slycot/tests/test_ab08n.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def ab08nX(self, ab08fun, A, B, C, D):
5353
assert_allclose(Af[:nu, :nu], np.array([[-4.]]))
5454
# Compute the structural invariants of the given system.
5555
out = ab08fun(n, m, p, A, B, C, D)
56+
# ruff: disable[RUF059]
5657
nu, rank, dinfz, nkror, nkrol, infz, kronr, kronl, Af, Bf = out[:10]
5758
assert_equal(nu, 2)
5859
# Compute the invariant zeros of the given system.

‎slycot/tests/test_ab09nd.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_slicot_ref():
3838

3939
d = np.zeros((3,2))
4040

41+
# ruff: disable[RUF059]
4142
nr, ar, br, cr, dr, ns, hsv = \
4243
ab09nd(dico, job, equil, n, m, p, a, b, c, d, alpha, nr, tol1, tol2)
4344

@@ -85,6 +86,7 @@ def test_gh242_regression():
8586
c = np.zeros((p, n))
8687
d = np.array([[42.24]])
8788

89+
# ruff: disable[RUF059]
8890
nr, ar, br, cr, dr, ns, hsv = \
8991
ab09nd(dico='C', job='B', equil='S', n=a.shape[0],
9092
m=b.shape[1], p=c.shape[0], A=a, B=b, C=c, D=d)

0 commit comments

Comments
 (0)