11import numpy as np
22import pytest
33
4- import pandas .util ._test_decorators as td
5-
64import pandas as pd
75import pandas ._testing as tm
86
97pytestmark = [pytest .mark .single_cpu , pytest .mark .bodo_udf_engine ]
108
119
12- @pytest .fixture
13- def skip_if_no_bodo ():
14- """Avoid using in test decorator which will cause bodo import immediately."""
15- td .skip_if_no ("bodo" )
10+ @pytest .fixture (params = ["bodo" ])
11+ def engine (request ):
12+ """Test bodo engine by itself to avoid extensions conflicting with numba.
13+
14+ Note: Using a fixture here to avoid importing at the start of the session.
15+ """
16+ if request .param == "bodo" :
17+ pytest .importorskip ("bodo" )
18+ return request .param
1619
1720
18- def test_bodo_vs_python_indexing (skip_if_no_bodo ):
21+ def test_bodo_vs_python_indexing (engine ):
1922 frame = pd .DataFrame (
2023 {"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ], "c" : [7.0 , 8.0 , 9.0 ]},
2124 )
@@ -33,14 +36,14 @@ def f(a):
3336 "reduction" ,
3437 [lambda x : x .mean (), lambda x : x .min (), lambda x : x .max (), lambda x : x .sum ()],
3538)
36- def test_bodo_vs_python_reductions (reduction , skip_if_no_bodo ):
39+ def test_bodo_vs_python_reductions (reduction , engine ):
3740 df = pd .DataFrame (np .ones ((4 , 4 ), dtype = np .float64 ))
3841 result = df .apply (reduction , engine = "bodo" , axis = 1 )
3942 expected = df .apply (reduction , engine = "python" , axis = 1 )
4043 tm .assert_series_equal (result , expected , check_series_type = False )
4144
4245
43- def test_bodo_vs_python_df_output (skip_if_no_bodo ):
46+ def test_bodo_vs_python_df_output (engine ):
4447 df = pd .DataFrame ({"A" : np .arange (20 ), "B" : ["hi" , "there" ] * 10 })
4548
4649 def f (a ):
@@ -52,7 +55,7 @@ def f(a):
5255 tm .assert_frame_equal (result , expected , check_frame_type = False , check_dtype = False )
5356
5457
55- def test_bodo_vs_python_args (skip_if_no_bodo ):
58+ def test_bodo_vs_python_args (engine ):
5659 msg = (
5760 "the 'bodo' engine does not support passing additional args/kwargs "
5861 "to apply function yet."
@@ -71,7 +74,7 @@ def f(x, y):
7174
7275
7376@pytest .mark .parametrize ("axis" , [0 , 1 ])
74- def test_bodo_vs_python_str_apply (axis , skip_if_no_bodo ):
77+ def test_bodo_vs_python_str_apply (axis , engine ):
7578 df = pd .DataFrame ({"A" : np .arange (20 )})
7679
7780 func = "mean"
@@ -82,7 +85,7 @@ def test_bodo_vs_python_str_apply(axis, skip_if_no_bodo):
8285 tm .assert_series_equal (result , expected , check_series_type = False )
8386
8487
85- def test_bodo_unsupported_axis (skip_if_no_bodo ):
88+ def test_bodo_unsupported_axis (engine ):
8689 """Tests that a BodoError is raised when trying to apply UDF column-wise"""
8790 frame = pd .DataFrame (
8891 {"a" : [1 , 2 , 3 ]},
@@ -98,7 +101,7 @@ def f(a):
98101 frame .apply (f , engine = "bodo" , axis = 0 )
99102
100103
101- def test_bodo_raw_unsupported (skip_if_no_bodo ):
104+ def test_bodo_raw_unsupported (engine ):
102105 """Tests that error gets raised when using raw=True"""
103106 frame = pd .DataFrame (
104107 {"a" : [1 , 2 , 3 ]},
@@ -113,7 +116,7 @@ def f(a):
113116 frame .apply (f , engine = "bodo" , raw = True , axis = 1 )
114117
115118
116- def test_bodo_result_type_unsupported (skip_if_no_bodo ):
119+ def test_bodo_result_type_unsupported (engine ):
117120 """Tests that error gets raised when passing any value to result_type"""
118121 frame = pd .DataFrame (
119122 {"a" : [1 , 2 , 3 ]},
0 commit comments