def rotate(clip, angle, unit='deg', resample='bicubic', expand=True):
 resample = {'bilinear': Image.BILINEAR, 'nearest': Image.NEAREST, 'bicubic': Image.BICUBIC}[resample]
 if (not hasattr(angle, '__call__')):
  a = (+ angle)
  angle = (lambda t: a)
 transpo = ([1, 0] if clip.ismask else [1, 0, 2])
 def fl(gf, t):
  a = angle(t)
  im = gf(t)
  if (unit == 'rad'):
   a = ((360.0 * a) / (2 * np.pi))
  if ((a == 90) and expand):
   return np.transpose(im, axes=transpo)[::(-1)]
  elif ((a == (-90)) and expand):
   return np.transpose(im, axes=transpo)[:, ::(-1)]
  elif ((a in [180, (-180)]) and expand):
   return im[::(-1), ::(-1)]
  elif (not PIL_FOUND):
   raise ValueError('Without "Pillow" installed, only angles 90, -90,180 are supported, please install "Pillow" withpip install pillow')
  else:
   return pil_rotater(im, a, resample=resample, expand=expand)
 return clip.fl(fl, apply_to=['mask'])

def rotate ( clip , angle , unit = 'deg' , resample = 'bicubic' , expand = True ) : resample = { 'bilinear' : Image . BILINEAR , 'nearest' : Image . NEAREST , 'bicubic' : Image . BICUBIC } [ resample ] if ( not hasattr ( angle , '__call__' ) ) : a = ( + angle ) angle = ( lambda t : a ) transpo = ( [ 1 , 0 ] if clip . ismask else [ 1 , 0 , 2 ] ) def fl ( gf , t ) : a = angle ( t ) im = gf ( t ) if ( unit == 'rad' ) : a = ( ( 360.0 * a ) / ( 2 * np . pi ) ) if ( ( a == 90 ) and expand ) : return np . transpose ( im , axes = transpo ) [ : : ( - 1 ) ] elif ( ( a == ( - 90 ) ) and expand ) : return np . transpose ( im , axes = transpo ) [ : , : : ( - 1 ) ] elif ( ( a in [ 180 , ( - 180 ) ] ) and expand ) : return im [ : : ( - 1 ) , : : ( - 1 ) ] elif ( not PIL_FOUND ) : raise ValueError ( 'Without "Pillow" installed, only angles 90, -90,180 are supported, please install "Pillow" withpip install pillow' ) else : return pil_rotater ( im , a , resample = resample , expand = expand ) return clip . fl ( fl , apply_to = [ 'mask' ] )
return the matrix to rotate a 2-d point about the origin by angle .