Esempio n. 1
0
    def test_cmov_window_special(self):
        _skip_if_no_scipy()
        try:
            from scikits.timeseries.lib import cmov_window
        except ImportError:
            raise nose.SkipTest

        win_types = ['kaiser', 'gaussian', 'general_gaussian', 'slepian']
        kwds = [{
            'beta': 1.
        }, {
            'std': 1.
        }, {
            'power': 2.,
            'width': 2.
        }, {
            'width': 0.5
        }]

        for wt, k in zip(win_types, kwds):
            vals = np.random.randn(10)
            xp = cmov_window(vals, 5, (wt, ) + tuple(k.values()))

            rs = mom.rolling_window(Series(vals), 5, wt, center=True, **k)
            assert_series_equal(Series(xp), rs)
Esempio n. 2
0
    def test_cmov_window_frame(self):
        try:
            from scikits.timeseries.lib import cmov_window
        except ImportError:
            raise nose.SkipTest

        # DataFrame
        vals = np.random.randn(10, 2)
        xp = cmov_window(vals, 5, 'boxcar')
        rs = mom.rolling_window(DataFrame(vals), 5, 'boxcar', center=True)
        assert_frame_equal(DataFrame(xp), rs)
Esempio n. 3
0
    def test_cmov_window_frame(self):
        try:
            from scikits.timeseries.lib import cmov_window
        except ImportError:
            raise nose.SkipTest

        # DataFrame
        vals = np.random.randn(10, 2)
        xp = cmov_window(vals, 5, 'boxcar')
        rs = mom.rolling_window(DataFrame(vals), 5, 'boxcar', center=True)
        assert_frame_equal(DataFrame(xp), rs)
Esempio n. 4
0
    def test_cmov_window_frame(self):
        tm._skip_if_no_scipy()
        try:
            from scikits.timeseries.lib import cmov_window
        except ImportError:
            raise nose.SkipTest("no scikits.timeseries")

        # DataFrame
        vals = np.random.randn(10, 2)
        xp = cmov_window(vals, 5, "boxcar")
        rs = mom.rolling_window(DataFrame(vals), 5, "boxcar", center=True)
        assert_frame_equal(DataFrame(xp), rs)
Esempio n. 5
0
    def test_cmov_window_regular(self):
        try:
            from scikits.timeseries.lib import cmov_window
        except ImportError:
            raise nose.SkipTest

        win_types = ['triang', 'blackman', 'hamming', 'bartlett', 'bohman',
                     'blackmanharris', 'nuttall', 'barthann']
        for wt in win_types:
            vals = np.random.randn(10)
            xp = cmov_window(vals, 5, wt)

            rs = mom.rolling_window(Series(vals), 5, wt, center=True)
            assert_series_equal(Series(xp), rs)
Esempio n. 6
0
    def test_cmov_window_regular(self):
        tm._skip_if_no_scipy()
        try:
            from scikits.timeseries.lib import cmov_window
        except ImportError:
            raise nose.SkipTest("no scikits.timeseries")

        win_types = ["triang", "blackman", "hamming", "bartlett", "bohman", "blackmanharris", "nuttall", "barthann"]
        for wt in win_types:
            vals = np.random.randn(10)
            xp = cmov_window(vals, 5, wt)

            rs = mom.rolling_window(Series(vals), 5, wt, center=True)
            assert_series_equal(Series(xp), rs)
    def test_cmov_window_regular(self):
        try:
            from scikits.timeseries.lib import cmov_window
        except ImportError:
            raise nose.SkipTest

        win_types = ['triang', 'blackman', 'hamming', 'bartlett', 'bohman',
                     'blackmanharris', 'nuttall', 'barthann']
        for wt in win_types:
            vals = np.random.randn(10)
            xp = cmov_window(vals, 5, wt)

            rs = mom.rolling_window(Series(vals), 5, wt, center=True)
            assert_series_equal(Series(xp), rs)
Esempio n. 8
0
    def test_cmov_window(self):
        try:
            from scikits.timeseries.lib import cmov_window
        except ImportError:
            raise nose.SkipTest

        vals = np.random.randn(10)
        xp = cmov_window(vals, 5, 'boxcar')

        rs = mom.rolling_window(vals, 5, 'boxcar', center=True)
        assert_almost_equal(xp.compressed(), rs[2:-2])
        assert_almost_equal(xp.mask, np.isnan(rs))

        xp = Series(rs)
        rs = mom.rolling_window(Series(vals), 5, 'boxcar', center=True)
        assert_series_equal(xp, rs)
Esempio n. 9
0
    def test_cmov_window_special(self):
        tm._skip_if_no_scipy()
        try:
            from scikits.timeseries.lib import cmov_window
        except ImportError:
            raise nose.SkipTest("no scikits.timeseries")

        win_types = ["kaiser", "gaussian", "general_gaussian", "slepian"]
        kwds = [{"beta": 1.0}, {"std": 1.0}, {"power": 2.0, "width": 2.0}, {"width": 0.5}]

        for wt, k in zip(win_types, kwds):
            vals = np.random.randn(10)
            xp = cmov_window(vals, 5, (wt,) + tuple(k.values()))

            rs = mom.rolling_window(Series(vals), 5, wt, center=True, **k)
            assert_series_equal(Series(xp), rs)
Esempio n. 10
0
    def test_cmov_window(self):
        try:
            from scikits.timeseries.lib import cmov_window
        except ImportError:
            raise nose.SkipTest

        vals = np.random.randn(10)
        xp = cmov_window(vals, 5, 'boxcar')

        rs = mom.rolling_window(vals, 5, 'boxcar', center=True)
        assert_almost_equal(xp.compressed(), rs[2:-2])
        assert_almost_equal(xp.mask, np.isnan(rs))

        xp = Series(rs)
        rs = mom.rolling_window(Series(vals), 5, 'boxcar', center=True)
        assert_series_equal(xp, rs)
Esempio n. 11
0
    def test_cmov_window_special(self):
        try:
            from scikits.timeseries.lib import cmov_window
        except ImportError:
            raise nose.SkipTest

        win_types = ['kaiser', 'gaussian', 'general_gaussian', 'slepian']
        kwds = [{'beta' : 1.}, {'std' : 1.}, {'power' : 2., 'width' : 2.},
                {'width' : 0.5}]

        for wt, k in zip(win_types, kwds):
            vals = np.random.randn(10)
            xp = cmov_window(vals, 5, (wt,) + tuple(k.values()))

            rs = mom.rolling_window(Series(vals), 5, wt, center=True,
                                    **k)
            assert_series_equal(Series(xp), rs)