Can't copy simulation in Python, wonder how to fix
JonathanHammer2 opened this issue · 2 comments
Hello again,
I am trying to copy a "master" simulation in Python into a new, independent, "copy" simulation so that I can make changes to the states independent of the "master" without affecting it.
I tried copy and also "deepcopy" per the following:
sim_copy = copy.copy(sim)
and I get an error about "pickling," per below. I'm wondering if you have a straightforward solution to this.
Update: I see the self copy as in : sim_copy = sim.copy()
Will this allow me to manipulate sim_copy without affecting "sim?"
Thanks
Thanks!
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1496, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/cycloastro/PycharmProjects/Kalman Python Project/main.py", line 268, in
main()
File "/Users/cycloastro/PycharmProjects/Kalman Python Project/main.py", line 128, in main
sim_copy = copy.copy(sim)
File "/Users/cycloastro/anaconda3/envs/pythonProject1/lib/python3.10/copy.py", line 92, in copy
rv = reductor(4)
ValueError: ctypes objects containing pointers cannot be pickled
Both
sim_copy = copy.copy(sim)
and
sim_copy = sim.copy()
works for me. To look into it, I'd need to know which version of python and rebound you're using. I'd also need to have some code that I can run to reproduces the issue..