From 4d7f12c27c61a87e8c25d3089898af4b5f54c64c Mon Sep 17 00:00:00 2001 From: DanRyanIrish Date: Wed, 19 Jun 2019 13:02:19 -0400 Subject: [PATCH 1/2] Fix bug in 2D plotting. Bug was caused when both data and WCS were 2D. In this case a slice list was being called, even though that list was only created when the data was 2D with a >2D WCS with missing axes. --- ndcube/mixins/plotting.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ndcube/mixins/plotting.py b/ndcube/mixins/plotting.py index feb835134..09ca39c75 100644 --- a/ndcube/mixins/plotting.py +++ b/ndcube/mixins/plotting.py @@ -201,23 +201,25 @@ def _plot_2D_cube(self, axes=None, plot_axis_indices=None, axes_coordinates=None data = np.ma.masked_array(data, self.mask) if axes is None: try: - axes_coord_check == [None, None] + axes_coord_check = axes_coordinates == [None, None] except: axes_coord_check = False if axes_coord_check: # Build slice list for WCS for initializing WCSAxes object. - if self.wcs.naxis is not 2: + if self.wcs.naxis != 2: slice_list = [] index = 0 - for i, bool_ in enumerate(self.missing_axes): + for bool_ in self.missing_axes: if not bool_: slice_list.append(axis_data[index]) index += 1 else: slice_list.append(1) - if index is not 2: + if index != 2: raise ValueError("Dimensions of WCS and data don't match") - ax = wcsaxes_compat.gca_wcs(self.wcs, slices=slice_list) + ax = wcsaxes_compat.gca_wcs(self.wcs, slices=tuple(slice_list)) + else: + ax = wcsaxes_compat.gca_wcs(self.wcs) # Set axis labels x_wcs_axis = utils.cube.data_axis_to_wcs_axis(plot_axis_indices[0], self.missing_axes) From 5e5cae542a1285ff0f5c2aface1cb708059f39b7 Mon Sep 17 00:00:00 2001 From: DanRyanIrish Date: Wed, 19 Jun 2019 13:11:10 -0400 Subject: [PATCH 2/2] Add changelog for PR #182. --- changelog/182.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/182.bugfix.rst diff --git a/changelog/182.bugfix.rst b/changelog/182.bugfix.rst new file mode 100644 index 000000000..fc6d9825e --- /dev/null +++ b/changelog/182.bugfix.rst @@ -0,0 +1 @@ +Fix 2D plotting from crashing when both data and WCS are 2D.