@@ -146,6 +146,37 @@ def test_assert_not_almost_equal_numbers_rtol(a, b):
146
146
_assert_not_almost_equal_both (a , b , rtol = 0.05 )
147
147
148
148
149
+ @pytest .mark .parametrize (
150
+ "a,b,rtol" ,
151
+ [
152
+ (1.00001 , 1.00005 , 0.001 ),
153
+ (- 0.908356 + 0.2j , - 0.908358 + 0.2j , 1e-3 ),
154
+ (0.1 + 1.009j , 0.1 + 1.006j , 0.1 ),
155
+ (0.1001 + 2.0j , 0.1 + 2.001j , 0.01 ),
156
+ ],
157
+ )
158
+ def test_assert_almost_equal_complex_numbers (a , b , rtol ):
159
+ _assert_almost_equal_both (a , b , rtol = rtol )
160
+ _assert_almost_equal_both (np .complex64 (a ), np .complex64 (b ), rtol = rtol )
161
+ _assert_almost_equal_both (np .complex128 (a ), np .complex128 (b ), rtol = rtol )
162
+
163
+
164
+ @pytest .mark .parametrize (
165
+ "a,b,rtol" ,
166
+ [
167
+ (0.58310768 , 0.58330768 , 1e-7 ),
168
+ (- 0.908 + 0.2j , - 0.978 + 0.2j , 0.001 ),
169
+ (0.1 + 1j , 0.1 + 2j , 0.01 ),
170
+ (- 0.132 + 1.001j , - 0.132 + 1.005j , 1e-5 ),
171
+ (0.58310768j , 0.58330768j , 1e-9 ),
172
+ ],
173
+ )
174
+ def test_assert_not_almost_equal_complex_numbers (a , b , rtol ):
175
+ _assert_not_almost_equal_both (a , b , rtol = rtol )
176
+ _assert_not_almost_equal_both (np .complex64 (a ), np .complex64 (b ), rtol = rtol )
177
+ _assert_not_almost_equal_both (np .complex128 (a ), np .complex128 (b ), rtol = rtol )
178
+
179
+
149
180
@pytest .mark .parametrize ("a,b" , [(0 , 0 ), (0 , 0.0 ), (0 , np .float64 (0 )), (0.00000001 , 0 )])
150
181
def test_assert_almost_equal_numbers_with_zeros (a , b ):
151
182
_assert_almost_equal_both (a , b )
0 commit comments