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

Can't clone model with Set initialized from Python 3 dict_keys #1510

Open
emma58 opened this issue Jun 18, 2020 · 0 comments
Open

Can't clone model with Set initialized from Python 3 dict_keys #1510

emma58 opened this issue Jun 18, 2020 · 0 comments

Comments

@emma58
Copy link
Contributor

emma58 commented Jun 18, 2020

In Python 3 (not 2 because in 2 keys() returns a list),

m = ConcreteModel()
some_dict = {1:2, 3:5, 5:8}
m.some_set = Set(initialize=some_dict.keys())
new = m.clone()

produces

ERROR: Unable to clone Pyomo component attribute. Component 'some_set'
    contains an uncopyable field '_init_values' (<class
    'pyomo.core.base.set.TuplizeValuesInitializer'>)

The original exception is swallowed, but it's a TypeError: can't pickle dict_keys objects. It seems like at some point it is Set's job to convert some_dict.keys() to a list or something friendlier?

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

No branches or pull requests

2 participants