Skip to content

Commit f7675c3

Browse files
committed
add tests
1 parent ca90f21 commit f7675c3

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

packages/python/plotly/plotly/tests/test_io/test_to_from_json.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import plotly.io as pio
33
import pytest
44
import plotly
5+
import numpy as np
56
import json
67
import os
78
import tempfile
@@ -259,3 +260,16 @@ def test_write_json_from_file_string(fig1, pretty, remove_uids):
259260
# Check contents that were written
260261
expected = pio.to_json(fig1, pretty=pretty, remove_uids=remove_uids)
261262
assert result == expected
263+
264+
265+
def test_to_dict_empty_np_array_int64():
266+
fig = go.Figure(
267+
[
268+
go.Bar(
269+
x=np.array([], dtype="str"),
270+
y=np.array([], dtype="int64"),
271+
)
272+
]
273+
)
274+
# to_dict() should not raise an exception
275+
fig.to_dict()

packages/python/plotly/plotly/tests/test_optional/test_px/test_px.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,3 +360,18 @@ def test_render_mode(backend):
360360
)
361361
assert fig.data[0].type == "histogram2dcontour"
362362
assert fig.data[1].type == "scatter"
363+
364+
365+
def test_empty_df_int64(backend):
366+
# Load px data, then filter it such that the dataframe is empty
367+
df = px.data.tips(return_type=backend)
368+
df = nw.from_native(px.data.tips(return_type=backend))
369+
df_empty = df.filter(nw.col("day") == "banana").to_native()
370+
371+
fig = px.scatter(
372+
df_empty,
373+
x="total_bill",
374+
y="size", # size is an int64 column
375+
)
376+
# to_dict() should not raise an exception
377+
fig.to_dict()

0 commit comments

Comments
 (0)