@@ -25,12 +25,15 @@ def data():
2525 ([False , False ], False , False , False , False ),
2626 ],
2727)
28- def test_any_all (values , exp_any , exp_all , exp_any_noskip , exp_all_noskip ):
28+ def test_any_all (
29+ values , exp_any , exp_all , exp_any_noskip , exp_all_noskip , using_python_scalars
30+ ):
2931 # the methods return numpy scalars
30- exp_any = pd .NA if exp_any is pd .NA else np .bool_ (exp_any )
31- exp_all = pd .NA if exp_all is pd .NA else np .bool_ (exp_all )
32- exp_any_noskip = pd .NA if exp_any_noskip is pd .NA else np .bool_ (exp_any_noskip )
33- exp_all_noskip = pd .NA if exp_all_noskip is pd .NA else np .bool_ (exp_all_noskip )
32+ if not using_python_scalars :
33+ exp_any = pd .NA if exp_any is pd .NA else np .bool_ (exp_any )
34+ exp_all = pd .NA if exp_all is pd .NA else np .bool_ (exp_all )
35+ exp_any_noskip = pd .NA if exp_any_noskip is pd .NA else np .bool_ (exp_any_noskip )
36+ exp_all_noskip = pd .NA if exp_all_noskip is pd .NA else np .bool_ (exp_all_noskip )
3437
3538 for con in [pd .array , pd .Series ]:
3639 a = con (values , dtype = "boolean" )
@@ -39,23 +42,30 @@ def test_any_all(values, exp_any, exp_all, exp_any_noskip, exp_all_noskip):
3942 assert a .any (skipna = False ) is exp_any_noskip
4043 assert a .all (skipna = False ) is exp_all_noskip
4144
42- assert np .any (a .any ()) is exp_any
43- assert np .all (a .all ()) is exp_all
4445
45-
46- def test_reductions_return_types (dropna , data , all_numeric_reductions ):
46+ def test_reductions_return_types (
47+ dropna , data , all_numeric_reductions , using_python_scalars
48+ ):
4749 op = all_numeric_reductions
4850 s = pd .Series (data )
4951 if dropna :
5052 s = s .dropna ()
5153
52- if op in ("sum" , "prod" ):
53- assert isinstance (getattr (s , op )(), np .int_ )
54- elif op == "count" :
55- # Oddly on the 32 bit build (but not Windows), this is intc (!= intp)
56- assert isinstance (getattr (s , op )(), np .integer )
57- elif op in ("min" , "max" ):
58- assert isinstance (getattr (s , op )(), np .bool_ )
54+ if using_python_scalars :
55+ expected = {
56+ "sum" : int ,
57+ "prod" : int ,
58+ "count" : int ,
59+ "min" : bool ,
60+ "max" : bool ,
61+ }.get (op , float )
5962 else :
60- # "mean", "std", "var", "median", "kurt", "skew"
61- assert isinstance (getattr (s , op )(), np .float64 )
63+ expected = {
64+ "sum" : np .int_ ,
65+ "prod" : np .int_ ,
66+ "count" : np .integer ,
67+ "min" : np .bool_ ,
68+ "max" : np .bool_ ,
69+ }.get (op , np .float64 )
70+ result = getattr (s , op )()
71+ assert isinstance (result , expected ), f"{ type (result )} vs { expected } "
0 commit comments