From d4f399e174cc0d246838f67ff8454a2b652491cd Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Wed, 22 May 2024 11:10:24 -0400 Subject: [PATCH] Remove things deprecated since v3.9 (#2878) * Remove things deprecated since v3.9 * DOC: Complete remove rotate canvas section --- CHANGES.rst | 11 ++ docs/imviz/plugins.rst | 30 ---- docs/reference/api_plugins.rst | 3 - jdaviz/configs/cubeviz/helper.py | 17 --- jdaviz/configs/cubeviz/plugins/slice/slice.py | 34 +---- .../plugins/tests/test_cubeviz_helper.py | 6 +- jdaviz/configs/imviz/imviz.yaml | 1 - jdaviz/configs/imviz/plugins/__init__.py | 1 - .../imviz/plugins/rotate_canvas/__init__.py | 1 - .../plugins/rotate_canvas/rotate_canvas.py | 137 ------------------ .../plugins/rotate_canvas/rotate_canvas.vue | 91 ------------ .../plugins/rotate_canvas/tests/__init__.py | 0 .../rotate_canvas/tests/test_rotate_canvas.py | 34 ----- .../plugins/line_analysis/line_analysis.py | 16 +- .../line_analysis/tests/test_line_analysis.py | 2 +- 15 files changed, 15 insertions(+), 369 deletions(-) delete mode 100644 jdaviz/configs/imviz/plugins/rotate_canvas/__init__.py delete mode 100644 jdaviz/configs/imviz/plugins/rotate_canvas/rotate_canvas.py delete mode 100644 jdaviz/configs/imviz/plugins/rotate_canvas/rotate_canvas.vue delete mode 100644 jdaviz/configs/imviz/plugins/rotate_canvas/tests/__init__.py delete mode 100644 jdaviz/configs/imviz/plugins/rotate_canvas/tests/test_rotate_canvas.py diff --git a/CHANGES.rst b/CHANGES.rst index 8cf290d4f8..59f231ed95 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -42,15 +42,26 @@ Cubeviz spectrum in ``dataset``. This affects: model fitting, gaussian smooth, line analysis, and moment maps. [#2827] +- Removed deprecated ``cubeviz.select_slice()`` method. Use ``cubeviz.select_wavelength()`` + instead. [#2878] + +- In the Slice plugin, the following deprecated properties were removed: ``wavelength`` (use ``value``), + ``wavelength_unit`` (use ``value_unit``), ``show_wavelength`` (use ``show_value``), + ``slice`` (use ``value``). [#2878] + Imviz ^^^^^ +- Deprecated Rotate Canvas plugin was removed; use Orientation plugin instead. [#2878] + Mosviz ^^^^^^ Specviz ^^^^^^^ +- In the Line Analysis plugin, deprecated ``width`` was removed (use ``continuum_width``). [#2878] + Specviz2d ^^^^^^^^^ diff --git a/docs/imviz/plugins.rst b/docs/imviz/plugins.rst index cecb45fd7b..4fc58c1a06 100644 --- a/docs/imviz/plugins.rst +++ b/docs/imviz/plugins.rst @@ -197,10 +197,6 @@ For an image with a valid WCS, the compass will show directions to North (N) and East (E) for ICRS sky coordinates. It also shows the currently displayed data label, the X and Y directions, and the zoom box. -Note that when the axes canvas is rotated (by :ref:`rotate-canvas`), the zoom box corresponds -to the set zoom limits, not the extent of the viewer. Instead, the compass image itself is -shown rotated/flipped to the same orientation. - When you have multiple viewers created in Imviz, use the Viewer dropdown menu to change the active viewer that it tracks. @@ -400,32 +396,6 @@ To import a regions file or object from the API: fp.import_region(region) - -.. _rotate-canvas: - -Canvas Rotation -=============== - -.. note:: - - This plugin is deprecated in favor of rotation via :ref:`imviz-orientation` and will be removed - in a future release. - -The canvas rotation plugin allows rotating and horizontally flipping the image to any arbitrary -value by rotating the canvas axes themselves. Note that this does not affect the underlying data, and -exporting data to the notebook via the API will therefore not exhibit the same rotation. - -The :ref:`imviz-compass` will also rotate (and flip) accordingly, but will show the zoom box -corresponding to the zoom limits, not the region shown in the viewer itself. - -Presets are provided to reset the orientation as well as to set north up and east either to the -right or the left, as well as a slider and input to set the angle and a switch to set whether the -axes should be flipped horizontally after applying the rotation (a vertical flip can be achieved -via a 180 deg rotation and a horizontal flip). - -Due to browser limitations, Canvas Rotation is only available on Chromium-based browsers. - - .. _imviz-export-plot: Export diff --git a/docs/reference/api_plugins.rst b/docs/reference/api_plugins.rst index cd4956af7f..c7ee208e22 100644 --- a/docs/reference/api_plugins.rst +++ b/docs/reference/api_plugins.rst @@ -69,9 +69,6 @@ Plugins API .. automodapi:: jdaviz.configs.imviz.plugins.orientation.orientation :no-inheritance-diagram: -.. automodapi:: jdaviz.configs.imviz.plugins.rotate_canvas.rotate_canvas - :no-inheritance-diagram: - .. automodapi:: jdaviz.configs.mosviz.plugins.row_lock.row_lock :no-inheritance-diagram: diff --git a/jdaviz/configs/cubeviz/helper.py b/jdaviz/configs/cubeviz/helper.py index 15dd1425c4..41de2f5a29 100644 --- a/jdaviz/configs/cubeviz/helper.py +++ b/jdaviz/configs/cubeviz/helper.py @@ -1,7 +1,6 @@ import numpy as np from astropy.io import fits from astropy.io import registry as io_registry -from astropy.utils.decorators import deprecated from specutils import Spectrum1D from specutils.io.registers import _astropy_has_priorities @@ -101,22 +100,6 @@ def load_data(self, data, data_label=None, override_cube_limit=False, **kwargs): color='warning', sender=self, timeout=10000) self.app.hub.broadcast(msg) - @deprecated(since="3.9", alternative="select_wavelength") - def select_slice(self, slice): - """ - Select a slice by index. - - Parameters - ---------- - slice : int - Slice integer to select - """ - if not isinstance(slice, int): - raise TypeError("slice must be an integer") - if slice < 0: - raise ValueError("slice must be positive") - self.plugins['Slice'].slice = slice - def select_wavelength(self, wavelength): """ Select the slice closest to the provided wavelength. diff --git a/jdaviz/configs/cubeviz/plugins/slice/slice.py b/jdaviz/configs/cubeviz/plugins/slice/slice.py index 03a7945e81..9871c61f70 100644 --- a/jdaviz/configs/cubeviz/plugins/slice/slice.py +++ b/jdaviz/configs/cubeviz/plugins/slice/slice.py @@ -6,7 +6,6 @@ import numpy as np from astropy import units as u from astropy.units import UnitsWarning -from astropy.utils.decorators import deprecated from traitlets import Bool, Int, Unicode, observe from jdaviz.configs.cubeviz.plugins.viewers import (WithSliceIndicator, WithSliceSelection, @@ -149,40 +148,9 @@ def slice_selection_viewers(self): def slice_indicator_viewers(self): return [v for v in self.app._viewer_store.values() if isinstance(v, WithSliceIndicator)] - @property - @deprecated(since="3.9", alternative="value") - def wavelength(self): - return self.user_api.value - - @property - @deprecated(since="3.9", alternative="value_unit") - def wavelength_unit(self): - return self.user_api.value_unit - - @property - @deprecated(since="3.9", alternative="show_value") - def show_wavelength(self): - return self.user_api.show_value - - @property - @deprecated(since="3.9", alternative="value") - def slice(self): - # this assumes the first slice_selection_viewer (and layer) - return self.slice_selection_viewers[0].slice - - @slice.setter - @deprecated(since="3.9", alternative="value") - def slice(self, slice): - # this assumes the first slice_selection_viewer (and layer) - value = self.slice_selection_viewers[0].slice_values[slice] - self.value = value - @property def user_api(self): - # NOTE: remove slice, wavelength, show_wavelength after deprecation period - expose = ['slice', 'wavelength', 'show_wavelength', - 'value', - 'show_indicator', 'show_value'] + expose = ['value', 'show_indicator', 'show_value'] if self.allow_disable_snapping: expose += ['snap_to_slice'] return PluginUserApi(self, expose=expose) diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_helper.py b/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_helper.py index 09e01d71c9..ecc66c4ca3 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_helper.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_helper.py @@ -21,11 +21,7 @@ def test_plugin_user_apis(cubeviz_helper): for plugin_name, plugin_api in cubeviz_helper.plugins.items(): plugin = plugin_api._obj for attr in plugin_api._expose: - if plugin_name == 'Slice' and attr in ('slice', 'wavelength', - 'wavelength_unit', 'show_wavelength'): - # deprecated, so would raise a deprecation warning - continue - assert hasattr(plugin, attr) + assert hasattr(plugin, attr), f"{attr} not in {plugin_name}" def test_remote_server_disable_save_serverside(): diff --git a/jdaviz/configs/imviz/imviz.yaml b/jdaviz/configs/imviz/imviz.yaml index 7a8eaed9ae..dd5ded7d00 100644 --- a/jdaviz/configs/imviz/imviz.yaml +++ b/jdaviz/configs/imviz/imviz.yaml @@ -30,7 +30,6 @@ tray: - imviz-aper-phot-simple - imviz-catalogs - imviz-footprints - - imviz-rotate-canvas - export viewer_area: - container: col diff --git a/jdaviz/configs/imviz/plugins/__init__.py b/jdaviz/configs/imviz/plugins/__init__.py index d03d67ea92..18283e0bf0 100644 --- a/jdaviz/configs/imviz/plugins/__init__.py +++ b/jdaviz/configs/imviz/plugins/__init__.py @@ -8,5 +8,4 @@ from .aper_phot_simple import * # noqa from .line_profile_xy import * # noqa from .catalogs import * # noqa -from .rotate_canvas import * # noqa from .footprints import * # noqa diff --git a/jdaviz/configs/imviz/plugins/rotate_canvas/__init__.py b/jdaviz/configs/imviz/plugins/rotate_canvas/__init__.py deleted file mode 100644 index d1677a93e1..0000000000 --- a/jdaviz/configs/imviz/plugins/rotate_canvas/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .rotate_canvas import * # noqa diff --git a/jdaviz/configs/imviz/plugins/rotate_canvas/rotate_canvas.py b/jdaviz/configs/imviz/plugins/rotate_canvas/rotate_canvas.py deleted file mode 100644 index ffa6b1159c..0000000000 --- a/jdaviz/configs/imviz/plugins/rotate_canvas/rotate_canvas.py +++ /dev/null @@ -1,137 +0,0 @@ -import os -from traitlets import Bool, Unicode, observe - -from glue_jupyter.common.toolbar_vuetify import read_icon - -from jdaviz.configs.imviz.wcs_utils import get_compass_info -from jdaviz.core.custom_traitlets import FloatHandleEmpty -from jdaviz.core.events import AddDataMessage, RemoveDataMessage, CanvasRotationChangedMessage -from jdaviz.core.registries import tray_registry -from jdaviz.core.template_mixin import PluginTemplateMixin, ViewerSelectMixin -from jdaviz.core.user_api import PluginUserApi -from jdaviz.core.tools import ICON_DIR - -__all__ = ['RotateCanvas'] - - -@tray_registry('imviz-rotate-canvas', label="Canvas Rotation", viewer_requirements='image') -class RotateCanvas(PluginTemplateMixin, ViewerSelectMixin): - """ - See the :ref:`Canvas Rotation Plugin Documentation ` for more details. - - Only the following attributes and methods are available through the - :ref:`public plugin API `: - - * :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.show` - * :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 to show orientation/compass information. - * ``angle``: - Angle to rotate the axes canvas, clockwise. - * ``flip_horizontal``: - Whether to flip the canvas horizontally, after applying rotation. - * :meth:`reset` - * :meth:`set_north_up_east_left` - * :meth:`set_north_up_east_right` - """ - template_file = __file__, "rotate_canvas.vue" - - angle = FloatHandleEmpty(0).tag(sync=True) # degrees, clockwise - flip_horizontal = Bool(False).tag(sync=True) # horizontal flip applied after rotation - has_wcs = Bool(False).tag(sync=True) - - icon_nuer = Unicode(read_icon(os.path.join(ICON_DIR, 'right-east.svg'), 'svg+xml')).tag(sync=True) # noqa - icon_nuel = Unicode(read_icon(os.path.join(ICON_DIR, 'left-east.svg'), 'svg+xml')).tag(sync=True) # noqa - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - self.hub.subscribe(self, AddDataMessage, handler=self._on_viewer_data_changed) - self.hub.subscribe(self, RemoveDataMessage, handler=self._on_viewer_data_changed) - - @property - def user_api(self): - return PluginUserApi(self, expose=('viewer', 'angle', 'flip_horizontal', 'reset', - 'set_north_up_east_right', 'set_north_up_east_left')) - - @property - def ref_data(self): - return self.app.get_viewer_by_id(self.viewer.selected_id).state.reference_data - - def _on_viewer_data_changed(self, msg=None): - if not self.viewer_selected: # pragma: no cover - return - self.has_wcs = getattr(self.ref_data, 'coords', None) is not None - - @observe('viewer_selected') - def _viewer_selected_changed(self, *args, **kwargs): - if not hasattr(self, 'viewer'): - return - vid = self.viewer.selected_id - self.angle = self.app._viewer_item_by_id(vid).get('canvas_angle', 0) - self.flip_horizontal = self.app._viewer_item_by_id(vid).get('canvas_flip_horizontal', False) - - def _get_wcs_angles(self): - if not self.has_wcs: - raise ValueError("reference data does not have WCS, cannot determine orientation") - ref_data = self.ref_data - if ref_data is None: # pragma: no cover - raise ValueError("no data loaded in viewer, cannot determine orientation") - _, _, _, _, _, _, degn, dege, flip = get_compass_info(ref_data.coords, ref_data.shape) - return degn, dege, flip - - def reset(self): - """ - Reset the rotation to an angle of 0 and no flip - """ - self.angle = 0 - self.flip_horizontal = False - - def set_north_up_east_left(self): - """ - Set the rotation angle and flip to achieve North up and East left according to the reference - image WCS. - """ - degn, dege, flip = self._get_wcs_angles() - self.angle = -degn - self.flip_horizontal = flip - - def set_north_up_east_right(self): - """ - Set the rotation angle and flip to achieve North up and East right according to the - reference image WCS. - """ - degn, dege, flip = self._get_wcs_angles() - self.angle = -degn - self.flip_horizontal = not flip - - def vue_reset(self, *args, **kwargs): - self.reset() # pragma: no cover - - def vue_set_north_up_east_left(self, *args, **kwargs): - self.set_north_up_east_left() # pragma: no cover - - def vue_set_north_up_east_right(self, *args, **kwargs): - self.set_north_up_east_right() # pragma: no cover - - @observe('angle') - def _angle_changed(self, *args, **kwargs): - try: - angle = float(self.angle) - except ValueError: # pragma: no cover - # empty string, etc - angle = 0 - - # Rotate selected viewer canvas. This changes zoom too. - self.app._viewer_item_by_id(self.viewer.selected_id)['canvas_angle'] = angle - # broadcast message (used by compass, etc) - self.hub.broadcast(CanvasRotationChangedMessage(self.viewer.selected_id, - angle, self.flip_horizontal, sender=self)) - - @observe('flip_horizontal') - def _flip_changed(self, *args, **kwargs): - self.app._viewer_item_by_id(self.viewer.selected_id)['canvas_flip_horizontal'] = self.flip_horizontal # noqa - self.hub.broadcast(CanvasRotationChangedMessage(self.viewer.selected_id, - self.angle, self.flip_horizontal, - sender=self)) diff --git a/jdaviz/configs/imviz/plugins/rotate_canvas/rotate_canvas.vue b/jdaviz/configs/imviz/plugins/rotate_canvas/rotate_canvas.vue deleted file mode 100644 index 7698962edb..0000000000 --- a/jdaviz/configs/imviz/plugins/rotate_canvas/rotate_canvas.vue +++ /dev/null @@ -1,91 +0,0 @@ - - - diff --git a/jdaviz/configs/imviz/plugins/rotate_canvas/tests/__init__.py b/jdaviz/configs/imviz/plugins/rotate_canvas/tests/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/jdaviz/configs/imviz/plugins/rotate_canvas/tests/test_rotate_canvas.py b/jdaviz/configs/imviz/plugins/rotate_canvas/tests/test_rotate_canvas.py deleted file mode 100644 index 63379bdfdc..0000000000 --- a/jdaviz/configs/imviz/plugins/rotate_canvas/tests/test_rotate_canvas.py +++ /dev/null @@ -1,34 +0,0 @@ -import pytest -import numpy as np - -from jdaviz.configs.imviz.tests.utils import BaseImviz_WCS_NoWCS - - -class TestImvizRotateCanvas(BaseImviz_WCS_NoWCS): - def test_rotate_canvas(self): - rc = self.imviz.plugins['Canvas Rotation'] - - # reference data has WCS - assert rc._obj.has_wcs is True - rc.angle = 10 - rc.flip_horizontal = True - - rc.set_north_up_east_left() - assert np.allclose(rc.angle, -0.0005285079750789092) - assert rc.flip_horizontal is False - - rc.set_north_up_east_right() - assert np.allclose(rc.angle, -0.0005285079750789092) - assert rc.flip_horizontal is True - - rc.reset() - assert np.allclose(rc.angle, 0.0) - assert rc.flip_horizontal is False - - # removing WCS data should disable orientation options - self.imviz.app.remove_data_from_viewer('imviz-0', 'has_wcs[SCI,1]') - assert rc._obj.has_wcs is False - - with pytest.raises(ValueError, - match="reference data does not have WCS, cannot determine orientation"): - rc.set_north_up_east_left() diff --git a/jdaviz/configs/specviz/plugins/line_analysis/line_analysis.py b/jdaviz/configs/specviz/plugins/line_analysis/line_analysis.py index c1a6f6cff9..5fea5bb25e 100644 --- a/jdaviz/configs/specviz/plugins/line_analysis/line_analysis.py +++ b/jdaviz/configs/specviz/plugins/line_analysis/line_analysis.py @@ -1,5 +1,4 @@ import os -import logging import numpy as np from glue.core.message import (SubsetDeleteMessage, @@ -139,23 +138,10 @@ def _default_spectrum_viewer_reference_name(self): self.app._jdaviz_helper, '_default_spectrum_viewer_reference_name', 'spectrum-viewer' ) - # backwards compatibility for width (replace with user API deprecation) - @property - def width(self): - logging.warning(f"DeprecationWarning: width was replaced by continuum_width in 3.9 and will be removed in a future release") # noqa - return self.continuum_width - - @width.setter - def width(self, width): - logging.warning("DeprecationWarning: width was replaced by continuum_width in 3.9 and will be removed in a future release") # noqa - self.continuum_width = width - @property def user_api(self): - # deprecated: width was replaced with continuum_width in 3.9 so should be removed from the - # user API and the property and setter above as soon as 3.11. return PluginUserApi(self, expose=('dataset', 'spectral_subset', - 'continuum', 'width', 'continuum_width', 'get_results')) + 'continuum', 'continuum_width', 'get_results')) @property def line_items(self): diff --git a/jdaviz/configs/specviz/plugins/line_analysis/tests/test_line_analysis.py b/jdaviz/configs/specviz/plugins/line_analysis/tests/test_line_analysis.py index 79a19d9192..92771d35ab 100644 --- a/jdaviz/configs/specviz/plugins/line_analysis/tests/test_line_analysis.py +++ b/jdaviz/configs/specviz/plugins/line_analysis/tests/test_line_analysis.py @@ -260,7 +260,7 @@ def test_continuum_surrounding_invalid_width(specviz_helper, spectrum1d): assert 'Subset 1' in plugin.spectral_subset.labels plugin.continuum_subset_selected = 'Surrounding' plugin.spectral_subset_selected = 'Subset 1' - plugin.width = 11 + plugin.continuum_width = 11 assert plugin.results[0]['result'] == ''