9 | 9 |
similarity index 75% |
10 | 10 |
rename from adaptive/learner/meta_data_saver.py |
11 | 11 |
rename to adaptive/learner/data_saver.py |
... | ... |
@@ -1,7 +1,9 @@ |
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
+from collections import OrderedDict |
|
4 |
+ |
|
3 | 5 |
class DataSaver: |
4 |
- """Save meta data associated with the values that need to be learned. |
|
6 |
+ """Save extra data associated with the values that need to be learned. |
|
5 | 7 |
|
6 | 8 |
Parameters |
7 | 9 |
---------- |
... | ... |
@@ -20,9 +22,8 @@ class DataSaver: |
20 | 22 |
""" |
21 | 23 |
|
22 | 24 |
def __init__(self, learner, arg_picker): |
23 |
- super().__init__() |
|
24 | 25 |
self.learner = learner |
25 |
- self.meta_data = {} |
|
26 |
+ self.extra_data = OrderedDict() |
|
26 | 27 |
self.function = learner.function |
27 | 28 |
self.arg_picker = arg_picker |
28 | 29 |
|
... | ... |
@@ -31,7 +32,7 @@ class DataSaver: |
31 | 32 |
self.loss = self.learner.loss |
32 | 33 |
self.remove_unfinished = self.learner.remove_unfinished |
33 | 34 |
|
34 |
- def add_point(self, x, y): |
|
35 |
- result = self.arg_picker(y) |
|
36 |
- self.meta_data[x] = y |
|
37 |
- self.learner.add_point(x, result) |
|
35 |
+ def add_point(self, x, result): |
|
36 |
+ y = self.arg_picker(result) |
|
37 |
+ self.extra_data[x] = result |
|
38 |
+ self.learner.add_point(x, y) |
... | ... |
@@ -496,7 +496,7 @@ |
496 | 496 |
"cell_type": "markdown", |
497 | 497 |
"metadata": {}, |
498 | 498 |
"source": [ |
499 |
- "Now the `DataSavingLearner` will have an dictionary attribute `meta_data` that has `x` as key and the extra data as values." |
|
499 |
+ "Now the `DataSavingLearner` will have an dictionary attribute `extra_data` that has `x` as key and the data that was returned by `learner.function` as values." |
|
500 | 500 |
] |
501 | 501 |
}, |
502 | 502 |
{ |
... | ... |
@@ -505,7 +505,7 @@ |
505 | 505 |
"metadata": {}, |
506 | 506 |
"outputs": [], |
507 | 507 |
"source": [ |
508 |
- "learner.meta_data" |
|
508 |
+ "learner.extra_data" |
|
509 | 509 |
] |
510 | 510 |
}, |
511 | 511 |
{ |