Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_to_tuple():
assert to_tuple(10) == (-10, 10)
assert to_tuple(0.5) == (-0.5, 0.5)
assert to_tuple((-20, 20)) == (-20, 20)
assert to_tuple([-20, 20]) == (-20, 20)
assert to_tuple(100, low=30) == (30, 100)
assert to_tuple(10, bias=1) == (-9, 11)
assert to_tuple(100, bias=2) == (-98, 102)
def test_to_tuple():
assert to_tuple(10) == (-10, 10)
assert to_tuple(0.5) == (-0.5, 0.5)
assert to_tuple((-20, 20)) == (-20, 20)
assert to_tuple([-20, 20]) == (-20, 20)
assert to_tuple(100, low=30) == (30, 100)
assert to_tuple(10, bias=1) == (-9, 11)
assert to_tuple(100, bias=2) == (-98, 102)
def __init__(self, alpha=(0.2, 0.5), strength=(0.2, 0.7), always_apply=False, p=0.5):
super(IAAEmboss, self).__init__(always_apply, p)
self.alpha = to_tuple(alpha, 0.0)
self.strength = to_tuple(strength, 0.0)
def __init__(self, r_shift_limit=20, g_shift_limit=20, b_shift_limit=20, always_apply=False, p=0.5):
super(RGBShift, self).__init__(always_apply, p)
self.r_shift_limit = to_tuple(r_shift_limit)
self.g_shift_limit = to_tuple(g_shift_limit)
self.b_shift_limit = to_tuple(b_shift_limit)
def __init__(self, hue_shift_limit=20, sat_shift_limit=30, val_shift_limit=20, always_apply=False, p=0.5):
super(HueSaturationValue, self).__init__(always_apply, p)
self.hue_shift_limit = to_tuple(hue_shift_limit)
self.sat_shift_limit = to_tuple(sat_shift_limit)
self.val_shift_limit = to_tuple(val_shift_limit)
def __init__(
self,
distort_limit=0.05,
shift_limit=0.05,
interpolation=cv2.INTER_LINEAR,
border_mode=cv2.BORDER_REFLECT_101,
value=None,
mask_value=None,
always_apply=False,
p=0.5,
):
super(OpticalDistortion, self).__init__(always_apply, p)
self.shift_limit = to_tuple(shift_limit)
self.distort_limit = to_tuple(distort_limit)
self.interpolation = interpolation
self.border_mode = border_mode
self.value = value
self.mask_value = mask_value
def __init__(self, threshold=128, always_apply=False, p=0.5):
super(Solarize, self).__init__(always_apply, p)
if isinstance(threshold, (int, float)):
self.threshold = to_tuple(threshold, low=threshold)
else:
self.threshold = to_tuple(threshold, low=0)
def __init__(
self,
shift_limit=0.0625,
scale_limit=0.1,
rotate_limit=45,
interpolation=cv2.INTER_LINEAR,
border_mode=cv2.BORDER_REFLECT_101,
value=None,
mask_value=None,
always_apply=False,
p=0.5,
):
super(ShiftScaleRotate, self).__init__(always_apply, p)
self.shift_limit = to_tuple(shift_limit)
self.scale_limit = to_tuple(scale_limit, bias=1.0)
self.rotate_limit = to_tuple(rotate_limit)
self.interpolation = interpolation
self.border_mode = border_mode
self.value = value
self.mask_value = mask_value
scale=1.0,
translate_percent=None,
translate_px=None,
rotate=0.0,
shear=0.0,
order=1,
cval=0,
mode="reflect",
always_apply=False,
p=0.5,
):
super(IAAAffine, self).__init__(always_apply, p)
self.scale = to_tuple(scale, 1.0)
self.translate_percent = to_tuple(translate_percent, 0)
self.translate_px = to_tuple(translate_px, 0)
self.rotate = to_tuple(rotate)
self.shear = to_tuple(shear)
self.order = order
self.cval = cval
self.mode = mode
def __init__(self, hue_shift_limit=20, sat_shift_limit=30, val_shift_limit=20, always_apply=False, p=0.5):
super(HueSaturationValue, self).__init__(always_apply, p)
self.hue_shift_limit = to_tuple(hue_shift_limit)
self.sat_shift_limit = to_tuple(sat_shift_limit)
self.val_shift_limit = to_tuple(val_shift_limit)