Esempio n. 1
0
def test_exps_setter():
    """Test setter for GeneralizedContractionShell.exps."""
    test = skip_init(GeneralizedContractionShell)
    test.exps = np.array([1.0, 2.0, 3.0])
    assert (
        isinstance(test._exps, np.ndarray)
        and test._exps.dtype == float
        and np.allclose(test._exps, np.array([1, 2, 3]))
    )

    test = skip_init(GeneralizedContractionShell)
    test.coeffs = np.array([1.0, 2.0, 3.0])
    test.exps = np.array([1.0, 2.0, 3.0])
    assert (
        isinstance(test._exps, np.ndarray)
        and test._exps.dtype == float
        and np.allclose(test._exps, np.array([1, 2, 3]))
    )

    test = skip_init(GeneralizedContractionShell)
    with pytest.raises(TypeError):
        test.exps = [1, 2, 3]
    with pytest.raises(TypeError):
        test.exps = np.array([1, 2, 3], dtype=bool)
    with pytest.raises(ValueError):
        test.coeffs = np.array([1.0, 2.0, 3.0])
        test.exps = np.array([4.0, 5.0])
    with pytest.raises(ValueError):
        test.coeffs = np.array([[1.0], [2.0], [3.0]])
        test.exps = np.array([4.0, 5.0])
Esempio n. 2
0
def test_angmom_components_cart():
    """Test GeneralizedContractionShell.angmom_components_cart."""
    test = skip_init(GeneralizedContractionShell)
    test._angmom = 0
    assert np.allclose(test.angmom_components_cart, [(0, 0, 0)])
    test._angmom = 1
    assert np.allclose(test.angmom_components_cart, [(1, 0, 0), (0, 1, 0), (0, 0, 1)])
    test._angmom = 2
    assert np.allclose(
        test.angmom_components_cart,
        [(2, 0, 0), (1, 1, 0), (1, 0, 1), (0, 2, 0), (0, 1, 1), (0, 0, 2)],
    )
    test._angmom = 3
    assert np.allclose(
        test.angmom_components_cart,
        [
            (3, 0, 0),
            (2, 1, 0),
            (2, 0, 1),
            (1, 2, 0),
            (1, 1, 1),
            (1, 0, 2),
            (0, 3, 0),
            (0, 2, 1),
            (0, 1, 2),
            (0, 0, 3),
        ],
    )
    test._angmom = 10
    assert len(test.angmom_components_cart) == 11 * 12 / 2
Esempio n. 3
0
def test_num_sph():
    """Test GeneralizedContractionShell.num_sph."""
    test = skip_init(GeneralizedContractionShell)
    last_num_sph = 1
    for i in range(100):
        test._angmom = i
        assert test.num_sph == last_num_sph
        last_num_sph = test.num_sph + 2
Esempio n. 4
0
def test_num_cart():
    """Test GeneralizedContractionShell.num_cart."""
    test = skip_init(GeneralizedContractionShell)
    last_num_cart = 0
    for i in range(100):
        test._angmom = i
        assert test.num_cart == last_num_cart + i + 1
        last_num_cart = test.num_cart
Esempio n. 5
0
def test_init():
    """Test BaseFourIndexSymmetric.__init__."""
    Test = disable_abstract(BaseFourIndexSymmetric)  # noqa: N806
    test = skip_init(Test)
    contractions = GeneralizedContractionShell(1, np.array([1, 2, 3]), np.ones(1), np.ones(1))
    Test.__init__(test, [contractions])
    assert test._axes_contractions[0][0] == contractions
    with pytest.raises(TypeError):
        Test.__init__(test, [contractions], [contractions])
Esempio n. 6
0
def test_init():
    """Test BaseOneIndex.__init__."""
    Test = disable_abstract(BaseOneIndex)  # noqa: N806
    test = skip_init(Test)
    contractions = GeneralizedContractionShell(1, np.array([1, 2, 3]), np.ones(1), np.ones(1))
    Test.__init__(test, [contractions])
    assert test._axes_contractions == ((contractions,),)
    with pytest.raises(TypeError):
        Test.__init__(test, [contractions], [contractions])
Esempio n. 7
0
def test_angmom_components_sph():
    """Test GeneralizedContractionShell.angmom_components_sph."""
    test = skip_init(GeneralizedContractionShell)
    test._angmom = 0
    assert np.allclose(test.angmom_components_sph, (0,))
    test._angmom = 1
    assert np.allclose(test.angmom_components_sph, (-1, 0, 1))
    test._angmom = 2
    assert np.allclose(test.angmom_components_sph, (-2, -1, 0, 1, 2))
    test._angmom = 3
    assert np.allclose(test.angmom_components_sph, (-3, -2, -1, 0, 1, 2, 3))
