Coverage for intelligence_toolkit/tests/unit/anonymize_case_data/test_synthesizability_statistics.py: 100%
31 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-16 13:41 -0300
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-16 13:41 -0300
1# Copyright (c) 2024 Microsoft Corporation. All rights reserved.
2# Licensed under the MIT license. See LICENSE file in the project.
4import pytest
5from intelligence_toolkit.anonymize_case_data.synthesizability_statistics import (
6 SynthesizabilityStatistics,
7)
10def test_synthesizability_statistics_initialization():
11 stats = SynthesizabilityStatistics(
12 num_cols=5,
13 overall_att_count=100,
14 possible_combinations=1000,
15 possible_combinations_per_row=10.5,
16 mean_vals_per_record=3.2,
17 max_combinations_per_record=9.2,
18 excess_combinations_ratio=1.14,
19 )
21 assert stats.num_cols == 5
22 assert stats.overall_att_count == 100
23 assert stats.possible_combinations == 1000
24 assert stats.possible_combinations_per_row == 10.5
25 assert stats.mean_vals_per_record == 3.2
26 assert stats.max_combinations_per_record == 9.2
27 assert stats.excess_combinations_ratio == 1.14
30def test_synthesizability_statistics_repr():
31 stats = SynthesizabilityStatistics(
32 num_cols=3,
33 overall_att_count=50,
34 possible_combinations=500,
35 possible_combinations_per_row=5.0,
36 mean_vals_per_record=2.5,
37 max_combinations_per_record=5.7,
38 excess_combinations_ratio=0.88,
39 )
41 repr_str = repr(stats)
43 assert "SynthesizabilityStatistics" in repr_str
44 assert "num_cols=3" in repr_str
45 assert "overall_att_count=50" in repr_str
46 assert "possible_combinations=500" in repr_str
47 assert "possible_combinations_per_row=5.0" in repr_str
48 assert "mean_vals_per_record=2.5" in repr_str
49 assert "max_combinations_per_record=5.7" in repr_str
50 assert "excess_combinations_ratio=0.88" in repr_str
53def test_synthesizability_statistics_zero_values():
54 stats = SynthesizabilityStatistics(
55 num_cols=0,
56 overall_att_count=0,
57 possible_combinations=0,
58 possible_combinations_per_row=0.0,
59 mean_vals_per_record=0.0,
60 max_combinations_per_record=0.0,
61 excess_combinations_ratio=0.0,
62 )
64 assert stats.num_cols == 0
65 assert stats.overall_att_count == 0
66 assert stats.possible_combinations == 0
67 assert stats.possible_combinations_per_row == 0.0
68 assert stats.mean_vals_per_record == 0.0
69 assert stats.max_combinations_per_record == 0.0
70 assert stats.excess_combinations_ratio == 0.0