Skip to content

Commit

Permalink
Handle unpickling of old style Parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Feb 28, 2019
1 parent 5c44bea commit b0332f4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion param/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -2218,13 +2218,22 @@ def __getstate__(self):

return state

def __setstate__(self,state):
def __setstate__(self, state):
"""
Restore objects from the state dictionary to this object.
During this process the object is considered uninitialized.
"""
self.initialized=False

# Handle renamed slots introduced for instance params
if '_attrib_name' in state:
state['name'] = state.pop('_attrib_name')
if '_owner' in state:
state['owner'] = state.pop('_owner')
if '_instance__params' not in state:
state['_instance__params'] = {}

for name,value in state.items():
setattr(self,name,value)
self.initialized=True
Expand Down

1 comment on commit b0332f4

@jbednar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks; that's just the fix I thought might be needed!

Please sign in to comment.