Hello, I am new to SfePy (it looks amazing) I have a question: Is it possible to dump a state variable ?
from sfepy.discrete import Problem problem = Problem.from_conf_file( "C:/ProgramData/Anaconda3/Lib/site-packages/sfepy/examples/linear_elasticity/its2D_1.py") state = problem.solve()
from pickle import dump with open("state.dat","wb") as f: dump(state,f)
TypeError Traceback (most recent call last) <ipython-input-18-15429a83d7eb> in <module> 1 from pickle import dump 2 with open("state.dat","wb") as f: ----> 3 dump(state,f)
C:\ProgramData\Anaconda3\lib\site-packages\sfepy\discrete\common\extmods\cmesh.cp36-win_amd64.pyd in sfepy.discrete.common.extmods.cmesh.CMesh.__reduce_cython__()
TypeError: no default __reduce__ due to non-trivial __cinit__
Best regards,
Hi,
On 6/18/20 10:03 AM, francoisbrest@hotmail.fr wrote:
Hello, I am new to SfePy (it looks amazing) I have a question: Is it possible to dump a state variable ?
Not at the moment. What do you want to achieve? Maybe Problem.save_restart() and Problem.load_restart() might help?
from sfepy.discrete import Problem problem = Problem.from_conf_file( "C:/ProgramData/Anaconda3/Lib/site-packages/sfepy/examples/linear_elasticity/its2D_1.py") state = problem.solve()
from pickle import dump with open("state.dat","wb") as f: dump(state,f)
TypeError Traceback (most recent call last) <ipython-input-18-15429a83d7eb> in <module> 1 from pickle import dump 2 with open("state.dat","wb") as f: ----> 3 dump(state,f)
C:\ProgramData\Anaconda3\lib\site-packages\sfepy\discrete\common\extmods\cmesh.cp36-win_amd64.pyd in sfepy.discrete.common.extmods.cmesh.CMesh.__reduce_cython__()
TypeError: no default __reduce__ due to non-trivial __cinit__
The variables reference the underlying mesh, which uses a C/cython code. That is not currently picklable and it is non-trivial to fix that. We are aware of the problem, but IMO it will not be fixed in near future, as it it a relatively low priority issue (just created [1]).
Best regards, r. [1] https://github.com/sfepy/sfepy/issues/622
participants (2)
-
francoisbrest@hotmail.fr
-
Robert Cimrman