-
Notifications
You must be signed in to change notification settings - Fork 1
/
sumstat.py
executable file
·43 lines (31 loc) · 1.22 KB
/
sumstat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
import argparse
import logging
import sys
from respdiff import cli
from respdiff.stats import SummaryStatistics
def _log_threshold(stats, label):
percentile_rank = stats.get_percentile_rank(stats.threshold)
logging.info(' %s: %4.2f percentile rank', label, percentile_rank)
def main():
cli.setup_logging()
parser = argparse.ArgumentParser(description='generate statistics file from reports')
cli.add_arg_report_filename(parser)
cli.add_arg_stats_filename(parser)
args = parser.parse_args()
reports = cli.get_reports_from_filenames(args)
try:
sumstats = SummaryStatistics(reports)
except ValueError as exc:
logging.critical(exc)
sys.exit(1)
logging.info('Total sample size: %d', sumstats.sample_size)
logging.info('Upper boundaries:')
_log_threshold(sumstats.target_disagreements, 'target_disagreements')
_log_threshold(sumstats.upstream_unstable, 'upstream_unstable')
_log_threshold(sumstats.not_reproducible, 'not_reproducible')
for field_name, mismatch_stats in sumstats.fields.items():
_log_threshold(mismatch_stats.total, field_name)
sumstats.export_json(args.stats_filename)
if __name__ == '__main__':
main()