Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterators in IndexedComponent #1995

Closed
bknueven opened this issue May 27, 2021 · 0 comments · Fixed by #2007
Closed

Iterators in IndexedComponent #1995

bknueven opened this issue May 27, 2021 · 0 comments · Fixed by #2007

Comments

@bknueven
Copy link
Contributor

In making Egret fully Pyomo 6 compatible grid-parity-exchange/Egret/pull/232, I noticed an incongruity and potential performance issue in IndexedComponent:

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

These standard dict-like iterator methods all return a list, which is not as promised in their docstrings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant