Skip to content

Commit a3940ee

Browse files
committed
Simplify tests
1 parent c6390f4 commit a3940ee

File tree

1 file changed

+30
-54
lines changed

1 file changed

+30
-54
lines changed

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

Lines changed: 30 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,39 @@
22
import numpy as np
33
from plotly.tests.test_optional.optional_utils import NumpyTestUtilsMixin
44
import plotly.graph_objs as go
5+
import plotly.io as pio
6+
7+
pio.renderers.default = 'iframe'
58

69
class TestSkippedBase64Keys(NumpyTestUtilsMixin, TestCase):
710
def test_np_geojson(self):
8-
choropleth_coordinates = np.array([[
9-
# Use the min / max of both coordinates to make a simple square
10-
[-87.359296, 35.00118],
11-
[-87.359296, 30.247195],
12-
[-85.004212, 30.247195],
13-
[-85.004212, 35.00118],
14-
]])
11+
normal_coordinates = [[
12+
[-87, 35],
13+
[-87, 30],
14+
[-85, 30],
15+
[-85, 35],
16+
]]
17+
18+
numpy_coordinates = np.array(normal_coordinates)
1519

16-
data = [{
17-
"type": "choropleth",
18-
"name": "choropleth + RAW",
19-
"locations": ["AL"],
20-
"featureidkey": "properties.id",
21-
"z": np.array([10]),
22-
"showscale": False,
23-
"geojson": {
24-
"type": "Feature",
25-
"properties": {
26-
"id": "AL"
27-
},
28-
"geometry": {
29-
"type": "Polygon",
30-
"coordinates": choropleth_coordinates
31-
}
32-
}
33-
}]
20+
data = [{
21+
"type": "choropleth",
22+
"locations": ["AL"],
23+
"featureidkey": "properties.id",
24+
"z": np.array([10]),
25+
"geojson": {
26+
"type": "Feature",
27+
"properties": {
28+
"id": "AL"
29+
},
30+
"geometry": {
31+
"type": "Polygon",
32+
"coordinates": numpy_coordinates
33+
}
34+
}
35+
}]
3436

35-
fig = go.Figure(data=data)
36-
exp_data = {
37-
'featureidkey': 'properties.id',
38-
'geojson': {
39-
'geometry': {
40-
'coordinates': [[
41-
[-87.359296, 35.00118],
42-
[-87.359296, 30.247195],
43-
[-85.004212, 30.247195],
44-
[-85.004212, 35.00118],
45-
]],
46-
'type': 'Polygon'
47-
},
48-
'properties': {
49-
'id': 'AL'
50-
},
51-
'type': 'Feature'
52-
},
53-
'locations': ['AL'],
54-
'name': 'choropleth + RAW',
55-
'showscale': False,
56-
'type': 'choropleth',
57-
'z': {
58-
'bdata': 'Cg==',
59-
'dtype': 'i1'
60-
}
61-
}
62-
fig.show()
37+
fig = go.Figure(data=data)
38+
fig.show()
6339

64-
self.assert_fig_equal(fig.data[0], exp_data)
40+
assert (fig["data"][0]["geojson"]["geometry"]["coordinates"] == normal_coordinates).all()

0 commit comments

Comments
 (0)