Browse code

2D: fix bug for when first points are added that are not bounds

Bas Nijholt authored on 16/11/2017 00:07:19
Showing 1 changed files
... ...
@@ -162,14 +162,14 @@ class Learner2D(BaseLearner):
162 162
         return np.delete(self.values_combined,
163 163
                          list(self._interp.values()), axis=0)
164 164
 
165
-    def ip(self):
166
-        points = self.scale(self.points)
167
-        return interpolate.LinearNDInterpolator(points, self.values)
168
-
169 165
     @property
170 166
     def n_real(self):
171 167
         return self.n - len(self._interp)
172 168
 
169
+    def ip(self):
170
+        points = self.scale(self.points)
171
+        return interpolate.LinearNDInterpolator(points, self.values)
172
+
173 173
     def ip_combined(self):
174 174
         points = self.scale(self.points_combined)
175 175
         values = self.values_combined
... ...
@@ -223,7 +223,6 @@ class Learner2D(BaseLearner):
223 223
             self._values = np.resize(self._values, (nmax, self.vdim))
224 224
             self._values[n] = value
225 225
 
226
-        # Remove the point if in the stack.
227 226
         self._stack.pop(point, None)
228 227
 
229 228
     def _fill_stack(self, stack_till=None):
... ...
@@ -288,8 +287,9 @@ class Learner2D(BaseLearner):
288 287
                 # The while loop is needed because `stack_till` could be larger
289 288
                 # than the number of triangles between the points. Therefore
290 289
                 # it could fill up till a length smaller than `stack_till`.
291
-                if self.n >= 2**self.ndim:
292
-                    # Only fill the stack if no more bounds left in _stack
290
+                no_bounds_in_stack = not any(p in self._stack
291
+                                             for p in self._bounds_points)
292
+                if no_bounds_in_stack:
293 293
                     self._fill_stack(stack_till=n_left)
294 294
                 new_points, new_loss_improvements = self._split_stack(n_left)
295 295
                 points += new_points