8
8
from packaging import version
9
9
import unittest .mock as mock
10
10
from plotly .express ._core import build_dataframe
11
+ from plotly import optional_imports
11
12
from pandas .testing import assert_frame_equal
12
13
import sys
13
14
import warnings
14
15
15
16
17
+ # FIXME: don't test with vaex if vaex isn't installed
18
+ if (optional_imports .get_module ("vaex" ) is None ) and (sys .version_info >= (3 , 12 )):
19
+ TEST_LIBS = ["polars" ]
20
+ else :
21
+ TEST_LIBS = ["vaex" , "polars" ]
22
+
23
+
16
24
def test_numpy ():
17
25
fig = px .scatter (x = [1 , 2 , 3 ], y = [2 , 3 , 4 ], color = [1 , 3 , 9 ])
18
26
assert np .all (fig .data [0 ].x == np .array ([1 , 2 , 3 ]))
@@ -342,7 +350,7 @@ def __dataframe__(self, allow_copy: bool = True):
342
350
or sys .version_info >= (3 , 12 ),
343
351
reason = "plotly doesn't use a dataframe interchange protocol for pandas < 2.0.2" ,
344
352
)
345
- @pytest .mark .parametrize ("test_lib" , [ "vaex" , "polars" ] )
353
+ @pytest .mark .parametrize ("test_lib" , TEST_LIBS )
346
354
def test_build_df_from_vaex_and_polars (test_lib ):
347
355
if test_lib == "vaex" :
348
356
import vaex as lib
@@ -365,7 +373,7 @@ def test_build_df_from_vaex_and_polars(test_lib):
365
373
or sys .version_info >= (3 , 12 ),
366
374
reason = "plotly doesn't use a dataframe interchange protocol for pandas < 2.0.2" ,
367
375
)
368
- @pytest .mark .parametrize ("test_lib" , [ "vaex" , "polars" ] )
376
+ @pytest .mark .parametrize ("test_lib" , TEST_LIBS )
369
377
@pytest .mark .parametrize (
370
378
"hover_data" , [["sepal_width" ], {"sepal_length" : False , "sepal_width" : ":.2f" }]
371
379
)
@@ -391,7 +399,12 @@ def test_build_df_with_hover_data_from_vaex_and_polars(test_lib, hover_data):
391
399
)
392
400
393
401
394
- def test_timezones (constructor ):
402
+ def test_timezones (request , constructor ):
403
+ # FIXME: PyArrow requires a different format for datetime constructors with timezones
404
+ from .conftest import pyarrow_table_constructor
405
+ if constructor is pyarrow_table_constructor :
406
+ request .applymarker (pytest .mark .xfail )
407
+
395
408
df = nw .from_native (
396
409
constructor ({"date" : ["2015-04-04 19:31:30+01:00" ], "value" : [3 ]})
397
410
).with_columns (nw .col ("date" ).str .to_datetime (format = "%Y-%m-%d %H:%M:%S%z" ))
0 commit comments