Skip to content

Commit 3efa752

Browse files
committed
Change validation between 0, 1
1 parent 126432c commit 3efa752

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

sdmetrics/column_pairs/statistical/contingency_similarity.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ def _validate_inputs(
6363
if (
6464
not isinstance(real_association_threshold, (int, float))
6565
or real_association_threshold < 0
66+
or real_association_threshold > 1
6667
):
67-
raise ValueError(
68-
'`real_association_threshold` must be a number greater than or equal to zero.'
69-
)
68+
raise ValueError('real_association_threshold must be a number between 0 and 1.')
7069

7170
@classmethod
7271
def compute_breakdown(
@@ -105,7 +104,7 @@ def compute_breakdown(
105104
if real_association_threshold > 0:
106105
contingency_2d = contingency_real_counts.unstack(fill_value=0) # noqa: PD010
107106
real_cramer = association(contingency_2d.values, method='cramer')
108-
if real_cramer < real_association_threshold:
107+
if real_cramer <= real_association_threshold:
109108
return {'score': np.nan}
110109

111110
contingency_real = contingency_real_counts / len(real)

tests/unit/column_pairs/statistical/test_contingency_similarity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def test__validate_inputs(self):
9292
)
9393

9494
expected_bad_threshold_error = re.escape(
95-
'`real_association_threshold` must be a number greater than or equal to zero.'
95+
'real_association_threshold must be a number between 0 and 1.'
9696
)
9797
with pytest.raises(ValueError, match=expected_bad_threshold_error):
9898
ContingencySimilarity._validate_inputs(

0 commit comments

Comments
 (0)