From da1797f976d273b6ec3cdaae22ce47635e90712c Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Tue, 9 Nov 2021 11:27:38 -0800 Subject: [PATCH] minor changes --- .gitignore | 1 + glue/core/data.py | 4 +- glue/utils/wcs.py | 12 +++++ glue/viewers/common/qt/data_slice_widget.py | 1 - glue/viewers/image/qt/data_viewer.py | 4 +- glue/viewers/image/qt/slice_widget.py | 4 -- glue/viewers/image/viewer.py | 14 +----- glue/viewers/profile/layer_artist.py | 1 - glue/viewers/profile/qt/options_widget.py | 2 - tox.ini | 49 +++++++++++---------- 10 files changed, 43 insertions(+), 49 deletions(-) diff --git a/.gitignore b/.gitignore index a0e61c527..4b94e7cf4 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ glue/qt/glue_qt_resources.py .pytest_cache .tox .vscode +.history diff --git a/glue/core/data.py b/glue/core/data.py index a479e99a3..121b76ebb 100644 --- a/glue/core/data.py +++ b/glue/core/data.py @@ -27,8 +27,7 @@ from glue.core.contracts import contract from glue.core.joins import get_mask_with_key_joins from glue.config import settings, data_translator, subset_state_translator -from glue.utils import (compute_statistic, - unbroadcast, iterate_chunks, +from glue.utils import (compute_statistic, unbroadcast, iterate_chunks, datetime64_to_mpl, broadcast_to, categorical_ndarray, format_choices, random_views_for_dask_array) from glue.core.coordinate_helpers import axis_label @@ -1657,7 +1656,6 @@ def compute_statistic(self, statistic, cid, subset_state=None, axis=None, values = self.compute_statistic(statistic, cid, subset_state=subset_state, axis=axis, finite=finite, positive=positive, percentile=percentile, view=chunk_view) - result[chunk_view[axis_index]] = values return result diff --git a/glue/utils/wcs.py b/glue/utils/wcs.py index 06345d1ea..9d402dd73 100644 --- a/glue/utils/wcs.py +++ b/glue/utils/wcs.py @@ -2,7 +2,19 @@ def get_identity_wcs(naxis): + """ + [summary] + Parameters + ---------- + naxis : [type] + [description] + + Returns + ------- + [type] + [description] + """ wcs = WCS(naxis=naxis) wcs.wcs.ctype = ['X'] * naxis wcs.wcs.crval = [0.] * naxis diff --git a/glue/viewers/common/qt/data_slice_widget.py b/glue/viewers/common/qt/data_slice_widget.py index 49c9f426f..fdadb442a 100644 --- a/glue/viewers/common/qt/data_slice_widget.py +++ b/glue/viewers/common/qt/data_slice_widget.py @@ -109,7 +109,6 @@ def __init__(self, label='', world=None, lo=0, hi=10, def set_label_from_slider(self): value = self.state.slice_center - if self.state.use_world: value = self._world[value] if self._world_warning: diff --git a/glue/viewers/image/qt/data_viewer.py b/glue/viewers/image/qt/data_viewer.py index af8f798bc..69c5bfff4 100644 --- a/glue/viewers/image/qt/data_viewer.py +++ b/glue/viewers/image/qt/data_viewer.py @@ -39,8 +39,8 @@ class ImageViewer(MatplotlibImageMixin, MatplotlibDataViewer): tools = ['select:rectangle', 'select:xrange', 'select:yrange', 'select:circle', 'select:polygon', 'image:point_selection', - 'image:contrast_bias', - 'profile-viewer'] + 'image:contrast_bias', 'profile-viewer', + ] def __init__(self, session, parent=None, state=None): MatplotlibDataViewer.__init__(self, session, wcs=True, parent=parent, state=state) diff --git a/glue/viewers/image/qt/slice_widget.py b/glue/viewers/image/qt/slice_widget.py index 1e41c8ed1..0184b313b 100644 --- a/glue/viewers/image/qt/slice_widget.py +++ b/glue/viewers/image/qt/slice_widget.py @@ -6,7 +6,6 @@ from glue.viewers.image.state import AggregateSlice from glue.utils.decorators import avoid_circular - __all__ = ['MultiSliceWidgetHelper'] @@ -57,7 +56,6 @@ def sync_state_from_sliders(self, *args): else: slices.append(self.viewer_state.slices[i]) self.viewer_state.slices = tuple(slices) - self._reference_data = self.viewer_state.reference_data @avoid_circular @@ -96,7 +94,6 @@ def sync_sliders_from_state(self, *args): pixel_axis=world_axis_index, world_axis=world_axis_index) world_unit = self.data.coords.world_axis_units[world_axis_index] - world_warning = len(dependent_axes(self.data.coords, i)) > 1 world_label = self.data.world_component_ids[i].label else: @@ -110,7 +107,6 @@ def sync_sliders_from_state(self, *args): world_unit=world_unit, world_warning=world_warning) self.slider_state = slider.state - self.slider_state.add_callback('slice_center', self.sync_state_from_sliders) self._sliders.append(slider) self.layout.addWidget(slider) diff --git a/glue/viewers/image/viewer.py b/glue/viewers/image/viewer.py index 70e01ce97..1aa58e086 100644 --- a/glue/viewers/image/viewer.py +++ b/glue/viewers/image/viewer.py @@ -1,7 +1,5 @@ import os -from astropy.wcs import WCS - from glue.core.subset import roi_to_subset_state from glue.core.coordinates import Coordinates, LegacyCoordinates from glue.core.coordinate_helpers import dependent_axes @@ -12,21 +10,11 @@ from glue.viewers.image.frb_artist import imshow from glue.viewers.image.composite_array import CompositeArray +from glue.utils.wcs import get_identity_wcs __all__ = ['MatplotlibImageMixin'] -def get_identity_wcs(naxis): - - wcs = WCS(naxis=naxis) - wcs.wcs.ctype = ['X'] * naxis - wcs.wcs.crval = [0.] * naxis - wcs.wcs.crpix = [1.] * naxis - wcs.wcs.cdelt = [1.] * naxis - - return wcs - - EXTRA_FOOTER = """ # Set tick label size - for now tick_params (called lower down) doesn't work # properly, but these lines won't be needed in future. diff --git a/glue/viewers/profile/layer_artist.py b/glue/viewers/profile/layer_artist.py index 0a1164c83..2d6c5c752 100644 --- a/glue/viewers/profile/layer_artist.py +++ b/glue/viewers/profile/layer_artist.py @@ -45,7 +45,6 @@ def _calculate_profile_thread(self, reset=False): # otherwise the thread tries to send these to the glue logger (which # uses Qt), which then results in this kind of error: # QObject::connect: Cannot queue arguments of type 'QTextCursor' - with warnings.catch_warnings(): warnings.simplefilter("ignore") if reset: diff --git a/glue/viewers/profile/qt/options_widget.py b/glue/viewers/profile/qt/options_widget.py index 8bee8955c..0c750b2c6 100644 --- a/glue/viewers/profile/qt/options_widget.py +++ b/glue/viewers/profile/qt/options_widget.py @@ -41,7 +41,6 @@ def __init__(self, viewer_state, session, parent=None): self.viewer_state.add_callback('x_att', self._on_attribute_change) self.ui.text_warning.hide() - self.ui.axes_editor.button_apply_all.clicked.connect(self._apply_all_viewers) def _on_function_change(self, *args): @@ -52,7 +51,6 @@ def _on_function_change(self, *args): layout=self.ui.layout_slices) self.ui.text_warning.hide() self.ui.text_warning.setText('') - else: if self.profile_slice_helper: self.profile_slice_helper.remove() diff --git a/tox.ini b/tox.ini index e71ecab5c..45f2ea5a1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,10 @@ [tox] envlist = - py{37,38,39}-{codestyle,test,docs}-{pyqt57,pyqt58,pyqt59,pyqt510,pyqt511,pyqt512,pyqt513,pyside511,pyside512,pyside513}-all-{dev,legacy} -requires = pip >= 18.0 - setuptools >= 30.3.0 + py{37,38,39}-{test,docs}-{pyqt57,pyqt58,pyqt59,pyqt510,pyqt511,pyqt512,pyqt513,pyside511,pyside512,pyside513}-all-{dev,legacy} + codestyle +requires = + pip >= 18.0 + setuptools >= 30.3.0 [testenv] passenv = @@ -17,6 +19,27 @@ changedir = test: .tmp/{envname} docs: doc deps = + all: pytest-qt + all: pytest-cov + dev: git+https://github.com/astropy/astropy + dev: git+https://github.com/numpy/numpy + legacy: astropy==4.0.* + legacy: bottleneck==1.3.* + legacy: dill==0.2.* + legacy: echo==0.5.* + legacy: h5py==2.10.* + legacy: ipykernel==5.3.* + legacy: ipython==7.16.* + legacy: matplotlib==3.2.* + legacy: mpl-scatter-density==0.7.* + legacy: numpy==1.17.* + legacy: openpyxl==3.0.* + legacy: pandas==1.2.* + legacy: qtconsole==4.3.* + legacy: qtpy==1.9.* + legacy: scipy==1.1.* + legacy: setuptools==30.3.* + legacy: xlrd==1.2.* pyqt59: PyQt5==5.9.* pyqt510: PyQt5==5.10.* pyqt511: PyQt5==5.11.* @@ -27,26 +50,6 @@ deps = pyside512: PySide2==5.12.* pyside513: PySide2==5.13.* pyside514: PySide2==5.14.* - dev: git+https://github.com/numpy/numpy - dev: git+https://github.com/astropy/astropy - legacy: numpy==1.17.* - legacy: matplotlib==3.2.* - legacy: scipy==1.1.* - legacy: pandas==1.2.* - legacy: echo==0.5.* - legacy: astropy==4.0.* - legacy: setuptools==30.3.* - legacy: qtpy==1.9.* - legacy: ipython==7.16.* - legacy: ipykernel==5.3.* - legacy: qtconsole==4.3.* - legacy: dill==0.2.* - legacy: xlrd==1.2.* - legacy: h5py==2.10.* - legacy: mpl-scatter-density==0.7.* - legacy: bottleneck==1.3.* - legacy: openpyxl==3.0.* - all: pytest-qt extras = test all: all