Skip to content

Commit 3fb8498

Browse files
pesapstaadecker
authored andcommitted
Merge pull request #113 from staadecker/hotfix
Remove outdated patch causing crash
2 parents cfef79e + d7e9f16 commit 3fb8498

File tree

3 files changed

+3
-54
lines changed

3 files changed

+3
-54
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 & 51 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
@@ -16,63 +15,13 @@ def patch_pyomo():
1615
if _patched_pyomo:
1716
return
1817

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

2822
_patched_pyomo = True
2923

3024

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

switch_model/wecc/get_inputs/post_process_steps/reserve_technologies.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
name="no_fosill_reserve",
1414
msg="Aggregating candidate projects by load zone for specified technologies",
1515
only_with_config=True,
16-
priority=4
16+
priority=4,
1717
)
1818
def post_process(config):
19-
""" This function sets to zero the column that allows each candidate technology to
19+
"""This function sets to zero the column that allows each candidate technology to
2020
proividee"""
2121

2222
fname = "generation_projects_info.csv"

0 commit comments

Comments
 (0)