Skip to content

Commit

Permalink
Make source ruff check-clean
Browse files Browse the repository at this point in the history
Removed unused imports.

Removed unused variables in test: these were cut-and-paste from other
tests, and not needed for the tests in questions.

Other minor fixes.
  • Loading branch information
roryyorke committed Jan 19, 2025
1 parent f305cc5 commit 8978584
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 45 deletions.
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
4 changes: 2 additions & 2 deletions 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 All @@ -1838,7 +1838,7 @@ def ab13md(Z, nblock, itype, x=None):
return bound, d, g, x[:m+mr-1]


def ag08bd(l,n,m,p,A,E,B,C,D,equil='N',tol=0.0,ldwork=None):
def ag08bd(l,n,m,p,A,E,B,C,D,equil='N',tol=0.0,ldwork=None): # noqa: E741
""" Af,Ef,nrank,niz,infz,kronr,infe,kronl = ag08bd(l,n,m,p,A,E,B,C,D,[equil,tol,ldwork])
To extract from the system pencil
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
4 changes: 2 additions & 2 deletions slycot/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _parse_docsection(section_name, docstring, checkvars):
continue
section_indent = next(docline).index("-")

for l in docline:
for l in docline: # noqa: E741
# ignore blank lines
if not l.strip():
continue
Expand Down Expand Up @@ -121,7 +121,7 @@ def _parse_docsection(section_name, docstring, checkvars):
break # docstring
body_indent = len(mmatch.group(1))
message += mmatch.group(2) + '\n'
for l in docline:
for l in docline: # noqa: E741
if l and not l[:body_indent].isspace():
break # message body
message += l[body_indent:] + '\n'
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
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -76,7 +76,7 @@ def test1_tg01fd():
def test2_tg01fd():
""" verify that Q and Z output with compq and compz set to 'U' equals the dot product of Q and Z input and Q and Z output with compq and compz set to 'I' """

l = 30
l = 30 # noqa: E741
n = 30
m = 70
p = 44
Expand Down
4 changes: 2 additions & 2 deletions slycot/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ def tf01rd(n,m,p,N,A,B,C,ldwork=None):
raise_if_slycot_error(out[-1], arg_list)
return out[0]

def tg01ad(l,n,m,p,A,E,B,C,thresh=0.0,job='A'):
def tg01ad(l,n,m,p,A,E,B,C,thresh=0.0,job='A'): # noqa: E741
""" A,E,B,C,lscale,rscale = tg01ad(l,n,m,p,A,E,B,C,[thresh,job])
To balance the matrices of the system pencil
Expand Down Expand Up @@ -1069,7 +1069,7 @@ def tg01ad(l,n,m,p,A,E,B,C,thresh=0.0,job='A'):
raise_if_slycot_error(info, arg_list)
return A,E,B,C,lscale,rscale

def tg01fd(l,n,m,p,A,E,B,C,Q=None,Z=None,compq='N',compz='N',joba='N',tol=0.0,ldwork=None):
def tg01fd(l,n,m,p,A,E,B,C,Q=None,Z=None,compq='N',compz='N',joba='N',tol=0.0,ldwork=None): # noqa: E741
""" A,E,B,C,ranke,rnka22,Q,Z = tg01fd(l,n,m,p,A,E,B,C,[Q,Z,compq,compz,joba,tol,ldwork])
To compute for the descriptor system (A-lambda E,B,C)
Expand Down

0 comments on commit 8978584

Please sign in to comment.