When trying to use the copy standard library to make a deep copy of a dictionary of a Scipp object, the library tries to pickle the object which it can't do because Scipp objects are un-pickable:
import scipp as sc
import copy
test = sc.scalar(2, unit='m')
copy.deepcopy(sc.to_dict(test))
A possible solution to this issue is simply to implement the __ copy__ and __ deepcopy__ methods which, when implemented, gets called by the copy library instead of it trying to pickle the class.
When trying to use the
copystandard library to make a deep copy of a dictionary of a Scipp object, the library tries to pickle the object which it can't do because Scipp objects are un-pickable:A possible solution to this issue is simply to implement the
__ copy__and__ deepcopy__methods which, when implemented, gets called by the copy library instead of it trying to pickle the class.