Skip to content

Commit cee5818

Browse files
committed
Remove outdated patch
1 parent e8054f8 commit cee5818

File tree

2 files changed

+1
-50
lines changed

2 files changed

+1
-50
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def read(*rnames):
6969
],
7070
python_requires='>=3.7',
7171
install_requires=[
72-
"Pyomo>=6.0", # We need a version that works with glpk 4.60+
72+
"Pyomo>=6.1", # 6.1 Has all the bug fixes we need
7373
"pint", # needed by Pyomo when we run our tests, but not included
7474
"testfixtures", # used for standard tests
7575
"pandas", # used for input upgrades and testing that functionality

switch_model/utilities/patches.py

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import inspect
21
import textwrap
32
import types
43
from typing import Type
@@ -15,60 +14,12 @@ def patch_pyomo():
1514
if _patched_pyomo:
1615
return
1716

18-
# fix Pyomo issue #2019. Once PR #2020 gets released this will no longer be needed
19-
from pyomo.core.base.misc import _robust_sort_keyfcn
20-
setattr(_robust_sort_keyfcn, "__call__", fixed_robust_sort_keyfcn)
21-
2217
# Patch Set and Param to allow specifying input file location (via input_file="...")
2318
extend_to_allow_loading(Set)
2419
extend_to_allow_loading(Param)
2520

2621
_patched_pyomo = True
2722

28-
def fixed_robust_sort_keyfcn(self, val, use_key=True):
29-
"""Generate a tuple ( str(type_name), val ) for sorting the value.
30-
31-
`key=` expects a function. We are generating a functor so we
32-
have a convenient place to store the _typemap, which converts
33-
the type-specific functions for converting a value to the second
34-
argument of the sort key.
35-
36-
"""
37-
if use_key and self._key is not None:
38-
val = self._key(val)
39-
40-
try:
41-
i, _typename = self._typemap[val.__class__]
42-
except KeyError:
43-
# If this is not a type we have seen before, determine what
44-
# to use for the second value in the tuple.
45-
_type = val.__class__
46-
_typename = _type.__name__
47-
try:
48-
# 1: Check if the type is comparable. In Python 3, sorted()
49-
# uses "<" to compare objects.
50-
val < val
51-
i = 1
52-
except:
53-
try:
54-
# 2: try converting the value to string
55-
str(val)
56-
i = 2
57-
except:
58-
# 3: fallback on id(). Not deterministic
59-
# (run-to-run), but at least is consistent within
60-
# this run.
61-
i = 3
62-
self._typemap[_type] = i, _typename
63-
if i == 1:
64-
return _typename, val
65-
elif i == 3:
66-
return _typename, tuple(self(v, use_key=False) for v in val)
67-
elif i == 2:
68-
return _typename, str(val)
69-
else:
70-
return _typename, id(val)
71-
7223
def extend_to_allow_loading(cls: Type):
7324
def new_init(self, *args, input_file=None, input_column=None, input_optional=None, **kwargs):
7425
self.__old_init__(*args, **kwargs)

0 commit comments

Comments
 (0)