Ejemplo n.º 1
0
def test_monomial_basis_negative_degree():
    """
    Test that an error is raised when trying to create a monomial basis with a
    negative degree.
    """
    with pytest.raises(ValueError):
        monomial_basis(1, 2, -3)
Ejemplo n.º 2
0
Tests for turning hermitian matrices and algebraic expressions into matrix form.
"""

import pytest
import sympy as sp

from kdotp_symmetry._to_matrix import to_matrix

from kdotp_symmetry._expr_utils import expr_to_vector, monomial_basis, matrix_to_expr_operator
from kdotp_symmetry._repr_utils import hermitian_to_vector, hermitian_basis, repr_to_matrix_operator


@pytest.mark.parametrize(
    'operator,basis,to_vector_fct,result',
    [(matrix_to_expr_operator([[0, 1, 0], [1, 0, 0], [0, 0, -1]
                               ]), monomial_basis(*range(3)), expr_to_vector,
      sp.Matrix([
          [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
          [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, -1, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
          [0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, -1, 0],
          [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, -1, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
      ])),
     (matrix_to_expr_operator([[0, 1, 0], [1, 0, 0], [0, 0, -1]
                               ]), monomial_basis(*range(2)), expr_to_vector,
      sp.Matrix([[1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, -1]])),
Ejemplo n.º 3
0
def test_monomial_basis_negative_degree():
    with pytest.raises(ValueError):
        monomial_basis(1, 2, -3)
Ejemplo n.º 4
0
def test_monomial_basis(dim, basis):
    assert monomial_basis(*range(dim + 1)) == basis
Ejemplo n.º 5
0
def test_monomial_basis(dim, basis):
    """
    Test the creation of the monomial basis.
    """
    assert monomial_basis(*range(dim + 1)) == basis