def test_calculate_axes_angles_uses_W_if_available(self): ws = _create_mock_workspace(IMDEventWorkspace, SpecialCoordinateSystem.HKL, has_oriented_lattice=True) ws.getExperimentInfo().run().get().value = [0, 1, 1, 0, 0, 1, 1, 0, 0] model = SliceViewerModel(ws) axes_angles = model.get_axes_angles() self.assertAlmostEqual(axes_angles[1, 2], np.pi / 4, delta=1e-10) for iy in range(1, 3): self.assertAlmostEqual(axes_angles[0, iy], np.pi / 2, delta=1e-10) # test force_orthog works axes_angles = model.get_axes_angles(force_orthogonal=True) self.assertAlmostEqual(axes_angles[1, 2], np.pi / 2, delta=1e-10)
def test_calculate_axes_angles_returns_none_if_nonorthogonal_transform_not_supported( self): model = SliceViewerModel( _create_mock_workspace(MatrixWorkspace, SpecialCoordinateSystem.QLab, has_oriented_lattice=False)) self.assertIsNone(model.get_axes_angles())
def test_calculate_axes_angles_uses_W_if_basis_vectors_unavailable_and_W_available_MDHisto( self): #test MD histo ws = _create_mock_workspace(IMDHistoWorkspace, SpecialCoordinateSystem.HKL, has_oriented_lattice=True, ndims=3) ws.getBasisVector.side_effect = lambda x: [0.0] ws.getExperimentInfo().run().get().value = [0, 1, 1, 0, 0, 1, 1, 0, 0] model = SliceViewerModel(ws) axes_angles = model.get_axes_angles() self.assertAlmostEqual(axes_angles[1, 2], np.pi / 4, delta=1e-10) for iy in range(1, 3): self.assertAlmostEqual(axes_angles[0, iy], np.pi / 2, delta=1e-10) # test force_orthog works axes_angles = model.get_axes_angles(force_orthogonal=True) self.assertAlmostEqual(axes_angles[1, 2], np.pi / 2, delta=1e-10)
def test_calculate_axes_angles_uses_identity_if_W_unavailable(self): ws = _create_mock_workspace(IMDEventWorkspace, SpecialCoordinateSystem.HKL, has_oriented_lattice=True) ws.getExperimentInfo().run().get.side_effect = KeyError model = SliceViewerModel(ws) axes_angles = model.get_axes_angles() self.assertAlmostEqual(axes_angles[1, 2], np.pi / 2, delta=1e-10) for iy in range(1, 3): self.assertAlmostEqual(axes_angles[0, iy], np.pi / 2, delta=1e-10)
def test_calculate_axes_angles_uses_basis_vectors_even_if_WMatrix_log_available_MDHisto( self): #test MD histo ws = _create_mock_workspace(IMDHistoWorkspace, SpecialCoordinateSystem.HKL, has_oriented_lattice=True) ws.getExperimentInfo().run().get().value = [0, 1, 1, 0, 0, 1, 1, 0, 0] model = SliceViewerModel(ws) # should revert to orthogonal axes_angles = model.get_axes_angles() self.assertAlmostEqual(axes_angles[1, 2], np.pi / 2, delta=1e-10) for iy in range(1, 3): self.assertAlmostEqual(axes_angles[0, iy], np.pi / 2, delta=1e-10)