[Compare] Add validation for dataset lengths for the Wilcoxon test. (#4341)

This commit is contained in:
Pavel Bairov 2024-12-18 12:31:35 +02:00 committed by GitHub
parent 21955e9065
commit 4f88cf9265
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -13,6 +13,8 @@ def perform_test(test_type, baseline, current, **kwargs):
return None, "Datasets are identical"
else:
return None, "No variability"
if (len(set(baseline)) != len(set(current))) and test_type == 'wilcoxon':
return None, "Datasets have different lengths"
if test_type == 'wilcoxon':
return wilcoxon(current, baseline, **kwargs)
@ -31,7 +33,7 @@ for group_name, metrics in input_data['metrics'].items():
group_results = {}
for metric_name, metric_data in metrics.items():
stat, p = perform_test(test_type, metric_data['baseline'], metric_data['current'], **options)
if p == "No variability" or p == "Datasets are identical":
if p == "No variability" or p == "Datasets are identical" or p == "Datasets have different lengths":
group_results[metric_name] = {'statistic': "N/A", 'p-value': p}
else:
group_results[metric_name] = {'statistic': stat, 'p-value': p}