|
| 1 | +import json |
1 | 2 | from unittest import TestCase
|
2 | 3 | import numpy as np
|
3 | 4 | from plotly.tests.test_optional.optional_utils import NumpyTestUtilsMixin
|
@@ -34,8 +35,9 @@ def test_np_geojson(self):
|
34 | 35 | fig = go.Figure(data=data)
|
35 | 36 |
|
36 | 37 | assert (
|
37 |
| - fig["data"][0]["geojson"]["geometry"]["coordinates"] == normal_coordinates |
38 |
| - ).all() |
| 38 | + json.loads(fig.to_json())["data"][0]["geojson"]["geometry"]["coordinates"] |
| 39 | + == normal_coordinates |
| 40 | + ) |
39 | 41 |
|
40 | 42 | def test_np_layers(self):
|
41 | 43 | layout = {
|
@@ -68,18 +70,15 @@ def test_np_layers(self):
|
68 | 70 |
|
69 | 71 | fig = go.Figure(data=data, layout=layout)
|
70 | 72 |
|
71 |
| - assert fig.layout["mapbox"]["layers"][0]["line"]["dash"] == (2.5, 1) |
| 73 | + assert (fig.layout["mapbox"]["layers"][0]["line"]["dash"] == (2.5, 1)).all() |
72 | 74 |
|
73 |
| - assert ( |
74 |
| - fig.layout["mapbox"]["layers"][0]["source"]["features"][0]["geometry"][ |
75 |
| - "coordinates" |
76 |
| - ] |
77 |
| - == [[0.25, 52], [0.75, 50]] |
78 |
| - ).all() |
| 75 | + assert json.loads(fig.to_json())["layout"]["mapbox"]["layers"][0]["source"][ |
| 76 | + "features" |
| 77 | + ][0]["geometry"]["coordinates"] == [[0.25, 52], [0.75, 50]] |
79 | 78 |
|
80 | 79 | def test_np_range(self):
|
81 | 80 | layout = {"xaxis": {"range": np.array([0, 1])}}
|
82 | 81 |
|
83 | 82 | fig = go.Figure(data=[{"type": "scatter"}], layout=layout)
|
84 | 83 |
|
85 |
| - assert fig.layout["xaxis"]["range"] == (0, 1) |
| 84 | + assert json.loads(fig.to_json())["layout"]["xaxis"]["range"] == [0, 1] |
0 commit comments