def __rmul__(self, other): if isinstance(other, int): other = _sympify(other) if isinstance(other, Expr): other_ds = DomainScalar.from_sympy(other) return self.from_dm(other_ds * self._dm) return NotImplemented
def __mul__(self, other): if isinstance(other, type(self)): return self.from_dm(self._dm * other._dm) elif isinstance(other, int): other = _sympify(other) if isinstance(other, Expr): Kx = self.ring try: other_ds = DomainScalar(Kx.from_sympy(other), Kx) except (CoercionFailed, ValueError): other_ds = DomainScalar.from_sympy(other) return self.from_dm(self._dm * other_ds) return NotImplemented
def test_DomainScalar_from_sympy(): expr = S(1) B = DomainScalar.from_sympy(expr) assert B == DomainScalar(ZZ(1), ZZ)