Skip to content

Commit

Permalink
Fixed profile and table tests
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Jan 24, 2023
1 parent 6d03a8b commit f9be4f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions glue/viewers/profile/qt/tests/test_data_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,20 +374,20 @@ def test_unit_conversion():
assert viewer.state.x_min == 1.e9
assert viewer.state.x_max == 3.e9
assert viewer.state.y_min == 1.
assert viewer.state.y_max == 3000.
assert viewer.state.y_max == 3.

viewer.state.x_display_unit = 'GHz'
viewer.state.y_display_unit = 'Jy'
viewer.state.y_display_unit = 'mJy'

x, y = viewer.state.layers[0].profile
assert_allclose(x, [1, 2, 3])
assert_allclose(y, [1, 2, 3])
assert_allclose(y, [1000, 2000, 3000])

x, y = viewer.state.layers[1].profile
assert_allclose(x, 2.99792458 / np.array([1, 2, 3]))
assert_allclose(y, [2, 1, 3])
assert_allclose(y, [2000, 1000, 3000])

assert viewer.state.x_min == 1.
assert viewer.state.x_max == 3.
assert viewer.state.y_min == 1.
assert viewer.state.y_max == 3.
assert viewer.state.y_min == 1000.
assert viewer.state.y_max == 3000.
7 changes: 4 additions & 3 deletions glue/viewers/profile/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,14 @@ def _layers_changed(self, *args):
# FIXME: should use uuid in following not id() but GroupedSubset doesn't have uuid (yet)
current_layers = [id(layer_state.layer) for layer_state in self.layers]
if not hasattr(self, '_last_layers') or self._last_layers != current_layers:
self._update_combo_ref_data()
self._update_y_display_unit_choices()
self._last_layers = current_layers
self._last_layers = current_layers
self._update_combo_ref_data()
self._update_y_display_unit_choices()

def _update_x_display_unit_choices(self):

if self.reference_data is None:
ProfileViewerState.x_display_unit.set_choices(self, [])
return

component = self.reference_data.get_component(self.x_att)
Expand Down
2 changes: 1 addition & 1 deletion glue/viewers/table/qt/data_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def headerData(self, section, orientation, role):
if orientation == Qt.Horizontal:
column_name = self.columns[section].label
units = self._data.get_component(self.columns[section]).units
if units != '':
if units is not None and units != '':
column_name += "\n{0}".format(units)
return column_name
elif orientation == Qt.Vertical:
Expand Down

0 comments on commit f9be4f3

Please sign in to comment.