if not isinstance(symbol, Symbol):
raise TypeError('symbols must be Symbol instances')
if not isinstance(coefficient, numbers.Rational):
- raise TypeError('coefficients must be Rational instances')
+ raise TypeError('coefficients must be rational numbers')
coefficients = [(symbol, Fraction(coefficient))
for symbol, coefficient in coefficients if coefficient != 0]
if not isinstance(constant, numbers.Rational):
- raise TypeError('constant must be a Rational instance')
+ raise TypeError('constant must be a rational number')
constant = Fraction(constant)
if len(coefficients) == 0:
return Rational(constant)