@@ -33,6 +33,25 @@ def __setstate__(self, function):
33
33
34
34
35
35
class SequenceLearner (BaseLearner ):
36
+ """A learner that will learn a sequence.
37
+
38
+ This is useful when your problem cannot be formulated in terms of
39
+ another adaptive learner, but you still want to use Adaptive's
40
+ routines to run, save, and plot.
41
+
42
+ Parameters
43
+ ----------
44
+ function : callable
45
+ The function to learn. Must take a single element `sequence`.
46
+ sequence : sequence
47
+ The sequence to learn.
48
+
49
+ Attributes
50
+ ----------
51
+ data : dict
52
+ The data as a mapping from "index of element in sequence" => value.
53
+ """
54
+
36
55
def __init__ (self , function , sequence ):
37
56
self ._original_function = function
38
57
self .function = _IgnoreFirstArgument (function )
@@ -65,7 +84,10 @@ def _get_data(self):
65
84
66
85
def _set_data (self , data ):
67
86
if data :
68
- self .tell_many (* zip (* data .items ()))
87
+ indices , values = zip (* data .items ())
88
+ # the points aren't used by tell, so we can safely pass None
89
+ points = [(i , None ) for i in indices ]
90
+ self .tell_many (points , values )
69
91
70
92
def loss (self , real = True ):
71
93
if not (self ._to_do_indices or self .pending_points ):
0 commit comments