test_lbl.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:bark 作者: kylerbrown 项目源码 文件源码
def test_writeread(tmpdir):
    fname = os.path.join(tmpdir.dirname, 'temp.lbl')
    times = np.reshape(np.arange(0,20), (-1,2))
    labels = [chr(i) for i in np.arange(10) + 65]
    dtype = [('name', np.unicode_, max([len(x) for x in labels])),
             ('start', float), ('stop', float)]
    rec_array = np.array([(l, sta, sto) for l, (sta, sto) in zip(labels, times)],
                    dtype=dtype)
    lbl.write(fname, rec_array)
    rec_array2 = lbl.read(fname)
    for x, y in zip(rec_array['name'], rec_array2['name']):
        assert x == y, 'label named do not match'
    assert np.all(np.isclose(rec_array['start'], rec_array2['start'])), 'starts do not match'
    assert np.all(np.isclose(rec_array['stop'], rec_array2['stop'])), 'stops do not match'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号