8000 Merge pull request #246 from roryyorke/ruff-clean · python-control/Slycot@bbfe718 · GitHub
[go: up one dir, main page]

Skip to content

Commit bbfe718

Browse files
authored
Merge pull request #246 from roryyorke/ruff-clean
Fix or silence `ruff check` warnings; add `ruff check` to Github Actions
2 parents a2ee35a + f1cb889 commit bbfe718

File tree

12 files changed

+40
-39
lines changed

12 files changed

+40
-39
lines changed

.github/workflows/slycot-build-and-test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@ on:
1212

1313
jobs:
1414

15+
ruff-lint:
16+
name: Static lint checks with ruff
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout Slycot
20+
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
submodules: 'recursive'
24+
- name: Set up Python
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: '3.11'
28+
- name: Run ruff check
29+
run: |
30+
pip install ruff
31+
ruff check slycot
32+
1533
build-sdist:
1634
# Super fast sniff build. If this fails, don't start the other jobs
1735
name: Build sdist on Ubuntu

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ write_to = "slycot/version.py"
5151
[tool.pytest.ini_options]
5252
# run the tests with compiled and installed package
5353
addopts = "--pyargs slycot"
54+
55+
[tool.ruff.lint]
56+
ignore = [ "E741" ]

slycot/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@
7979

8080
from .version import __version__
8181

82+
__all__ = [
83+
ab01nd, ab04md, ab05md, ab05nd, ab07nd, ab08nd, ab08nz,
84+
ab09ad, ab09ax, ab09bd, ab09md, ab09nd, ab13bd, ab13dd,
85+
ab13ed, ab13fd, ab13md, ag08bd, mb02ed, mb03rd, mb03vd,
86+
mb03vy, mb03wd, mb05md, mb05nd, mc01td, sb01bd, sb02md,
87+
sb02mt, sb02od, sb03md, sb03md57, sb03od, sb04md, sb04qd,
88+
sb10ad, sb10dd, sb10fd, sb10hd, sb10jd, sb10yd, sg02ad,
89+
sg03ad, sg03bd, tb01id, tb01pd, tb03ad, tb04ad, tb05ad,
90+
tc01od, tc04ad, td04ad, tf01md, tf01rd, tg01ad, tg01fd,
91+
__version__
92+
]
8293

8394
def test():
8495
import pytest

slycot/analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ def ab13md(Z, nblock, itype, x=None):
18271827
else:
18281828
fact='F'
18291829
if len(x) != m+mr-1:
1830-
raise ValueError(f'Require len(x)==m+mr-1, but'
1830+
raise ValueError('Require len(x)==m+mr-1, but'
18311831
+ f' len(x)={len(x)}, m={m}, mr={mr}')
18321832
x = np.concatenate([x,np.zeros(2*m-1-len(x))])
18331833

slycot/examples.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def sb02md_example():
3333
print('rcond =', out[1])
3434

3535
def sb03md_example():
36-
from numpy import zeros
3736
A = array([ [3, 1, 1],
3837
[1, 3, 0],
3938
[0, 0, 3]])
@@ -47,7 +46,7 @@ def sb03md_example():
4746
print('scaling factor:', out[3])
4847

4948
def ab08nd_example():
50-
from numpy import zeros, size
49+
from numpy import zeros
5150
from scipy.linalg import eigvals
5251
A = array([ [1, 0, 0, 0, 0, 0],
5352
[0, 1, 0, 0, 0, 0],
@@ -153,7 +152,7 @@ def mc01td_example():
153152
print('The polynomial has', out[2], 'unstable zeros')
154153

155154
def sb02od_example():
156-
from numpy import zeros, shape, dot, ones
155+
from numpy import dot, ones
157156
A = array([ [0, 1],
158157
[0, 0]])
159158
B = array([ [0],

slycot/tests/test_ab13bd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# ab08n* tests
33

44
import numpy as np
5-
from numpy.testing import assert_allclose, assert_array_equal, assert_equal
5+
from numpy.testing import assert_allclose, assert_array_equal
66
from scipy import linalg, signal
77

88
from slycot import analysis

slycot/tests/test_ab13md.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22
import pytest
3-
from numpy.testing import assert_allclose, assert_array_less
3+
from numpy.testing import assert_allclose
44

55
from slycot import ab13md
66

slycot/tests/test_mb.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# test_mb.py - test suite for linear algebra commands
33
# bnavigator <code@bnavigator.de>, Aug 2019
44

5-
import sys
6-
75
import numpy as np
86
import pytest
97
from numpy.testing import assert_allclose
@@ -96,19 +94,6 @@ def test_mb02ed_parameter_errors():
9694
[1.0000, 2.0000],
9795
]
9896
)
99-
X = np.array(
100-
[
101-
[0.2408, 0.4816],
102-
[0.1558, 0.3116],
103-
[0.1534, 0.3068],
104-
[0.2302, 0.4603],
105-
[0.1467, 0.2934],
106-
[0.1537, 0.3075],
107-
[0.2349, 0.4698],
108-
[0.1498, 0.2995],
109-
[0.1653, 0.3307],
110-
]
111-
)
11297

11398
# Test for wrong parameter typet
11499
with pytest.raises(expected_exception=SlycotParameterError, match='typet must be either "R" or "C"') as cm:
@@ -162,19 +147,6 @@ def test_mb02ed_matrix_error():
162147
[1.0000, 2.0000],
163148
]
164149
)
165-
X = np.array(
166-
[
167-
[0.2408, 0.4816],
168-
[0.1558, 0.3116],
169-
[0.1534, 0.3068],
170-
[0.2302, 0.4603],
171-
[0.1467, 0.2934],
172-
[0.1537, 0.3075],
173-
[0.2349, 0.4698],
174-
[0.1498, 0.2995],
175-
[0.1653, 0.3307],
176-
]
177-
)
178150

179151
with pytest.raises(SlycotArithmeticError,
180152
match = "The reduction algorithm failed. "

slycot/tests/test_sb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from slycot import synthesis
99
from slycot.exceptions import (SlycotArithmeticError, SlycotParameterError,
10-
SlycotResultWarning, raise_if_slycot_error)
10+
SlycotResultWarning)
1111

1212
from .test_exceptions import assert_docstring_parse
1313

slycot/tests/test_tb05ad.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# ===================================================
22
# tb05ad tests
33

4-
import sys
5-
64
import numpy as np
75
import pytest
86
from numpy.testing import assert_almost_equal

slycot/tests/test_tg01ad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# tg01ad tests
33

44
import numpy as np
5-
from numpy.testing import assert_almost_equal, assert_equal, assert_raises
5+
from numpy.testing import assert_almost_equal
66

77
from slycot import transform
88

slycot/tests/test_tg01fd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# tg01fd tests
33

44
import numpy as np
5-
from numpy.testing import assert_almost_equal, assert_equal, assert_raises
5+
from numpy.testing import assert_almost_equal, assert_equal
66

77
from slycot import transform
88

0 commit comments

Comments
 (0)
0