From d0d7f0b18ab5cca2c573448b757c45bc0eee69c6 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 29 May 2025 08:56:25 +0200 Subject: [PATCH] maths/radix2_fft.py: Fix calculation for Python 3.14 (#12772) * maths/radix2_fft.py: Fix calculation for Python 3.14 As suggested at: * https://github.com/TheAlgorithms/Python/issues/12729#issuecomment-2878608477 * https://github.com/TheAlgorithms/Python/pull/12710#discussion_r2080117333 @MaximSmolskiy @KirilBangachev @skirpichev Careful review, please. I am just implementing the suggestion, but I do not have any expertise in this area. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Change test results * GitHub Actions: Rename job from build to directory_writer It is confusing to have two jobs named `build`. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/directory_writer.yml | 2 +- maths/radix2_fft.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/directory_writer.yml b/.github/workflows/directory_writer.yml index 55d89f455a25..3edb5c91a951 100644 --- a/.github/workflows/directory_writer.yml +++ b/.github/workflows/directory_writer.yml @@ -3,7 +3,7 @@ name: directory_writer on: [push] jobs: - build: + directory_writer: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/maths/radix2_fft.py b/maths/radix2_fft.py index d41dc82d5588..ccd5cdcc0160 100644 --- a/maths/radix2_fft.py +++ b/maths/radix2_fft.py @@ -40,13 +40,13 @@ class FFT: Print product >>> x.product # 2x + 3x^2 + 8x^3 + 4x^4 + 6x^5 - [(-0+0j), (2+0j), (3+0j), (8+0j), (6+0j), (8+0j)] + [(-0-0j), (2+0j), (3-0j), (8-0j), (6+0j), (8+0j)] __str__ test >>> print(x) A = 0*x^0 + 1*x^1 + 2*x^0 + 3*x^2 B = 0*x^2 + 1*x^3 + 2*x^4 - A*B = 0*x^(-0+0j) + 1*x^(2+0j) + 2*x^(3+0j) + 3*x^(8+0j) + 4*x^(6+0j) + 5*x^(8+0j) + A*B = 0*x^(-0-0j) + 1*x^(2+0j) + 2*x^(3-0j) + 3*x^(8-0j) + 4*x^(6+0j) + 5*x^(8+0j) """ def __init__(self, poly_a=None, poly_b=None): @@ -147,7 +147,9 @@ def __multiply(self): inverce_c = new_inverse_c next_ncol *= 2 # Unpack - inverce_c = [round(x[0].real, 8) + round(x[0].imag, 8) * 1j for x in inverce_c] + inverce_c = [ + complex(round(x[0].real, 8), round(x[0].imag, 8)) for x in inverce_c + ] # Remove leading 0's while inverce_c[-1] == 0: