Skip to content

Commit 259d509

Browse files
committed
Add tests for layers and range keys
1 parent a3940ee commit 259d509

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

packages/python/plotly/plotly/tests/test_optional/test_graph_objs/test_skipped_b64_keys.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,58 @@ def test_np_geojson(self):
3838
fig.show()
3939

4040
assert (fig["data"][0]["geojson"]["geometry"]["coordinates"] == normal_coordinates).all()
41+
42+
def test_np_layers(self):
43+
layout = {
44+
"mapbox": {
45+
"layers": [
46+
{
47+
"sourcetype": "geojson",
48+
"type": "line",
49+
"line": {
50+
"dash": np.array([2.5, 1])
51+
},
52+
"source": {
53+
"type": "FeatureCollection",
54+
"features": [
55+
{
56+
"type": "Feature",
57+
"geometry": {
58+
"type": "LineString",
59+
"coordinates": np.array([[0.25, 52], [0.75, 50]])
60+
},
61+
}
62+
]
63+
}
64+
},
65+
],
66+
"center": {
67+
"lon": 0.5,
68+
"lat": 51
69+
}
70+
},
71+
}
72+
data = [
73+
{
74+
"type": "scattermapbox"
75+
}
76+
]
77+
78+
fig = go.Figure(data=data, layout=layout)
79+
80+
# TODO: This is failing because the actual value of the "dash" field
81+
# is converted to the { b64, dtype } object.
82+
# assert fig.layout['mapbox']['layers'][0]['line']['dash'] == (2.5, 1)
83+
84+
assert (fig.layout['mapbox']['layers'][0]['source']['features'][0]['geometry']['coordinates'] == [[0.25, 52], [0.75, 50]]).all()
85+
86+
def test_np_range(self):
87+
layout = {
88+
"xaxis": {
89+
"range": np.array([0, 1])
90+
}
91+
}
92+
93+
fig = go.Figure(data=[{ "type": "scatter" }], layout=layout)
94+
95+
assert fig.layout["xaxis"]["range"] == (0, 1)

0 commit comments

Comments
 (0)