I've had good luck with CloudPickle, a package, when Pickle doesn't work.
________________________________
From: sympy@googlegroups.com <sympy@googlegroups.com> on behalf of Thomas Ligon 
<thomassli...@gmail.com>
Sent: Saturday, January 28, 2023 8:38:46 AM
To: sympy <sympy@googlegroups.com>
Subject: [sympy] pickle for Function and Derivative

Should pickle work for Function and Derivative? I found Sympy issue #4297 and 
the answer seems to be no.
Nevertheless, here is what I have:
I have a private dictionary containing expressions of symbols, and everything 
works fine.
Then I created a new private dictionary that includes Function and Derivative, 
and I can't pickle it. Here are some code snippets:

    q1S, q2S = symbols('q1, q2')
    q1F = Function('q1')
...
    varX = globals()['CuspData']
    fileName = os.path.join(config.pickle_dir, 'CuspData.pckl')
    f = open(fileName, "wb")
    varX = {'q1d0': q1F(tS), 'q1d1': Derivative(q1F(tS), tS)} # test
    #with evaluate(False): pickle.dump(varX, f)
    pickle.dump(varX, f)
    f.close()
The error is "Can't pickle q1: attribute lookup q1 on __main__ failed"

--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
sympy+unsubscr...@googlegroups.com<mailto:sympy+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/6821930c-117b-4b15-abec-f003782dcf85n%40googlegroups.com<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fsympy%2F6821930c-117b-4b15-abec-f003782dcf85n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7C%7Cc5103a600fa7464d65a108db014e21b1%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638105207308186052%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=LyBC8Il5LJujrUCR%2BOpyIjbAOo%2BLUWs8El3KhWmF2uA%3D&reserved=0>.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/DM8P223MB0221F457D9C21C63B53D31E8B2CD9%40DM8P223MB0221.NAMP223.PROD.OUTLOOK.COM.

Reply via email to