@@ -1026,6 +1026,40 @@ def test_group_keep_n(self):
10261026 dialog .n_values_spin .setValue (3 )
10271027 self .assertListEqual (dialog .get_merge_attributes (), [])
10281028
1029+ def test_group_less_frequent_missing (self ):
1030+ """
1031+ Widget gives MaskedArray to GroupItemsDialog which can have missing
1032+ values.
1033+ gh-4599
1034+ """
1035+ def _test_correctness ():
1036+ dialog .frequent_abs_radio .setChecked (True )
1037+ dialog .frequent_abs_spin .setValue (3 )
1038+ self .assertListEqual (dialog .get_merge_attributes (), ["b" , "c" ])
1039+
1040+ dialog .frequent_rel_radio .setChecked (True )
1041+ dialog .frequent_rel_spin .setValue (50 )
1042+ self .assertListEqual (dialog .get_merge_attributes (), ["b" , "c" ])
1043+
1044+ dialog .n_values_radio .setChecked (True )
1045+ dialog .n_values_spin .setValue (1 )
1046+ self .assertListEqual (dialog .get_merge_attributes (), ["b" , "c" ])
1047+
1048+ # masked array
1049+ data_masked = np .ma .array (
1050+ [0 , 0 , np .nan , 0 , 1 , 1 , 2 ], mask = [0 , 0 , 1 , 0 , 0 , 0 , 0 ]
1051+ )
1052+ dialog = GroupItemsDialog (self .v , data_masked , [], {})
1053+ _test_correctness ()
1054+
1055+ data_array = np .array ([0 , 0 , np .nan , 0 , 1 , 1 , 2 ])
1056+ dialog = GroupItemsDialog (self .v , data_array , [], {})
1057+ _test_correctness ()
1058+
1059+ data_list = [0 , 0 , None , 0 , 1 , 1 , 2 ]
1060+ dialog = GroupItemsDialog (self .v , data_list , [], {})
1061+ _test_correctness ()
1062+
10291063
10301064if __name__ == '__main__' :
10311065 unittest .main ()
0 commit comments