Beispiel #1
0
def test_contains():
    vec1 = np.arange(2, 6)
    vec2 = np.arange(-4, 5, 2)

    grid = TensorGrid(vec1, vec2)

    point_list = []
    for x in vec1:
        for y in vec2:
            point_list.append((x, y))

    assert all(p in grid for p in point_list)

    assert not (0, 0) in grid
    assert (0, 0) not in grid
    assert (2, 0, 0) not in grid

    # Fuzzy check
    assert grid.approx_contains((2.1, -2.1), tol=0.15)
    assert not grid.approx_contains((2.2, -2.1), tol=0.15)

    # 1d points
    grid = TensorGrid(vec1)
    assert 3 in grid
    assert 7 not in grid