@@ -32,16 +32,20 @@ def f(x):
32
32
ser .map (f )
33
33
34
34
35
- def test_map_callable (datetime_series ):
35
+ def test_map_callable (datetime_series , engine ):
36
36
with np .errstate (all = "ignore" ):
37
- tm .assert_series_equal (datetime_series .map (np .sqrt ), np .sqrt (datetime_series ))
37
+ tm .assert_series_equal (
38
+ datetime_series .map (np .sqrt , engine = engine ), np .sqrt (datetime_series )
39
+ )
38
40
39
41
# map function element-wise
40
- tm .assert_series_equal (datetime_series .map (math .exp ), np .exp (datetime_series ))
42
+ tm .assert_series_equal (
43
+ datetime_series .map (math .exp , engine = engine ), np .exp (datetime_series )
44
+ )
41
45
42
46
# empty series
43
47
s = Series (dtype = object , name = "foo" , index = Index ([], name = "bar" ))
44
- rs = s .map (lambda x : x )
48
+ rs = s .map (lambda x : x , engine = engine )
45
49
tm .assert_series_equal (s , rs )
46
50
47
51
# check all metadata (GH 9322)
@@ -52,7 +56,7 @@ def test_map_callable(datetime_series):
52
56
53
57
# index but no data
54
58
s = Series (index = [1 , 2 , 3 ], dtype = np .float64 )
55
- rs = s .map (lambda x : x )
59
+ rs = s .map (lambda x : x , engine = engine )
56
60
tm .assert_series_equal (s , rs )
57
61
58
62
@@ -269,10 +273,10 @@ def test_map_decimal(string_series):
269
273
assert isinstance (result .iloc [0 ], Decimal )
270
274
271
275
272
- def test_map_na_exclusion ():
276
+ def test_map_na_exclusion (engine ):
273
277
s = Series ([1.5 , np .nan , 3 , np .nan , 5 ])
274
278
275
- result = s .map (lambda x : x * 2 , na_action = "ignore" )
279
+ result = s .map (lambda x : x * 2 , na_action = "ignore" , engine = engine )
276
280
exp = s * 2
277
281
tm .assert_series_equal (result , exp )
278
282
@@ -604,3 +608,23 @@ def test_map_kwargs():
604
608
result = Series ([2 , 4 , 5 ]).map (lambda x , y : x + y , y = 2 )
605
609
expected = Series ([4 , 6 , 7 ])
606
610
tm .assert_series_equal (result , expected )
611
+
612
+
613
+ def test_map_engine_no_function ():
614
+ s = Series ([1 , 2 ])
615
+
616
+ with pytest .raises (ValueError , match = "engine argument can only be specified" ):
617
+ s .map ({}, engine = "something" )
618
+
619
+ with pytest .raises (ValueError , match = "engine argument can only be specified" ):
620
+ s .map ({1 : 2 }, engine = "something" )
621
+
622
+ with pytest .raises (ValueError , match = "engine argument can only be specified" ):
623
+ s .map (Series ([3 , 4 ]), engine = "something" )
624
+
625
+
626
+ def test_map_engine_not_executor ():
627
+ s = Series ([1 , 2 ])
628
+
629
+ with pytest .raises (ValueError , match = "Not a valid engine: 'something'" ):
630
+ s .map (lambda x : x , engine = "something" )
0 commit comments