Skip to content
Snippets Groups Projects

Resolve "(LearnerND) add iso-surface plot feature"

Merged Jorn Hoofwijk requested to merge 112-learnernd-add-iso-surface-plot-feature into master
Compare and Show latest version
2 files
+ 33
34
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -577,11 +577,6 @@ class LearnerND(BaseLearner):
else:
raise ValueError("Only 1 or 2-dimensional plots can be generated.")
def get_range(self):
r_min = min(self.data[v] for v in self.tri.vertices)
r_max = max(self.data[v] for v in self.tri.vertices)
return r_min, r_max
def _get_isosurface(self, level=0.0):
if self.ndim != 3 or self.vdim != 1:
raise Exception('Isosurface plotting is only supported'
@@ -633,7 +628,8 @@ class LearnerND(BaseLearner):
faces.append(plane[1:])
if len(faces) == 0:
r_min, r_max = self.get_range()
r_min = min(self.data[v] for v in self.tri.vertices)
r_max = max(self.data[v] for v in self.tri.vertices)
raise ValueError(
f"Could not draw isosurface for level={level}, as"
@@ -682,7 +678,7 @@ class LearnerND(BaseLearner):
# If the volume of the two triangles combined is zero then they
# belong to the same plane.
for simplex_key, color in color_dict.items():
points = np.array([hull.points[i] for i in np.unique(simplex_key + simplex)])
points = np.array([hull.points[i] for i in set(simplex_key + simplex)])
if np.linalg.matrix_rank(points[1:] - points[0]) < 3:
return color
if scipy.spatial.ConvexHull(points).volume < 1e-5:
@@ -695,4 +691,4 @@ class LearnerND(BaseLearner):
x, y, z = zip(*self._bounds_points)
i, j, k = hull.simplices.T
return plotly.graph_objs.Mesh3d(x=x, y=y, z=z, i=i, j=j, k=k,
facecolor=(colors), opacity=opacity)
facecolor=colors, opacity=opacity)
Loading