Skip to content

Commit

Permalink
better check
Browse files Browse the repository at this point in the history
  • Loading branch information
jnumainville committed Mar 13, 2024
1 parent 5db46ea commit 3b3b415
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def create_client_connection(
"""
if isinstance(obj, Figure):
# this is a plotly figure, it will never be updated, so wrap once and send
obj = DeephavenFigure(obj)
obj = DeephavenFigure(obj, is_plotly_fig=True)

figure_connection = DeephavenFigureConnection(obj, connection)
initial_message = json.dumps(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ def __init__(
has_color: bool = False,
trace_generator: Generator[dict[str, Any], None, None] | None = None,
has_subplots: bool = False,
is_plotly_fig: bool = False,
):
"""
Create a new DeephavenFigure
Expand All @@ -407,6 +408,7 @@ def __init__(
has_color: If this figure has color
trace_generator: The trace generator
has_subplots: If this figure has subplots
is_plotly_fig: If this is a plotly figure
"""
# keep track of function that called this, and it's args
self._head_node = DeephavenHeadNode()
Expand All @@ -428,6 +430,8 @@ def __init__(

self._has_subplots = has_subplots

self._is_plotly_fig = is_plotly_fig

self._liveness_scope = LivenessScope()

def copy_mappings(self: DeephavenFigure, offset: int = 0) -> list[DataMapping]:
Expand Down Expand Up @@ -584,8 +588,8 @@ def get_figure(self) -> DeephavenFigure | None:
Returns:
The figure
"""
if not self._head_node.get_figure():
# if there is no figure stored in the node, a plotly figure was passed directly
if self._is_plotly_fig:
# a plotly figure was passed directly
# just return this figure since it will never be updated
return self
return self._head_node.get_figure()
Expand Down Expand Up @@ -680,6 +684,7 @@ def copy(self) -> DeephavenFigure:
self._has_color,
self._trace_generator,
self._has_subplots,
self._is_plotly_fig,
)
new_figure._head_node = self._head_node.copy_graph()
return new_figure
Expand Down

0 comments on commit 3b3b415

Please sign in to comment.