7
7
import base64
8
8
import datetime
9
9
from plotly .express .imshow_utils import rescale_intensity
10
+ from plotly .tests .b64 import _b64
10
11
11
12
img_rgb = np .array ([[[255 , 0 , 0 ], [0 , 255 , 0 ], [0 , 0 , 255 ]]], dtype = np .uint8 )
12
13
img_gray = np .arange (100 , dtype = float ).reshape ((10 , 10 ))
@@ -181,7 +182,7 @@ def test_imshow_xarray(binary_string):
181
182
assert fig .layout .xaxis .title .text == "dim_cols"
182
183
assert fig .layout .yaxis .title .text == "dim_rows"
183
184
if not binary_string :
184
- assert np .all (np .array (fig .data [0 ].x ) == np . array (da .coords ["dim_cols" ]))
185
+ assert np .all (np .array (fig .data [0 ].x ) == _b64 (da .coords ["dim_cols" ]))
185
186
186
187
187
188
def test_imshow_xarray_slicethrough ():
@@ -191,7 +192,7 @@ def test_imshow_xarray_slicethrough():
191
192
# Dimensions are used for axis labels and coordinates
192
193
assert fig .layout .xaxis .title .text == "dim_2"
193
194
assert fig .layout .yaxis .title .text == "dim_1"
194
- assert np .all (np .array (fig .data [0 ].x ) == np . array (da .coords ["dim_2" ]))
195
+ assert np .all (np .array (fig .data [0 ].x ) == _b64 (da .coords ["dim_2" ]))
195
196
196
197
197
198
def test_imshow_xarray_facet_col_string ():
@@ -203,7 +204,7 @@ def test_imshow_xarray_facet_col_string():
203
204
# Dimensions are used for axis labels and coordinates
204
205
assert fig .layout .xaxis .title .text == "dim_2"
205
206
assert fig .layout .yaxis .title .text == "dim_1"
206
- assert np .all (np .array (fig .data [0 ].x ) == np . array (da .coords ["dim_2" ]))
207
+ assert np .all (np .array (fig .data [0 ].x ) == _b64 (da .coords ["dim_2" ]))
207
208
208
209
209
210
def test_imshow_xarray_animation_frame_string ():
@@ -215,7 +216,7 @@ def test_imshow_xarray_animation_frame_string():
215
216
# Dimensions are used for axis labels and coordinates
216
217
assert fig .layout .xaxis .title .text == "dim_2"
217
218
assert fig .layout .yaxis .title .text == "dim_1"
218
- assert np .all (np .array (fig .data [0 ].x ) == np . array (da .coords ["dim_2" ]))
219
+ assert np .all (np .array (fig .data [0 ].x ) == _b64 (da .coords ["dim_2" ]))
219
220
220
221
221
222
def test_imshow_xarray_animation_facet_slicethrough ():
@@ -225,7 +226,7 @@ def test_imshow_xarray_animation_facet_slicethrough():
225
226
# Dimensions are used for axis labels and coordinates
226
227
assert fig .layout .xaxis .title .text == "dim_3"
227
228
assert fig .layout .yaxis .title .text == "dim_2"
228
- assert np .all (np .array (fig .data [0 ].x ) == np . array (da .coords ["dim_3" ]))
229
+ assert np .all (np .array (fig .data [0 ].x ) == _b64 (da .coords ["dim_3" ]))
229
230
230
231
231
232
def test_imshow_labels_and_ranges ():
@@ -291,8 +292,7 @@ def test_imshow_dataframe():
291
292
assert fig .data [0 ].x [0 ] == df .columns [0 ]
292
293
assert fig .data [0 ].x [0 ] == "nation"
293
294
assert fig .layout .xaxis .title .text is None
294
- assert fig .data [0 ].y [0 ] == df .index [0 ]
295
- assert fig .data [0 ].y [0 ] == 0
295
+ assert fig .data [0 ].y == _b64 (df .index )
296
296
assert fig .layout .yaxis .title .text is None
297
297
298
298
df = px .data .medals_wide (indexed = True )
0 commit comments