From 4d36f5692a965ab95364b79688a7a1e665f6e502 Mon Sep 17 00:00:00 2001 From: Philipp Holl Date: Sun, 3 Nov 2024 13:21:38 +0100 Subject: [PATCH] [vis] Fix Plotly cylinder/sphere with non-NumPy backend --- phi/vis/_dash/_plotly_plots.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/phi/vis/_dash/_plotly_plots.py b/phi/vis/_dash/_plotly_plots.py index 93a8ef95e..361b02d3e 100644 --- a/phi/vis/_dash/_plotly_plots.py +++ b/phi/vis/_dash/_plotly_plots.py @@ -481,9 +481,15 @@ def plot_one_material(data, color, alpha: float): math.map(plot_one_material, data, color, alpha, dims=merge_shapes(color, alpha), unwrap_scalars=True) def _sphere_vertex_count(self, radius: Tensor, space: Box): + with math.NUMPY: + radius = math.convert(radius) + space = math.convert(space) size_in_fig = radius.max / space.size.max - vertex_count = np.clip(int(size_in_fig ** .5 * 50), 4, 64) - return vertex_count + def individual_vertex_count(size_in_fig): + if ~np.isfinite(size_in_fig): + return 0 + return np.clip(int(abs(size_in_fig) ** .5 * 50), 4, 64) + return math.map(individual_vertex_count, size_in_fig) class Scatter3D(Recipe):