def testDataConcatenationCy32(self): data = sp.zeros((100, 1), dtype=sp.float32) data[sp.arange(0, 100, 10)] = 1.0 filt = sp.zeros((5, 1), dtype=sp.float32) filt[2] = 1.0 hist = sp.zeros((4, 1), dtype=sp.float32) fout = _mcfilter_hist_cy32(data, filt, hist)[0] cut = int(sp.floor(5.0 / 2)) assert_equal(data[:-cut], sp.array([fout[cut:]]).T)
def testHistoryCy32(self): """test history item""" tf = 3 nc = 2 data = sp.randn(100, nc).astype(sp.float32) filt = sp.ones((tf, nc), dtype=sp.float32) hist = sp.zeros((tf - 1, nc), dtype=sp.float32) fout, hist = _mcfilter_hist_cy32(data, filt, hist) assert_equal(hist, data[-(tf - 1):])
def testHistoryCy32(self): """test history item""" tf = 3 nc = 2 data = sp.randn(100, nc).astype(sp.float32) filt = sp.ones((tf, nc), dtype=sp.float32) hist = sp.zeros((tf - 1, nc), dtype=sp.float32) fout, hist = _mcfilter_hist_cy32(data, filt, hist) assert_equal(hist, data[-(tf - 1):])
def testDataConcatenationCy32(self): data = sp.zeros((100, 1), dtype=sp.float32) data[sp.arange(0, 100, 10)] = 1.0 filt = sp.zeros((5, 1), dtype=sp.float32) filt[2] = 1.0 hist = sp.zeros((4, 1), dtype=sp.float32) fout = _mcfilter_hist_cy32(data, filt, hist)[0] cut = sp.floor(5.0 / 2) assert_equal(data[:-cut], sp.array([fout[cut:]]).T)
def testPyVsCyOnesCy32(self): """test python and cython, float""" tf = 3 nc = 2 data = sp.ones((20, nc), dtype=sp.float32) filt = sp.ones((tf, nc), dtype=sp.float32) hist = sp.ones((tf - 1, nc), dtype=sp.float32) fopy, hopy = _mcfilter_hist_py(data, filt, hist) focy, hocy = _mcfilter_hist_cy32(data, filt, hist) assert_almost_equal(fopy, focy)
def testPyVsCyOnesCy32(self): """test python and cython, float""" tf = 3 nc = 2 data = sp.ones((20, nc), dtype=sp.float32) filt = sp.ones((tf, nc), dtype=sp.float32) hist = sp.ones((tf - 1, nc), dtype=sp.float32) fopy, hopy = _mcfilter_hist_py(data, filt, hist) focy, hocy = _mcfilter_hist_cy32(data, filt, hist) assert_almost_equal(fopy, focy)
def testStepsCy32(self): tf = 3 nc = 2 data = sp.vstack([sp.concatenate([sp.arange(1, 4)] * 5)] * 2).T.astype( sp.float32) filt = sp.ones((tf, nc), dtype=sp.float32) / float(tf) hist_py = sp.ones((tf - 1, nc), dtype=sp.float32) hist_cy = sp.ones((tf - 1, nc), dtype=sp.float32) fopy, hopy = _mcfilter_hist_py(data, filt, hist_py) focy, hocy = _mcfilter_hist_cy32(data, filt, hist_cy) assert_almost_equal(fopy, focy)
def testPyVsCyRandnCy32(self): """test python and cython""" tf = 3 nc = 2 data = sp.randn(20, nc).astype(sp.float32) filt = sp.ones((tf, nc), dtype=sp.float32) hist_py = sp.ones((tf - 1, nc), dtype=sp.float32) hist_cy = sp.ones((tf - 1, nc), dtype=sp.float32) fopy, hopy = _mcfilter_hist_py(data, filt, hist_py) focy, hocy = _mcfilter_hist_cy32(data, filt, hist_cy) assert_almost_equal(fopy, focy, decimal=5)
def testStepsCy32(self): tf = 3 nc = 2 data = sp.vstack([sp.concatenate( [sp.arange(1, 4)] * 5)] * 2).T.astype(sp.float32) filt = sp.ones((tf, nc), dtype=sp.float32) / float(tf) hist_py = sp.ones((tf - 1, nc), dtype=sp.float32) hist_cy = sp.ones((tf - 1, nc), dtype=sp.float32) fopy, hopy = _mcfilter_hist_py(data, filt, hist_py) focy, hocy = _mcfilter_hist_cy32(data, filt, hist_cy) assert_almost_equal(fopy, focy)
def testPyVsCyRandnCy32(self): """test python and cython""" tf = 3 nc = 2 data = sp.randn(20, nc).astype(sp.float32) filt = sp.ones((tf, nc), dtype=sp.float32) hist_py = sp.ones((tf - 1, nc), dtype=sp.float32) hist_cy = sp.ones((tf - 1, nc), dtype=sp.float32) fopy, hopy = _mcfilter_hist_py(data, filt, hist_py) focy, hocy = _mcfilter_hist_cy32(data, filt, hist_cy) assert_almost_equal(fopy, focy, decimal=5)