Skip to content

Commit a42ce8a

Browse files
committed
Fix labelled data counts not covering all selected train IDs
1 parent ff368ed commit a42ce8a

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

extra_data/keydata.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,9 @@ def data_counts(self, labelled=True):
398398

399399
if labelled:
400400
import pandas as pd
401-
return pd.Series(counts, index=train_ids)
401+
res = pd.Series(0, index=self.train_ids)
402+
res.loc[train_ids] = counts
403+
return res
402404
else:
403405
all_tids_arr = np.array(self.train_ids)
404406
res = np.zeros(len(all_tids_arr), dtype=np.uint64)

extra_data/tests/test_keydata.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_get_train_keep_dims(mock_jungfrau_run):
170170
assert val.shape == (1, 16, 512, 1024)
171171

172172

173-
def test_data_counts(mock_reduced_spb_proc_run):
173+
def test_data_counts(mock_reduced_spb_proc_run, mock_jungfrau_run):
174174
run = RunDirectory(mock_reduced_spb_proc_run)
175175

176176
# control data
@@ -189,6 +189,14 @@ def test_data_counts(mock_reduced_spb_proc_run):
189189
assert count.index.tolist() == mod.train_ids
190190
assert count.values.sum() == mod.shape[0]
191191

192+
# Combine data with more train IDs than our original sources, and
193+
# ensure that the data counts now cover these additional train IDs
194+
# as well with 0.
195+
multi_run = run.union(RunDirectory(mock_jungfrau_run))
196+
mod = multi_run['SPB_DET_AGIPD1M-1/DET/0CH0:xtdf', 'image.data']
197+
count = mod.data_counts()
198+
assert count.index.tolist() == mod.train_ids
199+
192200

193201
def test_data_counts_empty(mock_fxe_raw_run):
194202
run = RunDirectory(mock_fxe_raw_run)

0 commit comments

Comments
 (0)