@@ -38,10 +38,7 @@ def test_expanding_apply_consistency_sum_nans(request, all_data, min_periods, f)
3838@pytest .mark .parametrize ("ddof" , [0 , 1 ])
3939def test_moments_consistency_var (all_data , min_periods , ddof ):
4040 var_x = all_data .expanding (min_periods = min_periods ).var (ddof = ddof )
41- if isinstance (all_data , Series ):
42- assert not (var_x < 0 ).any ()
43- else :
44- assert not (var_x < 0 ).any ().any ()
41+ assert not (var_x < 0 ).any (axis = None )
4542
4643 if ddof == 0 :
4744 # check that biased var(x) == mean(x^2) - mean(x)^2
@@ -56,10 +53,7 @@ def test_moments_consistency_var_constant(consistent_data, min_periods, ddof):
5653 var_x = consistent_data .expanding (min_periods = min_periods ).var (ddof = ddof )
5754
5855 # check that variance of constant series is identically 0
59- if isinstance (consistent_data , Series ):
60- assert not (var_x > 0 ).any ()
61- else :
62- assert not (var_x > 0 ).any ().any ()
56+ assert not (var_x > 0 ).any (axis = None )
6357 expected = consistent_data * np .nan
6458 expected [count_x >= max (min_periods , 1 )] = 0.0
6559 if ddof == 1 :
@@ -70,25 +64,16 @@ def test_moments_consistency_var_constant(consistent_data, min_periods, ddof):
7064@pytest .mark .parametrize ("ddof" , [0 , 1 ])
7165def test_expanding_consistency_var_std_cov (all_data , min_periods , ddof ):
7266 var_x = all_data .expanding (min_periods = min_periods ).var (ddof = ddof )
73- if isinstance (all_data , Series ):
74- assert not (var_x < 0 ).any ()
75- else :
76- assert not (var_x < 0 ).any ().any ()
67+ assert not (var_x < 0 ).any (axis = None )
7768
7869 std_x = all_data .expanding (min_periods = min_periods ).std (ddof = ddof )
79- if isinstance (all_data , Series ):
80- assert not (std_x < 0 ).any ()
81- else :
82- assert not (std_x < 0 ).any ().any ()
70+ assert not (std_x < 0 ).any (axis = None )
8371
8472 # check that var(x) == std(x)^2
8573 tm .assert_equal (var_x , std_x * std_x )
8674
8775 cov_x_x = all_data .expanding (min_periods = min_periods ).cov (all_data , ddof = ddof )
88- if isinstance (all_data , Series ):
89- assert not (cov_x_x < 0 ).any ()
90- else :
91- assert not (cov_x_x < 0 ).any ().any ()
76+ assert not (cov_x_x < 0 ).any (axis = None )
9277
9378 # check that var(x) == cov(x, x)
9479 tm .assert_equal (var_x , cov_x_x )
0 commit comments