From d58d19d64b6c69ae3303192289685e0d96856d44 Mon Sep 17 00:00:00 2001 From: R-Palazzo Date: Tue, 21 Nov 2023 16:13:34 -0600 Subject: [PATCH] set validate_metadata_matches_data in diagnostic --- sdmetrics/reports/base_report.py | 3 -- .../reports/multi_table/diagnostic_report.py | 3 ++ .../reports/single_table/diagnostic_report.py | 3 ++ .../single_table/test_diagnostic_report.py | 36 ------------------- 4 files changed, 6 insertions(+), 39 deletions(-) diff --git a/sdmetrics/reports/base_report.py b/sdmetrics/reports/base_report.py index 285ce04f..bf72906f 100644 --- a/sdmetrics/reports/base_report.py +++ b/sdmetrics/reports/base_report.py @@ -80,9 +80,6 @@ def _validate(self, real_data, synthetic_data, metadata): The metadata of the table. """ self._validate_data_format(real_data, synthetic_data) - if self.__class__.__name__ == 'DiagnosticReport': - return - self._validate_metadata_matches_data(real_data, synthetic_data, metadata) @staticmethod diff --git a/sdmetrics/reports/multi_table/diagnostic_report.py b/sdmetrics/reports/multi_table/diagnostic_report.py index 6ccaa9bf..9428f9d8 100644 --- a/sdmetrics/reports/multi_table/diagnostic_report.py +++ b/sdmetrics/reports/multi_table/diagnostic_report.py @@ -17,3 +17,6 @@ def __init__(self): 'Data Structure': Structure(), 'Relationship Validity': RelationshipValidity() } + + def _validate_metadata_matches_data(self, real_data, synthetic_data, metadata): + self._validate_relationships(real_data, synthetic_data, metadata) diff --git a/sdmetrics/reports/single_table/diagnostic_report.py b/sdmetrics/reports/single_table/diagnostic_report.py index 4e36815e..1e96fc81 100644 --- a/sdmetrics/reports/single_table/diagnostic_report.py +++ b/sdmetrics/reports/single_table/diagnostic_report.py @@ -16,3 +16,6 @@ def __init__(self): 'Data Validity': DataValidity(), 'Data Structure': Structure(), } + + def _validate_metadata_matches_data(self, real_data, synthetic_data, metadata): + return diff --git a/tests/unit/reports/single_table/test_diagnostic_report.py b/tests/unit/reports/single_table/test_diagnostic_report.py index fb1af0be..b744ce98 100644 --- a/tests/unit/reports/single_table/test_diagnostic_report.py +++ b/tests/unit/reports/single_table/test_diagnostic_report.py @@ -1,7 +1,3 @@ -from unittest.mock import Mock - -import pandas as pd - from sdmetrics.reports.single_table import DiagnosticReport from sdmetrics.reports.single_table._properties import DataValidity, Structure @@ -18,35 +14,3 @@ def test___init__(self): assert report.is_generated is False assert isinstance(report._properties['Data Validity'], DataValidity) assert isinstance(report._properties['Data Structure'], Structure) - - def test__validate_with_data_metadata_mismatch(self): - """Test the ``_validate`` method doesn't raise an error.""" - # Setup - base_report = DiagnosticReport() - mock__validate_metadata_matches_data = Mock( - side_effect=ValueError('error message') - ) - base_report._validate_metadata_matches_data = mock__validate_metadata_matches_data - - real_data = pd.DataFrame({ - 'column1': [1, 2, 3], - 'column2': ['a', 'b', 'c'], - 'column3': [4, 5, 6] - }) - synthetic_data = pd.DataFrame({ - 'column1': [1, 2, 3], - 'column2': ['a', 'b', 'c'], - 'column4': [4, 5, 6] - }) - metadata = { - 'columns': { - 'column1': {'sdtype': 'numerical'}, - 'column2': {'sdtype': 'categorical'}, - } - } - - # Run - result = base_report._validate(real_data, synthetic_data, metadata) - - # Assert - assert result is None