import numbers
import re
-from collections import OrderedDict, defaultdict
+from collections import OrderedDict, defaultdict, Mapping
from fractions import Fraction, gcd
return Expression.fromstring(coefficients)
if coefficients is None:
return Rational(constant)
- if isinstance(coefficients, dict):
+ if isinstance(coefficients, Mapping):
coefficients = coefficients.items()
for symbol, coefficient in coefficients:
if not isinstance(symbol, Symbol):
def subs(self, symbol, expression=None):
if expression is None:
- if isinstance(symbol, dict):
+ if isinstance(symbol, Mapping):
symbol = symbol.items()
substitutions = symbol
else: