Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix incompatible attribute #8

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from regions import RectanglePixelRegion, PixCoord
from specutils import Spectrum1D

from glue.core.exceptions import IncompatibleAttribute
from glue.config import data_translator
from glue.config import settings as glue_settings
from glue.core import BaseData, HubListener, Data, DataCollection
Expand Down Expand Up @@ -451,8 +452,11 @@ def get_data_from_viewer(self, viewer_reference, data_label=None,

if cls is not None:
handler, _ = data_translator.get_handler_for(cls)
layer_data = handler.to_object(layer_data,
statistic=statistic)
try:
layer_data = handler.to_object(layer_data,
statistic=statistic)
except IncompatibleAttribute:
Copy link

Choose a reason for hiding this comment

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

Looks awfully similar to glue-viz/glue-astronomy#39 but I think we're patching different things?

Copy link
Author

Choose a reason for hiding this comment

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

Ah yes it does seem like the same thing. I think we do want to handle things better in glue-astronomy but I think we still want to raise an error there rather than silently fail, and we do want to catch those exceptions here.

Copy link
Author

Choose a reason for hiding this comment

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

So I would suggest we go ahead with this PR, modify the glue-astronomy one to raise a better exception, and then update the exception we catch in jdaviz once glue-astronomy is released.

continue

data[label] = layer_data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def _on_viewer_data_changed(self, msg=None):
if msg is not None and msg.viewer_id != self._viewer_id:
return

self._viewer_data = self.app.get_data_from_viewer('spectrum-viewer')
self._viewer_data = self.app.get_data_from_viewer('spectrum-viewer',
include_subsets=False)

self.dc_items = [data.label
for data in self.app.data_collection
Expand Down
8 changes: 6 additions & 2 deletions jdaviz/configs/specviz/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from glue.core.subset import Subset
from glue.config import data_translator
from glue_jupyter.bqplot.profile import BqplotProfileView
from glue.core.exceptions import IncompatibleAttribute

import astropy
from astropy.utils.introspection import minversion
Expand Down Expand Up @@ -66,8 +67,11 @@ def data(self, cls=None):

if _class is not None:
handler, _ = data_translator.get_handler_for(_class)
layer_data = handler.to_object(layer_data,
statistic=statistic)
try:
layer_data = handler.to_object(layer_data,
statistic=statistic)
except IncompatibleAttribute:
continue
data.append(layer_data)

return data
Expand Down