Skip to content

Commit

Permalink
fix + test
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Palazzo committed Nov 16, 2023
1 parent a8a8b44 commit 1551d07
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 1 addition & 5 deletions sdmetrics/reports/multi_table/_properties/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Multi table base property class."""
import warnings

import numpy as np
import pandas as pd

Expand Down Expand Up @@ -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()]
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/reports/multi_table/test_diagnostic_report.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)

0 comments on commit 1551d07

Please sign in to comment.