Skip to content
Snippets Groups Projects
Commit 583b58de authored by Bas Nijholt's avatar Bas Nijholt
Browse files

2D: fix plotting when no data

parent 30f44009
No related branches found
No related tags found
1 merge request!7implement 2D learner
......@@ -816,13 +816,16 @@ class Learner2D(BaseLearner):
self._interp = {}
def plot(self, n_x=201, n_y=201):
x = np.linspace(*self.bounds[0], n_x)
y = np.linspace(*self.bounds[1], n_y)
ip = interpolate.LinearNDInterpolator(self.points_real,
self.values_real)
z = ip(x[:, None], y[None, :])
return hv.Image(z)
if self.n_real >= 4:
x = np.linspace(*self.bounds[0], n_x)
y = np.linspace(*self.bounds[1], n_y)
ip = interpolate.LinearNDInterpolator(self.points_real,
self.values_real)
z = ip(x[:, None], y[None, :])
return hv.Image(z)
else:
return hv.Image(np.zeros((2, 2)))
def __getstate__(self):
return (self._values.copy(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment