コード例 #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')
コード例 #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))
コード例 #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
コード例 #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')
コード例 #5
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',)))
コード例 #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', )))
コード例 #7
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))
コード例 #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
コード例 #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))
コード例 #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([(), []], ([], ()))
コード例 #11
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))
コード例 #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([(), []], ([], ()))
コード例 #13
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',)))
コード例 #14
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,)))
コード例 #15
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,)))
コード例 #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', )))
コード例 #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, )))
コード例 #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, )))
コード例 #19
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',)))
コード例 #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', )))
コード例 #21
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)])
コード例 #22
0
ファイル: test_reference.py プロジェクト: jamesmudd/diffcalc
 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())
コード例 #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)
コード例 #24
0
ファイル: test_reference.py プロジェクト: robwalton/diffcalc
 def test_default_n_phi(self):
     assert_2darray_almost_equal(self.reference.n_phi.tolist(), matrix('0; 0; 1').tolist())
コード例 #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())
コード例 #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)])
コード例 #27
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)
コード例 #28
0
ファイル: test_reference.py プロジェクト: robwalton/diffcalc
 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())
コード例 #29
0
ファイル: test_reference.py プロジェクト: jamesmudd/diffcalc
 def test_default_n_phi(self):
     assert_2darray_almost_equal(self.reference.n_phi.tolist(),
                                 matrix('0; 0; 1').tolist())
コード例 #30
0
ファイル: test_numjy.py プロジェクト: jamesmudd/diffcalc
 def test_tolist(self):
     l = [[1, 2], [3, 4]]
     assert_2darray_almost_equal(self.m(l).tolist(), l)
コード例 #31
0
 def test_tolist(self):
     l = [[1, 2], [3, 4]]
     assert_2darray_almost_equal(self.m(l).tolist(), l)