diff --git a/sdmetrics/reports/multi_table/_properties/base.py b/sdmetrics/reports/multi_table/_properties/base.py index 1ca70f18..4c063660 100644 --- a/sdmetrics/reports/multi_table/_properties/base.py +++ b/sdmetrics/reports/multi_table/_properties/base.py @@ -1,6 +1,4 @@ """Multi table base property class.""" -import warnings - import numpy as np import pandas as pd @@ -37,9 +35,7 @@ def _get_num_iterations(self, metadata): elif self._num_iteration_case == 'relationship': try: return len(metadata['relationships']) - except KeyError as e: - message = f'{type(e).__name__}: {e}. No relationships found in the data.' - warnings.warn(message) + except KeyError: return 0 elif self._num_iteration_case == 'column_pair': num_columns = [len(table['columns']) for table in metadata['tables'].values()] diff --git a/tests/integration/reports/multi_table/test_diagnostic_report.py b/tests/integration/reports/multi_table/test_diagnostic_report.py index 0e0dcb76..986075a9 100644 --- a/tests/integration/reports/multi_table/test_diagnostic_report.py +++ b/tests/integration/reports/multi_table/test_diagnostic_report.py @@ -1,5 +1,6 @@ import numpy as np import pandas as pd +import pytest from sdmetrics.demos import load_demo from sdmetrics.reports.multi_table import DiagnosticReport @@ -170,3 +171,14 @@ def test_get_details_with_table_name(self): }) pd.testing.assert_frame_equal(details, expected_dataframe) + + def test_metadata_without_relationship(self): + """Test that no warning is raised when the metadata does not contain relationships.""" + # Setup + real_data, synthetic_data, metadata = load_demo(modality='multi_table') + del metadata['relationships'] + report = DiagnosticReport() + + # Run and Assert + with pytest.warns(None): + report.generate(real_data, synthetic_data, metadata)