Skip to content

Commit

Permalink
Merge branch 'Pyomo:main' into pyros_pr
Browse files Browse the repository at this point in the history
  • Loading branch information
natalieisenberg committed Jun 9, 2021
2 parents 059c217 + 3cfcfb8 commit db122e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions pyomo/core/base/indexed_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,17 @@ def iteritems(self):

def keys(self):
"""Return an iterator of the keys in the dictionary"""
return [ x for x in self ]
return iter(self)

def values(self):
"""Return an iterator of the component data objects in the dictionary"""
return [ self[x] for x in self ]
for s in self:
yield self[s]

def items(self):
"""Return an iterator of (index,data) tuples from the dictionary"""
return [ (x, self[x]) for x in self ]
for s in self:
yield s, self[s]

def __getitem__(self, index):
"""
Expand Down
2 changes: 1 addition & 1 deletion pyomo/core/tests/unit/test_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TestConvertToPrefixNotation(unittest.TestCase):
def test_linear_expression(self):
m = pe.ConcreteModel()
m.x = pe.Var([1, 2, 3, 4])
e = LinearExpression(constant=3, linear_coefs=m.x.keys(), linear_vars=m.x.values())
e = LinearExpression(constant=3, linear_coefs=list(m.x.keys()), linear_vars=list(m.x.values()))
expected = [(LinearExpression, 9), 3, 1, 2, 3, 4, m.x[1], m.x[2], m.x[3], m.x[4]]
pn = convert_expression_to_prefix_notation(e)
self.assertEqual(pn, expected)
Expand Down

0 comments on commit db122e5

Please sign in to comment.