当前位置: 首页>>代码示例>>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;未经允许,请勿转载。