diff --git a/.github/workflows/slycot-build-and-test.yml b/.github/workflows/slycot-build-and-test.yml index 1c542d12..4050bad9 100644 --- a/.github/workflows/slycot-build-and-test.yml +++ b/.github/workflows/slycot-build-and-test.yml @@ -12,6 +12,24 @@ on: jobs: + ruff-lint: + name: Static lint checks with ruff + runs-on: ubuntu-latest + steps: + - name: Checkout Slycot + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: 'recursive' + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Run ruff check + run: | + pip install ruff + ruff check slycot + build-sdist: # Super fast sniff build. If this fails, don't start the other jobs name: Build sdist on Ubuntu diff --git a/pyproject.toml b/pyproject.toml index c984562f..dea6895f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,3 +51,6 @@ write_to = "slycot/version.py" [tool.pytest.ini_options] # run the tests with compiled and installed package addopts = "--pyargs slycot" + +[tool.ruff.lint] +ignore = [ "E741" ] diff --git a/slycot/__init__.py b/slycot/__init__.py index c1243ea5..6cb415d0 100644 --- a/slycot/__init__.py +++ b/slycot/__init__.py @@ -79,6 +79,17 @@ from .version import __version__ + __all__ = [ + ab01nd, ab04md, ab05md, ab05nd, ab07nd, ab08nd, ab08nz, + ab09ad, ab09ax, ab09bd, ab09md, ab09nd, ab13bd, ab13dd, + ab13ed, ab13fd, ab13md, ag08bd, mb02ed, mb03rd, mb03vd, + mb03vy, mb03wd, mb05md, mb05nd, mc01td, sb01bd, sb02md, + sb02mt, sb02od, sb03md, sb03md57, sb03od, sb04md, sb04qd, + sb10ad, sb10dd, sb10fd, sb10hd, sb10jd, sb10yd, sg02ad, + sg03ad, sg03bd, tb01id, tb01pd, tb03ad, tb04ad, tb05ad, + tc01od, tc04ad, td04ad, tf01md, tf01rd, tg01ad, tg01fd, + __version__ + ] def test(): import pytest diff --git a/slycot/analysis.py b/slycot/analysis.py index 230eedb9..4d5383c4 100644 --- a/slycot/analysis.py +++ b/slycot/analysis.py @@ -1827,7 +1827,7 @@ def ab13md(Z, nblock, itype, x=None): else: fact='F' if len(x) != m+mr-1: - raise ValueError(f'Require len(x)==m+mr-1, but' + raise ValueError('Require len(x)==m+mr-1, but' + f' len(x)={len(x)}, m={m}, mr={mr}') x = np.concatenate([x,np.zeros(2*m-1-len(x))]) diff --git a/slycot/examples.py b/slycot/examples.py index cf306913..9e41a256 100644 --- a/slycot/examples.py +++ b/slycot/examples.py @@ -33,7 +33,6 @@ def sb02md_example(): print('rcond =', out[1]) def sb03md_example(): - from numpy import zeros A = array([ [3, 1, 1], [1, 3, 0], [0, 0, 3]]) @@ -47,7 +46,7 @@ def sb03md_example(): print('scaling factor:', out[3]) def ab08nd_example(): - from numpy import zeros, size + from numpy import zeros from scipy.linalg import eigvals A = array([ [1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], @@ -153,7 +152,7 @@ def mc01td_example(): print('The polynomial has', out[2], 'unstable zeros') def sb02od_example(): - from numpy import zeros, shape, dot, ones + from numpy import dot, ones A = array([ [0, 1], [0, 0]]) B = array([ [0], diff --git a/slycot/tests/test_ab13bd.py b/slycot/tests/test_ab13bd.py index dd2a735a..ed4f6b92 100644 --- a/slycot/tests/test_ab13bd.py +++ b/slycot/tests/test_ab13bd.py @@ -2,7 +2,7 @@ # ab08n* tests import numpy as np -from numpy.testing import assert_allclose, assert_array_equal, assert_equal +from numpy.testing import assert_allclose, assert_array_equal from scipy import linalg, signal from slycot import analysis diff --git a/slycot/tests/test_ab13md.py b/slycot/tests/test_ab13md.py index 5a30f5ba..ac933e1f 100644 --- a/slycot/tests/test_ab13md.py +++ b/slycot/tests/test_ab13md.py @@ -1,6 +1,6 @@ import numpy as np import pytest -from numpy.testing import assert_allclose, assert_array_less +from numpy.testing import assert_allclose from slycot import ab13md diff --git a/slycot/tests/test_mb.py b/slycot/tests/test_mb.py index 5dc5dcd5..745d382a 100644 --- a/slycot/tests/test_mb.py +++ b/slycot/tests/test_mb.py @@ -2,8 +2,6 @@ # test_mb.py - test suite for linear algebra commands # bnavigator <code@bnavigator.de>, Aug 2019 -import sys - import numpy as np import pytest from numpy.testing import assert_allclose @@ -96,19 +94,6 @@ def test_mb02ed_parameter_errors(): [1.0000, 2.0000], ] ) - X = np.array( - [ - [0.2408, 0.4816], - [0.1558, 0.3116], - [0.1534, 0.3068], - [0.2302, 0.4603], - [0.1467, 0.2934], - [0.1537, 0.3075], - [0.2349, 0.4698], - [0.1498, 0.2995], - [0.1653, 0.3307], - ] - ) # Test for wrong parameter typet 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(): [1.0000, 2.0000], ] ) - X = np.array( - [ - [0.2408, 0.4816], - [0.1558, 0.3116], - [0.1534, 0.3068], - [0.2302, 0.4603], - [0.1467, 0.2934], - [0.1537, 0.3075], - [0.2349, 0.4698], - [0.1498, 0.2995], - [0.1653, 0.3307], - ] - ) with pytest.raises(SlycotArithmeticError, match = "The reduction algorithm failed. " diff --git a/slycot/tests/test_sb.py b/slycot/tests/test_sb.py index e6f97a07..ceccad3b 100644 --- a/slycot/tests/test_sb.py +++ b/slycot/tests/test_sb.py @@ -7,7 +7,7 @@ from slycot import synthesis from slycot.exceptions import (SlycotArithmeticError, SlycotParameterError, - SlycotResultWarning, raise_if_slycot_error) + SlycotResultWarning) from .test_exceptions import assert_docstring_parse diff --git a/slycot/tests/test_tb05ad.py b/slycot/tests/test_tb05ad.py index 900a49a2..e940c45f 100644 --- a/slycot/tests/test_tb05ad.py +++ b/slycot/tests/test_tb05ad.py @@ -1,8 +1,6 @@ # =================================================== # tb05ad tests -import sys - import numpy as np import pytest from numpy.testing import assert_almost_equal diff --git a/slycot/tests/test_tg01ad.py b/slycot/tests/test_tg01ad.py index 864d41be..885f4c1c 100644 --- a/slycot/tests/test_tg01ad.py +++ b/slycot/tests/test_tg01ad.py @@ -2,7 +2,7 @@ # tg01ad tests import numpy as np -from numpy.testing import assert_almost_equal, assert_equal, assert_raises +from numpy.testing import assert_almost_equal from slycot import transform diff --git a/slycot/tests/test_tg01fd.py b/slycot/tests/test_tg01fd.py index 902d1ef2..27bc9cb4 100644 --- a/slycot/tests/test_tg01fd.py +++ b/slycot/tests/test_tg01fd.py @@ -2,7 +2,7 @@ # tg01fd tests import numpy as np -from numpy.testing import assert_almost_equal, assert_equal, assert_raises +from numpy.testing import assert_almost_equal, assert_equal from slycot import transform