m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
401 B

6 months ago
  1. import os
  2. import tempfile
  3. import pickle
  4. from mpmath import *
  5. def pickler(obj):
  6. fn = tempfile.mktemp()
  7. f = open(fn, 'wb')
  8. pickle.dump(obj, f)
  9. f.close()
  10. f = open(fn, 'rb')
  11. obj2 = pickle.load(f)
  12. f.close()
  13. os.remove(fn)
  14. return obj2
  15. def test_pickle():
  16. obj = mpf('0.5')
  17. assert obj == pickler(obj)
  18. obj = mpc('0.5','0.2')
  19. assert obj == pickler(obj)