GeezerVison is showing github.com — Merge branch 'master' into pr-593 · python-control/python-control@649c394
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: control/tests/convert_test.py +7-9Lines changed: 7 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -184,9 +184,7 @@ def testTf2ssStaticSiso(self): | 184 | 184 | assert 0 == gsiso.nstates | 185 | 185 | assert 1 == gsiso.ninputs | 186 | 186 | assert 1 == gsiso.noutputs | 187 | | - # in all cases ratios are exactly representable, so assert_array_equal | 188 | | - # is fine | 189 | | - np.testing.assert_array_equal([[0.5]], gsiso.D) | | 187 | + np.testing.assert_allclose([[0.5]], gsiso.D) | 190 | 188 |
| 191 | 189 | def testTf2ssStaticMimo(self): | 192 | 190 | """Regression: tf2ss for MIMO static gain""" | @@ -198,13 +196,13 @@ def testTf2ssStaticMimo(self): | 198 | 196 | assert 3 == gmimo.ninputs | 199 | 197 | assert 2 == gmimo.noutputs | 200 | 198 | d = np.array([[0.5, 30, 0.0625], [-0.5, -1.25, 101.3]]) | 201 | | - np.testing.assert_array_equal(d, gmimo.D) | | 199 | + np.testing.assert_allclose(d, gmimo.D) | 202 | 200 |
| 203 | 201 | def testSs2tfStaticSiso(self): | 204 | 202 | """Regression: ss2tf for SISO static gain""" | 205 | 203 | gsiso = ss2tf(ss([], [], [], 0.5)) | 206 | | - np.testing.assert_array_equal([[[0.5]]], gsiso.num) | 207 | | - np.testing.assert_array_equal([[[1.]]], gsiso.den) | | 204 | + np.testing.assert_allclose([[[0.5]]], gsiso.num) | | 205 | + np.testing.assert_allclose([[[1.]]], gsiso.den) | 208 | 206 |
| 209 | 207 | def testSs2tfStaticMimo(self): | 210 | 208 | """Regression: ss2tf for MIMO static gain""" | @@ -217,8 +215,8 @@ def testSs2tfStaticMimo(self): | 217 | 215 |
| 218 | 216 | # we need a 3x2x1 array to compare with gtf.num | 219 | 217 | numref = d[..., np.newaxis] | 220 | | - np.testing.assert_array_equal(numref, | 221 | | - np.array(gtf.num) / np.array(gtf.den)) | | 218 | + np.testing.assert_allclose(numref, | | 219 | + np.array(gtf.num) / np.array(gtf.den)) | 222 | 220 |
| 223 | 221 | @slycotonly | 224 | 222 | def testTf2SsDuplicatePoles(self): | @@ -229,7 +227,7 @@ def testTf2SsDuplicatePoles(self): | 229 | 227 | [[1], [1, 0]]] | 230 | 228 | g = tf(num, den) | 231 | 229 | s = ss(g) | 232 | | - np.testing.assert_array_equal(g.pole(), s.pole()) | | 230 | + np.testing.assert_allclose(g.pole(), s.pole()) | 233 | 231 |
| 234 | 232 | @slycotonly | 235 | 233 | def test_tf2ss_robustness(self): | |
Collapse file Copy file name to clipboardExpand all lines: control/tests/descfcn_test.py +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -53,26 +53,26 @@ def test_static_nonlinear_call(satsys): | 53 | 53 | input = [-2, -1, -0.5, 0, 0.5, 1, 2] | 54 | 54 | desired = [-1, -1, -0.5, 0, 0.5, 1, 1] | 55 | 55 | for x, y in zip(input, desired): | 56 | | - assert satsys(x) == y | | 56 | + np.testing.assert_allclose(satsys(x), y) | 57 | 57 |
| 58 | 58 | # Test squeeze properties | 59 | 59 | assert satsys(0.) == 0. | 60 | 60 | assert satsys([0.], squeeze=True) == 0. | 61 | | - np.testing.assert_array_equal(satsys([0.]), [0.]) | | 61 | + np.testing.assert_allclose(satsys([0.]), [0.]) | 62 | 62 |
| 63 | 63 | # Test SIMO nonlinearity | 64 | 64 | def _simofcn(t, x, u, params): | 65 | 65 | return np.array([np.cos(u), np.sin(u)]) | 66 | 66 | simo_sys = ct.NonlinearIOSystem(None, outfcn=_simofcn, input=1, output=2) | 67 | | - np.testing.assert_array_equal(simo_sys([0.]), [1, 0]) | 68 | | - np.testing.assert_array_equal(simo_sys([0.], squeeze=True), [1, 0]) | | 67 | + np.testing.assert_allclose(simo_sys([0.]), [1, 0]) | | 68 | + np.testing.assert_allclose(simo_sys([0.], squeeze=True), [1, 0]) | 69 | 69 |
| 70 | 70 | # Test MISO nonlinearity | 71 | 71 | def _misofcn(t, x, u, params={}): | 72 | 72 | return np.array([np.sin(u[0]) * np.cos(u[1])]) | 73 | 73 | miso_sys = ct.NonlinearIOSystem(None, outfcn=_misofcn, input=2, output=1) | 74 | | - np.testing.assert_array_equal(miso_sys([0, 0]), [0]) | 75 | | - np.testing.assert_array_equal(miso_sys([0, 0], squeeze=True), [0]) | | 74 | + np.testing.assert_allclose(miso_sys([0, 0]), [0]) | | 75 | + np.testing.assert_allclose(miso_sys([0, 0], squeeze=True), [0]) | 76 | 76 |
| 77 | 77 |
| 78 | 78 | # Test saturation describing function in multiple ways | |
Collapse file Copy file name to clipboardExpand all lines: control/tests/interconnect_test.py +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -36,10 +36,10 @@ def test_summing_junction(inputs, output, dimension, D): | 36 | 36 | sum = ct.summing_junction( | 37 | 37 | inputs=inputs, output=output, dimension=dimension) | 38 | 38 | dim = 1 if dimension is None else dimension | 39 | | - np.testing.assert_array_equal(sum.A, np.ndarray((0, 0))) | 40 | | - np.testing.assert_array_equal(sum.B, np.ndarray((0, ninputs*dim))) | 41 | | - np.testing.assert_array_equal(sum.C, np.ndarray((dim, 0))) | 42 | | - np.testing.assert_array_equal(sum.D, D) | | 39 | + np.testing.assert_allclose(sum.A, np.ndarray((0, 0))) | | 40 | + np.testing.assert_allclose(sum.B, np.ndarray((0, ninputs*dim))) | | 41 | + np.testing.assert_allclose(sum.C, np.ndarray((dim, 0))) | | 42 | + np.testing.assert_allclose(sum.D, D) | 43 | 43 |
| 44 | 44 |
| 45 | 45 | def test_summation_exceptions(): | @@ -96,7 +96,7 @@ def test_interconnect_implicit(): | 96 | 96 | # Setting connections to False should lead to an empty connection map | 97 | 97 | empty = ct.interconnect( | 98 | 98 | (C, P, sumblk), connections=False, inplist=['r'], outlist=['y']) | 99 | | - np.testing.assert_array_equal(empty.connect_map, np.zeros((4, 3))) | | 99 | + np.testing.assert_allclose(empty.connect_map, np.zeros((4, 3))) | 100 | 100 |
| 101 | 101 | # Implicit summation across repeated signals | 102 | 102 | kp_io = ct.tf2io(kp, inputs='e', outputs='u', name='kp') | |
Collapse file Copy file name to clipboardExpand all lines: control/tests/iosys_test.py +28-28Lines changed: 28 additions & 28 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -89,10 +89,10 @@ def test_ss2io(self, tsys): | 89 | 89 | # Create an input/output system from the linear system | 90 | 90 | linsys = tsys.siso_linsys | 91 | 91 | iosys = ct.ss2io(linsys) | 92 | | - np.testing.assert_array_equal(linsys.A, iosys.A) | 93 | | - np.testing.assert_array_equal(linsys.B, iosys.B) | 94 | | - np.testing.assert_array_equal(linsys.C, iosys.C) | 95 | | - np.testing.assert_array_equal(linsys.D, iosys.D) | | 92 | + np.testing.assert_allclose(linsys.A, iosys.A) | | 93 | + np.testing.assert_allclose(linsys.B, iosys.B) | | 94 | + np.testing.assert_allclose(linsys.C, iosys.C) | | 95 | + np.testing.assert_allclose(linsys.D, iosys.D) | 96 | 96 |
| 97 | 97 | # Try adding names to things | 98 | 98 | iosys_named = ct.ss2io(linsys, inputs='u', outputs='y', | @@ -104,10 +104,10 @@ def test_ss2io(self, tsys): | 104 | 104 | assert iosys_named.find_state('x0') is None | 105 | 105 | assert iosys_named.find_state('x1') == 0 | 106 | 106 | assert iosys_named.find_state('x2') == 1 | 107 | | - np.testing.assert_array_equal(linsys.A, iosys_named.A) | 108 | | - np.testing.assert_array_equal(linsys.B, iosys_named.B) | 109 | | - np.testing.assert_array_equal(linsys.C, iosys_named.C) | 110 | | - np.testing.assert_array_equal(linsys.D, iosys_named.D) | | 107 | + np.testing.assert_allclose(linsys.A, iosys_named.A) | | 108 | + np.testing.assert_allclose(linsys.B, iosys_named.B) | | 109 | + np.testing.assert_allclose(linsys.C, iosys_named.C) | | 110 | + np.testing.assert_allclose(linsys.D, iosys_named.D) | 111 | 111 |
| 112 | 112 | def test_iosys_unspecified(self, tsys): | 113 | 113 | """System with unspecified inputs and outputs""" | @@ -1132,14 +1132,14 @@ def test_lineariosys_statespace(self, tsys): | 1132 | 1132 | assert isinstance(iosys_siso, ct.StateSpace) | 1133 | 1133 |
| 1134 | 1134 | # Make sure that state space functions work for LinearIOSystems | 1135 | | - np.testing.assert_array_equal( | | 1135 | + np.testing.assert_allclose( | 1136 | 1136 | iosys_siso.pole(), tsys.siso_linsys.pole()) | 1137 | 1137 | omega = np.logspace(.1, 10, 100) | 1138 | 1138 | mag_io, phase_io, omega_io = iosys_siso.frequency_response(omega) | 1139 | 1139 | mag_ss, phase_ss, omega_ss = tsys.siso_linsys.frequency_response(omega) | 1140 | | - np.testing.assert_array_equal(mag_io, mag_ss) | 1141 | | - np.testing.assert_array_equal(phase_io, phase_ss) | 1142 | | - np.testing.assert_array_equal(omega_io, omega_ss) | | 1140 | + np.testing.assert_allclose(mag_io, mag_ss) | | 1141 | + np.testing.assert_allclose(phase_io, phase_ss) | | 1142 | + np.testing.assert_allclose(omega_io, omega_ss) | 1143 | 1143 |
| 1144 | 1144 | # LinearIOSystem methods should override StateSpace methods | 1145 | 1145 | io_mul = iosys_siso * iosys_siso2 | @@ -1150,19 +1150,19 @@ def test_lineariosys_statespace(self, tsys): | 1150 | 1150 |
| 1151 | 1151 | # And make sure the systems match | 1152 | 1152 | ss_series = tsys.siso_linsys * tsys.siso_linsys | 1153 | | - np.testing.assert_array_equal(io_mul.A, ss_series.A) | 1154 | | - np.testing.assert_array_equal(io_mul.B, ss_series.B) | 1155 | | - np.testing.assert_array_equal(io_mul.C, ss_series.C) | 1156 | | - np.testing.assert_array_equal(io_mul.D, ss_series.D) | | 1153 | + np.testing.assert_allclose(io_mul.A, ss_series.A) | | 1154 | + np.testing.assert_allclose(io_mul.B, ss_series.B) | | 1155 | + np.testing.assert_allclose(io_mul.C, ss_series.C) | | 1156 | + np.testing.assert_allclose(io_mul.D, ss_series.D) | 1157 | 1157 |
| 1158 | 1158 | # Make sure that series does the same thing | 1159 | 1159 | io_series = ct.series(iosys_siso, iosys_siso2) | 1160 | 1160 | assert isinstance(io_series, ct.InputOutputSystem) | 1161 | 1161 | assert isinstance(io_series, ct.StateSpace) | 1162 | | - np.testing.assert_array_equal(io_series.A, ss_series.A) | 1163 | | - np.testing.assert_array_equal(io_series.B, ss_series.B) | 1164 | | - np.testing.assert_array_equal(io_series.C, ss_series.C) | 1165 | | - np.testing.assert_array_equal(io_series.D, ss_series.D) | | 1162 | + np.testing.assert_allclose(io_series.A, ss_series.A) | | 1163 | + np.testing.assert_allclose(io_series.B, ss_series.B) | | 1164 | + np.testing.assert_allclose(io_series.C, ss_series.C) | | 1165 | + np.testing.assert_allclose(io_series.D, ss_series.D) | 1166 | 1166 |
| 1167 | 1167 | # Test out feedback as well | 1168 | 1168 | io_feedback = ct.feedback(iosys_siso, iosys_siso2) | @@ -1173,10 +1173,10 @@ def test_lineariosys_statespace(self, tsys): | 1173 | 1173 |
| 1174 | 1174 | # And make sure the systems match | 1175 | 1175 | ss_feedback = ct.feedback(tsys.siso_linsys, tsys.siso_linsys) | 1176 | | - np.testing.assert_array_equal(io_feedback.A, ss_feedback.A) | 1177 | | - np.testing.assert_array_equal(io_feedback.B, ss_feedback.B) | 1178 | | - np.testing.assert_array_equal(io_feedback.C, ss_feedback.C) | 1179 | | - np.testing.assert_array_equal(io_feedback.D, ss_feedback.D) | | 1176 | + np.testing.assert_allclose(io_feedback.A, ss_feedback.A) | | 1177 | + np.testing.assert_allclose(io_feedback.B, ss_feedback.B) | | 1178 | + np.testing.assert_allclose(io_feedback.C, ss_feedback.C) | | 1179 | + np.testing.assert_allclose(io_feedback.D, ss_feedback.D) | 1180 | 1180 |
| 1181 | 1181 | # Make sure series interconnections are done in the right order | 1182 | 1182 | ss_sys1 = ct.rss(2, 3, 2) | @@ -1190,10 +1190,10 @@ def test_lineariosys_statespace(self, tsys): | 1190 | 1190 |
| 1191 | 1191 | # While we are at it, check that the state space matrices match | 1192 | 1192 | ss_series = ss_sys2 * ss_sys1 | 1193 | | - np.testing.assert_array_equal(io_series.A, ss_series.A) | 1194 | | - np.testing.assert_array_equal(io_series.B, ss_series.B) | 1195 | | - np.testing.assert_array_equal(io_series.C, ss_series.C) | 1196 | | - np.testing.assert_array_equal(io_series.D, ss_series.D) | | 1193 | + np.testing.assert_allclose(io_series.A, ss_series.A) | | 1194 | + np.testing.assert_allclose(io_series.B, ss_series.B) | | 1195 | + np.testing.assert_allclose(io_series.C, ss_series.C) | | 1196 | + np.testing.assert_allclose(io_series.D, ss_series.D) | 1197 | 1197 |
| 1198 | 1198 | def test_docstring_example(self): | 1199 | 1199 | P = ct.LinearIOSystem( | |
Collapse file Copy file name to clipboardExpand all lines: control/tests/lti_test.py +8-8Lines changed: 8 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,13 +15,13 @@ class TestLTI: | 15 | 15 |
| 16 | 16 | def test_pole(self): | 17 | 17 | sys = tf(126, [-1, 42]) | 18 | | - np.testing.assert_equal(sys.pole(), 42) | 19 | | - np.testing.assert_equal(pole(sys), 42) | | 18 | + np.testing.assert_allclose(sys.pole(), 42) | | 19 | + np.testing.assert_allclose(pole(sys), 42) | 20 | 20 |
| 21 | 21 | def test_zero(self): | 22 | 22 | sys = tf([-1, 42], [1, 10]) | 23 | | - np.testing.assert_equal(sys.zero(), 42) | 24 | | - np.testing.assert_equal(zero(sys), 42) | | 23 | + np.testing.assert_allclose(sys.zero(), 42) | | 24 | + np.testing.assert_allclose(zero(sys), 42) | 25 | 25 |
| 26 | 26 | def test_issiso(self): | 27 | 27 | assert issiso(1) | @@ -58,8 +58,8 @@ def test_damp(self): | 58 | 58 | p = -wn * zeta + 1j * wn * np.sqrt(1 - zeta**2) | 59 | 59 | sys = tf(1, [1, 2 * zeta * wn, wn**2]) | 60 | 60 | expected = ([wn, wn], [zeta, zeta], [p, p.conjugate()]) | 61 | | - np.testing.assert_equal(sys.damp(), expected) | 62 | | - np.testing.assert_equal(damp(sys), expected) | | 61 | + np.testing.assert_allclose(sys.damp(), expected) | | 62 | + np.testing.assert_allclose(damp(sys), expected) | 63 | 63 |
| 64 | 64 | # Also test the discrete time case. | 65 | 65 | dt = 0.001 | @@ -72,8 +72,8 @@ def test_damp(self): | 72 | 72 |
| 73 | 73 | def test_dcgain(self): | 74 | 74 | sys = tf(84, [1, 2]) | 75 | | - np.testing.assert_equal(sys.dcgain(), 42) | 76 | | - np.testing.assert_equal(dcgain(sys), 42) | | 75 | + np.testing.assert_allclose(sys.dcgain(), 42) | | 76 | + np.testing.assert_allclose(dcgain(sys), 42) | 77 | 77 |
| 78 | 78 | @pytest.mark.parametrize("dt1, dt2, expected", | 79 | 79 | [(None, None, True), | |
Collapse file Copy file name to clipboardExpand all lines: control/tests/matlab_test.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -420,7 +420,7 @@ def testRlocus_list(self, siso, mplcleanup): | 420 | 420 | klist = [1, 10, 100] | 421 | 421 | rlist, klist_out = rlocus(siso.tf2, klist, plot=False) | 422 | 422 | np.testing.assert_equal(len(rlist), len(klist)) | 423 | | - np.testing.assert_array_equal(klist, klist_out) | | 423 | + np.testing.assert_allclose(klist, klist_out) | 424 | 424 |
| 425 | 425 | def testNyquist(self, siso): | 426 | 426 | """Call nyquist()""" | |
Collapse file Copy file name to clipboardExpand all lines: control/tests/rlocus_test.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,7 +42,7 @@ def testRootLocus(self, sys): | 42 | 42 |
| 43 | 43 | roots, k_out = root_locus(sys, klist, plot=False) | 44 | 44 | np.testing.assert_equal(len(roots), len(klist)) | 45 | | - np.testing.assert_array_equal(klist, k_out) | | 45 | + np.testing.assert_allclose(klist, k_out) | 46 | 46 | self.check_cl_poles(sys, roots, klist) | 47 | 47 |
| 48 | 48 | def test_without_gains(self, sys): | |
Collapse file Copy file name to clipboardExpand all lines: control/tests/statesp_test.py +16-16Lines changed: 16 additions & 16 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -172,12 +172,12 @@ def test_copy_constructor(self): | 172 | 172 |
| 173 | 173 | # Change the original A matrix | 174 | 174 | A[0, 0] = -2 | 175 | | - np.testing.assert_array_equal(linsys.A, [[-1]]) # original value | 176 | | - np.testing.assert_array_equal(cpysys.A, [[-1]]) # original value | | 175 | + np.testing.assert_allclose(linsys.A, [[-1]]) # original value | | 176 | + np.testing.assert_allclose(cpysys.A, [[-1]]) # original value | 177 | 177 |
| 178 | 178 | # Change the A matrix for the original system | 179 | 179 | linsys.A[0, 0] = -3 | 180 | | - np.testing.assert_array_equal(cpysys.A, [[-1]]) # original value | | 180 | + np.testing.assert_allclose(cpysys.A, [[-1]]) # original value | 181 | 181 |
| 182 | 182 | def test_copy_constructor_nodt(self, sys322): | 183 | 183 | """Test the copy constructor when an object without dt is passed""" | @@ -207,24 +207,24 @@ def test_D_broadcast(self, sys623): | 207 | 207 | """Test broadcast of D=0 to the right shape""" | 208 | 208 | # Giving D as a scalar 0 should broadcast to the right shape | 209 | 209 | sys = StateSpace(sys623.A, sys623.B, sys623.C, 0) | 210 | | - np.testing.assert_array_equal(sys623.D, sys.D) | | 210 | + np.testing.assert_allclose(sys623.D, sys.D) | 211 | 211 |
| 212 | 212 | # Giving D as a matrix of the wrong size should generate an error | 213 | 213 | with pytest.raises(ValueError): | 214 | 214 | sys = StateSpace(sys.A, sys.B, sys.C, np.array([[0]])) | 215 | 215 |
| 216 | 216 | # Make sure that empty systems still work | 217 | 217 | sys = StateSpace([], [], [], 1) | 218 | | - np.testing.assert_array_equal(sys.D, [[1]]) | | 218 | + np.testing.assert_allclose(sys.D, [[1]]) | 219 | 219 |
| 220 | 220 | sys = StateSpace([], [], [], [[0]]) | 221 | | - np.testing.assert_array_equal(sys.D, [[0]]) | | 221 | + np.testing.assert_allclose(sys.D, [[0]]) | 222 | 222 |
| 223 | 223 | sys = StateSpace([], [], [], [0]) | 224 | | - np.testing.assert_array_equal(sys.D, [[0]]) | | 224 | + np.testing.assert_allclose(sys.D, [[0]]) | 225 | 225 |
| 226 | 226 | sys = StateSpace([], [], [], 0) | 227 | | - np.testing.assert_array_equal(sys.D, [[0]]) | | 227 | + np.testing.assert_allclose(sys.D, [[0]]) | 228 | 228 |
| 229 | 229 | def test_pole(self, sys322): | 230 | 230 | """Evaluate the poles of a MIMO system.""" | @@ -388,7 +388,7 @@ def test_freq_resp(self): | 388 | 388 |
| 389 | 389 | np.testing.assert_almost_equal(mag, true_mag) | 390 | 390 | np.testing.assert_almost_equal(phase, true_phase) | 391 | | - np.testing.assert_equal(omega, true_omega) | | 391 | + np.testing.assert_almost_equal(omega, true_omega) | 392 | 392 |
| 393 | 393 | # Deprecated version of the call (should return warning) | 394 | 394 | with pytest.warns(DeprecationWarning, match="will be removed"): | @@ -516,15 +516,15 @@ def test_dc_gain_discr(self): | 516 | 516 | """Test DC gain for discrete-time state-space systems.""" | 517 | 517 | # static gain | 518 | 518 | sys = StateSpace([], [], [], 2, True) | 519 | | - np.testing.assert_equal(sys.dcgain(), 2) | | 519 | + np.testing.assert_allclose(sys.dcgain(), 2) | 520 | 520 |
| 521 | 521 | # averaging filter | 522 | 522 | sys = StateSpace(0.5, 0.5, 1, 0, True) | 523 | 523 | np.testing.assert_allclose(sys.dcgain(), 1) | 524 | 524 |
| 525 | 525 | # differencer | 526 | 526 | sys = StateSpace(0, 1, -1, 1, True) | 527 | | - np.testing.assert_equal(sys.dcgain(), 0) | | 527 | + np.testing.assert_allclose(sys.dcgain(), 0) | 528 | 528 |
| 529 | 529 | # summer | 530 | 530 | sys = StateSpace(1, 1, 1, 0, True) | @@ -592,14 +592,14 @@ def test_matrix_static_gain(self): | 592 | 592 | g3 = StateSpace([], [], [], d2.T) | 593 | 593 |
| 594 | 594 | h1 = g1 * g2 | 595 | | - np.testing.assert_array_equal(np.dot(d1, d2), h1.D) | | 595 | + np.testing.assert_allclose(np.dot(d1, d2), h1.D) | 596 | 596 | h2 = g1 + g3 | 597 | | - np.testing.assert_array_equal(d1 + d2.T, h2.D) | | 597 | + np.testing.assert_allclose(d1 + d2.T, h2.D) | 598 | 598 | h3 = g1.feedback(g2) | 599 | 599 | np.testing.assert_array_almost_equal( | 600 | 600 | solve(np.eye(2) + np.dot(d1, d2), d1), h3.D) | 601 | 601 | h4 = g1.append(g2) | 602 | | - np.testing.assert_array_equal(block_diag(d1, d2), h4.D) | | 602 | + np.testing.assert_allclose(block_diag(d1, d2), h4.D) | 603 | 603 |
| 604 | 604 | def test_remove_useless_states(self): | 605 | 605 | """Regression: _remove_useless_states gives correct ABC sizes.""" | @@ -633,7 +633,7 @@ def test_minreal_static_gain(self): | 633 | 633 | np.testing.assert_array_equal(g1.A, g2.A) | 634 | 634 | np.testing.assert_array_equal(g1.B, g2.B) | 635 | 635 | np.testing.assert_array_equal(g1.C, g2.C) | 636 | | - np.testing.assert_array_equal(g1.D, g2.D) | | 636 | + np.testing.assert_allclose(g1.D, g2.D) | 637 | 637 |
| 638 | 638 | def test_empty(self): | 639 | 639 | """Regression: can we create an empty StateSpace object?""" | @@ -651,7 +651,7 @@ def test_matrix_to_state_space(self): | 651 | 651 | np.testing.assert_array_equal(np.empty((0, 0)), g.A) | 652 | 652 | np.testing.assert_array_equal(np.empty((0, D.shape[1])), g.B) | 653 | 653 | np.testing.assert_array_equal(np.empty((D.shape[0], 0)), g.C) | 654 | | - np.testing.assert_array_equal(D, g.D) | | 654 | + np.testing.assert_allclose(D, g.D) | 655 | 655 |
| 656 | 656 | def test_lft(self): | 657 | 657 | """ test lft function with result obtained from matlab implementation""" | |
Collapse file Copy file name to clipboardExpand all lines: control/tests/timeresp_test.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -364,7 +364,7 @@ def test_step_nostates(self, dt): | 364 | 364 | """ | 365 | 365 | sys = TransferFunction([1], [1], dt) | 366 | 366 | t, y = step_response(sys) | 367 | | - np.testing.assert_array_equal(y, np.ones(len(t))) | | 367 | + np.testing.assert_allclose(y, np.ones(len(t))) | 368 | 368 |
| 369 | 369 | def assert_step_info_match(self, sys, info, info_ref): | 370 | 370 | """Assert reasonable step_info accuracy.""" | |
Collapse file Copy file name to clipboardExpand all lines: control/tests/xferfcn_input_test.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -69,7 +69,7 @@ def test_clean_part(num, fun, dtype): | 69 | 69 | for i, numi in enumerate(num_): | 70 | 70 | assert len(numi) == ref_.shape[1] | 71 | 71 | for j, numj in enumerate(numi): | 72 | | - np.testing.assert_array_equal(numj, ref_[i, j, ...]) | | 72 | + np.testing.assert_allclose(numj, ref_[i, j, ...]) | 73 | 73 |
| 74 | 74 |
| 75 | 75 | @pytest.mark.parametrize("badinput", [[[0., 1.], [2., 3.]], "a"]) | |
|