Skip to content

Commit

Permalink
docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Palazzo committed Oct 23, 2023
1 parent f6dfb3e commit 7b360b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions sdmetrics/single_column/statistical/key_uniqueness.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class KeyUniqueness(SingleColumnMetric):
"""Key uniqueness metric.
Compute the fraction of rows in the synthetic data that are unique.
The proportion of data points in the synthetic data that are unique.
Attributes:
name (str):
Expand Down Expand Up @@ -51,7 +51,7 @@ def compute_breakdown(cls, real_data, synthetic_data):

@classmethod
def compute(cls, real_data, synthetic_data):
"""Compute the key uniqueness of two columns.
"""Compute the key uniqueness metric.
Args:
real_data (pandas.Series):
Expand All @@ -61,7 +61,7 @@ def compute(cls, real_data, synthetic_data):
Returns:
float:
The key uniqueness of the two columns.
The proportion of data points in the synthetic data that are unique.
"""
return cls.compute_breakdown(real_data, synthetic_data)['score']

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/single_column/statistical/test_key_uniqueness.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_compute_breakdown_with_duplicates_in_real_data(self):
synthetic_data = pd.Series([1, 2, np.nan, 3, np.nan, 5, 2, np.nan, 6, None])
metric = KeyUniqueness()

# Run
# Run and Assert
expected_message = 'The real data contains NA or duplicate values.'
with pytest.raises(InvalidDataError, match=expected_message):
metric.compute_breakdown(real_data, synthetic_data)
Expand All @@ -49,6 +49,7 @@ def test_compute(self, compute_breakdown_mock):
result = metric.compute(real_data, synthetic_data)

# Assert
compute_breakdown_mock.assert_called_once_with(real_data, synthetic_data)
assert result == 0.6

@patch('sdmetrics.single_column.statistical.key_uniqueness.SingleColumnMetric.normalize')
Expand Down

0 comments on commit 7b360b5

Please sign in to comment.