Пример #1
0
def test_Location_intersect_mask(loc_nd, hypercube_grid_shape_nd):
    assert np.array_equal(
        np.ones(loc_nd.shape[0], dtype=np.bool),
        Location.intersect_mask(loc_nd, loc_nd, hypercube_grid_shape_nd))
Пример #2
0
def test_Location_intersect_mask2(a, b, expected):
    assert np.array_equal(Location.intersect_mask(a, b, (10, 10)), expected)
Пример #3
0
def test_Location_intersect1(loc10d, loc_nd, hypercube_grid_shape_nd):
    with pytest.raises(UserWarning):
        Location.intersect(loc10d, loc_nd, hypercube_grid_shape_nd)
    with pytest.raises(UserWarning):
        Location.intersect(loc_nd, loc10d, hypercube_grid_shape_nd)
Пример #4
0
def test_Location_intersect2(loc_nd, hypercube_grid_shape_nd):
    assert np.array_equal(
        loc_nd, Location.intersect(loc_nd, loc_nd, hypercube_grid_shape_nd))
Пример #5
0
def test_Location_init_invalid(invalid_coord):
    with pytest.raises(AssertionError):
        Location(invalid_coord)
Пример #6
0
def test_Location_dtype():
    assert Location((3.0, 3.0)).dtype == np.int64
Пример #7
0
def test_Location_init2(loc_nd, coord_nd, ndim, ncoord):
    assert np.array_equal(coord_nd, Location(coord_nd))
    assert Location(coord_nd).shape == (ncoord, ndim)
Пример #8
0
def loc10d():
    return Location(np.random.randint(0, 3, 10))
Пример #9
0
def loc_nd(coord_nd):
    return Location(coord_nd)
Пример #10
0
def loc2d(coord2d):
    return Location(coord2d)
Пример #11
0
def test_Location_dtype():
    assert Location((3.0, 3.0)).dtype == np.int64


def test_Location_intersect1(loc10d, loc_nd, hypercube_grid_shape_nd):
    with pytest.raises(UserWarning):
        Location.intersect(loc10d, loc_nd, hypercube_grid_shape_nd)
    with pytest.raises(UserWarning):
        Location.intersect(loc_nd, loc10d, hypercube_grid_shape_nd)


def test_Location_intersect2(loc_nd, hypercube_grid_shape_nd):
    assert np.array_equal(
        loc_nd, Location.intersect(loc_nd, loc_nd, hypercube_grid_shape_nd))


def test_Location_intersect_mask(loc_nd, hypercube_grid_shape_nd):
    assert np.array_equal(
        np.ones(loc_nd.shape[0], dtype=np.bool),
        Location.intersect_mask(loc_nd, loc_nd, hypercube_grid_shape_nd))


@pytest.mark.parametrize("a,b,expected", [
    (Location([[3, 3], [3, 4]]), Location([3, 3]), np.array([True, False])),
    (Location([3, 3]), Location([[3, 3], [3, 4]]), np.array([True])),
    (Location([3, 6]), Location([[3, 3], [3, 4]]), np.array([False])),
    (Location([[3, 6], [6, 3]]), Location([[3, 3]]), np.array([False, False])),
])
def test_Location_intersect_mask2(a, b, expected):
    assert np.array_equal(Location.intersect_mask(a, b, (10, 10)), expected)