Skip to content

Help wanted: Why do maths/radix2_fft.py test results change on Python 3.14 beta? #12729

Closed
@cclauss

Description

@cclauss
Member

See the required changes https://github.com/TheAlgorithms/Python/pull/12710/files#r2080117333

Repository commit

Same as #12710

Python version (python --version)

Python 3.14 beta 1

Dependencies version (pip freeze)

Same as:

Expected behavior

Doctest results do not need to change between Python 3.13 and 3.14 beta.

Actual behavior

See changes required in:

Activity

changed the title [-]Help requested: Why do maths/radix2_fft.py test results change on Python 3.14 beta?[/-] [+]Help wanted: Why do maths/radix2_fft.py test results change on Python 3.14 beta?[/+] on May 12, 2025
pinned this issue on May 12, 2025
MaximSmolskiy

MaximSmolskiy commented on May 13, 2025

@MaximSmolskiy
Member

@cclauss In Python 3.14 Release Notes (https://docs.python.org/3.14/whatsnew/3.14.html) there are mentions of changes related to complex numbers:

  • Implement mixed-mode arithmetic rules combining real and complex numbers as specified by C standards since C99. (Contributed by Sergey B Kirpichev in gh-69639.)

This may be the reason for changes in the doctests.

cclauss

cclauss commented on May 14, 2025

@cclauss
MemberAuthor
skirpichev

skirpichev commented on May 14, 2025

@skirpichev

JFR, above pr was merged not before latest beta. Did you test alphas?

cclauss

cclauss commented on May 14, 2025

@cclauss
MemberAuthor
skirpichev

skirpichev commented on May 14, 2025

@skirpichev

My question was did you test 3.14 alphas?

skirpichev

skirpichev commented on May 14, 2025

@skirpichev

Anyway, so far I can guess this might be related to:

        inverce_c = [round(x[0].real, 8) + round(x[0].imag, 8) * 1j for x in inverce_c]

Probably, you want rather complex(round(x[0].real, 8), round(x[0].imag, 8)). But with above pattern you can get different answers on 3.14 and 3.13. Example:

Python 3.14.0a7 (tags/v3.14.0a7:29af6cee02, Apr  9 2025, 12:48:04) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 + (-0.0)*1j
(1-0j)
Python 3.13.3 (tags/v3.13.3:6280bb5478, Apr  9 2025, 10:07:49) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 + (-0.0)*1j
(1+0j)

Obviously, the last answer is incorrect as a replacement of complex(1, -0.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @skirpichev@cclauss@MaximSmolskiy

      Issue actions

        Help wanted: Why do maths/radix2_fft.py test results change on Python 3.14 beta? · Issue #12729 · TheAlgorithms/Python