コード例 #1
0
ファイル: test_extras.py プロジェクト: niccalle/numpy
 def test_2d_wo_missing(self):
     # Test corrcoef on 1 2D variable w/o missing values
     x = self.data.reshape(3, 4)
     assert_almost_equal(np.corrcoef(x), corrcoef(x))
     assert_almost_equal(np.corrcoef(x, rowvar=False), corrcoef(x, rowvar=False))
     with catch_warn_mae():
         warnings.simplefilter("ignore")
         assert_almost_equal(np.corrcoef(x, rowvar=False, bias=True), corrcoef(x, rowvar=False, bias=True))
コード例 #2
0
ファイル: test_extras.py プロジェクト: Prastaruszek/numpy
 def test_1d_wo_missing(self):
     # Test cov on 1D variable w/o missing values
     x = self.data
     assert_almost_equal(np.corrcoef(x), corrcoef(x))
     assert_almost_equal(np.corrcoef(x, rowvar=False),
                         corrcoef(x, rowvar=False))
     assert_almost_equal(np.corrcoef(x, rowvar=False, bias=True),
                         corrcoef(x, rowvar=False, bias=True))
コード例 #3
0
ファイル: test_extras.py プロジェクト: Prastaruszek/numpy
 def test_2d_wo_missing(self):
     # Test corrcoef on 1 2D variable w/o missing values
     x = self.data.reshape(3, 4)
     assert_almost_equal(np.corrcoef(x), corrcoef(x))
     assert_almost_equal(np.corrcoef(x, rowvar=False),
                         corrcoef(x, rowvar=False))
     assert_almost_equal(np.corrcoef(x, rowvar=False, bias=True),
                         corrcoef(x, rowvar=False, bias=True))
コード例 #4
0
ファイル: test_extras.py プロジェクト: SylvainCorlay/numpy
 def test_1d_w_missing(self):
     # Test corrcoef 1 1D variable w/missing values
     x = self.data
     x[-1] = masked
     x -= x.mean()
     nx = x.compressed()
     assert_almost_equal(np.corrcoef(nx), corrcoef(x))
     assert_almost_equal(np.corrcoef(nx, rowvar=False),
                         corrcoef(x, rowvar=False))
     with catch_warn_mae():
         warnings.simplefilter("ignore")
         assert_almost_equal(np.corrcoef(nx, rowvar=False, bias=True),
                             corrcoef(x, rowvar=False, bias=True))
     try:
         corrcoef(x, allow_masked=False)
     except ValueError:
         pass
     # 2 1D variables w/ missing values
     nx = x[1:-1]
     assert_almost_equal(np.corrcoef(nx, nx[::-1]), corrcoef(x, x[::-1]))
     assert_almost_equal(np.corrcoef(nx, nx[::-1], rowvar=False),
                         corrcoef(x, x[::-1], rowvar=False))
     with catch_warn_mae():
         warnings.simplefilter("ignore")
         # ddof and bias have no or negligible effect on the function
         assert_almost_equal(np.corrcoef(nx, nx[::-1]),
                             corrcoef(x, x[::-1], bias=1))
         assert_almost_equal(np.corrcoef(nx, nx[::-1]),
                             corrcoef(x, x[::-1], ddof=2))
コード例 #5
0
ファイル: test_extras.py プロジェクト: SylvainCorlay/numpy
 def test_ddof(self):
     # ddof raises DeprecationWarning
     x, y = self.data, self.data2
     expected = np.corrcoef(x)
     expected2 = np.corrcoef(x, y)
     with catch_warn_mae():
         warnings.simplefilter("always")
         assert_warns(DeprecationWarning, corrcoef, x, ddof=-1)
         warnings.simplefilter("ignore")
         # ddof has no or negligible effect on the function
         assert_almost_equal(np.corrcoef(x, ddof=0), corrcoef(x, ddof=0))
         assert_almost_equal(corrcoef(x, ddof=-1), expected)
         assert_almost_equal(corrcoef(x, y, ddof=-1), expected2)
         assert_almost_equal(corrcoef(x, ddof=3), expected)
         assert_almost_equal(corrcoef(x, y, ddof=3), expected2)
