@@ -509,7 +509,7 @@ def test_symmetry():
509
509
510
510
@pytest .mark .parametrize (
511
511
'name' ,
512
- set (ALL_METRICS ) - METRIC_UNDEFINED_BINARY_MULTICLASS )
512
+ sorted ( set (ALL_METRICS ) - METRIC_UNDEFINED_BINARY_MULTICLASS ) )
513
513
def test_sample_order_invariance (name ):
514
514
random_state = check_random_state (0 )
515
515
y_true = random_state .randint (0 , 2 , size = (20 , ))
@@ -561,7 +561,7 @@ def test_sample_order_invariance_multilabel_and_multioutput():
561
561
562
562
@pytest .mark .parametrize (
563
563
'name' ,
564
- set (ALL_METRICS ) - METRIC_UNDEFINED_BINARY_MULTICLASS )
564
+ sorted ( set (ALL_METRICS ) - METRIC_UNDEFINED_BINARY_MULTICLASS ) )
565
565
def test_format_invariance_with_1d_vectors (name ):
566
566
random_state = check_random_state (0 )
567
567
y1 = random_state .randint (0 , 2 , size = (20 , ))
@@ -636,8 +636,8 @@ def test_format_invariance_with_1d_vectors(name):
636
636
637
637
638
638
@pytest .mark .parametrize (
639
- 'name' ,
640
- set (CLASSIFICATION_METRICS ) - METRIC_UNDEFINED_BINARY_MULTICLASS )
639
+ 'name' ,
640
+ sorted ( set (CLASSIFICATION_METRICS ) - METRIC_UNDEFINED_BINARY_MULTICLASS ) )
641
641
def test_classification_invariance_string_vs_numbers_labels (name ):
642
642
# Ensure that classification metrics with string labels are invariant
643
643
random_state = check_random_state (0 )
@@ -767,22 +767,23 @@ def check_single_sample_multioutput(name):
767
767
768
768
769
769
@pytest .mark .parametrize (
770
- 'name' ,
771
- ( set ( ALL_METRICS )
772
- # Those metrics are not always defined with one sample
773
- # or in multiclass classification
774
- - METRIC_UNDEFINED_BINARY_MULTICLASS
775
- - set (THRESHOLDED_METRICS )))
770
+ 'name' ,
771
+ sorted (
772
+ set ( ALL_METRICS )
773
+ # Those metrics are not always defined with one sample
774
+ # or in multiclass classification
775
+ - METRIC_UNDEFINED_BINARY_MULTICLASS - set (THRESHOLDED_METRICS )))
776
776
def test_single_sample (name ):
777
777
check_single_sample (name )
778
778
779
779
780
- @pytest .mark .parametrize ('name' , MULTIOUTPUT_METRICS | MULTILABELS_METRICS )
780
+ @pytest .mark .parametrize ('name' ,
781
+ sorted (MULTIOUTPUT_METRICS | MULTILABELS_METRICS ))
781
782
def test_single_sample_multioutput (name ):
782
783
check_single_sample_multioutput (name )
783
784
784
785
785
- @pytest .mark .parametrize ('name' , MULTIOUTPUT_METRICS )
786
+ @pytest .mark .parametrize ('name' , sorted ( MULTIOUTPUT_METRICS ) )
786
787
def test_multioutput_number_of_output_differ (name ):
787
788
y_true = np .array ([[1 , 0 , 0 , 1 ], [0 , 1 , 1 , 1 ], [1 , 1 , 0 , 1 ]])
788
789
y_pred = np .array ([[0 , 0 ], [1 , 0 ], [0 , 0 ]])
@@ -791,7 +792,7 @@ def test_multioutput_number_of_output_differ(name):
791
792
assert_raises (ValueError , metric , y_true , y_pred )
792
793
793
794
794
- @pytest .mark .parametrize ('name' , MULTIOUTPUT_METRICS )
795
+ @pytest .mark .parametrize ('name' , sorted ( MULTIOUTPUT_METRICS ) )
795
796
def test_multioutput_regression_invariance_to_dimension_shuffling (name ):
796
797
# test invariance to dimension shuffling
797
798
random_state = check_random_state (0 )
@@ -846,7 +847,7 @@ def test_multilabel_representation_invariance():
846
847
"dense and sparse indicator formats." % name )
847
848
848
849
849
- @pytest .mark .parametrize ('name' , MULTILABELS_METRICS )
850
+ @pytest .mark .parametrize ('name' , sorted ( MULTILABELS_METRICS ) )
850
851
def test_raise_value_error_multilabel_sequences (name ):
851
852
# make sure the multilabel-sequence format raises ValueError
852
853
multilabel_sequences = [
@@ -862,7 +863,7 @@ def test_raise_value_error_multilabel_sequences(name):
862
863
assert_raises (ValueError , metric , seq , seq )
863
864
864
865
865
- @pytest .mark .parametrize ('name' , METRICS_WITH_NORMALIZE_OPTION )
866
+ @pytest .mark .parametrize ('name' , sorted ( METRICS_WITH_NORMALIZE_OPTION ) )
866
867
def test_normalize_option_binary_classification (name ):
867
868
# Test in the binary case
868
869
n_samples = 20
@@ -879,7 +880,7 @@ def test_normalize_option_binary_classification(name):
879
880
measure )
880
881
881
882
882
- @pytest .mark .parametrize ('name' , METRICS_WITH_NORMALIZE_OPTION )
883
+ @pytest .mark .parametrize ('name' , sorted ( METRICS_WITH_NORMALIZE_OPTION ) )
883
884
def test_normalize_option_multiclass_classification (name ):
884
885
# Test in the multiclass case
885
886
random_state = check_random_state (0 )
@@ -986,7 +987,7 @@ def check_averaging(name, y_true, y_true_binarize, y_pred, y_pred_binarize,
986
987
raise ValueError ("Metric is not recorded as having an average option" )
987
988
988
989
989
- @pytest .mark .parametrize ('name' , METRICS_WITH_AVERAGING )
990
+ @pytest .mark .parametrize ('name' , sorted ( METRICS_WITH_AVERAGING ) )
990
991
def test_averaging_multiclass (name ):
991
992
n_samples , n_classes = 50 , 3
992
993
random_state = check_random_state (0 )
@@ -1003,7 +1004,8 @@ def test_averaging_multiclass(name):
1003
1004
1004
1005
1005
1006
@pytest .mark .parametrize (
1006
- 'name' , METRICS_WITH_AVERAGING | THRESHOLDED_METRICS_WITH_AVERAGING )
1007
+ 'name' ,
1008
+ sorted (METRICS_WITH_AVERAGING | THRESHOLDED_METRICS_WITH_AVERAGING ))
1007
1009
def test_averaging_multilabel (name ):
1008
1010
n_samples , n_classes = 40 , 5
1009
1011
_ , y = make_multilabel_classification (n_features = 1 , n_classes = n_classes ,
@@ -1019,7 +1021,7 @@ def test_averaging_multilabel(name):
1019
1021
y_pred , y_pred_binarize , y_score )
1020
1022
1021
1023
1022
- @pytest .mark .parametrize ('name' , METRICS_WITH_AVERAGING )
1024
+ @pytest .mark .parametrize ('name' , sorted ( METRICS_WITH_AVERAGING ) )
1023
1025
def test_averaging_multilabel_all_zeroes (name ):
1024
1026
y_true = np .zeros ((20 , 3 ))
1025
1027
y_pred = np .zeros ((20 , 3 ))
@@ -1044,7 +1046,7 @@ def test_averaging_binary_multilabel_all_zeroes():
1044
1046
y_pred_binarize , is_multilabel = True )
1045
1047
1046
1048
1047
- @pytest .mark .parametrize ('name' , METRICS_WITH_AVERAGING )
1049
+ @pytest .mark .parametrize ('name' , sorted ( METRICS_WITH_AVERAGING ) )
1048
1050
def test_averaging_multilabel_all_ones (name ):
1049
1051
y_true = np .ones ((20 , 3 ))
1050
1052
y_pred = np .ones ((20 , 3 ))
@@ -1136,9 +1138,10 @@ def check_sample_weight_invariance(name, metric, y1, y2):
1136
1138
1137
1139
1138
1140
@pytest .mark .parametrize (
1139
- 'name' ,
1140
- (set (ALL_METRICS ).intersection (set (REGRESSION_METRICS ))
1141
- - METRICS_WITHOUT_SAMPLE_WEIGHT ))
1141
+ 'name' ,
1142
+ sorted (
1143
+ set (ALL_METRICS ).intersection (set (REGRESSION_METRICS )) -
1144
+ METRICS_WITHOUT_SAMPLE_WEIGHT ))
1142
1145
def test_regression_sample_weight_invariance (name ):
1143
1146
n_samples = 50
1144
1147
random_state = check_random_state (0 )
@@ -1150,9 +1153,10 @@ def test_regression_sample_weight_invariance(name):
1150
1153
1151
1154
1152
1155
@pytest .mark .parametrize (
1153
- 'name' ,
1154
- (set (ALL_METRICS ) - set (REGRESSION_METRICS )
1155
- - METRICS_WITHOUT_SAMPLE_WEIGHT - METRIC_UNDEFINED_BINARY ))
1156
+ 'name' ,
1157
+ sorted (
1158
+ set (ALL_METRICS ) - set (REGRESSION_METRICS ) -
1159
+ METRICS_WITHOUT_SAMPLE_WEIGHT - METRIC_UNDEFINED_BINARY ))
1156
1160
def test_binary_sample_weight_invariance (name ):
1157
1161
# binary
1158
1162
n_samples = 50
@@ -1168,10 +1172,10 @@ def test_binary_sample_weight_invariance(name):
1168
1172
1169
1173
1170
1174
@pytest .mark .parametrize (
1171
- 'name' ,
1172
- ( set ( ALL_METRICS ) - set ( REGRESSION_METRICS )
1173
- - METRICS_WITHOUT_SAMPLE_WEIGHT
1174
- - METRIC_UNDEFINED_BINARY_MULTICLASS ))
1175
+ 'name' ,
1176
+ sorted (
1177
+ set ( ALL_METRICS ) - set ( REGRESSION_METRICS ) -
1178
+ METRICS_WITHOUT_SAMPLE_WEIGHT - METRIC_UNDEFINED_BINARY_MULTICLASS ))
1175
1179
def test_multiclass_sample_weight_invariance (name ):
1176
1180
# multiclass
1177
1181
n_samples = 50
@@ -1187,9 +1191,9 @@ def test_multiclass_sample_weight_invariance(name):
1187
1191
1188
1192
1189
1193
@pytest .mark .parametrize (
1190
- 'name' ,
1191
- ( MULTILABELS_METRICS | THRESHOLDED_MULTILABEL_METRICS |
1192
- MULTIOUTPUT_METRICS ) - METRICS_WITHOUT_SAMPLE_WEIGHT )
1194
+ 'name' ,
1195
+ sorted (( MULTILABELS_METRICS | THRESHOLDED_MULTILABEL_METRICS
1196
+ | MULTIOUTPUT_METRICS ) - METRICS_WITHOUT_SAMPLE_WEIGHT ) )
1193
1197
def test_multilabel_sample_weight_invariance (name ):
1194
1198
# multilabel indicator
1195
1199
random_state = check_random_state (0 )
@@ -1235,7 +1239,8 @@ def test_no_averaging_labels():
1235
1239
1236
1240
1237
1241
@pytest .mark .parametrize (
1238
- 'name' , MULTILABELS_METRICS - {"unnormalized_multilabel_confusion_matrix" })
1242
+ 'name' ,
1243
+ sorted (MULTILABELS_METRICS - {"unnormalized_multilabel_confusion_matrix" }))
1239
1244
def test_multilabel_label_permutations_invariance (name ):
1240
1245
random_state = check_random_state (0 )
1241
1246
n_samples , n_classes = 20 , 4
@@ -1255,7 +1260,7 @@ def test_multilabel_label_permutations_invariance(name):
1255
1260
1256
1261
1257
1262
@pytest .mark .parametrize (
1258
- 'name' , THRESHOLDED_MULTILABEL_METRICS | MULTIOUTPUT_METRICS )
1263
+ 'name' , sorted ( THRESHOLDED_MULTILABEL_METRICS | MULTIOUTPUT_METRICS ) )
1259
1264
def test_thresholded_multilabel_multioutput_permutations_invariance (name ):
1260
1265
random_state = check_random_state (0 )
1261
1266
n_samples , n_classes = 20 , 4
0 commit comments