def invertQTransform(tr):
 try:
  import numpy.linalg
  arr = np.array([[tr.m11(), tr.m12(), tr.m13()], [tr.m21(), tr.m22(), tr.m23()], [tr.m31(), tr.m32(), tr.m33()]])
  inv = numpy.linalg.inv(arr)
  return QtGui.QTransform(inv[(0, 0)], inv[(0, 1)], inv[(0, 2)], inv[(1, 0)], inv[(1, 1)], inv[(1, 2)], inv[(2, 0)], inv[(2, 1)])
 except ImportError:
  inv = tr.inverted()
  if (inv[1] is False):
   raise Exception('Transform is not invertible.')
  return inv[0]

def invertQTransform ( tr ) : try : import numpy . linalg arr = np . array ( [ [ tr . m11 ( ) , tr . m12 ( ) , tr . m13 ( ) ] , [ tr . m21 ( ) , tr . m22 ( ) , tr . m23 ( ) ] , [ tr . m31 ( ) , tr . m32 ( ) , tr . m33 ( ) ] ] ) inv = numpy . linalg . inv ( arr ) return QtGui . QTransform ( inv [ ( 0 , 0 ) ] , inv [ ( 0 , 1 ) ] , inv [ ( 0 , 2 ) ] , inv [ ( 1 , 0 ) ] , inv [ ( 1 , 1 ) ] , inv [ ( 1 , 2 ) ] , inv [ ( 2 , 0 ) ] , inv [ ( 2 , 1 ) ] ) except ImportError : inv = tr . inverted ( ) if ( inv [ 1 ] is False ) : raise Exception ( 'Transform is not invertible.' ) return inv [ 0 ]
return a qtransform that is the inverse of *tr* .