import operator
from abc import ABC, abstractmethod
-from collections import OrderedDict
+from collections import OrderedDict, Mapping
from .linexprs import Symbol
"""
def __new__(cls, coordinates=None):
- if isinstance(coordinates, dict):
+ if isinstance(coordinates, Mapping):
coordinates = coordinates.items()
self = object().__new__(cls)
self._coordinates = OrderedDict()
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: