Ejemplo n.º 1
0
 def test_wrong_length(self):
     try:
         assert_2darray_almost_equal(((1, 2), (3, 4)), ((1, 2), (3, 4, 5)))
         assert False
     except AssertionError, e:
         eq_(e.args[0],
             '((1, 2), (3, 4)) != ((1, 2), (3, 4, 5)) as sizes differ')
Ejemplo n.º 2
0
 def test_generate_possible_sample_solutions_fixed_chi(self):
     result = self.calc._generate_possible_solutions(
         (.1, .2, .3, .4), ('mu', 'eta', 'chi', 'phi'), ('chi', ))
     generated = self._hardcoded_generate_possible_sample_solutions(
         .1, .2, .3, .4, 'chi')
     assert_2darray_almost_equal(generated, result)
     eq_(4**3, len(result))
Ejemplo n.º 3
0
 def test_wrong_value(self):
     try:
         assert_2darray_almost_equal(((1, 2), (3, 4)),
                                     ((1.0000001, 2), (3, 4)))
         assert False
     except AssertionError:
         pass
Ejemplo n.º 4
0
 def test_wrong_length(self):
     try:
         assert_2darray_almost_equal(((1, 2), (3, 4)), ((1, 2), (3, 4, 5)))
         assert False
     except AssertionError, e:
         eq_(e.args[0],
             '((1, 2), (3, 4)) != ((1, 2), (3, 4, 5)) as sizes differ')
    def test_generate_possible_det_soln_no_limits_constrained_qaz_or_naz(self):
        # we will enfoce the order too, incase this later effects heuristically
        # made choices
        expected = (
                    (.1, .2),
                    (.1, -.2),
                    (.1, .2 - pi),
                    (.1, pi - .2),
                    (-.1, .2),
                    (-.1, -.2),
                    (-.1, .2 - pi),
                    (-.1, pi - .2),
                    (.1 - pi, .2),  # pi + x cuts to x-pi
                    (.1 - pi, -.2),
                    (.1 - pi, .2 - pi),
                    (.1 - pi, pi - .2),
                    (pi - .1, .2),
                    (pi - .1, -.2),
                    (pi - .1, .2 - pi),
                    (pi - .1, pi - .2),
                   )

        assert_2darray_almost_equal(expected,
            self.calc._generate_possible_solutions(
                (.1, .2), ('delta', NUNAME), ('naz',)))
        assert_2darray_almost_equal(expected,
            self.calc._generate_possible_solutions(
                (.1, .2), ('delta', NUNAME), ('qaz',)))
Ejemplo n.º 6
0
    def test_generate_possible_det_soln_no_limits_constrained_qaz_or_naz(self):
        # we will enfoce the order too, incase this later effects heuristically
        # made choices
        expected = (
            (.1, .2),
            (.1, -.2),
            (.1, .2 - pi),
            (.1, pi - .2),
            (-.1, .2),
            (-.1, -.2),
            (-.1, .2 - pi),
            (-.1, pi - .2),
            (.1 - pi, .2),  # pi + x cuts to x-pi
            (.1 - pi, -.2),
            (.1 - pi, .2 - pi),
            (.1 - pi, pi - .2),
            (pi - .1, .2),
            (pi - .1, -.2),
            (pi - .1, .2 - pi),
            (pi - .1, pi - .2),
        )

        assert_2darray_almost_equal(
            expected,
            self.calc._generate_possible_solutions((.1, .2), ('delta', NUNAME),
                                                   ('naz', )))
        assert_2darray_almost_equal(
            expected,
            self.calc._generate_possible_solutions((.1, .2), ('delta', NUNAME),
                                                   ('qaz', )))
 def test_generate_possible_sample_solutions_fixed_chi(self):
     result = self.calc._generate_possible_solutions(
         (.1, .2, .3, .4), ('mu', 'eta', 'chi', 'phi'), ('chi',))
     generated = self._hardcoded_generate_possible_sample_solutions(
         .1, .2, .3, .4, 'chi')
     assert_2darray_almost_equal(generated, result)
     eq_(4 ** 3, len(result))
Ejemplo n.º 8
0
 def test_wrong_value(self):
     try:
         assert_2darray_almost_equal(((1, 2), (3, 4)),
                                     ((1.0000001, 2), (3, 4)))
         assert False
     except AssertionError:
         pass
Ejemplo n.º 9
0
 def test_generate_possible_sample_solutions_fixed_chi_positive_mu(self):
     self.hardware.set_lower_limit('mu', 0)
     result = self.calc._generate_possible_solutions(
         (.1, .2, .3, .4), ('mu', 'eta', 'chi', 'phi'), ('chi', ))
     generated = self._hardcoded_generate_possible_sample_solutions(
         .1, .2, .3, .4, 'chi')
     assert_2darray_almost_equal(generated, result)
     eq_(2 * (4**2), len(result))
Ejemplo n.º 10
0
 def test__passes(self):
     assert_2darray_almost_equal(((1, 2), (3, 4)),
                                 ((1.00000001, 2), (3, 4)))
     assert_2darray_almost_equal(((1, 2), (3, 4)), ((1.0000001, 2), (3, 4)),
                                 6)
     assert_2darray_almost_equal(((1, 2), (3, 4)), [(1, 2), [3, 4]])
     assert_2darray_almost_equal(((), ()), ((), ()))
     assert_2darray_almost_equal([(), []], ([], ()))
 def test_generate_possible_sample_solutions_fixed_chi_positive_mu(self):
     self.hardware.set_lower_limit('mu', 0)
     result = self.calc._generate_possible_solutions(
         (.1, .2, .3, .4), ('mu', 'eta', 'chi', 'phi'), ('chi',))
     generated = self._hardcoded_generate_possible_sample_solutions(
         .1, .2, .3, .4, 'chi')
     assert_2darray_almost_equal(generated, result)
     eq_(2 * (4 ** 2), len(result))
Ejemplo n.º 12
0
 def test__passes(self):
     assert_2darray_almost_equal(((1, 2), (3, 4)),
                                 ((1.00000001, 2), (3, 4)))
     assert_2darray_almost_equal(((1, 2), (3, 4)),
                                 ((1.0000001, 2), (3, 4)), 6)
     assert_2darray_almost_equal(((1, 2), (3, 4)),
                                 [(1, 2), [3, 4]])
     assert_2darray_almost_equal(((), ()), ((), ()))
     assert_2darray_almost_equal([(), []], ([], ()))
    def test_generate_possible_det_soln_with_limits_constrained_delta(self):
        self.hardware.set_lower_limit(NUNAME, 0)
        expected = (
                    (.1, .2),
                    (.1, pi - .2),
                   )

        assert_2darray_almost_equal(expected,
            self.calc._generate_possible_solutions(
                (.1, .2), ('delta', NUNAME), ('delta',)))
    def test_generate_possible_det_solutions_with_limits_constrained_nu(self):
        self.hardware.set_upper_limit('delta', 0)
        expected = (
                    (-.1, .2),
                    (.1 - pi, .2),  # cuts to .1-pi
                   )

        assert_2darray_almost_equal(expected,
            self.calc._generate_possible_solutions(
                (.1, .2), ('delta', NUNAME), (NUNAME,)))
    def test_generate_possible_det_solutions_no_limits_constrained_nu(self):
        expected = (
                    (.1, .2),
                    (-.1, .2),
                    (.1 - pi, .2),
                    (pi - .1, .2),
                   )

        assert_2darray_almost_equal(expected,
            self.calc._generate_possible_solutions(
                (.1, .2), ('delta', NUNAME), (NUNAME,)))
Ejemplo n.º 16
0
    def test_generate_possible_det_soln_with_limits_constrained_delta(self):
        self.hardware.set_lower_limit(NUNAME, 0)
        expected = (
            (.1, .2),
            (.1, pi - .2),
        )

        assert_2darray_almost_equal(
            expected,
            self.calc._generate_possible_solutions((.1, .2), ('delta', NUNAME),
                                                   ('delta', )))
Ejemplo n.º 17
0
    def test_generate_possible_det_solutions_with_limits_constrained_nu(self):
        self.hardware.set_upper_limit('delta', 0)
        expected = (
            (-.1, .2),
            (.1 - pi, .2),  # cuts to .1-pi
        )

        assert_2darray_almost_equal(
            expected,
            self.calc._generate_possible_solutions((.1, .2), ('delta', NUNAME),
                                                   (NUNAME, )))
