Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

aperture photometry: do not hide prev results when resetting #2112

Merged
merged 3 commits into from
Mar 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,11 @@ def __init__(self, *args, **kwargs):
self.session.hub.subscribe(self, SubsetUpdateMessage, handler=self._on_subset_update)
self.session.hub.subscribe(self, LinkUpdatedMessage, handler=self._on_link_update)

def reset_results(self):
self.result_available = False
self.results = []
self.plot_available = False
self.radial_plot = ''
bqplot_clear_figure(self._fig)

@observe('dataset_selected')
def _dataset_selected_changed(self, event={}):
try:
self._selected_data = self.dataset.selected_dc_item
if self._selected_data is None:
self.reset_results()
return
self.counts_factor = 0
self.pixel_area = 0
Expand Down Expand Up @@ -143,7 +135,6 @@ def _dataset_selected_changed(self, event={}):
self.pixel_area = 0.04 * 0.04

except Exception as e:
self.reset_results()
self._selected_data = None
self.hub.broadcast(SnackbarMessage(
f"Failed to extract {self.dataset_selected}: {repr(e)}",
Expand Down Expand Up @@ -174,7 +165,6 @@ def _on_link_update(self, msg):
def _subset_selected_changed(self, event={}):
subset_selected = event.get('new', self.subset_selected)
if self._selected_data is None or subset_selected == '':
self.reset_results()
return

try:
Expand All @@ -196,7 +186,6 @@ def _subset_selected_changed(self, event={}):

except Exception as e:
self._selected_subset = None
self.reset_results()
self.hub.broadcast(SnackbarMessage(
f"Failed to extract {subset_selected}: {repr(e)}", color='error', sender=self))

Expand Down Expand Up @@ -249,7 +238,6 @@ def _bg_subset_selected_changed(self, event={}):

def vue_do_aper_phot(self, *args, **kwargs):
if self._selected_data is None or self._selected_subset is None:
self.reset_results()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think you need to reset when new calculation is requested.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you show a case where that is needed? I think everything just gets overwritten for a successful run and the code is redundant, but I'm not 100% sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is, when this button is pressed, things should be cleared and only show new calculated results. If there is any failure at all (this, or the except Exception as e below), no numbers should show, to make it clear that something has gone wrong.

The logic here should not affect the issue you are trying to fix. Deleting a Subset should not trigger this method.

Or am I misunderstanding the situtation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting all subsets does trigger resetting the results and ends up hiding both the most recent results and the entire table. I can move the entire table outside of that logic and to its own logic (just checking the length of the table or something), but that feels like extraneous logic and inconsistent behavior to me.

Screen.Recording.2023-03-24.at.11.13.49.AM.mov

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete subset event triggers vue_do_aper_phot? 🤯

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but the subset selection itself becomes blank, and then _subset_selected_changed clears the results.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, we can stop clearing for that. But I am saying it should still clear within vue_do_aper_phot.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should all the previous results (including the table) disappear? What if instead we show a message that the previous run failed above all of those so they are not lost?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so what if we show the error message in the UI in place of the results and keep the table?

This might be a good enough compromise.

self.hub.broadcast(SnackbarMessage(
"No data for aperture photometry", color='error', sender=self))
return
Expand Down Expand Up @@ -430,14 +418,14 @@ def vue_do_aper_phot(self, *args, **kwargs):
else:
bqplot_marks = [bqplot_line]

self._fig.marks = bqplot_marks

except Exception as e: # pragma: no cover
self.reset_results()
bqplot_clear_figure(self._fig)
self.hub.broadcast(SnackbarMessage(
f"Aperture photometry failed: {repr(e)}", color='error', sender=self))

else:
self._fig.marks = bqplot_marks

# Parse results for GUI.
tmp = []
for key in phot_table.colnames:
Expand Down