Skip to content

Commit

Permalink
Backport PR #2591: Compat with glue-core 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim authored and meeseeksmachine committed Dec 6, 2023
1 parent 6cd180f commit a09b55b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Bug Fixes
---------

- Compatibility with glue-core 1.17. [#2591]

Cubeviz
^^^^^^^

Expand Down
15 changes: 12 additions & 3 deletions jdaviz/configs/default/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import matplotlib
import numpy as np

from astropy.utils import minversion
from astropy.visualization import (
ManualInterval, ContrastBiasStretch, PercentileInterval
)
Expand Down Expand Up @@ -32,6 +33,8 @@

__all__ = ['PlotOptions']

GLUE_LT_1_17 = not minversion("glue", "1.17")


class SplineStretch:
"""
Expand Down Expand Up @@ -89,7 +92,10 @@ def update_knots(self, x, y):

# Add the spline stretch to the glue stretch registry if not registered
if "spline" not in stretches:
stretches.add("spline", SplineStretch(), display="Spline")
if GLUE_LT_1_17:
stretches.add("spline", SplineStretch(), display="Spline")
else:
stretches.add("spline", SplineStretch, display="Spline")


@tray_registry('g-plot-options', label="Plot Options")
Expand All @@ -102,7 +108,7 @@ class PlotOptions(PluginTemplateMixin):
:ref:`public plugin API <plugin-apis>`:
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.show`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.close_in_tray`
* ``viewer`` (:class:`~jdaviz.core.template_mixin.ViewerSelect`):
* ``viewer_multiselect``
Expand Down Expand Up @@ -846,7 +852,10 @@ def _update_stretch_curve(self, msg=None):
# procedure in glue's CompositeArray:
interval = ManualInterval(self.stretch_vmin_value, self.stretch_vmax_value)
contrast_bias = ContrastBiasStretch(self.image_contrast_value, self.image_bias_value)
stretch = stretches.members[self.stretch_function_value]
if GLUE_LT_1_17:
stretch = stretches.members[self.stretch_function_value]
else:
stretch = stretches.members[self.stretch_function_value]()
layer_cmap = layer.state.cmap

# show the colorbar
Expand Down

0 comments on commit a09b55b

Please sign in to comment.