@@ -1406,80 +1406,30 @@ def _create_data(self):
14061406 data2 = array (np .random .rand (12 ))
14071407 return data , data2
14081408
1409- def test_ddof (self ):
1410- # ddof raises DeprecationWarning
1411- x , y = self ._create_data ()
1412- expected = np .corrcoef (x )
1413- expected2 = np .corrcoef (x , y )
1414- with pytest .warns (DeprecationWarning ):
1415- corrcoef (x , ddof = - 1 )
1416-
1417- with warnings .catch_warnings ():
1418- warnings .filterwarnings (
1419- 'ignore' , "bias and ddof have no effect" , DeprecationWarning )
1420-
1421- # ddof has no or negligible effect on the function
1422- assert_almost_equal (np .corrcoef (x , ddof = 0 ), corrcoef (x , ddof = 0 ))
1423- assert_almost_equal (corrcoef (x , ddof = - 1 ), expected )
1424- assert_almost_equal (corrcoef (x , y , ddof = - 1 ), expected2 )
1425- assert_almost_equal (corrcoef (x , ddof = 3 ), expected )
1426- assert_almost_equal (corrcoef (x , y , ddof = 3 ), expected2 )
1427-
1428- def test_bias (self ):
1429- x , y = self ._create_data ()
1430- expected = np .corrcoef (x )
1431- # bias raises DeprecationWarning
1432- with pytest .warns (DeprecationWarning ):
1433- corrcoef (x , y , True , False )
1434- with pytest .warns (DeprecationWarning ):
1435- corrcoef (x , y , True , True )
1436- with pytest .warns (DeprecationWarning ):
1437- corrcoef (x , y , bias = False )
14381409
1439- with warnings .catch_warnings ():
1440- warnings .filterwarnings (
1441- 'ignore' , "bias and ddof have no effect" , DeprecationWarning )
1442- # bias has no or negligible effect on the function
1443- assert_almost_equal (corrcoef (x , bias = 1 ), expected )
14441410
14451411 def test_1d_without_missing (self ):
14461412 # Test cov on 1D variable w/o missing values
14471413 x = self ._create_data ()[0 ]
14481414 assert_almost_equal (np .corrcoef (x ), corrcoef (x ))
14491415 assert_almost_equal (np .corrcoef (x , rowvar = False ),
14501416 corrcoef (x , rowvar = False ))
1451- with warnings .catch_warnings ():
1452- warnings .filterwarnings (
1453- 'ignore' , "bias and ddof have no effect" , DeprecationWarning )
1454- assert_almost_equal (np .corrcoef (x , rowvar = False , bias = True ),
1455- corrcoef (x , rowvar = False , bias = True ))
14561417
14571418 def test_2d_without_missing (self ):
14581419 # Test corrcoef on 1 2D variable w/o missing values
14591420 x = self ._create_data ()[0 ].reshape (3 , 4 )
14601421 assert_almost_equal (np .corrcoef (x ), corrcoef (x ))
14611422 assert_almost_equal (np .corrcoef (x , rowvar = False ),
14621423 corrcoef (x , rowvar = False ))
1463- with warnings .catch_warnings ():
1464- warnings .filterwarnings (
1465- 'ignore' , "bias and ddof have no effect" , DeprecationWarning )
1466- assert_almost_equal (np .corrcoef (x , rowvar = False , bias = True ),
1467- corrcoef (x , rowvar = False , bias = True ))
14681424
14691425 def test_1d_with_missing (self ):
14701426 # Test corrcoef 1 1D variable w/missing values
14711427 x = self ._create_data ()[0 ]
14721428 x [- 1 ] = masked
14731429 x -= x .mean ()
14741430 nx = x .compressed ()
1475- assert_almost_equal (np .corrcoef (nx ), corrcoef (x ))
14761431 assert_almost_equal (np .corrcoef (nx , rowvar = False ),
14771432 corrcoef (x , rowvar = False ))
1478- with warnings .catch_warnings ():
1479- warnings .filterwarnings (
1480- 'ignore' , "bias and ddof have no effect" , DeprecationWarning )
1481- assert_almost_equal (np .corrcoef (nx , rowvar = False , bias = True ),
1482- corrcoef (x , rowvar = False , bias = True ))
14831433 try :
14841434 corrcoef (x , allow_masked = False )
14851435 except ValueError :
@@ -1489,14 +1439,6 @@ def test_1d_with_missing(self):
14891439 assert_almost_equal (np .corrcoef (nx , nx [::- 1 ]), corrcoef (x , x [::- 1 ]))
14901440 assert_almost_equal (np .corrcoef (nx , nx [::- 1 ], rowvar = False ),
14911441 corrcoef (x , x [::- 1 ], rowvar = False ))
1492- with warnings .catch_warnings ():
1493- warnings .filterwarnings (
1494- 'ignore' , "bias and ddof have no effect" , DeprecationWarning )
1495- # ddof and bias have no or negligible effect on the function
1496- assert_almost_equal (np .corrcoef (nx , nx [::- 1 ]),
1497- corrcoef (x , x [::- 1 ], bias = 1 ))
1498- assert_almost_equal (np .corrcoef (nx , nx [::- 1 ]),
1499- corrcoef (x , x [::- 1 ], ddof = 2 ))
15001442
15011443 def test_2d_with_missing (self ):
15021444 # Test corrcoef on 2D variable w/ missing value
@@ -1507,16 +1449,6 @@ def test_2d_with_missing(self):
15071449 test = corrcoef (x )
15081450 control = np .corrcoef (x )
15091451 assert_almost_equal (test [:- 1 , :- 1 ], control [:- 1 , :- 1 ])
1510- with warnings .catch_warnings ():
1511- warnings .filterwarnings (
1512- 'ignore' , "bias and ddof have no effect" , DeprecationWarning )
1513- # ddof and bias have no or negligible effect on the function
1514- assert_almost_equal (corrcoef (x , ddof = - 2 )[:- 1 , :- 1 ],
1515- control [:- 1 , :- 1 ])
1516- assert_almost_equal (corrcoef (x , ddof = 3 )[:- 1 , :- 1 ],
1517- control [:- 1 , :- 1 ])
1518- assert_almost_equal (corrcoef (x , bias = 1 )[:- 1 , :- 1 ],
1519- control [:- 1 , :- 1 ])
15201452
15211453
15221454class TestPolynomial :
0 commit comments