當前位置: 首頁>>代碼示例>>Python>>正文


Python numpy.nancumsum方法代碼示例

本文整理匯總了Python中numpy.nancumsum方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.nancumsum方法的具體用法?Python numpy.nancumsum怎麽用?Python numpy.nancumsum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy的用法示例。


在下文中一共展示了numpy.nancumsum方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testNanCumReduction

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import nancumsum [as 別名]
def testNanCumReduction(self):
        raw = np.random.randint(5, size=(8, 8, 8))
        raw[:2, 2:4, 4:6] = np.nan

        arr = tensor(raw, chunk_size=3)

        res1 = self.executor.execute_tensor(nancumsum(arr, axis=1), concat=True)
        res2 = self.executor.execute_tensor(nancumprod(arr, axis=1), concat=True)
        expected1 = np.nancumsum(raw, axis=1)
        expected2 = np.nancumprod(raw, axis=1)
        np.testing.assert_array_equal(res1[0], expected1)
        np.testing.assert_array_equal(res2[0], expected2)

        raw = sps.random(8, 8, density=.1, format='lil')
        raw[:2, 2:4] = np.nan

        arr = tensor(raw, chunk_size=3)

        res1 = self.executor.execute_tensor(nancumsum(arr, axis=1), concat=True)[0]
        res2 = self.executor.execute_tensor(nancumprod(arr, axis=1), concat=True)[0]
        expected1 = np.nancumsum(raw.A, axis=1)
        expected2 = np.nancumprod(raw.A, axis=1)
        self.assertTrue(np.allclose(res1, expected1))
        self.assertTrue(np.allclose(res2, expected2)) 
開發者ID:mars-project,項目名稱:mars,代碼行數:26,代碼來源:test_reduction_execute.py

示例2: test_nanfunctions_matrices_general

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import nancumsum [as 別名]
def test_nanfunctions_matrices_general():
    # Check that it works and that type and
    # shape are preserved
    # 2018-04-29: moved here from core.tests.test_nanfunctions
    mat = np.matrix(np.eye(3))
    for f in (np.nanargmin, np.nanargmax, np.nansum, np.nanprod,
              np.nanmean, np.nanvar, np.nanstd):
        res = f(mat, axis=0)
        assert_(isinstance(res, np.matrix))
        assert_(res.shape == (1, 3))
        res = f(mat, axis=1)
        assert_(isinstance(res, np.matrix))
        assert_(res.shape == (3, 1))
        res = f(mat)
        assert_(np.isscalar(res))

    for f in np.nancumsum, np.nancumprod:
        res = f(mat, axis=0)
        assert_(isinstance(res, np.matrix))
        assert_(res.shape == (3, 3))
        res = f(mat, axis=1)
        assert_(isinstance(res, np.matrix))
        assert_(res.shape == (3, 3))
        res = f(mat)
        assert_(isinstance(res, np.matrix))
        assert_(res.shape == (1, 3*3)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:28,代碼來源:test_interaction.py

示例3: test_nancumsum

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import nancumsum [as 別名]
def test_nancumsum(self):
        tgt = np.cumsum(self.mat)
        for mat in self.integer_arrays():
            assert_equal(np.nancumsum(mat), tgt) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:6,代碼來源:test_nanfunctions.py

示例4: test_result_values

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import nancumsum [as 別名]
def test_result_values(self):
        for axis in (-2, -1, 0, 1, None):
            tgt = np.cumprod(_ndat_ones, axis=axis)
            res = np.nancumprod(_ndat, axis=axis)
            assert_almost_equal(res, tgt)
            tgt = np.cumsum(_ndat_zeros,axis=axis)
            res = np.nancumsum(_ndat, axis=axis)
            assert_almost_equal(res, tgt) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:10,代碼來源:test_nanfunctions.py

示例5: test_nancumsum

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import nancumsum [as 別名]
def test_nancumsum(self):
        def ref_impl(a):
            return np.nancumsum(a)

        def sdc_impl(a):
            return numpy_like.nancumsum(a)

        self.check_reduction_basic(ref_impl, sdc_impl) 
開發者ID:IntelPython,項目名稱:sdc,代碼行數:10,代碼來源:test_sdc_numpy.py

示例6: test_nancumsum

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import nancumsum [as 別名]
def test_nancumsum(self):
        self.check(np.nancumsum) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:4,代碼來源:test_quantity_non_ufuncs.py


注:本文中的numpy.nancumsum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。