def test_add_argparse_options():
    import argparse
    parser = argparse.ArgumentParser()
    add_argparse_options(parser)
    # Test default values
    args = parser.parse_args([])
    get_downscaler(args.downscaling_method, vars(args))
    # Test correct parsing
    args = parser.parse_args(["--downscaling-method", "average"])
    assert args.downscaling_method == "average"
    assert args.outside_value is None
    args = parser.parse_args(
        ["--downscaling-method", "average", "--outside-value", "255"])
    assert args.downscaling_method == "average"
    assert args.outside_value == 255.
    args = parser.parse_args(["--downscaling-method", "majority"])
    assert args.downscaling_method == "majority"
    args = parser.parse_args(["--downscaling-method", "stride"])
    assert args.downscaling_method == "stride"
def test_get_downscaler_auto_segmentation():
    d = get_downscaler("auto", info={"type": "segmentation"})
    assert isinstance(d, StridingDownscaler)
def test_get_downscaler(method, options):
    d = get_downscaler(method, options)
    assert isinstance(d, Downscaler)
def test_get_downscaler_auto_image():
    d = get_downscaler("auto", info={"type": "image"})
    assert isinstance(d, AveragingDownscaler)