Skip to content

Remove unneccessary Numba usage -> use numpy vectorization#39

Merged
yiitozer merged 3 commits into
groupmm:masterfrom
Curucail:numba-to-numpy-vectorization
May 12, 2026
Merged

Remove unneccessary Numba usage -> use numpy vectorization#39
yiitozer merged 3 commits into
groupmm:masterfrom
Curucail:numba-to-numpy-vectorization

Conversation

@Curucail

@Curucail Curucail commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Note

Contains changes from PR #38 , so it should be merged first.

Summary

Remove unnecessary Numba usage from helpers that are either already vectorized, trivially small, or safely replaceable with NumPy.

File-by-file Changes

synctoolbox/feature/utils.py

  • Replaced the column-by-column normalization loop with vectorized NumPy logic:
    • computes all column norms at once with np.linalg.norm(..., axis=0)
    • identifies below-threshold columns with a boolean mask
    • normalizes regular columns in one array operation
    • replaces below-threshold columns with the normalized all-ones unit vector

synctoolbox/feature/pitch.py

  • Replaced repeated slice summation in a loop with a cumulative-sum implementation:
    • builds a prefix sum of f_square
    • computes each variable-length window sum as prefix_sum[stop] - prefix_sum[start]
    • writes all segment sums into f_pitch[midi_pitch, :] at once

synctoolbox/dtw/anchor.py

  • Removed jit decorator, function is trivially small

synctoolbox/dtw/mrmsdtw.py

  • Removed jit decorator, function is trivially small

synctoolbox/dtw/cost.py

  • Removed unused from numba import jit.
  • Removed stale commented-out #@jit(nopython=True) lines above cosine_distance and euclidean_distance.

Verification & Testing

  • Full test suite passes
  • Performed a custom regression test by comparing before/after function outputs with tight tolerance

@stefan-balke stefan-balke mentioned this pull request May 9, 2026
@yiitozer yiitozer merged commit dd092dd into groupmm:master May 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants