(B)
Invert B if B*B.rev() is scalar.
Invert B if B*B.rev() is scalar.
Invert B if B * B . rev () is scalar .
def inv(B):
    "Invert B if B*B.rev() is scalar."
    Bnorm = B * B.rev()
    if Bnorm.is_scalar():
        invB = B.rev() / Bnorm.obj
        return invB
    else:
        raise TypeError('Cannot calculate inverse of ' + str(B) + ' since \n'
                        + 'B*Brev() = ' + str(Bnorm) + ' is not a scalar.\n')
def inv ( B ) : Bnorm = B * B . rev ( ) if Bnorm . is_scalar ( ) : invB = B . rev ( ) / Bnorm . obj return invB else : raise TypeError ( 'Cannot calculate inverse of ' + str ( B ) + ' since \n' + 'B*Brev() = ' + str ( Bnorm ) + ' is not a scalar.\n' )