When running my klz_majoron_limits script on the QMUL machines I kept encountering this error (shortened slightly because it was rather unwieldy):
Traceback (most recent call last):
File "echidna/scripts/klz_majoron_limits.py", line 346, in <module>
main(args)
File "echidna/scripts/klz_majoron_limits.py", line 239, in main
per_bin=per_bin, use_pre_made=False)
File "/common/users/back/snoplus/software/echidna276/echidna/echidna/limit/fit.py", line 107, in __init__
self.make_fixed_background(fixed_backgrounds) # sets attribute
File "/common/users/back/snoplus/software/echidna276/echidna/echidna/limit/fit.py", line 615, in make_fixed_background
spectrum = copy.deepcopy(spectrum)
File "/data/back/software/python/lib/python2.7/copy.py", line 190, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/data/back/software/python/lib/python2.7/copy.py", line 334, in _reconstruct
state = deepcopy(state, memo)
File "/data/back/software/python/lib/python2.7/copy.py", line 163, in deepcopy
y = copier(x, memo)
File "/data/back/software/python/lib/python2.7/copy.py", line 257, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
...
File "/data/back/software/python/lib/python2.7/copy.py", line 190, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/data/back/software/python/lib/python2.7/copy.py", line 334, in _reconstruct
state = deepcopy(state, memo)
File "/data/back/software/python/lib/python2.7/copy.py", line 163, in deepcopy
y = copier(x, memo)
File "/data/back/software/python/lib/python2.7/copy.py", line 257, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/data/back/software/python/lib/python2.7/copy.py", line 190, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/data/back/software/python/lib/python2.7/copy.py", line 329, in _reconstruct
y = callable(*args)
File "/common/users/back/snoplus/software/echidna276/lib/python2.7/copy_reg.py", line 93, in __newobj__
return cls.__new__(cls, *args)
TypeError: object.__new__(thread.lock) is not safe, use thread.lock.__new__()
but not getting the error when running the same script (at the same commit) with the same version of python (2.7.6) on my laptop.
I am not sure of the cause of this, but it can be avoided by using copy.copy instead of copy.deepcopy.
The motivation for using deepcopy on spectra was that it copies all member objects e.g. instances of SpectraConfig, SpectraFitConfig, RateParameter, etc. as well so that if these are modified in the copy, the original would remain un-affected. However, on further thought, within the Fit class, the only instances that should be altered are FitParameter and derived classes. For fixed backgrounds these do not exist anyway (because they are fixed), so I think it should be safe to change the two instances here and here to just copy.copy.
When running my
klz_majoron_limits
script on the QMUL machines I kept encountering this error (shortened slightly because it was rather unwieldy):but not getting the error when running the same script (at the same commit) with the same version of python (2.7.6) on my laptop.
I am not sure of the cause of this, but it can be avoided by using
copy.copy
instead ofcopy.deepcopy
.The motivation for using
deepcopy
on spectra was that it copies all member objects e.g. instances ofSpectraConfig
,SpectraFitConfig
,RateParameter
, etc. as well so that if these are modified in the copy, the original would remain un-affected. However, on further thought, within theFit
class, the only instances that should be altered areFitParameter
and derived classes. For fixed backgrounds these do not exist anyway (because they are fixed), so I think it should be safe to change the two instances here and here to justcopy.copy
.@snoplusuk/core any objections?