Esempio n. 1
0
    def test_repr(self):
        for arg in self.valid_args:
            u, beta = arg
            stt = mm.STT(u, beta)

            assert repr(stt) == ('STT(u={}, beta={}, '
                                 'name=\'stt\')'.format(u, beta))

        stt = mm.STT((1, 2, 3), 15, name='test_name')
        assert repr(stt) == 'STT(u=(1, 2, 3), beta=15, name=\'test_name\')'
    def test_repr(self):
        for arg in self.valid_args:
            u, beta = arg
            stt = mm.STT(u, beta)

            assert repr(stt) == "STT(u={}, beta={}, name=\"stt\")".format(
                u, beta)

        stt = mm.STT((1, 2, 3), 15, name="test_name")
        assert repr(stt) == 'STT(u=(1, 2, 3), beta=15, name=\"test_name\")'
Esempio n. 3
0
    def test_init_valid_args(self):
        for arg in self.valid_args:
            u, beta = arg
            stt = mm.STT(u, beta)

            assert stt.u == u
            assert isinstance(stt.u, tuple)
            assert stt.beta == beta
            assert isinstance(stt.beta, numbers.Real)
Esempio n. 4
0
    def setup(self):
        gamma = 2.21e5
        self.precession = mm.Precession(gamma)
        alpha = 0.5
        self.damping = mm.Damping(alpha)
        u = (0, 0, 500)
        beta = 0.2
        self.stt = mm.STT(u=u, beta=beta)

        self.terms = [self.precession, self.damping, self.stt]

        self.invalid_terms = [
            1, 2.5, 0, 'abc', [3, 7e-12], [self.precession, self.damping]
        ]
Esempio n. 5
0
    def test_repr_latex_(self):
        for arg in self.valid_args:
            u, beta = arg
            stt = mm.STT(u, beta)
            latex = stt._repr_latex_()

            # Assert some characteristics of LaTeX string.
            assert isinstance(latex, str)
            assert latex[0] == latex[-1] == '$'
            assert r'\beta' in latex
            assert r'\mathbf{m}' in latex
            assert r'\mathbf{u}' in latex
            assert r'\times' in latex
            assert r'\boldsymbol' in latex
            assert r'\nabla' in latex
Esempio n. 6
0
 def test_script(self):
     for arg in self.valid_args:
         u, beta = arg
         stt = mm.STT(u, beta)
         with pytest.raises(NotImplementedError):
             script = stt._script
Esempio n. 7
0
    def test_name(self):
        for arg in self.valid_args:
            u, beta = arg
            stt = mm.STT(u, beta)

            assert stt.name == 'stt'
Esempio n. 8
0
    def test_init_invalid_args(self):
        for arg in self.invalid_args:
            u, beta = arg

            with pytest.raises(Exception):
                stt = mm.STT(gamma)