Skip to content

Add opt-in correction for zero-duration survey activities - #402

Merged
FlxPo merged 2 commits into
mainfrom
feature/survey-zero-duration-correction
Jul 30, 2026
Merged

Add opt-in correction for zero-duration survey activities#402
FlxPo merged 2 commits into
mainfrom
feature/survey-zero-duration-correction

Conversation

@FlxPo

@FlxPo FlxPo commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Motivation

Rounded survey clocks can produce zero-duration activities when one trip arrives at the same reported time the next trip departs. These zeros distort downstream activity-duration distributions.

Changes

  • Add the opt-in correct_zero_durations survey parameter.
  • Fit corrections reproducibly from the survey using weighted, interval-censored Gamma distributions.
  • Apply corrections during EMP survey creation and include the flag in the cache hash.
  • Share available travel time across adjacent corrections so trips cannot become negative.
  • Raise ValueError for ENTD until its parser loads and standardizes the trip times already present in the survey.
  • Add tests and user/method documentation.

Example (if relevant)

survey = mobility.EMPMobilitySurvey(
    correct_zero_durations=True,
)

The feature is disabled by default and does not require an external CSV.

AI-assisted contribution

  • AI used for substantial parts of this PR

If substantial, briefly describe:

  • Scope of AI-assisted content: implementation, tests, refactoring, and documentation.
  • What you reviewed or changed: survey API, correction method, capacity constraints, and ENTD handling.
  • How you validated it: focused tests, downstream MRMT tests, strict documentation build, and compilation checks.

Checklist

  • I have reviewed all code in this PR
  • I understand the code and can maintain it
  • I added or ran appropriate tests/checks for the changed behavior

@FlxPo
FlxPo changed the base branch from work/cch-parquet-cache-current to main July 30, 2026 15:16
@FlxPo FlxPo closed this Jul 30, 2026
@FlxPo FlxPo reopened this Jul 30, 2026
@FlxPo FlxPo closed this Jul 30, 2026
@FlxPo FlxPo reopened this Jul 30, 2026
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.10490% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.97%. Comparing base (8795552) to head (cb52d4d).

Files with missing lines Patch % Lines
mobility/surveys/zero_duration_activities.py 94.53% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #402      +/-   ##
==========================================
+ Coverage   82.86%   82.97%   +0.10%     
==========================================
  Files         231      232       +1     
  Lines       15835    15978     +143     
==========================================
+ Hits        13121    13257     +136     
- Misses       2714     2721       +7     

☔ 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.

@FlxPo
FlxPo merged commit a193347 into main Jul 30, 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.

1 participant