예제 #1
0
    def test_construction_with_named_fields(self):
        frame, point, transpose, dimrange = "HKL", (None, None, 0.5), False, (-15, 15)
        info = SliceInfo(frame=frame, point=point, transpose=transpose, range=dimrange)

        self.assertEqual(frame, info.frame)
        self.assertEqual(point, info.slicepoint)
        self.assertEqual(dimrange, info.range)
        self.assertEqual(point[2], info.value)
예제 #2
0
    def test_set_transform(self):
        # make sliceinfo with unit transform (default)
        info = SliceInfo(frame=SpecialCoordinateSystem.HKL,
                         point=(None, None, 0.5),
                         transpose=False,
                         range=[None, None, (-15, 15)],
                         qflags=[True, True, True])

        info.set_transform(NonOrthogonalTransform(angle=radians(120)))

        self.assertEqual(info.can_support_nonorthogonal_axes(), True)
예제 #3
0
    def test_transform_selects_dimensions_correctly_when_transposed(self):
        # Set slice info such that display(X,Y) = data(Z,Y)
        slice_pt = 0.5
        info = SliceInfo(frame="HKL", point=(slice_pt, None, None), transpose=True, range=(-15, 15))

        frame_point = (0.5, 1.0, -1.5)
        slice_frame = info.transform(frame_point)

        self.assertEqual(frame_point[2], slice_frame[0])
        self.assertEqual(frame_point[1], slice_frame[1])
        self.assertEqual(frame_point[0], slice_frame[2])
        self.assertEqual(slice_pt, info.value)
예제 #4
0
    def _assert_can_support_nonorthogonal_axes(self, expectation, frame,
                                               qflags):
        frame, point, transpose, = frame, (None, None, 0.5), False
        dimrange, spatial = (None, None, (-15, 15)), qflags

        info = SliceInfo(frame=frame,
                         point=point,
                         transpose=transpose,
                         range=dimrange,
                         qflags=spatial)

        self.assertEqual(expectation, info.can_support_nonorthogonal_axes())
예제 #5
0
    def test_construction_with_named_fields(self):
        indices, frame, point, dimrange = (0, 1, 2), "HKL", (None, None,
                                                             0.5), (-15, 15)
        info = SliceInfo(indices=indices,
                         frame=frame,
                         point=point,
                         range=dimrange)

        self.assertEqual(indices, info.indices)
        self.assertEqual(frame, info.frame)
        self.assertEqual(point, info.point)
        self.assertEqual(dimrange, info.range)
예제 #6
0
    def test_no_spatial_dimensions_sets_z_properties_None(self):
        frame, point, transpose, = SpecialCoordinateSystem.HKL, (None, None,
                                                                 0.5), False
        dimrange, spatial = (None, None, (-15, 15)), [False] * 3
        info = SliceInfo(frame=frame,
                         point=point,
                         transpose=transpose,
                         range=dimrange,
                         qflags=spatial)

        self.assertTrue(info.z_index is None)
        self.assertTrue(info.z_value is None)
        self.assertTrue(info.z_width is None)
예제 #7
0
    def test_transform_uses_indices_to_transform_to_slice_frame(self):
        # Set slice info such that display(X,Y) = data(Z,Y)
        info = SliceInfo(indices=(2, 1, 0),
                         frame="HKL",
                         point=(None, None, 0.5),
                         range=(-15, 15))

        frame_point = (0.5, 1.0, -1.5)
        slice_frame = info.transform(frame_point)

        self.assertEqual(frame_point[2], slice_frame[0])
        self.assertEqual(frame_point[1], slice_frame[1])
        self.assertEqual(frame_point[0], slice_frame[2])
예제 #8
0
    def test_transform_respects_nonortho_tr_if_given(self):
        # Set slice info such that display(X,Y) = data(Z,Y)
        info = SliceInfo(frame=SpecialCoordinateSystem.HKL,
                         point=(None, None, 0.5),
                         transpose=False,
                         range=[None, None, (-15, 15)],
                         qflags=[True, True, True],
                         nonortho_transform=FakeTransform())

        frame_point = (0.5, 1.0, -1.5)
        slice_frame = info.transform(frame_point)

        self.assertEqual(frame_point[0] + 1, slice_frame[0])
        self.assertEqual(frame_point[1] - 1, slice_frame[1])
        self.assertEqual(frame_point[2], slice_frame[2])
예제 #9
0
    def test_transform_selects_dimensions_correctly_when_transposed(self):
        # Set slice info such that display(X,Y) = data(Z,Y)
        slice_pt = 0.5
        info = SliceInfo(frame=SpecialCoordinateSystem.HKL,
                         point=(slice_pt, None, None),
                         transpose=True,
                         range=[(-15, 15), None, None],
                         qflags=[True, True, True])

        frame_point = (0.5, 1.0, -1.5)
        slice_frame = info.transform(frame_point)

        self.assertEqual(frame_point[2], slice_frame[0])
        self.assertEqual(frame_point[1], slice_frame[1])
        self.assertEqual(frame_point[0], slice_frame[2])
        self.assertEqual(slice_pt, info.z_value)
예제 #10
0
    def test_construction_with_named_fields(self):
        frame, point, transpose, = SpecialCoordinateSystem.HKL, (None, None,
                                                                 0.5), False
        dimrange, spatial = (None, None, (-15, 15)), [True] * 3
        info = SliceInfo(frame=frame,
                         point=point,
                         transpose=transpose,
                         range=dimrange,
                         qflags=spatial)

        self.assertEqual(frame, info.frame)
        self.assertEqual(point, info.slicepoint)
        self.assertEqual(dimrange, info.range)
        self.assertEqual(2, info.z_index)
        self.assertEqual(point[2], info.z_value)
        self.assertEqual(dimrange[2][1] - dimrange[2][0], info.z_width)
예제 #11
0
    def test_slice_center_transforms_center_to_correct_frame_and_order(self):
        peak_center = (1, 2, 3)
        frame = SpecialCoordinateSystem.QSample
        model = create_peaks_viewer_model(centers=[peak_center],
                                          fg_color="red")
        slice_info = SliceInfo(indices=(2, 1, 0),
                               frame=frame,
                               point=0.25,
                               range=(15, 15))

        slice_center = model.slice_center(0, slice_info)

        peak0 = model.ws.getPeak(0)
        peak0.getQSampleFrame.assert_called_once()
        peak0.getQLabFrame.assert_not_called()
        peak0.getHKL.assert_not_called()
        self.assertEqual(peak_center[0], slice_center)