5
5
import numpy as np
6
6
import pytest
7
7
8
+ from pandas import set_option
8
9
import pandas ._testing as tm
9
10
from pandas .core .api import (
10
11
DataFrame ,
@@ -65,9 +66,9 @@ def call_op(df, other, flex: bool, opname: str):
65
66
else :
66
67
op = getattr (operator , opname )
67
68
68
- expr . set_use_numexpr ( False )
69
+ set_option ( "compute.use_numexpr" , False )
69
70
expected = op (df , other )
70
- expr . set_use_numexpr ( True )
71
+ set_option ( "compute.use_numexpr" , True )
71
72
72
73
expr .get_test_result ()
73
74
@@ -107,9 +108,9 @@ def run_binary(self, df, other, flex: bool):
107
108
def run_frame (self , df , other , flex : bool ):
108
109
self .run_arithmetic (df , other , flex )
109
110
110
- expr . set_use_numexpr ( False )
111
+ set_option ( "compute.use_numexpr" , False )
111
112
binary_comp = other + 1
112
- expr . set_use_numexpr ( True )
113
+ set_option ( "compute.use_numexpr" , True )
113
114
self .run_binary (df , binary_comp , flex )
114
115
115
116
for i in range (len (df .columns )):
@@ -179,9 +180,9 @@ def testit():
179
180
result = expr ._can_use_numexpr (op , op_str , right , right , "evaluate" )
180
181
assert not result
181
182
182
- expr . set_use_numexpr ( False )
183
+ set_option ( "compute.use_numexpr" , False )
183
184
testit ()
184
- expr . set_use_numexpr ( True )
185
+ set_option ( "compute.use_numexpr" , True )
185
186
expr .set_numexpr_threads (1 )
186
187
testit ()
187
188
expr .set_numexpr_threads ()
@@ -215,9 +216,9 @@ def testit():
215
216
result = expr ._can_use_numexpr (op , op_str , right , f22 , "evaluate" )
216
217
assert not result
217
218
218
- expr . set_use_numexpr ( False )
219
+ set_option ( "compute.use_numexpr" , False )
219
220
testit ()
220
- expr . set_use_numexpr ( True )
221
+ set_option ( "compute.use_numexpr" , True )
221
222
expr .set_numexpr_threads (1 )
222
223
testit ()
223
224
expr .set_numexpr_threads ()
@@ -233,9 +234,9 @@ def testit():
233
234
expected = np .where (c , df .values , df .values + 1 )
234
235
tm .assert_numpy_array_equal (result , expected )
235
236
236
- expr . set_use_numexpr ( False )
237
+ set_option ( "compute.use_numexpr" , False )
237
238
testit ()
238
- expr . set_use_numexpr ( True )
239
+ set_option ( "compute.use_numexpr" , True )
239
240
expr .set_numexpr_threads (1 )
240
241
testit ()
241
242
expr .set_numexpr_threads ()
@@ -360,9 +361,9 @@ def test_frame_series_axis(self, axis, arith):
360
361
361
362
op_func = getattr (df , arith )
362
363
363
- expr . set_use_numexpr ( False )
364
+ set_option ( "compute.use_numexpr" , False )
364
365
expected = op_func (other , axis = axis )
365
- expr . set_use_numexpr ( True )
366
+ set_option ( "compute.use_numexpr" , True )
366
367
367
368
result = op_func (other , axis = axis )
368
369
tm .assert_frame_equal (expected , result )
@@ -387,9 +388,9 @@ def test_python_semantics_with_numexpr_installed(self, op, box, scalar):
387
388
result = method (scalar )
388
389
389
390
# compare result with numpy
390
- expr . set_use_numexpr ( False )
391
+ set_option ( "compute.use_numexpr" , False )
391
392
expected = method (scalar )
392
- expr . set_use_numexpr ( True )
393
+ set_option ( "compute.use_numexpr" , True )
393
394
tm .assert_equal (result , expected )
394
395
395
396
# compare result element-wise with Python
0 commit comments