Coverage for tests\utils\test_frequency.py: 100.00%
6 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-17 13:31 +0100
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-17 13:31 +0100
1# -*- coding: utf-8 -*-
3"""
4* Name: interactive-clustering/tests/utils/test_frequency.py
5* Description: Unittests for the `utils.frequency` module.
6* Author: Erwan SCHILD
7* Created: 17/03/2021
8* Licence: CeCILL (https://cecill.info/licences.fr.html)
9"""
11# ==============================================================================
12# IMPORT PYTHON DEPENDENCIES
13# ==============================================================================
15from cognitivefactory.interactive_clustering.utils.frequency import compute_clusters_frequency
18# ==============================================================================
19# test_compute_clusters_frequency_for_no_clustering_result
20# ==============================================================================
21def test_compute_clusters_frequency_for_no_clustering_result():
22 """
23 Test that the `utils.frequency.compute_clusters_frequency` works for no `clustering_result`.
24 """
26 # Check for no `clustering_result`.
27 assert not compute_clusters_frequency(clustering_result={})
30# ==============================================================================
31# test_compute_clusters_frequency_for_correct_clustering_result
32# ==============================================================================
33def test_compute_clusters_frequency_for_correct_clustering_result():
34 """
35 Test that the `utils.frequency.compute_clusters_frequency` works for correct `clustering_result`.
36 """
38 # Check for no `clustering_result`.
39 assert compute_clusters_frequency(
40 clustering_result={
41 "01": 0,
42 "02": 0,
43 "03": 0,
44 "04": 0,
45 "05": 0,
46 "06": 1,
47 "07": 1,
48 "08": 2,
49 "09": 2,
50 "10": 2,
51 }
52 ) == {
53 0: 0.5,
54 1: 0.2,
55 2: 0.3,
56 }