2
2
import numpy as np
3
3
from plotly .tests .test_optional .optional_utils import NumpyTestUtilsMixin
4
4
import plotly .graph_objs as go
5
+ import plotly .io as pio
6
+
7
+ pio .renderers .default = 'iframe'
5
8
6
9
class TestSkippedBase64Keys (NumpyTestUtilsMixin , TestCase ):
7
10
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 )
15
19
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
+ }]
34
36
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 ()
63
39
64
- self . assert_fig_equal (fig . data [0 ], exp_data )
40
+ assert (fig [ " data" ] [0 ][ "geojson" ][ "geometry" ][ "coordinates" ] == normal_coordinates ). all ( )
0 commit comments