File tree 2 files changed +16
-0
lines changed
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,16 @@ def __array_finalize__(self, obj):
56
56
self .name = getattr (obj , 'name' , '' )
57
57
self ._opts = getattr (obj , '_opts' , {})
58
58
59
+ # Make sure properties name and _opts are carried over
60
+ # when (un-)pickling.
61
+ def __reduce__ (self ):
62
+ value = super ().__reduce__ ()
63
+ return value [:2 ] + (value [2 ] + (self .__dict__ ,),)
64
+
65
+ def __setstate__ (self , state ):
66
+ self .__dict__ .update (state [- 1 ])
67
+ super ().__setstate__ (state [:- 1 ])
68
+
59
69
def __bool__ (self ):
60
70
try :
61
71
return bool (self [- 1 ])
Original file line number Diff line number Diff line change 4
4
import time
5
5
import unittest
6
6
import warnings
7
+ from concurrent .futures .process import ProcessPoolExecutor
7
8
from contextlib import contextmanager
8
9
from glob import glob
9
10
from runpy import run_path
@@ -899,6 +900,11 @@ def next(self):
899
900
900
901
Backtest (GOOG .iloc [:20 ], S ).run ()
901
902
903
+ def test_indicators_picklable (self ):
904
+ with ProcessPoolExecutor () as executor :
905
+ stats = executor .submit (Backtest .run , Backtest (SHORT_DATA , SmaCross )).result ()
906
+ assert stats ._strategy ._indicators [0 ]._opts , '._opts and .name were not unpickled'
907
+
902
908
903
909
class TestDocs (TestCase ):
904
910
DOCS_DIR = os .path .join (os .path .dirname (__file__ ), '..' , '..' , 'doc' )
You can’t perform that action at this time.
0 commit comments