Example #1
0
def check_normalize_c_param(mean, std):
    if len(mean) != len(std):
        raise ValueError("Length of mean and std must be equal.")
    for mean_value in mean:
        check_pos_float32(mean_value)
    for std_value in std:
        check_pos_float32(std_value)
Example #2
0
    def new_method(self, *args, **kwargs):
        [alpha], _ = parse_user_args(method, *args, **kwargs)
        type_check(alpha, (int, float), "alpha")
        check_positive(alpha, "alpha")
        check_pos_float32(alpha)

        return method(self, *args, **kwargs)
Example #3
0
 def new_method(self, *args, **kwargs):
     [image_batch_format, alpha, prob], _ = parse_user_args(method, *args, **kwargs)
     type_check(image_batch_format, (ImageBatchFormat,), "image_batch_format")
     check_pos_float32(alpha)
     check_positive(alpha, "alpha")
     check_value(prob, [0, 1], "prob")
     return method(self, *args, **kwargs)
Example #4
0
def check_degrees(degrees):
    """Check if the degrees is legal."""
    type_check(degrees, (numbers.Number, list, tuple), "degrees")
    if isinstance(degrees, numbers.Number):
        check_pos_float32(degrees, "degrees")
    elif isinstance(degrees, (list, tuple)):
        if len(degrees) == 2:
            type_check_list(degrees, (numbers.Number,), "degrees")
            for value in degrees:
                check_float32(value, "degrees")
            if degrees[0] > degrees[1]:
                raise ValueError("degrees should be in (min,max) format. Got (max,min).")
        else:
            raise TypeError("If degrees is a sequence, the length must be 2.")
Example #5
0
    def new_method(self, *args, **kwargs):
        [rescale, shift], _ = parse_user_args(method, *args, **kwargs)
        check_pos_float32(rescale)
        type_check(shift, (numbers.Number,), "shift")

        return method(self, *args, **kwargs)