fixed size read bug and added tests

This commit is contained in:
Erik Frojdh
2023-06-04 18:57:49 +02:00
parent d9828dd9a3
commit b8a8891c8d
3 changed files with 61 additions and 13 deletions

View File

@ -85,10 +85,33 @@ def test_read_file_with_37_frames(data_path):
def test_read_file_with_37_frames_in_chunks(data_path):
#File shoud contain 37 frames with 5 clusters each
#Full spec in utils/write_test_data.py
fname= (data_path/'37frames_with_5_clusters.clust').as_posix()
fname= data_path/'37frames_with_5_clusters.clust'
r = ClusterFileReader(fname)
total_clusters = 0
while (clusters:=r.read(7)).size:
total_clusters += clusters.size
assert total_clusters == 185
def test_read_file_with_noise_mask(data_path):
#No mask
fname= data_path/'noise_test.clust'
r = ClusterFileReader(fname)
cl = r.read(85) #file contains 70 clusters
assert cl.size == 70
#noise mask with zeros
noise_cut = np.zeros((400,400))
r = ClusterFileReader(fname)
cl = r.read(85, noise_cut)
assert cl.size == 70
#only pixel 80, 133 above noise
noise_cut[:] = 100
#TODO! Agree on orientation of noise mask!
# noise_cut[80,133] = 0
noise_cut[133,80] = 0
r = ClusterFileReader(fname)
cl = r.read(85, noise_cut)
assert cl.size == 10