Skip to content

Commit

Permalink
set validate_metadata_matches_data in diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Palazzo committed Nov 21, 2023
1 parent 3bb2392 commit d58d19d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 39 deletions.
3 changes: 0 additions & 3 deletions sdmetrics/reports/base_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions sdmetrics/reports/multi_table/diagnostic_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 3 additions & 0 deletions sdmetrics/reports/single_table/diagnostic_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
36 changes: 0 additions & 36 deletions tests/unit/reports/single_table/test_diagnostic_report.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

0 comments on commit d58d19d

Please sign in to comment.