def timeseriesdata_constructor_existing_file():
"""Tests the TimeSeriesData class constructor when the file exists. Tests
that the data are as expected, and that the filled data flag is set."""
tsd = TimeSeriesData("./tests/data/small.h5")
assert tsd.filled_data
#Validate that the time-series matrix data are correct
dat = np.matrix([[0, 2, 0, 0],
[2, 1, 3, 4],
[1, 1, 1, 1],
[0, 0, 1, 0]])
assert (dat == tsd.get_sparse_matrix().todense()).all()
assert (tsd.get_time_points() == [0, 4, 10, 12]).all()
sequence_ids = np.array([b'9247ec5fd33e99387d41e8fc0d7ee278',
b'53f74905f7826fee79dd09b0c12caddf',
b'8829fefe91ead511a30df118060b1030',
b'7f97b4991342bf629966aeac0708c94f'])
assert (sequence_ids == tsd.get_array_by_chunks("genes/sequenceids")).all()
sample_names = np.array([b'72c', b'29', b'qpa', b'15'])
assert (sample_names == tsd.get_array_by_chunks("samples/names")).all()
# __del__(self)
#Test if HDF5 file closed
评论列表
文章目录