Skip to content

Commit 37babd5

Browse files
committed
Test free-threading
1 parent e899c42 commit 37babd5

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

.github/workflows/build-dist.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ jobs:
2727
submodules: true
2828

2929
- name: Build wheels
30-
uses: pypa/cibuildwheel@v2.21
30+
uses: pypa/cibuildwheel@v2.23
3131
env:
32+
CIBW_ENABLE: cpython-freethreading
3233
# Skip builds(save time / avoid build error)
3334
CIBW_SKIP: "pp* *-musllinux_* *_i686 *-win32"
3435

@@ -53,7 +54,7 @@ jobs:
5354
platforms: all
5455

5556
- name: Build wheels
56-
uses: pypa/cibuildwheel@v2.21
57+
uses: pypa/cibuildwheel@v2.23
5758
env:
5859
CIBW_ARCHS_LINUX: aarch64
5960
CIBW_BUILD: cp*-manylinux_aarch64

.github/workflows/run-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
fail-fast: false
99
matrix:
10-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.10"]
10+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.13t", "pypy3.10"]
1111
os: [ubuntu-latest, windows-latest, macos-latest]
1212
runs-on: ${{ matrix.os }}
1313

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ classifiers = [
4343
"Programming Language :: C",
4444
"Programming Language :: C++",
4545
"Programming Language :: Python :: 3",
46+
"Programming Language :: Python :: Free Threading :: 1 - Unstable",
4647
]
4748
dependencies = ["numpy"]
4849

tests/test_resample.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def test_divide_match(in_rate, out_rate, dtype):
5353
y_divide = soxr.resample(x, in_rate, out_rate)
5454
y_split = soxr.resample(np.asfortranarray(x), in_rate, out_rate)
5555

56-
assert np.allclose(y_oneshot, y_divide)
57-
assert np.allclose(y_oneshot, y_split)
56+
assert np.all(y_oneshot == y_divide)
57+
assert np.all(y_oneshot == y_split)
5858

5959

6060
@pytest.mark.parametrize('in_rate, out_rate', [(44100, 32000), (32000, 44100)])
@@ -67,8 +67,8 @@ def test_length_match(in_rate, out_rate, length):
6767
y_divide = soxr.resample(x[:length], in_rate, out_rate)
6868
y_split = soxr.resample(np.asfortranarray(x)[:length], in_rate, out_rate)
6969

70-
assert np.allclose(y_oneshot, y_divide)
71-
assert np.allclose(y_oneshot, y_split)
70+
assert np.all(y_oneshot == y_divide)
71+
assert np.all(y_oneshot == y_split)
7272

7373

7474
@pytest.mark.parametrize('channels', [1, 2, 3, 5, 7, 24, 49])
@@ -80,8 +80,8 @@ def test_channel_match(channels):
8080
y_divide = soxr.resample(x[:, :channels], 44100, 32000)
8181
y_split = soxr.resample(np.asfortranarray(x)[:, :channels], 44100, 32000)
8282

83-
assert np.allclose(y_oneshot, y_divide)
84-
assert np.allclose(y_oneshot, y_split)
83+
assert np.all(y_oneshot == y_divide)
84+
assert np.all(y_oneshot == y_split)
8585

8686

8787
def stream_resample(x, in_rate, out_rate, chunk_size, dtype):
@@ -113,7 +113,7 @@ def test_stream_length(in_rate, out_rate, chunk_size, length, dtype):
113113
y_oneshot = soxr._resample_oneshot(x, in_rate, out_rate)
114114
y_stream = stream_resample(x, in_rate, out_rate, chunk_size, dtype)
115115

116-
assert np.allclose(y_oneshot, y_stream)
116+
assert np.all(y_oneshot == y_stream)
117117

118118

119119
@pytest.mark.parametrize('in_rate, out_rate', [(48000, 22050), (8000, 48000)])
@@ -177,9 +177,10 @@ def test_int_sine(in_rate, out_rate, dtype):
177177

178178

179179
@pytest.mark.parametrize('num_task', [2, 3, 4, 5, 6, 7, 8, 9, 12, 17, 32])
180-
def test_multithread(num_task):
180+
@pytest.mark.parametrize('dtype', ['float32', np.int16])
181+
def test_multithread(num_task, dtype):
181182
# test multi-thread operation
182-
x = np.random.randn(25999, 2).astype(np.float32)
183+
x = (np.random.randn(25999, 2) * 5000).astype(dtype)
183184

184185
with ThreadPoolExecutor() as p:
185186
results = p.map(
@@ -188,4 +189,4 @@ def test_multithread(num_task):
188189
)
189190
results = list(results)
190191

191-
assert np.allclose(results[-2], results[-1])
192+
assert np.all(results[-2] == results[-1])

0 commit comments

Comments
 (0)