Example #1
0
def test_empty(VectorArray):
    with pytest.raises(Exception):
        VectorArray.empty(-1)
    with pytest.raises(Exception):
        VectorArray.empty(1, reserve=-1)
    for dim, r in product((0, 1, 2, 10, 100), (0, 1, 100)):
        v = VectorArray.empty(dim, reserve=r)
        assert v.dim == dim
        assert len(v) == 0
        if hasattr(v, 'data'):
            d = v.data
            assert d.shape == (0, dim)
Example #2
0
def test_zeros(VectorArray):
    with pytest.raises(Exception):
        VectorArray.zeros(-1)
    with pytest.raises(Exception):
        VectorArray.zeros(1, count=-1)
    for dim, c in product((0, 1, 10, 100), (0, 1, 2, 30)):
        v = VectorArray.zeros(dim, count=c)
        assert v.dim == dim
        assert len(v) == c
        if min(dim, c) > 0:
            assert max(v.sup_norm()) == 0
            assert max(v.l2_norm()) == 0
        if hasattr(v, 'data'):
            d = v.data
            assert d.shape == (c, dim)
            assert np.allclose(d, np.zeros((c, dim)))
Example #3
0
def test_amax_zero_dim(VectorArray):
    for count in (0, 10):
        v = VectorArray.zeros(0, count=count)
        for ind in valid_inds(v):
            with pytest.raises(Exception):
                v.amax(ind)