test_database.py 文件源码

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

项目:ananke 作者: beiko-lab 项目源码 文件源码
def test_filter_data_zero_cols(temp_dir):
    """Tests that columns are correctly remove when they are empty"""
    tsd = TimeSeriesData(temp_dir + "/filter_cols.h5")
    data = [1, 3, 5, 1, 1, 2, 5, 6, 5, 6, 2, 8]
    indptr = [0,  3,  4,  8, 12]
    indices = [1, 3, 4, 2, 0, 1, 3, 4, 0, 1, 3, 4]
    sequences = ["qqq", "abc", "zzz", "hi"]
    tsd.resize_data(len(indptr) - 1, len(indptr), len(data))
    tsd.add_timeseries_data(data, indices, indptr, sequences)
    tsd.insert_array_by_chunks("samples/names", ["a", "b", "c", "d", "e"])
    tsd.insert_array_by_chunks("samples/time", [0, 10, 15, 30, 35],
                               transform_func = int)
    tsd.insert_array_by_chunks("samples/mask", ["1", "1", "1", "1", "1"])
    outfile = temp_dir + "/filtered_zeros.h5"
    with pytest.warns(UserWarning):
        tsd.filter_data(outfile, "abundance", 2)
    filtered_tsd = TimeSeriesData(temp_dir + "/filtered_zeros.h5")
    assert (filtered_tsd.h5_table["samples/names"][:] == \
            np.array([b'a', b'b', b'd', b'e'])).all()
    assert (filtered_tsd.h5_table["samples/mask"][:] == [b'1']*4).all()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号