6
6
from pandas .core .arrays .numpy_ import PandasArray , PandasDtype
7
7
import pandas .util .testing as tm
8
8
9
- from . import base
9
+ from .. import base
10
10
11
11
12
- @pytest .fixture
13
- def dtype ():
14
- return PandasDtype (np .dtype ('float' ))
12
+ @pytest .fixture ( params = [ 'float' , 'object' ])
13
+ def dtype (request ):
14
+ return PandasDtype (np .dtype (request . param ))
15
15
16
16
17
17
@pytest .fixture
@@ -38,6 +38,8 @@ def allow_in_pandas(monkeypatch):
38
38
39
39
@pytest .fixture
40
40
def data (allow_in_pandas , dtype ):
41
+ if dtype .numpy_dtype == 'object' :
42
+ return pd .Series ([(i ,) for i in range (100 )]).array
41
43
return PandasArray (np .arange (1 , 101 , dtype = dtype ._dtype ))
42
44
43
45
@@ -150,6 +152,19 @@ class TestArithmetics(BaseNumPyTests, base.BaseArithmeticOpsTests):
150
152
frame_scalar_exc = None
151
153
series_array_exc = None
152
154
155
+ def _check_op (self , s , op , other , op_name , exc = NotImplementedError ):
156
+ if s .dtype == 'object' :
157
+ raise pytest .skip ("Skipping for object dtype." )
158
+ super (TestArithmetics , self )._check_op (s , op , other , op_name , exc )
159
+
160
+ def _check_divmod_op (self , s , op , other , exc = Exception ):
161
+ if isinstance (s , pd .Series ) and s .dtype == 'object' :
162
+ raise pytest .skip ("Skipping for object dtype." )
163
+ elif isinstance (other , pd .Series ) and other .dtype == 'object' :
164
+ raise pytest .skip ("Skipping for object dtype." )
165
+
166
+ super (TestArithmetics , self )._check_divmod_op (s , op , other , exc )
167
+
153
168
def test_divmod_series_array (self , data ):
154
169
s = pd .Series (data )
155
170
self ._check_divmod_op (s , divmod , data , exc = None )
@@ -186,17 +201,24 @@ class TestPrinting(BaseNumPyTests, base.BasePrintingTests):
186
201
class TestNumericReduce (BaseNumPyTests , base .BaseNumericReduceTests ):
187
202
188
203
def check_reduce (self , s , op_name , skipna ):
204
+ if s .dtype == 'object' :
205
+ raise pytest .skip ("Skipping for object dtype." )
189
206
result = getattr (s , op_name )(skipna = skipna )
190
207
# avoid coercing int -> float. Just cast to the actual numpy type.
191
208
expected = getattr (s .astype (s .dtype ._dtype ), op_name )(skipna = skipna )
192
209
tm .assert_almost_equal (result , expected )
193
210
194
211
195
212
class TestBooleanReduce (BaseNumPyTests , base .BaseBooleanReduceTests ):
196
- pass
213
+
214
+ def check_reduce (self , s , op_name , skipna ):
215
+ if s .dtype == 'object' :
216
+ raise pytest .skip ("Skipping for object dtype." )
217
+
218
+ super (TestBooleanReduce , self ).check_reduce (s , op_name , skipna )
197
219
198
220
199
- class TestMising (BaseNumPyTests , base .BaseMissingTests ):
221
+ class TestMissing (BaseNumPyTests , base .BaseMissingTests ):
200
222
pass
201
223
202
224
0 commit comments