Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
fakufaku committed Aug 7, 2024
1 parent 0c305b1 commit 4c79c8a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ jobs:
fail-fast: false
max-parallel: 12
matrix:
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
#os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
#python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
os: [windows-latest]
python-version: [3.8, 3.9]
exclude:
- os: macos-latest
python-version: 3.8
Expand All @@ -33,20 +35,14 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
# pip install flake8
# stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Build package
run: |
python -m pip install -e .
- name: Test with pytest
run: |
pip install -U pytest setuptools build wheel twine
pytest
python ./tests/test_build_rir.py
# pytest
- name: Test the universal wheels
if: matrix.os == 'ubuntu-latest'
run: |
Expand Down
26 changes: 17 additions & 9 deletions pyroomacoustics/tests/test_build_rir.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ def build_rir_wrap(time, alpha, visibility, fs, fdl):
fdl2 = (fdl - 1) // 2

# the number of samples needed
N = int(np.ceil(time.max() * fs) + fdl + 1)
N = int(np.ceil(time.max() * fs) + fdl)

ir_ref = np.zeros(N + 1)
ir_cython = np.zeros(N + 1)
ir_ref = np.zeros(N)
ir_cython = np.zeros(N)

ir_cpp_f = ir_cython.astype(np.float32)

Expand Down Expand Up @@ -132,10 +132,10 @@ def test_short():
if not build_rir_available:
return

N = 101
N = 100
fs = 16000
fdl = 81
rir = np.zeros(N + 1, dtype=np.float32)
rir = np.zeros(N, dtype=np.float32)

time = np.array([0.0], dtype=np.float32)
alpha = np.array([1.0], dtype=np.float32)
Expand Down Expand Up @@ -163,7 +163,7 @@ def test_long():
N = 100
fs = 16000
fdl = 81
rir = np.zeros(N + 1, dtype=np.float32)
rir = np.zeros(N, dtype=np.float32)

time = np.array([(N - 1) / fs], dtype=np.float32)
alpha = np.array([1.0], dtype=np.float32)
Expand All @@ -182,7 +182,7 @@ def test_errors():
N = 300
fs = 16000
fdl = 81
rir = np.zeros(N + 1, dtype=np.float32)
rir = np.zeros(N, dtype=np.float32)

time = np.array([100 / fs, 200 / fs], dtype=np.float32)
alpha = np.array([1.0, 1.0], dtype=np.float32)
Expand All @@ -208,8 +208,8 @@ def test_delay_sum(dtype, tol):
np.random.seed(0)
irs = np.random.randn(n, taps).astype(dtype)
delays = np.random.randint(0, rir_len - taps, size=n, dtype=np.int32)
out1 = np.zeros(rir_len + 1, dtype=dtype)
out2 = np.zeros(rir_len + 1, dtype=dtype)
out1 = np.zeros(rir_len, dtype=dtype)
out2 = np.zeros(rir_len, dtype=dtype)

libroom.delay_sum(irs, delays, out1, n_threads)

Expand Down Expand Up @@ -316,8 +316,11 @@ def measure_runtime(dtype=np.float32, num_threads=4):
if __name__ == "__main__":
import matplotlib.pyplot as plt

print("frac del 1", flush=True)
test_fractional_delay(np.float32, 2e-2)
print("frac del 2", flush=True)
test_fractional_delay(np.float64, 2e-2)
print("del sum", flush=True)
test_delay_sum(np.float32, 1e-4)

for t, a, v in zip(times, alphas, visibilities):
Expand All @@ -330,12 +333,17 @@ def measure_runtime(dtype=np.float32, num_threads=4):
plt.plot(ir_cython, label="cython")
plt.legend()

print("short", flush=True)
test_short()
print("long", flush=True)
test_long()
print("errors", flush=True)
test_errors()

num_threads = os.cpu_count()
print("measure 1", flush=True)
measure_runtime(dtype=np.float32, num_threads=num_threads)
print("measure 2", flush=True)
measure_runtime(dtype=np.float64, num_threads=num_threads)

plt.show()

0 comments on commit 4c79c8a

Please sign in to comment.