perf: Optimize double barrier labeling with numpy vectorization

Replaced the O(H*N) nested loop in create_labels_double_barrier with an O(H) vectorized approach utilizing numpy slice-based operations and arrays. Also removed duplicate implementation of create_labels_double_barrier in the same file. Fixed formatting in .gitignore to properly ignore pycache files.

Measurements with `N=100000`, `horizon=20`:
Original time: ~0.83s
Vectorized time: ~0.02s
Improvement: Over 40x speedup with correct output handling bounds edge cases like `len(df) < horizon`.

Co-authored-by: maghdam <63883156+maghdam@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot]
2026-03-11 18:35:20 +00:00
co-authored by maghdam
parent 29fcbf0f9d
commit 16c7dadbad
17 changed files with 27 additions and 53 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.