-
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
4 changed files
with
316 additions
and
7 deletions.
There are no files selected for viewing
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
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
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,27 @@ | ||
import re | ||
|
||
import pandas as pd | ||
import pytest | ||
|
||
from sdmetrics.single_table.privacy.cap import ( | ||
CategoricalCAP, | ||
CategoricalGeneralizedCAP, | ||
CategoricalZeroCAP, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize('metric', [CategoricalCAP, CategoricalZeroCAP, CategoricalGeneralizedCAP]) | ||
def test_CAP_deprecation_message(metric): | ||
"""Test deprecation warning is raised when running the metric directly.""" | ||
# Setup | ||
real_data = pd.DataFrame({'col1': range(5), 'col2': ['A', 'B', 'C', 'A', 'B']}) | ||
synthetic_data = pd.DataFrame({'col1': range(5), 'col2': ['C', 'A', 'A', 'B', 'C']}) | ||
|
||
# Run and Assert | ||
expected_warning = re.escape( | ||
'Computing CAP metrics directly is deprecated. For improved privacy metrics, ' | ||
"please use the 'DisclosureProtection' and 'DisclosureProtectionEstimate' " | ||
'metrics instead.' | ||
) | ||
with pytest.warns(DeprecationWarning, match=expected_warning): | ||
metric.compute(real_data, synthetic_data, key_fields=['col1'], sensitive_fields=['col2']) |
Oops, something went wrong.