3
3
import numpy as np
4
4
import pytest
5
5
6
+ from pandas .compat import is_numpy_dev
7
+
6
8
import pandas as pd
7
9
import pandas ._testing as tm
8
10
@@ -98,11 +100,6 @@ def test_pos_numeric(self, df):
98
100
@pytest .mark .parametrize (
99
101
"df" ,
100
102
[
101
- # numpy changing behavior in the future
102
- pytest .param (
103
- pd .DataFrame ({"a" : ["a" , "b" ]}),
104
- marks = [pytest .mark .filterwarnings ("ignore" )],
105
- ),
106
103
pd .DataFrame ({"a" : np .array ([- 1 , 2 ], dtype = object )}),
107
104
pd .DataFrame ({"a" : [Decimal ("-1.0" ), Decimal ("2.0" )]}),
108
105
],
@@ -112,6 +109,25 @@ def test_pos_object(self, df):
112
109
tm .assert_frame_equal (+ df , df )
113
110
tm .assert_series_equal (+ df ["a" ], df ["a" ])
114
111
112
+ @pytest .mark .parametrize (
113
+ "df" ,
114
+ [
115
+ pytest .param (
116
+ pd .DataFrame ({"a" : ["a" , "b" ]}),
117
+ marks = [pytest .mark .filterwarnings ("ignore" )],
118
+ ),
119
+ ],
120
+ )
121
+ def test_pos_object_raises (self , df ):
122
+ # GH#21380
123
+ if is_numpy_dev :
124
+ with pytest .raises (
125
+ TypeError , match = r"^bad operand type for unary \+: \'str\'$"
126
+ ):
127
+ tm .assert_frame_equal (+ df , df )
128
+ else :
129
+ tm .assert_series_equal (+ df ["a" ], df ["a" ])
130
+
115
131
@pytest .mark .parametrize (
116
132
"df" , [pd .DataFrame ({"a" : pd .to_datetime (["2017-01-22" , "1970-01-01" ])})]
117
133
)
0 commit comments