You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code below is expected to work, but does not. The first m.test = Block statement goes through properly, but an error appears during the m.test2 = Block line.
Related issue: #326
This might be another manifestation of #134
from pyomo.environ import *
m = ConcreteModel()
m.s = RangeSet(1)
m.s2 = RangeSet(1)
m.set_mult = m.s * m.s2
m.s3 = RangeSet(1)
def _test(b, x, y, z):
print(x, y, z)
m.test = Block(m.set_mult, m.s3, rule=_test)
m.test2 = Block(m.set_mult, m.s3, rule=_test)
Output:
(1, 1, 1)
ERROR: Constructing component 'test2' from data=None failed: TypeError:
_test() takes exactly 4 arguments (5 given)
Traceback (most recent call last):
File "set_fail.py", line 11, in <module>
m.test2 = Block(m.set_mult, m.s3, rule=_test)
File "/home/qichen/git/pyomo/pyomo/core/base/block.py", line 540, in __setattr__
self.add_component(name, val)
File "/home/qichen/git/pyomo/pyomo/core/base/block.py", line 980, in add_component
val.construct(data)
File "/home/qichen/git/pyomo/pyomo/core/base/block.py", line 1796, in construct
self, self._rule, _block, idx, self._options)
File "/home/qichen/git/pyomo/pyomo/core/base/misc.py", line 80, in apply_indexed_rule
return rule(model, *index)
TypeError: _test() takes exactly 4 arguments (5 given)
This is using the current master branch commit 7d4eee7.
The text was updated successfully, but these errors were encountered:
The code below is expected to work, but does not. The first
m.test = Block
statement goes through properly, but an error appears during them.test2 = Block
line.Related issue: #326
This might be another manifestation of #134
Output:
This is using the current master branch commit 7d4eee7.
The text was updated successfully, but these errors were encountered: