Skip to content

Commit

Permalink
Merge pull request #246 from roryyorke/ruff-clean
Browse files Browse the repository at this point in the history
Fix or silence `ruff check` warnings; add `ruff check` to Github Actions
  • Loading branch information
bnavigator authored Feb 1, 2025
2 parents a2ee35a + f1cb889 commit bbfe718
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 39 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/slycot-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
11 changes: 11 additions & 0 deletions slycot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion slycot/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))])

Expand Down
5 changes: 2 additions & 3 deletions slycot/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]])
Expand All @@ -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],
Expand Down Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion slycot/tests/test_ab13bd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion slycot/tests/test_ab13md.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
28 changes: 0 additions & 28 deletions slycot/tests/test_mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# test_mb.py - test suite for linear algebra commands
# bnavigator <[email protected]>, Aug 2019

import sys

import numpy as np
import pytest
from numpy.testing import assert_allclose
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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. "
Expand Down
2 changes: 1 addition & 1 deletion slycot/tests/test_sb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions slycot/tests/test_tb05ad.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# ===================================================
# tb05ad tests

import sys

import numpy as np
import pytest
from numpy.testing import assert_almost_equal
Expand Down
2 changes: 1 addition & 1 deletion slycot/tests/test_tg01ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion slycot/tests/test_tg01fd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit bbfe718

Please sign in to comment.