Skip to content

Commit 5da9e5a

Browse files
MBradburypchtsp
andauthored
Use dict as the ordered dict type (#824)
Co-authored-by: Franco Peschiera <[email protected]>
1 parent aae2a29 commit 5da9e5a

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

pulp/pulp.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -141,24 +141,6 @@
141141

142142
log = logging.getLogger(__name__)
143143

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-
162144
try:
163145
import ujson as json # type: ignore[import-untyped]
164146
except ImportError:
@@ -661,7 +643,7 @@ def unfixValue(self):
661643
self.bounds(self._lowbound_original, self._upbound_original)
662644

663645

664-
class LpAffineExpression(_DICT_TYPE):
646+
class LpAffineExpression(dict):
665647
"""
666648
A linear combination of :class:`LpVariables<LpVariable>`.
667649
Can be initialised with the following:
@@ -1419,7 +1401,7 @@ def __init__(self, name="NoName", sense=const.LpMinimize):
14191401
warnings.warn("Spaces are not permitted in the name. Converted to '_'")
14201402
name = name.replace(" ", "_")
14211403
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]
14231405
self.name = name
14241406
self.sense = sense
14251407
self.sos1 = {}
@@ -1487,7 +1469,7 @@ def deepcopy(self):
14871469
lpcopy = LpProblem(name=self.name, sense=self.sense)
14881470
if self.objective is not None:
14891471
lpcopy.objective = self.objective.copy()
1490-
lpcopy.constraints = _DICT_TYPE[str, LpConstraint]()
1472+
lpcopy.constraints = {}
14911473
for k, v in self.constraints.items():
14921474
lpcopy.constraints[k] = v.copy()
14931475
lpcopy.sos1 = self.sos1.copy()

0 commit comments

Comments
 (0)