def check_for_x_over_absX(numerators, denominators):
 for den in list(denominators):
  if (den.owner and (den.owner.op == T.abs_) and (den.owner.inputs[0] in numerators)):
   if den.owner.inputs[0].type.dtype.startswith('complex'):
    pass
   else:
    denominators.remove(den)
    numerators.remove(den.owner.inputs[0])
    numerators.append(T.sgn(den.owner.inputs[0]))
 return (numerators, denominators)

def check_for_x_over_absX ( numerators , denominators ) : for den in list ( denominators ) : if ( den . owner and ( den . owner . op == T . abs_ ) and ( den . owner . inputs [ 0 ] in numerators ) ) : if den . owner . inputs [ 0 ] . type . dtype . startswith ( 'complex' ) : pass else : denominators . remove ( den ) numerators . remove ( den . owner . inputs [ 0 ] ) numerators . append ( T . sgn ( den . owner . inputs [ 0 ] ) ) return ( numerators , denominators )
convert x/abs(x) into sign(x) .