Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
73e969a
add exception classes
bnavigator May 3, 2020
e07206a
migrate analysis to new exceptions
bnavigator May 3, 2020
1f356f2
migrate math to new exceptions
bnavigator May 3, 2020
a8edfb4
migrate synthesis to the new exceptions
bnavigator May 3, 2020
de6e3df
migrate transform to new exceptions
bnavigator May 4, 2020
37e45d1
unify exception call signature
bnavigator May 4, 2020
2f44753
exception messages extracted from docstrings
repagh May 5, 2020
89429ad
count exception messages in synthesis
repagh May 5, 2020
0fd2ea5
Only on indexError should we report unhandled code
repagh May 5, 2020
d1b9ab1
simplify negative info parameter checks
bnavigator May 5, 2020
dbf643b
actually test error message/info matching. Did reveal some fixes to
repagh May 5, 2020
42cfb49
only check docstring if provided
bnavigator May 5, 2020
b9bfaae
correct sb01bd copy and paste error
repagh May 5, 2020
8b5b8f9
rework exception docstring parser
bnavigator May 5, 2020
ed027fb
fix python 2 compatibility in regexp
bnavigator May 6, 2020
1877bc3
adding a more extensive check of docstring parsing
repagh May 6, 2020
d2f684d
extend the parser to warnings
bnavigator May 6, 2020
0e8d63c
update exceptions doc and test [skip ci]
bnavigator May 6, 2020
7ad1517
more work on exception and warning handling
bnavigator May 7, 2020
18f054e
more cleanup, including file attributes for source files
bnavigator May 7, 2020
a44c952
dont assertRaisesRegex in Py2
bnavigator May 7, 2020
d81c7d1
optional type
bnavigator May 7, 2020
ad24193
typo in range [skip ci]
bnavigator May 7, 2020
ec8c968
only parse docstring when iwarn or info
bnavigator May 7, 2020
c0b1069
bring synthesis.py closer to numpydoc
bnavigator May 7, 2020
ad28baa
minor cosmetics in math.py and synthesis.py docstrings [skip ci]
bnavigator May 7, 2020
82b653a
fix infospec detection regex
bnavigator May 7, 2020
8f60923
fix iwarn catchall and checkvars initialization
bnavigator May 7, 2020
91fb7e6
revert file mode changes for py files [skip ci]
bnavigator May 7, 2020
fd74855
comma in mb05nd docstring [skip ci]
bnavigator May 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
only parse docstring when iwarn or info
catch all unhandled warnings
clean imports
  • Loading branch information
bnavigator committed May 7, 2020
commit ec8c96847539271e5dbe51222e748eb062e884bf
4 changes: 1 addition & 3 deletions slycot/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
# MA 02110-1301, USA.

from . import _wrapper
from .exceptions import raise_if_slycot_error, \
SlycotParameterError, SlycotArithmeticError
from .exceptions import raise_if_slycot_error, SlycotParameterError

import warnings

def ab01nd(n,m,A,B,jobz='N',tol=0,ldwork=None):
""" Ac,Bc,ncont,indcon,nblk,Z,tau = ab01nd_i(n,m,A,B,[jobz,tol,ldwork])
Expand Down
15 changes: 10 additions & 5 deletions slycot/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,12 @@ def raise_if_slycot_error(info, arg_list=None, docstring=None, checkvars={}):
iwarn, info = info
except TypeError:
iwarn = None
if docstring:
# possibly override with mandatory argument
if docstring and (iwarn or info):
# possibly override info with mandatory argument
checkvars['info'] = info
if iwarn is not None: # do not possibly override if not provided
# do not possibly override iwarn if not provided
if iwarn is not None:
checkvars['iwarn'] = iwarn
else:
iwarn = 0

exception, message = _parse_docsection("Raises", docstring, checkvars)
if exception and message:
Expand All @@ -250,3 +249,9 @@ def raise_if_slycot_error(info, arg_list=None, docstring=None, checkvars={}):
raise SlycotError("Caught unhandled nonzero INFO value {}"
.format(info),
info)
if not iwarn and 'iwarn' in checkvars:
iwarn = checkvars['iwarn']
if iwarn:
warn(SlycotWarning("Caught unhandled nonzero IWARN value {}"
.format(iwarn),
iwarn, info))
4 changes: 1 addition & 3 deletions slycot/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
# MA 02110-1301, USA.

from . import _wrapper
from .exceptions import raise_if_slycot_error, SlycotArithmeticError

import warnings
from .exceptions import raise_if_slycot_error

import numpy as np

Expand Down
5 changes: 2 additions & 3 deletions slycot/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@


from . import _wrapper
from .exceptions import raise_if_slycot_error, \
SlycotParameterError, SlycotArithmeticError
from .exceptions import raise_if_slycot_error, SlycotParameterError

import numpy as _np
import warnings


def sb01bd(n,m,np,alpha,A,B,w,dico,tol=0.0,ldwork=None):
""" A_z,w,nfp,nap,nup,F,Z = sb01bd(n,m,np,alpha,A,B,w,dico,[tol,ldwork])
Expand Down
11 changes: 10 additions & 1 deletion slycot/tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def assert_docstring_parse(docstring, exception_class, erange, checkvars={}):
try:
iwarn, info = e
except TypeError:
iwarn = 0
iwarn = None
info = e
if issubclass(exception_class, SlycotError):
with pytest.raises(exception_class) as ex_info:
Expand All @@ -78,3 +78,12 @@ def test_unhandled_info():
with pytest.raises(SlycotError) as ex_info:
raise_if_slycot_error(2, [], docstring="no valid docstring")
assert ex_info.value.info == 2
with pytest.warns(SlycotWarning) as wm:
raise_if_slycot_error([1, 0], [], docstring="no valid docstring")
assert wm[0].message.iwarn == 1
assert wm[0].message.info == 0
with pytest.warns(SlycotWarning) as wm:
raise_if_slycot_error(0, [], docstring="no valid docstring",
checkvars={'iwarn': 1})
assert wm[0].message.iwarn == 1
assert wm[0].message.info == 0
3 changes: 1 addition & 2 deletions slycot/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
# MA 02110-1301, USA.

from . import _wrapper
from .exceptions import raise_if_slycot_error, \
SlycotParameterError, SlycotArithmeticError
from .exceptions import raise_if_slycot_error, SlycotParameterError

import numpy as _np

Expand Down