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
5
7
- pio .renderers .default = 'iframe'
8
6
9
7
class TestSkippedBase64Keys (NumpyTestUtilsMixin , TestCase ):
10
8
def test_np_geojson (self ):
11
- normal_coordinates = [[
12
- [- 87 , 35 ],
13
- [- 87 , 30 ],
14
- [- 85 , 30 ],
15
- [- 85 , 35 ],
16
- ]]
9
+ normal_coordinates = [
10
+ [
11
+ [- 87 , 35 ],
12
+ [- 87 , 30 ],
13
+ [- 85 , 30 ],
14
+ [- 85 , 35 ],
15
+ ]
16
+ ]
17
17
18
- numpy_coordinates = np .array (normal_coordinates )
18
+ numpy_coordinates = np .array (normal_coordinates )
19
19
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
- }]
20
+ data = [
21
+ {
22
+ "type" : "choropleth" ,
23
+ "locations" : ["AL" ],
24
+ "featureidkey" : "properties.id" ,
25
+ "z" : np .array ([10 ]),
26
+ "geojson" : {
27
+ "type" : "Feature" ,
28
+ "properties" : {"id" : "AL" },
29
+ "geometry" : {"type" : "Polygon" , "coordinates" : numpy_coordinates },
30
+ },
31
+ }
32
+ ]
36
33
37
- fig = go .Figure (data = data )
38
- fig .show ()
34
+ fig = go .Figure (data = data )
39
35
40
- assert (fig ["data" ][0 ]["geojson" ]["geometry" ]["coordinates" ] == normal_coordinates ).all ()
36
+ assert (
37
+ fig ["data" ][0 ]["geojson" ]["geometry" ]["coordinates" ] == normal_coordinates
38
+ ).all ()
41
39
42
40
def test_np_layers (self ):
43
41
layout = {
@@ -46,50 +44,44 @@ def test_np_layers(self):
46
44
{
47
45
"sourcetype" : "geojson" ,
48
46
"type" : "line" ,
49
- "line" : {
50
- "dash" : np .array ([2.5 , 1 ])
51
- },
47
+ "line" : {"dash" : np .array ([2.5 , 1 ])},
52
48
"source" : {
53
49
"type" : "FeatureCollection" ,
54
50
"features" : [
55
51
{
56
52
"type" : "Feature" ,
57
53
"geometry" : {
58
54
"type" : "LineString" ,
59
- "coordinates" : np .array ([[0.25 , 52 ], [0.75 , 50 ]])
55
+ "coordinates" : np .array (
56
+ [[0.25 , 52 ], [0.75 , 50 ]]
57
+ ),
60
58
},
61
59
}
62
- ]
63
- }
60
+ ],
61
+ },
64
62
},
65
63
],
66
- "center" : {
67
- "lon" : 0.5 ,
68
- "lat" : 51
69
- }
64
+ "center" : {"lon" : 0.5 , "lat" : 51 },
70
65
},
71
66
}
72
- data = [
73
- {
74
- "type" : "scattermapbox"
75
- }
76
- ]
67
+ data = [{"type" : "scattermapbox" }]
77
68
78
69
fig = go .Figure (data = data , layout = layout )
79
70
80
71
# TODO: This is failing because the actual value of the "dash" field
81
- # is converted to the { b64, dtype } object.
72
+ # is converted to the { b64, dtype } object.
82
73
# 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 ()
74
+
75
+ assert (
76
+ fig .layout ["mapbox" ]["layers" ][0 ]["source" ]["features" ][0 ]["geometry" ][
77
+ "coordinates"
78
+ ]
79
+ == [[0.25 , 52 ], [0.75 , 50 ]]
80
+ ).all ()
85
81
86
82
def test_np_range (self ):
87
- layout = {
88
- "xaxis" : {
89
- "range" : np .array ([0 , 1 ])
90
- }
91
- }
83
+ layout = {"xaxis" : {"range" : np .array ([0 , 1 ])}}
92
84
93
- fig = go .Figure (data = [{ "type" : "scatter" }], layout = layout )
85
+ fig = go .Figure (data = [{"type" : "scatter" }], layout = layout )
94
86
95
- assert fig .layout ["xaxis" ]["range" ] == (0 , 1 )
87
+ assert fig .layout ["xaxis" ]["range" ] == (0 , 1 )
0 commit comments