Skip to content

fix(stattests): handle empty series inputs across divergence stat tests (#1900)#1901

Open
ArjunPakhan wants to merge 1 commit into
evidentlyai:mainfrom
ArjunPakhan:fix/divergence-stat-tests-empty-inputs
Open

fix(stattests): handle empty series inputs across divergence stat tests (#1900)#1901
ArjunPakhan wants to merge 1 commit into
evidentlyai:mainfrom
ArjunPakhan:fix/divergence-stat-tests-empty-inputs

Conversation

@ArjunPakhan

Copy link
Copy Markdown

Description

Fixes #1900.

When passing empty pd.Series([]) inputs into psi_stat_test, kl_div_stat_test, jensenshannon_stat_test, or hellinger_stat_test, the functions previously failed with ZeroDivisionError or ValueError: min() iterable argument is empty.

Changes Made

  1. Added early guard checks (reference_data.empty or current_data.empty) to return (np.nan, False) across _psi, _kl_div, _jensenshannon, and _hellinger_distance.
  2. Protected feel_zeroes and bin calculation in utils.py against empty sequence aggregations.
  3. Added unit tests in tests/stattests/test_empty_inputs.py to ensure empty inputs yield (np.nan, False) without throwing exceptions.

Testing

  • python -m pytest tests/stattests/test_empty_inputs.py (All 4 tests passing)

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.

Divergence stat tests crash or silently return wrong results on edge case inputs

1 participant