|
18 | 18 | get_required_lifting, |
19 | 19 | set_preserve_edge_attr, |
20 | 20 | check_pses_in_transforms, |
| 21 | + check_fes_in_transforms, |
| 22 | + get_fes_dimensions, |
| 23 | + get_all_encoding_dimensions, |
21 | 24 | ) |
22 | 25 |
|
23 | 26 | class TestConfigResolvers: |
@@ -733,3 +736,154 @@ def test_check_pses_in_transforms_mixed_combined_and_separate_with_new_encodings |
733 | 736 | }) |
734 | 737 | result = check_pses_in_transforms(transforms) |
735 | 738 | assert result == 24 # (8 + 4) + 7 + 5 |
| 739 | + |
| 740 | + def test_check_fes_in_transforms_empty(self): |
| 741 | + """Test check_fes_in_transforms with no encodings.""" |
| 742 | + transforms = OmegaConf.create({}) |
| 743 | + assert check_fes_in_transforms(transforms) == 0 |
| 744 | + |
| 745 | + def test_check_fes_single_transform_pprfe_list(self): |
| 746 | + """Single flat PPRFE: alpha list uses second element (ListConfig path).""" |
| 747 | + transforms = OmegaConf.create( |
| 748 | + { |
| 749 | + "transform_name": "PPRFE", |
| 750 | + "alpha_param_PPRFE": [0.1, 5], |
| 751 | + } |
| 752 | + ) |
| 753 | + assert check_fes_in_transforms(transforms) == 5 |
| 754 | + |
| 755 | + def test_check_fes_single_transform_pprfe_scalar(self): |
| 756 | + """Single flat PPRFE: scalar alpha counts as fixed dimension.""" |
| 757 | + transforms = OmegaConf.create( |
| 758 | + { |
| 759 | + "transform_name": "PPRFE", |
| 760 | + "alpha_param_PPRFE": 4, |
| 761 | + } |
| 762 | + ) |
| 763 | + assert check_fes_in_transforms(transforms) == 4 |
| 764 | + |
| 765 | + def test_check_fes_single_transform_sheaf(self): |
| 766 | + """Single flat SheafConnLapPE uses max_pe_dim.""" |
| 767 | + transforms = OmegaConf.create( |
| 768 | + {"transform_name": "SheafConnLapPE", "max_pe_dim": 6} |
| 769 | + ) |
| 770 | + assert check_fes_in_transforms(transforms) == 6 |
| 771 | + |
| 772 | + def test_check_fes_keyed_pprfe_list(self): |
| 773 | + """Keyed transform whose name contains PPRFE.""" |
| 774 | + transforms = OmegaConf.create( |
| 775 | + {"run_PPRFE_1": {"alpha_param_PPRFE": [0.1, 8]}} |
| 776 | + ) |
| 777 | + assert check_fes_in_transforms(transforms) == 8 |
| 778 | + |
| 779 | + def test_check_fes_keyed_pprfe_scalar(self): |
| 780 | + """Keyed PPRFE with scalar alpha_param.""" |
| 781 | + transforms = OmegaConf.create({"extra_PPRFE": {"alpha_param_PPRFE": 3}}) |
| 782 | + assert check_fes_in_transforms(transforms) == 3 |
| 783 | + |
| 784 | + def test_check_fes_keyed_sheaf(self): |
| 785 | + """Keyed transform whose name contains SheafConnLapPE.""" |
| 786 | + transforms = OmegaConf.create( |
| 787 | + {"custom_SheafConnLapPE": {"max_pe_dim": 9}} |
| 788 | + ) |
| 789 | + assert check_fes_in_transforms(transforms) == 9 |
| 790 | + |
| 791 | + def test_check_fes_combined_fes_pprfe_and_sheaf(self): |
| 792 | + """CombinedFEs inner loop: PPRFE list + SheafConnLapPE.""" |
| 793 | + transforms = OmegaConf.create( |
| 794 | + { |
| 795 | + "CombinedFEs": { |
| 796 | + "encodings": ["PPRFE", "SheafConnLapPE"], |
| 797 | + "parameters": { |
| 798 | + "PPRFE": {"alpha_param_PPRFE": [0.1, 7], "concat_to_x": True}, |
| 799 | + "SheafConnLapPE": { |
| 800 | + "max_pe_dim": 4, |
| 801 | + "stalk_dim": 2, |
| 802 | + "concat_to_x": True, |
| 803 | + }, |
| 804 | + }, |
| 805 | + } |
| 806 | + } |
| 807 | + ) |
| 808 | + assert check_fes_in_transforms(transforms) == 7 + 4 |
| 809 | + |
| 810 | + def test_check_fes_combined_fes_pprfe_default_alpha(self): |
| 811 | + """CombinedFEs PPRFE: missing alpha_param uses default [0.1, 10] -> 10.""" |
| 812 | + transforms = OmegaConf.create( |
| 813 | + { |
| 814 | + "CombinedFEs": { |
| 815 | + "encodings": ["PPRFE"], |
| 816 | + "parameters": {"PPRFE": {"concat_to_x": True}}, |
| 817 | + } |
| 818 | + } |
| 819 | + ) |
| 820 | + assert check_fes_in_transforms(transforms) == 10 |
| 821 | + |
| 822 | + def test_check_fes_combined_fes_pprfe_scalar_alpha(self): |
| 823 | + """CombinedFEs PPRFE: scalar alpha_param.""" |
| 824 | + transforms = OmegaConf.create( |
| 825 | + { |
| 826 | + "CombinedFEs": { |
| 827 | + "encodings": ["PPRFE"], |
| 828 | + "parameters": { |
| 829 | + "PPRFE": {"alpha_param_PPRFE": 11, "concat_to_x": True} |
| 830 | + }, |
| 831 | + } |
| 832 | + } |
| 833 | + ) |
| 834 | + assert check_fes_in_transforms(transforms) == 11 |
| 835 | + |
| 836 | + def test_get_fes_dimensions_khopfe(self): |
| 837 | + """get_fes_dimensions: KHopFE uses max_hop - 1.""" |
| 838 | + encodings = ["KHopFE"] |
| 839 | + parameters = {"KHopFE": {"max_hop": 5}} |
| 840 | + assert get_fes_dimensions(encodings, parameters) == [4] |
| 841 | + |
| 842 | + def test_get_fes_dimensions_pprfe_list_tuple(self): |
| 843 | + """get_fes_dimensions: PPRFE alpha as tuple -> second element.""" |
| 844 | + encodings = ["PPRFE"] |
| 845 | + parameters = {"PPRFE": {"alpha_param_PPRFE": (0.1, 6)}} |
| 846 | + assert get_fes_dimensions(encodings, parameters) == [6] |
| 847 | + |
| 848 | + def test_get_fes_dimensions_pprfe_omegaconf_list(self): |
| 849 | + """get_fes_dimensions: PPRFE alpha as OmegaConf list.""" |
| 850 | + parameters = OmegaConf.create( |
| 851 | + {"PPRFE": {"alpha_param_PPRFE": [0.1, 12]}} |
| 852 | + ) |
| 853 | + assert get_fes_dimensions(["PPRFE"], parameters) == [12] |
| 854 | + |
| 855 | + def test_get_fes_dimensions_pprfe_scalar(self): |
| 856 | + """get_fes_dimensions: PPRFE scalar alpha.""" |
| 857 | + encodings = ["PPRFE"] |
| 858 | + parameters = {"PPRFE": {"alpha_param_PPRFE": 5}} |
| 859 | + assert get_fes_dimensions(encodings, parameters) == [5] |
| 860 | + |
| 861 | + def test_get_fes_dimensions_pprfe_missing_uses_default(self): |
| 862 | + """get_fes_dimensions: missing PPRFE block uses default alpha upper bound 10.""" |
| 863 | + assert get_fes_dimensions(["PPRFE"], {}) == [10] |
| 864 | + |
| 865 | + def test_get_fes_dimensions_sheaf(self): |
| 866 | + """get_fes_dimensions: SheafConnLapPE.""" |
| 867 | + encodings = ["SheafConnLapPE"] |
| 868 | + parameters = {"SheafConnLapPE": {"max_pe_dim": 8}} |
| 869 | + assert get_fes_dimensions(encodings, parameters) == [8] |
| 870 | + |
| 871 | + def test_get_all_encoding_dimensions_khopfe_pprfe_sheaf(self): |
| 872 | + """get_all_encoding_dimensions: FE branches KHopFE, PPRFE list, SheafConnLapPE.""" |
| 873 | + encodings = ["KHopFE", "PPRFE", "SheafConnLapPE"] |
| 874 | + parameters = { |
| 875 | + "KHopFE": {"max_hop": 4}, |
| 876 | + "PPRFE": {"alpha_param_PPRFE": [0.1, 9]}, |
| 877 | + "SheafConnLapPE": {"max_pe_dim": 3}, |
| 878 | + } |
| 879 | + assert get_all_encoding_dimensions(encodings, parameters) == [3, 9, 3] |
| 880 | + |
| 881 | + def test_get_all_encoding_dimensions_pprfe_scalar(self): |
| 882 | + """get_all_encoding_dimensions: PPRFE scalar alpha.""" |
| 883 | + assert get_all_encoding_dimensions( |
| 884 | + ["PPRFE"], {"PPRFE": {"alpha_param_PPRFE": 2}} |
| 885 | + ) == [2] |
| 886 | + |
| 887 | + def test_get_all_encoding_dimensions_pprfe_missing_uses_default(self): |
| 888 | + """get_all_encoding_dimensions: PPRFE absent from parameters -> default 10.""" |
| 889 | + assert get_all_encoding_dimensions(["PPRFE"], {}) == [10] |
0 commit comments