Esempio n. 8
0
def test_angmom_components_sph():
    """Test GeneralizedContractionShell.angmom_components_sph."""
    test = skip_init(GeneralizedContractionShell)
    test._angmom = 0
    assert test.angmom_components_sph == ("c0",)
    test._angmom = 1
    assert test.angmom_components_sph == ("s1", "c0", "c1")
    test._angmom = 2
    assert test.angmom_components_sph == ("s2", "s1", "c0", "c1", "c2")
    test._angmom = 3
    assert test.angmom_components_sph == ("s3", "s2", "s1", "c0", "c1", "c2", "c3")
Esempio n. 9
0
def test_angmom_setter():
    """Test setter for GeneralizedContractionShell.angmom."""
    test = skip_init(GeneralizedContractionShell)
    test.angmom = 1
    assert isinstance(test._angmom, int) and test._angmom == 1
    test.angmom = 0
    assert isinstance(test._angmom, int) and test._angmom == 0
    with pytest.raises(ValueError):
        test.angmom = -2
    with pytest.raises(TypeError):
        test.angmom = "0"
    with pytest.raises(TypeError):
        test.angmom = 0.0
    with pytest.raises(TypeError):
        test.angmom = None
Esempio n. 10
0
def test_coord_setter():
    """Test setter for GeneralizedContractionShell.coord."""
    test = skip_init(GeneralizedContractionShell)
    test.coord = np.array([1.0, 2.0, 3.0])
    assert (
        isinstance(test._coord, np.ndarray)
        and test._coord.dtype == float
        and np.allclose(test._coord, np.array([1, 2, 3]))
    )
    test.coord = np.array([1, 2, 3])
    assert (
        isinstance(test._coord, np.ndarray)
        and test._coord.dtype == float
        and np.allclose(test._coord, np.array([1, 2, 3]))
    )

    with pytest.raises(TypeError):
        test.coord = [1, 2, 3]
    with pytest.raises(TypeError):
        test.coord = np.array([1, 2])
    with pytest.raises(TypeError):
        test.coord = np.array([1, 2, 3], dtype=bool)
Esempio n. 11
0
def test_init():
    """Test base.BaseGaussianRelatedArray."""
    Test = disable_abstract(BaseGaussianRelatedArray)  # noqa: N806
    test = skip_init(Test)
    contractions = GeneralizedContractionShell(1, np.array([1, 2, 3]),
                                               np.ones(1), np.ones(1))
    assert not hasattr(test, "_axes_contractions")
    with pytest.raises(TypeError):
        Test.__init__(test, set([contractions]))
    with pytest.raises(ValueError):
        Test.__init__(test, [])
    with pytest.raises(TypeError):
        Test.__init__(test, [1])
    with pytest.raises(TypeError):
        Test.__init__(test, [contractions.__dict__])

    Test.__init__(test, [contractions])
    assert test._axes_contractions == ((contractions, ), )
    Test.__init__(test, [contractions, contractions])
    assert test._axes_contractions == ((contractions, contractions), )
    Test.__init__(test, [contractions, contractions], [contractions])
    assert test._axes_contractions == ((contractions, contractions),
                                       (contractions, ))
Esempio n. 12
0
def test_exps_getter():
    """Test getter for GeneralizedContractionShell.exps."""
    test = skip_init(GeneralizedContractionShell)
    test._exps = [2.0, 3.0]
    assert test.exps == [2.0, 3.0]
Esempio n. 13
0
def test_angmom_getter():
    """Test getter for GeneralizedContractionShell.angmom."""
    test = skip_init(GeneralizedContractionShell)
    test._angmom = 1
    assert test.angmom == 1
Esempio n. 14
0
def test_coord_getter():
    """Test getter for GeneralizedContractionShell.coord."""
    test = skip_init(GeneralizedContractionShell)
    test._coord = 2
    assert test.coord == 2
Esempio n. 15
0
def test_num_seg_cont():
    """Test GeneralizedContractionShell.num_seg_cont."""
    test = skip_init(GeneralizedContractionShell)
    test._coeffs = np.random.rand(10, 21)
    assert test.num_seg_cont == 21
Esempio n. 16
0
def test_coeffs_getter():
    """Test getter for GeneralizedContractionShell.coeffs."""
    test = skip_init(GeneralizedContractionShell)
    test._coeffs = [2.0, 3.0]
    assert test.coeffs == [2.0, 3.0]