Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions plotly/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@ def _py_to_js(v, widget_manager):
Value that the ipywidget library can serialize natively
"""

# Handle Undefined
# ----------------
if v is Undefined:
return "_undefined_"

# Fast path for simple types
elif type(v) in (str, int, float, bool) or v is None:
return v

# Handle dict recursively
# -----------------------
if isinstance(v, dict):
elif isinstance(v, dict):
return {k: _py_to_js(v, widget_manager) for k, v in v.items()}

# Handle list/tuple recursively
Expand All @@ -53,11 +62,6 @@ def _py_to_js(v, widget_manager):
# Convert all other numpy arrays to lists
return v.tolist()

# Handle Undefined
# ----------------
if v is Undefined:
return "_undefined_"

# Handle simple value
# -------------------
else:
Expand Down