Skip to content

Commit fab8776

Browse files
committed
fix: when using selections we must use get_visible_data in case of sorting/filtering
1 parent 7d130c8 commit fab8776

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/ess/reflectometry/gui.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ def __init__(
7070
)
7171

7272
def run_when_selected_row_changes(change):
73-
if not change['old'] or change['old'][0]['r1'] != change['new'][0]['r1']:
73+
# Runs when there are no previous selections,
74+
# or the new selection is different from the old.
75+
if not change['old'] or (
76+
change['new'] and change['new'][0]['r1'] != change['old'][0]['r1']
77+
):
7478
self.run_workflow()
7579

7680
self.runs_table.observe(run_when_selected_row_changes, names='selections')
@@ -88,7 +92,7 @@ def run_workflow(self):
8892

8993
self.working_label.layout.display = ''
9094
row_idx = selections[0]['r1']
91-
run = self.runs_table.data.iloc[row_idx]['Run']
95+
run = self.runs_table.get_visible_data().iloc[row_idx]['Run']
9296

9397
workflow = amor.AmorWorkflow()
9498
workflow[SampleSize[SampleRun]] = sc.scalar(10, unit='mm')
@@ -226,7 +230,7 @@ def update_nexus_view(self, *_):
226230

227231
# Get the first selected row
228232
row_idx = selections[0]['r1']
229-
run = self.runs_table.data.iloc[row_idx]['Run']
233+
run = self.runs_table.get_visible_data().iloc[row_idx]['Run']
230234
filepath = self.run_to_filepath(run)
231235

232236
# Create and display the tree for this file
@@ -279,7 +283,7 @@ def on_tree_select(self, event):
279283
return
280284

281285
row_idx = selections[0]['r1']
282-
run = self.runs_table.data.iloc[row_idx]['Run']
286+
run = self.runs_table.get_visible_data().iloc[row_idx]['Run']
283287
filepath = self.run_to_filepath(run)
284288

285289
with h5py.File(filepath, 'r') as f:
@@ -497,7 +501,7 @@ def add_row(_):
497501
if len(self.reduction_table.selections) > 0:
498502
# Get the first selected row
499503
selection = self.reduction_table.selections[0]
500-
row = self.reduction_table.data.iloc[
504+
row = self.reduction_table.get_visible_data().iloc[
501505
selection['r1'] : selection['r2'] + 1
502506
]
503507
else:
@@ -661,9 +665,6 @@ def log_text(self, message):
661665
def log_progress(self, progress):
662666
self.progress_log.children = (progress,)
663667

664-
def log_plot(self, plot):
665-
"""Log a plot to the top of the plot log"""
666-
667668

668669
class AmorBatchReductionGUI(ReflectometryBatchReductionGUI):
669670
def __init__(self):
@@ -912,7 +913,7 @@ def get_row_key(self, row):
912913

913914
def get_selected_rows(self):
914915
chunks = [
915-
table.data.iloc[s['r1'] : s['r2'] + 1]
916+
table.get_visible_data().iloc[s['r1'] : s['r2'] + 1]
916917
for table in (self.reduction_table, self.custom_reduction_table)
917918
for s in table.selections
918919
]

0 commit comments

Comments
 (0)