diff --git a/control/iosys.py b/control/iosys.py index df75f3b54..49ab29c77 100644 --- a/control/iosys.py +++ b/control/iosys.py @@ -366,8 +366,8 @@ def _rhs(self, t, x, u): you may want to use :meth:`dynamics`. """ - NotImplemented("Evaluation not implemented for system of type ", - type(self)) + raise NotImplementedError("Evaluation not implemented for system of type ", + type(self)) def dynamics(self, t, x, u, params=None): """Compute the dynamics of a differential or difference equation. diff --git a/control/modelsimp.py b/control/modelsimp.py index 432b76b96..b1c1ae31c 100644 --- a/control/modelsimp.py +++ b/control/modelsimp.py @@ -476,7 +476,7 @@ def markov(Y, U, m=None, transpose=False): # Make sure there is enough data to compute parameters if m > n: - warn.warning("Not enough data for requested number of parameters") + warnings.warn("Not enough data for requested number of parameters") # # Original algorithm (with mapping to standard order) diff --git a/control/optimal.py b/control/optimal.py index 4913cc341..de45a8dd0 100644 --- a/control/optimal.py +++ b/control/optimal.py @@ -20,8 +20,6 @@ from .exception import ControlNotImplemented from .timeresp import TimeResponseData -__all__ = ['find_optimal_input'] - # Define module default parameter values _optimal_defaults = { 'optimal.minimize_method': None, diff --git a/control/statesp.py b/control/statesp.py index a2fa3dd73..af549cff6 100644 --- a/control/statesp.py +++ b/control/statesp.py @@ -59,6 +59,8 @@ from scipy.signal import cont2discrete from scipy.signal import StateSpace as signalStateSpace from warnings import warn + +from .exception import ControlSlycot from .frdata import FrequencyResponseData from .lti import LTI, _process_frequency_response from .namedio import common_timebase, isdtime diff --git a/control/tests/optimal_test.py b/control/tests/optimal_test.py index b100e7e14..cdea19bfa 100644 --- a/control/tests/optimal_test.py +++ b/control/tests/optimal_test.py @@ -381,17 +381,8 @@ def test_optimal_logging(capsys): @pytest.mark.parametrize("fun, args, exception, match", [ [opt.quadratic_cost, (np.zeros((2, 3)), np.eye(2)), ValueError, "Q matrix is the wrong shape"], - [opt.quadratic_cost, (np.eye(2), 1), ValueError, + [opt.quadratic_cost, (np.eye(2), np.eye(2, 3)), ValueError, "R matrix is the wrong shape"], -]) -def test_constraint_constructor_errors(fun, args, exception, match): - """Test various error conditions for constraint constructors""" - sys = ct.ss2io(ct.rss(2, 2, 2)) - with pytest.raises(exception, match=match): - fun(sys, *args) - - -@pytest.mark.parametrize("fun, args, exception, match", [ [opt.input_poly_constraint, (np.zeros((2, 3)), [0, 0]), ValueError, "polytope matrix must match number of inputs"], [opt.output_poly_constraint, (np.zeros((2, 3)), [0, 0]), ValueError,