コード例 #6
0
ファイル: test_extras.py プロジェクト: niccalle/numpy
    def test_2d_w_missing(self):
        # Test corrcoef on 2D variable w/ missing value
        x = self.data
        x[-1] = masked
        x = x.reshape(3, 4)

        test = corrcoef(x)
        control = np.corrcoef(x)
        assert_almost_equal(test[:-1, :-1], control[:-1, :-1])
        with catch_warn_mae():
            warnings.simplefilter("ignore")
            # ddof and bias have no or negligible effect on the function
            assert_almost_equal(corrcoef(x, ddof=-2)[:-1, :-1], control[:-1, :-1])
            assert_almost_equal(corrcoef(x, ddof=3)[:-1, :-1], control[:-1, :-1])
            assert_almost_equal(corrcoef(x, bias=1)[:-1, :-1], control[:-1, :-1])
コード例 #7
0
ファイル: test_extras.py プロジェクト: vikrantest/numpy
    def test_2d_with_missing(self):
        # Test corrcoef on 2D variable w/ missing value
        x = self.data
        x[-1] = masked
        x = x.reshape(3, 4)

        test = corrcoef(x)
        control = np.corrcoef(x)
        assert_almost_equal(test[:-1, :-1], control[:-1, :-1])
        with suppress_warnings() as sup:
            sup.filter(DeprecationWarning, "bias and ddof have no effect")
            # ddof and bias have no or negligible effect on the function
            assert_almost_equal(
                corrcoef(x, ddof=-2)[:-1, :-1], control[:-1, :-1])
            assert_almost_equal(
                corrcoef(x, ddof=3)[:-1, :-1], control[:-1, :-1])
            assert_almost_equal(
                corrcoef(x, bias=1)[:-1, :-1], control[:-1, :-1])
コード例 #8
0
    def test_2d_w_missing(self):
        # Test corrcoef on 2D variable w/ missing value
        x = self.data
        x[-1] = masked
        x = x.reshape(3, 4)

        test = corrcoef(x)
        control = np.corrcoef(x)
        assert_almost_equal(test[:-1, :-1], control[:-1, :-1])
        with catch_warn_mae():
            warnings.simplefilter("ignore")
            # ddof and bias have no or negligible effect on the function
            assert_almost_equal(
                corrcoef(x, ddof=-2)[:-1, :-1], control[:-1, :-1])
            assert_almost_equal(
                corrcoef(x, ddof=3)[:-1, :-1], control[:-1, :-1])
            assert_almost_equal(
                corrcoef(x, bias=1)[:-1, :-1], control[:-1, :-1])
コード例 #9
0
ファイル: test_extras.py プロジェクト: JamesHe1990/eeg-site
    def test_2d_w_missing(self):
        # Test corrcoef on 2D variable w/ missing value
        x = self.data
        x[-1] = masked
        x = x.reshape(3, 4)

        test = corrcoef(x)
        control = np.corrcoef(x)
        assert_almost_equal(test[:-1, :-1], control[:-1, :-1])
コード例 #10
0
ファイル: test_extras.py プロジェクト: Prastaruszek/numpy
    def test_2d_w_missing(self):
        # Test corrcoef on 2D variable w/ missing value
        x = self.data
        x[-1] = masked
        x = x.reshape(3, 4)

        test = corrcoef(x)
        control = np.corrcoef(x)
        assert_almost_equal(test[:-1, :-1], control[:-1, :-1])
コード例 #11
0
 def test_bias(self):
     x, y = self.data, self.data2
     expected = np.corrcoef(x)
     # bias raises DeprecationWarning
     with catch_warn_mae():
         warnings.simplefilter("always")
         assert_warns(DeprecationWarning, corrcoef, x, y, True, False)
         assert_warns(DeprecationWarning, corrcoef, x, y, True, True)
         assert_warns(DeprecationWarning, corrcoef, x, bias=False)
         warnings.simplefilter("ignore")
         # bias has no or negligible effect on the function
         assert_almost_equal(corrcoef(x, bias=1), expected)
コード例 #12
0
ファイル: test_extras.py プロジェクト: vikrantest/numpy
 def test_bias(self):
     x, y = self.data, self.data2
     expected = np.corrcoef(x)
     # bias raises DeprecationWarning
     with suppress_warnings() as sup:
         warnings.simplefilter("always")
         assert_warns(DeprecationWarning, corrcoef, x, y, True, False)
         assert_warns(DeprecationWarning, corrcoef, x, y, True, True)
         assert_warns(DeprecationWarning, corrcoef, x, bias=False)
         sup.filter(DeprecationWarning, "bias and ddof have no effect")
         # bias has no or negligible effect on the function
         assert_almost_equal(corrcoef(x, bias=1), expected)
