Skip to content

Add border fill strategies to individual speed and acceleration calculations - #595

Open
M-Colley wants to merge 1 commit into
PedestrianDynamics:mainfrom
M-Colley:feat/border-fill-strategy-speed-acceleration
Open

M-Colley wants to merge 1 commit into
PedestrianDynamics:mainfrom
M-Colley:feat/border-fill-strategy-speed-acceleration

Conversation

@M-Colley

Copy link
Copy Markdown

Summary

Fixes #552

Adds a border_fill: BorderFillMethod = BorderFillMethod.NONE parameter to compute_individual_speed and compute_individual_acceleration so downstream consumers can maintain a 1:1 row alignment with traj_data.data when border windows are incomplete:

  • BorderFillMethod.NONE (default): Preserves existing behavior by dropping incomplete border frames.
  • BorderFillMethod.NAN: Keeps all (id, frame) rows in their original order and fills incomplete border frames with NaN.
  • BorderFillMethod.LAST_VALUE: Keeps all (id, frame) rows in their original order and forward-/backward-fills incomplete border frames from the nearest valid value of the same pedestrian (without leaking values across pedestrians if a trajectory is shorter than the window).
  • SpeedCalculation.BORDER_SINGLE_SIDED: Leaves the output untouched regardless of border_fill.
  • Plotting & truncation audit: Audited all per-frame trajectory methods for border truncation (only _compute_movement_exclude_border, _compute_movememnt_adaptive_border, and _compute_movement_acceleration_exclude_border truncate border rows) and updated _plot_violin_xy so plot_speed_distribution / plot_density_distribution drop NaN entries cleanly instead of failing on NaN-padded inputs.
  • Documentation & tests: Documented BorderFillMethod and border_fill in the API docstrings and notebooks/user_guide.ipynb, and added unit tests in tests/unit_tests/methods/test_border_fill.py.

@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.68%. Comparing base (0604d9a) to head (1065fc2).

Files with missing lines Patch % Lines
pedpy/methods/method_utils.py 95.23% 1 Missing ⚠️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

Add fill strategy parameter to individual speed and accleration computation for border frames

1 participant