Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When running Quality Report, ContingencySimilarity produces a RuntimeWarning (The values in the array are unorderable.) #657

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def compute(cls, real_data, synthetic_data):
contingency_synthetic = synthetic.groupby(list(columns), dropna=False).size() / len(
synthetic
)
combined_index = contingency_real.index.union(contingency_synthetic.index)
combined_index = contingency_real.index.union(contingency_synthetic.index, sort=False)
contingency_synthetic = contingency_synthetic.reindex(combined_index, fill_value=0)
contingency_real = contingency_real.reindex(combined_index, fill_value=0)
diff = abs(contingency_real - contingency_synthetic).fillna(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def test_quality_report_with_errors():
None,
],
})
assert score == 0.7249603174603174
assert score == 0.7249603174603175
pd.testing.assert_frame_equal(properties, expected_properties)
pd.testing.assert_frame_equal(details_column_shapes, expected_details)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest.mock import patch

import pandas as pd
import pytest

from sdmetrics.column_pairs.statistical import ContingencySimilarity

Expand Down Expand Up @@ -53,3 +54,15 @@ def test_normalize(self, normalize_mock):
# Assert
normalize_mock.assert_called_once_with(raw_score)
assert result == normalize_mock.return_value

@pytest.mark.filterwarnings('error:.*The values in the array are unorderable.*:RuntimeWarning')
def test_no_runtime_warning_raised(self):
"""Test that no RuntimeWarning warning is raised when the metric is computed."""
# Setup
real_data = pd.DataFrame(data={'A': ['value'] * 4, 'B': ['1', '2', '3', pd.NA]})
synthetic_data = pd.DataFrame(data={'A': ['value'] * 3, 'B': ['1', '2', pd.NA]})

# Run and Assert
ContingencySimilarity.compute(
real_data=real_data[['A', 'B']], synthetic_data=synthetic_data[['A', 'B']]
)
Loading