def dimensions_changed(self): """Indicates that the dimensions have changed""" data_view = self._data_view sliceinfo = self.get_sliceinfo() if data_view.nonorthogonal_mode: if sliceinfo.can_support_nonorthogonal_axes(): # axes need to be recreated to have the correct transform associated data_view.create_axes_nonorthogonal(sliceinfo.get_northogonal_transform()) else: data_view.disable_tool_button(ToolItemText.NONORTHOGONAL_AXES) data_view.create_axes_orthogonal() else: if sliceinfo.can_support_nonorthogonal_axes(): data_view.enable_tool_button(ToolItemText.NONORTHOGONAL_AXES) else: data_view.disable_tool_button(ToolItemText.NONORTHOGONAL_AXES) ws_type = WorkspaceInfo.get_ws_type(self.model.ws) if ws_type == WS_TYPE.MDH or ws_type == WS_TYPE.MDE: if self.model.get_number_dimensions() > 2 and \ sliceinfo.slicepoint[data_view.dimensions.get_previous_states().index(None)] is None: # The dimension of the slicepoint has changed self.new_plot(dimensions_changing=True) else: self.new_plot(dimensions_transposing=True) else: self.new_plot() self._call_cutviewer_presenter_if_created("on_dimension_changed")
def _decide_plot_update_methods(self) -> Tuple[Callable, Callable]: """ Checks the type of workspace in self.model and decides which of the new_plot and update_plot_data methods to use :return: the new_plot method to use """ # TODO get rid of private access here ws_type = WorkspaceInfo.get_ws_type(self.model.ws) if ws_type == WS_TYPE.MDH: return self.new_plot_MDH, self.update_plot_data_MDH elif ws_type == WS_TYPE.MDE: return self.new_plot_MDE, self.update_plot_data_MDE else: return self.new_plot_matrix, self.update_plot_data_matrix
def get_dim_info(workspace, n: int) -> dict: """ returns dict of (minimum :float, maximum :float, number_of_bins :int, width :float, name :str, units :str, type :str, can_rebin: bool, qdim: bool) for dimension n """ dim = workspace.getDimension(n) return { 'minimum': dim.getMinimum(), 'maximum': dim.getMaximum(), 'number_of_bins': dim.getNBins(), 'width': dim.getBinWidth(), 'name': dim.name, 'units': dim.getUnits(), 'type': WorkspaceInfo.get_ws_type(workspace).name, 'can_rebin': WorkspaceInfo.can_support_dynamic_rebinning(workspace), 'qdim': dim.getMDFrame().isQ() }
def test_get_ws_type_with_MDEventWorkspace(self): mock_ws = mock.Mock(spec=MultipleExperimentInfos) mock_ws.isMDHistoWorkspace = mock.Mock(return_value=False) self.assertEqual(WS_TYPE.MDE, WorkspaceInfo.get_ws_type(mock_ws))
def test_get_ws_type_with_MatrixWorkspace(self): mock_ws = mock.Mock(spec=MatrixWorkspace) self.assertEqual(WS_TYPE.MATRIX, WorkspaceInfo.get_ws_type(mock_ws))