|
141 | 141 |
|
142 | 142 | log = logging.getLogger(__name__) |
143 | 143 |
|
144 | | -_DICT_TYPE = dict |
145 | | - |
146 | | -if sys.platform not in ["cli"]: |
147 | | - # iron python does not like an OrderedDict |
148 | | - try: |
149 | | - from odict import OrderedDict # type: ignore[import-not-found] |
150 | | - |
151 | | - _DICT_TYPE = OrderedDict # type: ignore[misc] |
152 | | - except ImportError: |
153 | | - pass |
154 | | - try: |
155 | | - # python 2.7 or 3.1 |
156 | | - from collections import OrderedDict |
157 | | - |
158 | | - _DICT_TYPE = OrderedDict # type: ignore[misc] |
159 | | - except ImportError: |
160 | | - pass |
161 | | - |
162 | 144 | try: |
163 | 145 | import ujson as json # type: ignore[import-untyped] |
164 | 146 | except ImportError: |
@@ -661,7 +643,7 @@ def unfixValue(self): |
661 | 643 | self.bounds(self._lowbound_original, self._upbound_original) |
662 | 644 |
|
663 | 645 |
|
664 | | -class LpAffineExpression(_DICT_TYPE): |
| 646 | +class LpAffineExpression(dict): |
665 | 647 | """ |
666 | 648 | A linear combination of :class:`LpVariables<LpVariable>`. |
667 | 649 | Can be initialised with the following: |
@@ -1419,7 +1401,7 @@ def __init__(self, name="NoName", sense=const.LpMinimize): |
1419 | 1401 | warnings.warn("Spaces are not permitted in the name. Converted to '_'") |
1420 | 1402 | name = name.replace(" ", "_") |
1421 | 1403 | self.objective: None | LpAffineExpression = None # type: ignore[annotation-unchecked] |
1422 | | - self.constraints: dict[str, LpConstraint] = _DICT_TYPE() # type: ignore[annotation-unchecked] |
| 1404 | + self.constraints: dict[str, LpConstraint] = {} # type: ignore[annotation-unchecked] |
1423 | 1405 | self.name = name |
1424 | 1406 | self.sense = sense |
1425 | 1407 | self.sos1 = {} |
@@ -1487,7 +1469,7 @@ def deepcopy(self): |
1487 | 1469 | lpcopy = LpProblem(name=self.name, sense=self.sense) |
1488 | 1470 | if self.objective is not None: |
1489 | 1471 | lpcopy.objective = self.objective.copy() |
1490 | | - lpcopy.constraints = _DICT_TYPE[str, LpConstraint]() |
| 1472 | + lpcopy.constraints = {} |
1491 | 1473 | for k, v in self.constraints.items(): |
1492 | 1474 | lpcopy.constraints[k] = v.copy() |
1493 | 1475 | lpcopy.sos1 = self.sos1.copy() |
|
0 commit comments