Ejemplo n.º 18
0
    def test_generate_possible_det_solutions_no_limits_constrained_nu(self):
        expected = (
            (.1, .2),
            (-.1, .2),
            (.1 - pi, .2),
            (pi - .1, .2),
        )

        assert_2darray_almost_equal(
            expected,
            self.calc._generate_possible_solutions((.1, .2), ('delta', NUNAME),
                                                   (NUNAME, )))
    def test_generate_poss_det_soln_no_lim_cons_qaz_or_naz_delta_and_nu_at_zro(self):  # @IgnorePep8
        # we will enfoce the order too, incase this later effects hearistically
        # made choices
        expected = (
                    (0., 0,),
                    (0., pi),
                    (pi, 0.),
                    (pi, pi)
                    )

        assert_2darray_almost_equal(expected,
            self.calc._generate_possible_solutions(
                (-2e-9, 2e-9), ('delta', NUNAME), ('naz',)))
        assert_2darray_almost_equal(expected,
            self.calc._generate_possible_solutions(
                (-2e-9, 2e-9), ('delta', NUNAME), ('qaz',)))
Ejemplo n.º 20
0
    def test_generate_poss_det_soln_no_lim_cons_qaz_or_naz_delta_and_nu_at_zro(
            self):  # @IgnorePep8
        # we will enfoce the order too, incase this later effects hearistically
        # made choices
        expected = ((
            0.,
            0,
        ), (0., pi), (pi, 0.), (pi, pi))

        assert_2darray_almost_equal(
            expected,
            self.calc._generate_possible_solutions(
                (-2e-9, 2e-9), ('delta', NUNAME), ('naz', )))
        assert_2darray_almost_equal(
            expected,
            self.calc._generate_possible_solutions(
                (-2e-9, 2e-9), ('delta', NUNAME), ('qaz', )))
 def test_merge_nearly_equal_detector_angle_pairs_4(self):
     pairs = [(1, 2.2), (1, 2), (1, 2), (1, 2.2)]
     assert_2darray_almost_equal(
         merge_nearly_equal_pairs(pairs), [(1, 2.2), (1, 2)])
Ejemplo n.º 22
0
 def test_n_phi_from_hkl_with_unity_matrix_010(self):
     self.get_UB.return_value = matrix('1 0 0; 0 1 0; 0 0 1')
     self.reference.n_hkl_configured = matrix('0; 1; 0')
     assert_2darray_almost_equal(self.reference.n_phi.tolist(),
                                 matrix('0; 1; 0').tolist())
Ejemplo n.º 23
0
 def test_merge_nearly_equal_detector_angle_pairs_different(self):
     pairs = [(1, 2), (1, 2.1)]
     assert_2darray_almost_equal(merge_nearly_equal_pairs(pairs), pairs)
Ejemplo n.º 24
0
 def test_default_n_phi(self):
     assert_2darray_almost_equal(self.reference.n_phi.tolist(), matrix('0; 0; 1').tolist())
Ejemplo n.º 25
0
 def test_n_phi_from_hkl_with_unity_matrix_001(self):
     self.ubcalc.UB = matrix('1 0 0; 0 1 0; 0 0 1')
     self.reference.n_hkl_configured = matrix('0; 0; 1')
     assert_2darray_almost_equal(self.reference.n_phi.tolist(), matrix('0; 0; 1').tolist())
Ejemplo n.º 26
0
 def test_merge_nearly_equal_detector_angle_pairs_4(self):
     pairs = [(1, 2.2), (1, 2), (1, 2), (1, 2.2)]
     assert_2darray_almost_equal(merge_nearly_equal_pairs(pairs), [(1, 2.2),
                                                                   (1, 2)])
 def test_merge_nearly_equal_detector_angle_pairs_different(self):
     pairs = [(1,2), (1,2.1)]
     assert_2darray_almost_equal(
         merge_nearly_equal_pairs(pairs), pairs)
Ejemplo n.º 28
0
 def test_n_phi_from_hkl_with_unity_matrix_010(self):
     self.get_UB.return_value = matrix('1 0 0; 0 1 0; 0 0 1')
     self.reference.n_hkl_configured = matrix('0; 1; 0')
     assert_2darray_almost_equal(self.reference.n_phi.tolist(), matrix('0; 1; 0').tolist())
Ejemplo n.º 29
0
 def test_default_n_phi(self):
     assert_2darray_almost_equal(self.reference.n_phi.tolist(),
                                 matrix('0; 0; 1').tolist())
Ejemplo n.º 30
0
 def test_tolist(self):
     l = [[1, 2], [3, 4]]
     assert_2darray_almost_equal(self.m(l).tolist(), l)
Ejemplo n.º 31
0
 def test_tolist(self):
     l = [[1, 2], [3, 4]]
     assert_2darray_almost_equal(self.m(l).tolist(), l)