コード例 #1
0
    def test_multivector(self, g2):
        p = g2.MultiVector(np.arange(4, dtype=np.int32))
        assert pretty.pretty(p) == repr(p)

        expected = textwrap.dedent("""\
        MultiVector(Layout([1, 1],
                           ids=BasisVectorIds.ordered_integers(2),
                           order=BasisBladeOrder.shortlex(2),
                           names=['', 'e1', 'e2', 'e12']),
                    [0, 1, 2, 3],
                    dtype=int32)""")

        # ipython printing only kicks in in ugly mode
        try:
            clifford.ugly()
            assert pretty.pretty(p) == expected
        finally:
            clifford.pretty()
コード例 #2
0
    def test_multivector_predefined(self):
        """ test the short printing of predefined layouts """
        from clifford.g2 import layout as g2
        p_i = g2.MultiVector(np.arange(4, dtype=np.int32))
        p_f = g2.MultiVector(np.arange(4, dtype=np.float64))
        assert pretty.pretty(p_i) == repr(p_i)
        assert pretty.pretty(p_f) == repr(p_f)

        # float is implied
        expected_i = "clifford.g2.layout.MultiVector([0, 1, 2, 3], dtype=int32)"
        expected_f = "clifford.g2.layout.MultiVector([0.0, 1.0, 2.0, 3.0])"

        # ipython printing only kicks in in ugly mode
        try:
            clifford.ugly()
            assert pretty.pretty(p_i) == expected_i
            assert pretty.pretty(p_f) == expected_f
        finally:
            clifford.pretty()