Skip to content

Commit

Permalink
[vis] Fix Plotly cylinder/sphere with non-NumPy backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Holl committed Nov 3, 2024
1 parent 2338cb1 commit 4d36f56
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions phi/vis/_dash/_plotly_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 4d36f56

Please sign in to comment.