def __abs__(self): if self.imag == 0: return abs(self.real) if self.real == 0: return abs(self.imag) return math.hypot(self.real, self.imag)