-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
tests/integration/reports/multi_table/_properties/test_structure.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from unittest.mock import Mock | ||
|
||
import pandas as pd | ||
from tqdm import tqdm | ||
|
||
from sdmetrics.demos import load_demo | ||
from sdmetrics.reports.multi_table._properties import Structure | ||
|
||
|
||
class TestStructure: | ||
|
||
def test_end_to_end(self): | ||
"""Test Structure multi-table.""" | ||
# Setup | ||
real_data, synthetic_data, metadata = load_demo(modality='multi_table') | ||
structure = Structure() | ||
|
||
# Run | ||
result = structure.get_score(real_data, synthetic_data, metadata) | ||
|
||
# Assert | ||
assert result == 1.0 | ||
|
||
expected_details = pd.DataFrame({ | ||
'Table': ['users', 'sessions', 'transactions'], | ||
'Metric': ['TableFormat', 'TableFormat', 'TableFormat'], | ||
'Score': [1.0, 1.0, 1.0], | ||
}) | ||
pd.testing.assert_frame_equal(structure.details, expected_details) | ||
|
||
def test_with_progress_bar(self): | ||
"""Test that the progress bar is correctly updated.""" | ||
# Setup | ||
real_data, synthetic_data, metadata = load_demo(modality='multi_table') | ||
structure = Structure() | ||
num_tables = len(metadata['tables']) | ||
|
||
progress_bar = tqdm(total=num_tables) | ||
mock_update = Mock() | ||
progress_bar.update = mock_update | ||
|
||
# Run | ||
result = structure.get_score(real_data, synthetic_data, metadata, progress_bar) | ||
|
||
# Assert | ||
assert result == 1.0 | ||
assert mock_update.call_count == num_tables |
14 changes: 14 additions & 0 deletions
14
tests/unit/reports/multi_table/_properties/test_structure.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""Test Structure multi-table class.""" | ||
from sdmetrics.reports.multi_table._properties import Structure | ||
from sdmetrics.reports.single_table._properties import Structure as SingleTableStructure | ||
|
||
|
||
def test__init__(): | ||
"""Test the ``__init__`` method.""" | ||
# Setup | ||
synthesis = Structure() | ||
|
||
# Assert | ||
assert synthesis._properties == {} | ||
assert synthesis._single_table_property == SingleTableStructure | ||
assert synthesis._num_iteration_case == 'table' |