Skip to content

Commit 13f2ce1

Browse files
committed
replace more assert_equal comparing possible float results
1 parent e3b964b commit 13f2ce1

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

control/tests/lti_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class TestLTI:
1515

1616
def test_pole(self):
1717
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)
2020

2121
def test_zero(self):
2222
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)
2525

2626
def test_issiso(self):
2727
assert issiso(1)
@@ -72,8 +72,8 @@ def test_damp(self):
7272

7373
def test_dcgain(self):
7474
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)
7777

7878
@pytest.mark.parametrize("dt1, dt2, expected",
7979
[(None, None, True),

control/tests/matlab_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def testRlocus_list(self, siso, mplcleanup):
420420
klist = [1, 10, 100]
421421
rlist, klist_out = rlocus(siso.tf2, klist, plot=False)
422422
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)
424424

425425
def testNyquist(self, siso):
426426
"""Call nyquist()"""

control/tests/rlocus_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def testRootLocus(self, sys):
4242

4343
roots, k_out = root_locus(sys, klist, plot=False)
4444
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)
4646
self.check_cl_poles(sys, roots, klist)
4747

4848
def test_without_gains(self, sys):

control/tests/statesp_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def test_freq_resp(self):
388388

389389
np.testing.assert_almost_equal(mag, true_mag)
390390
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)
392392

393393
# Deprecated version of the call (should return warning)
394394
with pytest.warns(DeprecationWarning, match="will be removed"):
@@ -516,15 +516,15 @@ def test_dc_gain_discr(self):
516516
"""Test DC gain for discrete-time state-space systems."""
517517
# static gain
518518
sys = StateSpace([], [], [], 2, True)
519-
np.testing.assert_equal(sys.dcgain(), 2)
519+
np.testing.assert_allclose(sys.dcgain(), 2)
520520

521521
# averaging filter
522522
sys = StateSpace(0.5, 0.5, 1, 0, True)
523523
np.testing.assert_allclose(sys.dcgain(), 1)
524524

525525
# differencer
526526
sys = StateSpace(0, 1, -1, 1, True)
527-
np.testing.assert_equal(sys.dcgain(), 0)
527+
np.testing.assert_allclose(sys.dcgain(), 0)
528528

529529
# summer
530530
sys = StateSpace(1, 1, 1, 0, True)

control/tests/xferfcn_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,8 @@ def test_minreal_4(self):
693693
h = (z - 1.00000000001) * (z + 1.0000000001) / (z**2 - 1)
694694
hm = h.minreal()
695695
hr = TransferFunction([1], [1], T)
696-
np.testing.assert_array_almost_equal(hm.num[0][0], hr.num[0][0])
697-
np.testing.assert_equal(hr.dt, hm.dt)
696+
np.testing.assert_allclose(hm.num[0][0], hr.num[0][0])
697+
np.testing.assert_allclose(hr.dt, hm.dt)
698698

699699
@slycotonly
700700
def test_state_space_conversion_mimo(self):
@@ -801,10 +801,10 @@ def test_matrix_array_multiply(self, matarrayin, X_, ij):
801801
def test_dcgain_cont(self):
802802
"""Test DC gain for continuous-time transfer functions"""
803803
sys = TransferFunction(6, 3)
804-
np.testing.assert_equal(sys.dcgain(), 2)
804+
np.testing.assert_allclose(sys.dcgain(), 2)
805805

806806
sys2 = TransferFunction(6, [1, 3])
807-
np.testing.assert_equal(sys2.dcgain(), 2)
807+
np.testing.assert_allclose(sys2.dcgain(), 2)
808808

809809
sys3 = TransferFunction(6, [1, 0])
810810
np.testing.assert_equal(sys3.dcgain(), np.inf)
@@ -819,7 +819,7 @@ def test_dcgain_discr(self):
819819
"""Test DC gain for discrete-time transfer functions"""
820820
# static gain
821821
sys = TransferFunction(6, 3, True)
822-
np.testing.assert_equal(sys.dcgain(), 2)
822+
np.testing.assert_allclose(sys.dcgain(), 2)
823823

824824
# averaging filter
825825
sys = TransferFunction(0.5, [1, -0.5], True)
@@ -837,7 +837,7 @@ def test_dcgain_discr(self):
837837

838838
# summer
839839
sys = TransferFunction([1, -1], [1], True)
840-
np.testing.assert_equal(sys.dcgain(), 0)
840+
np.testing.assert_allclose(sys.dcgain(), 0)
841841

842842
def test_ss2tf(self):
843843
"""Test SISO ss2tf"""

0 commit comments

Comments
 (0)