feat: add exclude_missing_ball_frames option for all tracking providers - #600
Open
aleks-drozy wants to merge 1 commit into
Open
feat: add exclude_missing_ball_frames option for all tracking providers#600aleks-drozy wants to merge 1 commit into
aleks-drozy wants to merge 1 commit into
Conversation
…iders Adds an exclude_missing_ball_frames parameter (default False) to the tracking deserializers for PFF, Second Spectrum, SkillCorner, Sportec, StatsPerform, and Tracab. When enabled, frames with sentinel/missing ball coordinates are parsed with ball_coordinates=None instead of being silently dropped or producing bogus values, matching the design converged on in PySport#523 discussion. Sportec has no native missing-ball sentinel, so the flag is accepted as a documented no-op there for interface consistency. Addresses PySport#528.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #528.
Adds an
exclude_missing_ball_frames: bool = Falseparameter to every tracking provider (PFF, Second Spectrum, SkillCorner, Sportec, StatsPerform, Tracab), threaded throughTrackingDataDeserializer.__init__and stored asself.exclude_missing_ball_frames. When enabled, frames whereball_coordinates is Noneafter parsing are skipped, matching the design agreed on in the #523 discussion (which only covered Second Spectrum).Additionally, for Second Spectrum specifically, I found the deserializer was not parsing the provider's own missing-ball sentinel: it uses a ball z-coordinate of
-10to mean "not tracked", but the code was previously constructing a literalPoint3D(x, y, -10)for those frames instead ofNone. That's fixed soball_coordinatesisNonefor sentinel frames regardless of whetherexclude_missing_ball_framesis set — this seemed like the correct fix rather than working around it, since otherwise the new flag would have nothing to filter on Second Spectrum data containing the sentinel.For the other five providers, missing-ball frames come from data that's simply absent/null in the source (no numeric sentinel), so no equivalent sentinel-parsing fix was needed there — just the new opt-in filter.
Testing:
test_missing_ball_sentinel_parsed_as_nonefor Second Spectrum, using a small fixture file with one normal frame and one sentinel (z=-10) frame, asserting the sentinel frame parses toball_coordinates=None.test_exclude_missing_ball_framestest per provider, verifying the flag actually filters outNone-ball frames.81 passed.ruff check/ruff format --check: clean.Happy to adjust naming/scope if you'd prefer a different API shape than what #523 converged on.