Python numpy.nancumsum() Examples
The following are 30
code examples of numpy.nancumsum().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example #1
Source File: test_reduction_execute.py From mars with Apache License 2.0 | 6 votes |
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))
Example #2
Source File: test_nanfunctions.py From coffeegrindsize with MIT License | 5 votes |
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)
Example #3
Source File: test_nanfunctions.py From pySINDy with MIT License | 5 votes |
def test_nancumsum(self): tgt = np.cumsum(self.mat) for mat in self.integer_arrays(): assert_equal(np.nancumsum(mat), tgt)
Example #4
Source File: test_nanfunctions.py From pySINDy with MIT License | 5 votes |
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)
Example #5
Source File: test_nanfunctions.py From mxnet-lambda with Apache License 2.0 | 5 votes |
def test_nancumsum(self): tgt = np.cumsum(self.mat) for mat in self.integer_arrays(): assert_equal(np.nancumsum(mat), tgt)
Example #6
Source File: test_nanfunctions.py From mxnet-lambda with Apache License 2.0 | 5 votes |
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)
Example #7
Source File: test_sdc_numpy.py From sdc with BSD 2-Clause "Simplified" License | 5 votes |
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)
Example #8
Source File: test_nanfunctions.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_nancumsum(self): tgt = np.cumsum(self.mat) for mat in self.integer_arrays(): assert_equal(np.nancumsum(mat), tgt)
Example #9
Source File: test_nanfunctions.py From elasticintel with GNU General Public License v3.0 | 5 votes |
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)
Example #10
Source File: test_interaction.py From coffeegrindsize with MIT License | 5 votes |
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))
Example #11
Source File: test_nanfunctions.py From coffeegrindsize with MIT License | 5 votes |
def test_nancumsum(self): tgt = np.cumsum(self.mat) for mat in self.integer_arrays(): assert_equal(np.nancumsum(mat), tgt)
Example #12
Source File: test_interaction.py From pySINDy with MIT License | 5 votes |
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))
Example #13
Source File: test_quantity_non_ufuncs.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_nancumsum(self): self.check(np.nancumsum)
Example #14
Source File: test_interaction.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
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))
Example #15
Source File: test_nanfunctions.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def test_nancumsum(self): tgt = np.cumsum(self.mat) for mat in self.integer_arrays(): assert_equal(np.nancumsum(mat), tgt)
Example #16
Source File: test_nanfunctions.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
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)
Example #17
Source File: test_interaction.py From twitter-stock-recommendation with MIT License | 5 votes |
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))
Example #18
Source File: test_nanfunctions.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_nancumsum(self): tgt = np.cumsum(self.mat) for mat in self.integer_arrays(): assert_equal(np.nancumsum(mat), tgt)
Example #19
Source File: test_nanfunctions.py From twitter-stock-recommendation with MIT License | 5 votes |
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)
Example #20
Source File: test_nanfunctions.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
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)
Example #21
Source File: test_nanfunctions.py From recruit with Apache License 2.0 | 5 votes |
def test_nancumsum(self): tgt = np.cumsum(self.mat) for mat in self.integer_arrays(): assert_equal(np.nancumsum(mat), tgt)
Example #22
Source File: test_nanfunctions.py From recruit with Apache License 2.0 | 5 votes |
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)
Example #23
Source File: test_nanfunctions.py From lambda-packs with MIT License | 5 votes |
def test_nancumsum(self): tgt = np.cumsum(self.mat) for mat in self.integer_arrays(): assert_equal(np.nancumsum(mat), tgt)
Example #24
Source File: test_nanfunctions.py From lambda-packs with MIT License | 5 votes |
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)
Example #25
Source File: test_nanfunctions.py From vnpy_crypto with MIT License | 5 votes |
def test_nancumsum(self): tgt = np.cumsum(self.mat) for mat in self.integer_arrays(): assert_equal(np.nancumsum(mat), tgt)
Example #26
Source File: test_nanfunctions.py From vnpy_crypto with MIT License | 5 votes |
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)
Example #27
Source File: test_interaction.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
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))
Example #28
Source File: test_nanfunctions.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_nancumsum(self): tgt = np.cumsum(self.mat) for mat in self.integer_arrays(): assert_equal(np.nancumsum(mat), tgt)
Example #29
Source File: test_interaction.py From recruit with Apache License 2.0 | 5 votes |
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))
Example #30
Source File: test_interaction.py From GraphicDesignPatternByPython with MIT License | 5 votes |
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))