Skip to content

maths/radix2_fft.py: Fix calculation for Python 3.14 #12772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/directory_writer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name: directory_writer
on: [push]
jobs:
build:
directory_writer:
Copy link
Member Author

@cclauss cclauss May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is too confusing to have two GitHub Actions jobs named build, so rename this job to document what it really does.

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 5 additions & 3 deletions maths/radix2_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down