|
1 | 1 | import json |
| 2 | +import math |
2 | 3 | import os |
3 | 4 | import unittest |
4 | 5 | from collections import defaultdict |
@@ -731,7 +732,44 @@ def test_categorical_diff(self): |
731 | 732 | }, |
732 | 733 | } |
733 | 734 | actual_diff = profile.diff(profile2) |
734 | | - self.assertDictEqual(expected_diff, actual_diff) |
| 735 | + |
| 736 | + assert expected_diff["categorical"] == actual_diff["categorical"] |
| 737 | + assert ( |
| 738 | + expected_diff["statistics"]["unique_count"] |
| 739 | + == actual_diff["statistics"]["unique_count"] |
| 740 | + ) |
| 741 | + assert math.isclose( |
| 742 | + expected_diff["statistics"]["unique_ratio"], |
| 743 | + actual_diff["statistics"]["unique_ratio"], |
| 744 | + ) |
| 745 | + assert ( |
| 746 | + expected_diff["statistics"]["categories"] |
| 747 | + == actual_diff["statistics"]["categories"] |
| 748 | + ) |
| 749 | + assert math.isclose( |
| 750 | + expected_diff["statistics"]["gini_impurity"], |
| 751 | + actual_diff["statistics"]["gini_impurity"], |
| 752 | + ) |
| 753 | + assert math.isclose( |
| 754 | + expected_diff["statistics"]["unalikeability"], |
| 755 | + actual_diff["statistics"]["unalikeability"], |
| 756 | + ) |
| 757 | + assert ( |
| 758 | + expected_diff["statistics"]["categorical_count"] |
| 759 | + == actual_diff["statistics"]["categorical_count"] |
| 760 | + ) |
| 761 | + assert math.isclose( |
| 762 | + expected_diff["statistics"]["chi2-test"]["chi2-statistic"], |
| 763 | + actual_diff["statistics"]["chi2-test"]["chi2-statistic"], |
| 764 | + ) |
| 765 | + assert ( |
| 766 | + expected_diff["statistics"]["chi2-test"]["deg_of_free"] |
| 767 | + == actual_diff["statistics"]["chi2-test"]["deg_of_free"] |
| 768 | + ) |
| 769 | + assert math.isclose( |
| 770 | + expected_diff["statistics"]["chi2-test"]["p-value"], |
| 771 | + actual_diff["statistics"]["chi2-test"]["p-value"], |
| 772 | + ) |
735 | 773 |
|
736 | 774 | # Test with one categorical column matching |
737 | 775 | df_not_categorical = pd.Series( |
|
0 commit comments