Skip to content

[3.13] gh-144173: fix flaky test_complex.test_truediv() (GH-144355)#145767

Merged
vstinner merged 1 commit intopython:3.13from
miss-islington:backport-c4333a1-3.13
Mar 10, 2026
Merged

[3.13] gh-144173: fix flaky test_complex.test_truediv() (GH-144355)#145767
vstinner merged 1 commit intopython:3.13from
miss-islington:backport-c4333a1-3.13

Conversation

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Mar 10, 2026

Previously, component-wise relative error bound was tested. However,
such bound can't exist already for complex multiplication as one can be
used to perform subtraction of floating-point numbers, e.g. x and y for
z0=1+1j and z1=x+yj.

>>> x, y = 1e-9+1j, 1+1j
>>> a = x*y*y.conjugate()/2;a
(1.0000000272292198e-09+1j)
>>> b = x*(y*y.conjugate()/2);b
(1e-09+1j)
>>> b == x
True
>>> (a.real-b.real)/math.ulp(b.real)
131672427.0

(cherry picked from commit c4333a1)

Co-authored-by: Sergey B Kirpichev skirpichev@gmail.com

Previously, component-wise relative error bound was tested.  However,
such bound can't exist already for complex multiplication as one can be
used to perform subtraction of floating-point numbers, e.g. x and y for
z0=1+1j and z1=x+yj.

```pycon
>>> x, y = 1e-9+1j, 1+1j
>>> a = x*y*y.conjugate()/2;a
(1.0000000272292198e-09+1j)
>>> b = x*(y*y.conjugate()/2);b
(1e-09+1j)
>>> b == x
True
>>> (a.real-b.real)/math.ulp(b.real)
131672427.0
```
(cherry picked from commit c4333a1)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
@bedevere-app bedevere-app bot added tests Tests in the Lib/test dir skip news labels Mar 10, 2026
@vstinner vstinner enabled auto-merge (squash) March 10, 2026 16:41
@vstinner vstinner merged commit f349433 into python:3.13 Mar 10, 2026
42 of 43 checks passed
@miss-islington miss-islington deleted the backport-c4333a1-3.13 branch March 10, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants