Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __neg__(self):
return Term.from_pauli(self, -1.0)
def __truediv__(self, other):
if isinstance(other, Number):
if other:
return Term.from_pauli(self, 1.0 / other)
raise ZeroDivisionError
return NotImplemented
def to_term(self):
"""Convert to Pauli Term"""
return Term.from_pauli(self)
def __mul__(self, other):
if isinstance(other, Number):
return Term.from_pauli(self, other)
if not isinstance(other, _PauliImpl):
return NotImplemented
if self.is_identity:
return other.to_term()
if other.is_identity:
return self.to_term()
if _n(self) == _n(other) and self.op == other.op:
return I.to_term()
return Term.from_paulipair(self, other)
def __rmul__(self, other):
if isinstance(other, Number):
return Term.from_pauli(self, other)
return NotImplemented