def test_w_nans(self):
     "Test the moving functions on series w/ NaNs"
     #
     data = np.random.rand(20)
     control = mf.mov_average(data, 3)
     # Test that we get the right result
     a = ma.array(data, mask=False)
     assert_almost_equal(control, mf.mov_average(a, 3))
     # Test with a masked element
     a.data[10] = 0
     a.mask[10] = True
     assert_almost_equal(control, mf.mov_average(a, 3))
     # Test w/ a masked element and an underlying nan
     a[10] = np.nan
     assert_almost_equal(control, mf.mov_average(a, 3))
 def test_w_nans(self):
     "Test the moving functions on series w/ NaNs"
     #
     data = np.random.rand(20)
     control = mf.mov_average(data, 3)
     # Test that we get the right result
     a = ma.array(data, mask=False)
     assert_almost_equal(control, mf.mov_average(a, 3))
     # Test with a masked element
     a.data[10] = 0
     a.mask[10] = True
     assert_almost_equal(control, mf.mov_average(a, 3))
     # Test w/ a masked element and an underlying nan
     a[10] = np.nan
     assert_almost_equal(control, mf.mov_average(a, 3))
示例#3
0
 def mave(self,tsl,span,*args,**kw):
     _ts = tsl._data
     span = int(span)
     _ts = tsm.mov_average(_ts,span)
     tsl._data = _ts
     return tsl