open-research / sumatra

http://neuralensemble.org/sumatra/
BSD 2-Clause "Simplified" License
127 stars 48 forks source link

sumatra.parameters.NTParameterSet cannot be modified after unpickling #383

Open abast opened 5 years ago

abast commented 5 years ago

After initializing a sumatra.parameters.NTParameterSet, it can be modified:

import sumatra.parameters
param = sumatra.parameters.NTParameterSet({'param1':'something'})
param
>> {'param1': 'something'}

param.param1 = 'something else'
param
>> {'param1': 'something else'}

param.param1
>> 'something else'

However, if a NTParameterSet object is generated by unpickling it, modifying it is not possible:

import pickle
param_unpickled = pickle.loads(pickle.dumps(param))
param_unpickled
>> {'param1': 'something else'}

param_unpickled.param1 = 'a third thing'
param_unpickled # modification appears to be successful
>> {'param1': 'a third thing'}

param_unpickled.param1 # but directly accessing the value returns the old value
>> 'something else'