Skip to content

OPT: speed up sliding staypoint generation#665

Merged
hongyeehh merged 1 commit intomie-lab:masterfrom
hongyeehh:optimize_sp
May 3, 2026
Merged

OPT: speed up sliding staypoint generation#665
hongyeehh merged 1 commit intomie-lab:masterfrom
hongyeehh:optimize_sp

Conversation

@hongyeehh
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes the generate_staypoints(..., method="sliding") pipeline by reducing per-user overhead (avoiding joblib when n_jobs==1) and by replacing repeated Shapely operations inside the sliding-window loop with NumPy-based computations.

Changes:

  • Add a fast path for n_jobs==1 that iterates per-user groups directly with tqdm progress.
  • Speed up per-user sliding staypoint generation by precomputing timestamp integer arrays, trig arrays for distance, and computing centroids from coordinate arrays (matching prior union/centroid behavior).
  • Add regression tests for timezone-aware, non-nanosecond timestamp units and for centroid behavior (duplicate points + antimeridian wrapping).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
trackintel/preprocessing/positionfixes.py Introduces optimized per-user sliding staypoint generation (faster distance + centroid computation, avoids parallel overhead for n_jobs==1).
tests/preprocessing/test_positionfixes.py Adds tests to ensure the optimized path preserves behavior for timestamp dtypes and centroid computation edge cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hongyeehh hongyeehh merged commit 312de84 into mie-lab:master May 3, 2026
10 checks passed
@hongyeehh hongyeehh deleted the optimize_sp branch May 3, 2026 21:25
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