Skip to content

Commit d56e9d0

Browse files
committed
enh: improved presentation of multiple datasets with identical sample names
1 parent a1c7e13 commit d56e9d0

File tree

8 files changed

+27
-14
lines changed

8 files changed

+27
-14
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- enh: instantaneous tool tips in block matrix
1111
- enh: show the created or quickviewed filter in analysis tab (#147)
1212
- enh: show the created plot in analysis tab
13+
- enh: improved presentation of multiple datasets with identical sample names
1314
- ref: tentative `set_pipeline`, so widgets have direct access to the pipeline
1415
- ref: raise ValueError in unreachable case in DataSlot creation
1516
- ref: restructure pipeline management through signaling

dcscope/gui/analysis/ana_basins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def update_content(self, slot_index=None, **kwargs):
107107
self.setUpdatesEnabled(False)
108108
self.listWidget_dataset.clear()
109109
self.treeWidget_basin_name.clear()
110-
for slot in self.pipeline.slots:
111-
self.listWidget_dataset.addItem(slot.name)
110+
for name in self.pipeline.deduce_display_names():
111+
self.listWidget_dataset.addItem(name)
112112
self.setUpdatesEnabled(True)
113113
if slot_index is None or slot_index < 0:
114114
slot_index = max(0, self.listWidget_dataset.currentRow())

dcscope/gui/analysis/ana_log.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ def update_content(self, slot_index=None, **kwargs):
128128
self.setUpdatesEnabled(False)
129129
self.listWidget_dataset.clear()
130130
self.listWidget_log_name.clear()
131-
for slot in self.pipeline.slots:
132-
self.listWidget_dataset.addItem(slot.name)
131+
for name in self.pipeline.deduce_display_names():
132+
self.listWidget_dataset.addItem(name)
133133
self.setUpdatesEnabled(True)
134134
if slot_index is None or slot_index < 0:
135135
slot_index = max(0, self.listWidget_dataset.currentRow())

dcscope/gui/analysis/ana_meta.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ def update_content(self, slot_index=None, **kwargs):
4949
slot_index = min(slot_index, len(self.pipeline.slot_ids) - 1)
5050

5151
self.comboBox_slots.clear()
52-
self.comboBox_slots.addItems(
53-
[ss.name for ss in self.pipeline.slots])
52+
self.comboBox_slots.addItems(self.pipeline.deduce_display_names())
5453
self.comboBox_slots.setCurrentIndex(slot_index)
5554
self.comboBox_slots.blockSignals(False)
5655
# populate content

dcscope/gui/analysis/ana_slot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def slot_names(self):
323323
if self.pipeline is None:
324324
return []
325325
else:
326-
return [slot.name for slot in self.pipeline.slots]
326+
return self.pipeline.deduce_display_names()
327327

328328
def get_dataset(self):
329329
"""Return dataset associated with the current slot index

dcscope/gui/analysis/ana_tables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ def update_content(self, slot_index=None, **kwargs):
225225
self.setUpdatesEnabled(False)
226226
self.listWidget_dataset.clear()
227227
self.listWidget_table_name.clear()
228-
for slot in self.pipeline.slots:
229-
self.listWidget_dataset.addItem(slot.name)
228+
for name in self.pipeline.deduce_display_names():
229+
self.listWidget_dataset.addItem(name)
230230
self.setUpdatesEnabled(True)
231231
if slot_index is None or slot_index < 0:
232232
slot_index = max(0, self.listWidget_dataset.currentRow())

dcscope/gui/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def add_dataslot(self, paths=None, is_dcor=False):
307307

308308
slot_ids.append(slot_id)
309309

310-
self.pipeline.compute_reduced_sample_names()
310+
self.pipeline.deduce_reduced_sample_names()
311311

312312
self.pp_mod_send.emit({"pipeline": {"slots_added": slot_ids}})
313313

dcscope/pipeline/core.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def paths(self):
120120
def reduced_sample_names(self):
121121
"""Return reduced sample names for all slots"""
122122
if len(self.slots) != len(self._reduced_sample_names):
123-
self.compute_reduced_sample_names()
123+
self.deduce_reduced_sample_names()
124124
return self._reduced_sample_names
125125

126126
def add_filter(self, filt=None, index=None):
@@ -306,9 +306,19 @@ def check_contour_spacing(self, plot_id):
306306
if old_plot_state != plot_state:
307307
plot.__setstate__(plot_state)
308308

309-
def compute_reduced_sample_names(self,
310-
slot_indices: list[int] = None,
311-
) -> list[str]:
309+
def deduce_display_names(self):
310+
"""Return slot names for displaying in lists and combo boxes in the UI
311+
"""
312+
unique_names = self.reduced_sample_names
313+
display_names = [
314+
(ss.name if ss.name == un else f"{ss.name} [{un[:80]}]")
315+
for ss, un in zip(self.slots, unique_names)
316+
]
317+
return display_names
318+
319+
def deduce_reduced_sample_names(self,
320+
slot_indices: list[int] = None,
321+
) -> list[str]:
312322
"""Return a list of reduced sample names for the given indices
313323
314324
The algorithm removes common prefixes and suffixes from sample names.
@@ -374,6 +384,9 @@ def compute_reduced_sample_names(self,
374384
for jj, ii in enumerate(idx):
375385
names[ii] = new_names[jj]
376386

387+
# avoid empty names at the end of it
388+
names = [n if n else s.name for n, s in zip(names, slots)]
389+
377390
if set_property:
378391
self._reduced_sample_names.clear()
379392
self._reduced_sample_names += names

0 commit comments

Comments
 (0)