예제 #1
0
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])
예제 #2
0
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])
예제 #3
0
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])
예제 #4
0
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'
    ])
예제 #5
0
        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)
예제 #6
0
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])