view test/test_frames.py @ 121:c45f957ef4d9

Add NumPy include path to setup; remove PyAPI stuff from non-PyAPI calls
author Chris Cannam
date Tue, 23 Jun 2015 10:43:08 +0100
parents 3e5791890b65
children
line wrap: on
line source

import vamp.frames as fr
import numpy as np

def to_lists(arrs):
    return [list([list(r) for r in f]) for f in arrs]

def test_frames_from_1d_buffer():
    buf = np.arange(6)
    ff = to_lists(fr.frames_from_array(buf, 2, 2))
    assert(ff == [[[0,1]],[[2,3]],[[4,5]]])
    ff = to_lists(fr.frames_from_array(buf, 1, 2))
    assert(ff == [[[0,1]],[[1,2]],[[2,3]],[[3,4]],[[4,5]],[[5,0]]])

def test_frames_from_2d_buffer():
    buf = np.array([np.arange(6),np.arange(6,12)])
    ff = to_lists(fr.frames_from_array(buf, 2, 2))
    assert(ff == [[[0,1],[6,7]],[[2,3],[8,9]],[[4,5],[10,11]]])
    ff = to_lists(fr.frames_from_array(buf, 1, 2))
    assert(ff == [[[0,1],[6,7]],[[1,2],[7,8]],[[2,3],[8,9]],
                  [[3,4],[9,10]],[[4,5],[10,11]],[[5,0],[11,0]]])