Skip to content

Commit

Permalink
Fix problem with missing reference in TestCorrelationChanges.
Browse files Browse the repository at this point in the history
  • Loading branch information
Liraim committed Oct 23, 2024
1 parent 9035eb2 commit 35fbad6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/evidently/tests/data_quality_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,10 @@ def calculate_value_for_test(self) -> Optional[Numeric]:
return (diff.abs() > self.corr_diff).sum().sum() / 2

current_correlations = current_correlations[self.column_name.display_name]
if reference_correlations is not None:
reference_correlations = reference_correlations[self.column_name.display_name]
diff = reference_correlations - current_correlations
if reference_correlations is None:
raise ValueError("Reference is required for test")
reference_correlations_data = reference_correlations[self.column_name.display_name]
diff = reference_correlations_data - current_correlations
return (diff.abs() > self.corr_diff).sum()

def get_description(self, value: Numeric) -> str:
Expand Down Expand Up @@ -1708,7 +1709,7 @@ def get_parameters(self) -> CheckValueParameters:
@default_renderer(wrap_type=TestCategoryShare)
class TestCategoryRenderer(TestRenderer):
@staticmethod
def _get_number_and_percents(s: pd.Series, num: int) -> pd.DataFrame:
def _get_number_and_percents(s: pd.Series, num: int) -> pd.Series:
"""Get a string with missing values numbers and percents from info for results table"""
return s.astype(str) + " (" + (s / num * 100).round(2).astype(str) + "%)"

Expand Down

0 comments on commit 35fbad6

Please sign in to comment.