1
+ from unittest import TestCase
2
+ import numpy as np
3
+ from plotly .tests .test_optional .optional_utils import NumpyTestUtilsMixin
4
+ import plotly .graph_objs as go
5
+
6
+ class TestSkippedBase64Keys (NumpyTestUtilsMixin , TestCase ):
7
+ 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
+ ]])
15
+
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
+ }]
34
+
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 ()
63
+
64
+ self .assert_fig_equal (fig .data [0 ], exp_data )
0 commit comments