66from pandas .core .arrays .numpy_ import PandasArray , PandasDtype
77import pandas .util .testing as tm
88
9- from . import base
9+ from .. import base
1010
1111
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 ))
1515
1616
1717@pytest .fixture
@@ -38,6 +38,8 @@ def allow_in_pandas(monkeypatch):
3838
3939@pytest .fixture
4040def data (allow_in_pandas , dtype ):
41+ if dtype .numpy_dtype == 'object' :
42+ return pd .Series ([(i ,) for i in range (100 )]).array
4143 return PandasArray (np .arange (1 , 101 , dtype = dtype ._dtype ))
4244
4345
@@ -150,6 +152,19 @@ class TestArithmetics(BaseNumPyTests, base.BaseArithmeticOpsTests):
150152 frame_scalar_exc = None
151153 series_array_exc = None
152154
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+
153168 def test_divmod_series_array (self , data ):
154169 s = pd .Series (data )
155170 self ._check_divmod_op (s , divmod , data , exc = None )
@@ -186,17 +201,24 @@ class TestPrinting(BaseNumPyTests, base.BasePrintingTests):
186201class TestNumericReduce (BaseNumPyTests , base .BaseNumericReduceTests ):
187202
188203 def check_reduce (self , s , op_name , skipna ):
204+ if s .dtype == 'object' :
205+ raise pytest .skip ("Skipping for object dtype." )
189206 result = getattr (s , op_name )(skipna = skipna )
190207 # avoid coercing int -> float. Just cast to the actual numpy type.
191208 expected = getattr (s .astype (s .dtype ._dtype ), op_name )(skipna = skipna )
192209 tm .assert_almost_equal (result , expected )
193210
194211
195212class 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 )
197219
198220
199- class TestMising (BaseNumPyTests , base .BaseMissingTests ):
221+ class TestMissing (BaseNumPyTests , base .BaseMissingTests ):
200222 pass
201223
202224
0 commit comments