@@ -33,6 +33,25 @@ def __setstate__(self, function):
3333
3434
3535class 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+
3655 def __init__ (self , function , sequence ):
3756 self ._original_function = function
3857 self .function = _IgnoreFirstArgument (function )
@@ -65,7 +84,10 @@ def _get_data(self):
6584
6685 def _set_data (self , data ):
6786 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 )
6991
7092 def loss (self , real = True ):
7193 if not (self ._to_do_indices or self .pending_points ):
0 commit comments