From 8c1c6c1763e8d4695754dceea072cc1ff58308bb Mon Sep 17 00:00:00 2001 From: alejandroaldas <52395149+alejandroaldas@users.noreply.github.com> Date: Sun, 24 Aug 2025 17:16:05 -0500 Subject: [PATCH] Codex/find and fix a bug (#12782) * Fix enumeration order in FFT string representation * updating DIRECTORY.md * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update radix2_fft.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: alejandroaldas Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maxim Smolskiy --- maths/radix2_fft.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/maths/radix2_fft.py b/maths/radix2_fft.py index ccd5cdcc0..5efbccc7a 100644 --- a/maths/radix2_fft.py +++ b/maths/radix2_fft.py @@ -39,14 +39,14 @@ class FFT: >>> x = FFT(A, B) Print product - >>> x.product # 2x + 3x^2 + 8x^3 + 4x^4 + 6x^5 + >>> x.product # 2x + 3x^2 + 8x^3 + 6x^4 + 8x^5 [(-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 = 0*x^0 + 1*x^1 + 0*x^2 + 2*x^3 + B = 2*x^0 + 3*x^1 + 4*x^2 + A*B = (-0-0j)*x^0 + (2+0j)*x^1 + (3-0j)*x^2 + (8-0j)*x^3 + (6+0j)*x^4 + (8+0j)*x^5 """ def __init__(self, poly_a=None, poly_b=None): @@ -159,13 +159,13 @@ class FFT: # Overwrite __str__ for print(); Shows A, B and A*B def __str__(self): a = "A = " + " + ".join( - f"{coef}*x^{i}" for coef, i in enumerate(self.polyA[: self.len_A]) + f"{coef}*x^{i}" for i, coef in enumerate(self.polyA[: self.len_A]) ) b = "B = " + " + ".join( - f"{coef}*x^{i}" for coef, i in enumerate(self.polyB[: self.len_B]) + f"{coef}*x^{i}" for i, coef in enumerate(self.polyB[: self.len_B]) ) c = "A*B = " + " + ".join( - f"{coef}*x^{i}" for coef, i in enumerate(self.product) + f"{coef}*x^{i}" for i, coef in enumerate(self.product) ) return f"{a}\n{b}\n{c}"