How to use the blueqat.pauli.Expr.from_term function in blueqat

To help you get started, we’ve selected a few blueqat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Blueqat / Blueqat / blueqat / pauli.py View on Github external
def __add__(self, other):
        if isinstance(other, Number):
            other = Expr.from_number(other)
        elif isinstance(other, Term):
            other = Expr.from_term(other)
        if isinstance(other, Expr):
            terms = self.terms_to_dict()
            for op, coeff in other.terms:
                if op in terms:
                    terms[op] += coeff
                    if terms[op] == 0:
                        del terms[op]
                else:
                    terms[op] = coeff
            return Expr.from_terms_dict(terms)
        return NotImplemented
github Blueqat / Blueqat / blueqat / pauli.py View on Github external
def __radd__(self, other):
        return other + Expr.from_term(self)
github Blueqat / Blueqat / blueqat / pauli.py View on Github external
def __sub__(self, other):
        return Expr.from_term(self) - other
github Blueqat / Blueqat / blueqat / pauli.py View on Github external
def to_expr(self):
        """Convert to Expr."""
        return Expr.from_term(self)
github Blueqat / Blueqat / blueqat / pauli.py View on Github external
def __add__(self, other):
        return Expr.from_term(self) + other
github Blueqat / Blueqat / blueqat / pauli.py View on Github external
def __rsub__(self, other):
        return other - Expr.from_term(self)