コード例 #13
0
ファイル: test_extras.py プロジェクト: SylvainCorlay/numpy
 def test_bias(self):
     x, y = self.data, self.data2
     expected = np.corrcoef(x)
     # bias raises DeprecationWarning
     with catch_warn_mae():
         warnings.simplefilter("always")
         assert_warns(DeprecationWarning, corrcoef, x, y, True, False)
         assert_warns(DeprecationWarning, corrcoef, x, y, True, True)
         assert_warns(DeprecationWarning, corrcoef, x, bias=False)
         warnings.simplefilter("ignore")
         # bias has no or negligible effect on the function
         assert_almost_equal(corrcoef(x, bias=1), expected)
コード例 #14
0
def G_reg1d(xx, yy, ww=None):
    """
    description needed
    ww: weights
    """
    rtn = []
    ab = polyfit(xx, yy, 1, w=ww)
    rtn.append(ab[0])
    rtn.append(ab[1])
    rtn.append(std(yy) / std(xx))
    rtn.append(mean(yy) - rtn[2] * mean(xx))
    r = corrcoef(xx, yy)
    rr = r[0, 1] * r[0, 1]
    rtn.append(rr)
    return rtn
コード例 #15
0
def G_reg1d(xx, yy, ww=None):
    '''
    计算斜率和截距
    ww: weights
    '''
    rtn = []
    ab = polyfit(xx, yy, 1, w=ww)
    rtn.append(ab[0])
    rtn.append(ab[1])
    rtn.append(std(yy) / std(xx))
    rtn.append(mean(yy) - rtn[2] * mean(xx))
    r = corrcoef(xx, yy)
    rr = r[0, 1] * r[0, 1]
    rtn.append(rr)
    return rtn
コード例 #16
0
ファイル: test_extras.py プロジェクト: phonx/FlipbookApp
 def test_1d_w_missing(self):
     "Test corrcoef 1 1D variable w/missing values"
     x = self.data
     x[-1] = masked
     x -= x.mean()
     nx = x.compressed()
     assert_almost_equal(np.corrcoef(nx), corrcoef(x))
     assert_almost_equal(np.corrcoef(nx, rowvar=False),
                         corrcoef(x, rowvar=False))
     assert_almost_equal(np.corrcoef(nx, rowvar=False, bias=True),
                         corrcoef(x, rowvar=False, bias=True))
     #
     try:
         corrcoef(x, allow_masked=False)
     except ValueError:
         pass
     #
     # 2 1D variables w/ missing values
     nx = x[1:-1]
     assert_almost_equal(np.corrcoef(nx, nx[::-1]), corrcoef(x, x[::-1]))
     assert_almost_equal(np.corrcoef(nx, nx[::-1], rowvar=False),
                         corrcoef(x, x[::-1], rowvar=False))
     assert_almost_equal(np.corrcoef(nx, nx[::-1], rowvar=False, bias=True),
                         corrcoef(x, x[::-1], rowvar=False, bias=True))
コード例 #17
0
ファイル: test_extras.py プロジェクト: Prastaruszek/numpy
 def test_1d_w_missing(self):
     # Test corrcoef 1 1D variable w/missing values
     x = self.data
     x[-1] = masked
     x -= x.mean()
     nx = x.compressed()
     assert_almost_equal(np.corrcoef(nx), corrcoef(x))
     assert_almost_equal(np.corrcoef(nx, rowvar=False),
                         corrcoef(x, rowvar=False))
     assert_almost_equal(np.corrcoef(nx, rowvar=False, bias=True),
                         corrcoef(x, rowvar=False, bias=True))
     #
     try:
         corrcoef(x, allow_masked=False)
     except ValueError:
         pass
     #
     # 2 1D variables w/ missing values
     nx = x[1:-1]
     assert_almost_equal(np.corrcoef(nx, nx[::-1]), corrcoef(x, x[::-1]))
     assert_almost_equal(np.corrcoef(nx, nx[::-1], rowvar=False),
                         corrcoef(x, x[::-1], rowvar=False))
     assert_almost_equal(np.corrcoef(nx, nx[::-1], rowvar=False, bias=True),
                         corrcoef(x, x[::-1], rowvar=False, bias=True))
コード例 #18
0
ファイル: test_extras.py プロジェクト: phonx/FlipbookApp
 def test_ddof(self):
     "Test ddof keyword"
     x = self.data
     assert_almost_equal(np.corrcoef(x, ddof=0), corrcoef(x, ddof=0))
コード例 #19
0
ファイル: test_extras.py プロジェクト: Prastaruszek/numpy
 def test_ddof(self):
     # Test ddof keyword
     x = self.data
     assert_almost_equal(np.corrcoef(x, ddof=0), corrcoef(x, ddof=0))