def test_args_confidence(parser): with pytest.raises(TypeError): parse_args( ['--confidence=-1', *default_metric_args, *default_inputs_args]) with pytest.raises(TypeError): parse_args( ['--confidence=2', *default_metric_args, *default_inputs_args]) parse_args(['--confidence=0', *default_metric_args, *default_inputs_args]) parse_args(['--confidence=1', *default_metric_args, *default_inputs_args])
def test_args_probability(parser): with pytest.raises(TypeError): parse_args( ['--probability=-1', *default_metric_args, *default_inputs_args]) with pytest.raises(TypeError): parse_args( ['--probability=2', *default_metric_args, *default_inputs_args]) parse_args(['--probability=0', *default_metric_args, *default_inputs_args]) parse_args(['--probability=1', *default_metric_args, *default_inputs_args])
def test_args_method(parser): with pytest.raises(SystemExit): parse_args(['--method', *default_metric_args, *default_inputs_args]) parse_args(['--method=CNH', *default_metric_args, *default_inputs_args]) parse_args( ['--method=General', *default_metric_args, *default_inputs_args])
def test_args_inputs_stdin(): with pytest.raises(SystemExit): parse_args( [*default_metric_args, '--inputs ', '--input-format', 'stdin']) with pytest.raises(SystemExit): parse_args([ *default_metric_args, '--inputs', '1', 'a', '3', '--input-format', 'stdin' ]) parse_args([ *default_metric_args, '--inputs', '1', '2.0', '3.0', '--input-format', 'stdin' ])
reference = stats.mean(inputs, axis=args.axis) if args.metric == Metric.Significant: s = significant_digits(array=inputs, reference=reference, axis=args.axis, base=args.base, error=args.error, method=args.method, probability=args.probability, confidence=args.confidence) elif args.metric == Metric.Contributing: s = contributing_digits(array=inputs, reference=reference, axis=args.axis, base=args.base, error=args.error, method=args.method, probability=args.probability, confidence=args.confidence) else: print(f'Error: unkown metric {args.metric}') sys.exit(1) exporter.export(s) if __name__ == '__main__': args = argparse.parse_args() main(args)
def test_args_metric(parser): with pytest.raises(SystemExit): parse_args(['--metric', *default_inputs_args]) parse_args(['--metric=Significant', *default_inputs_args]) parse_args(['--metric=Contributing', *default_inputs_args])