def test_boolean_ray_slice_overlap():
r"""Test to make sure that boolean objects (rays and slices, overlap)
behave the way we expect.
Test overlapping rays and slices.
"""
ds = fake_amr_ds()
sl = ds.r[:,:,0.25]
ra = ds.ray([0, 0, 0.25], [0, 1, 0.25])
# Get indices of both.
i1 = sl["index","morton_index"]
i1.sort()
i2 = ra["index","morton_index"]
i1.sort()
ii = np.concatenate((i1, i2))
ii.sort()
# Make some booleans
bo1 = sl & ra
bo2 = sl - ra
bo3 = sl | ra
bo4 = ds.union([sl, ra])
bo5 = ds.intersection([sl, ra])
# Now make sure the indices also behave as we expect.
line = np.intersect1d(i1, i2)
sheet_minus_line = np.setdiff1d(i1, i2)
sheet = np.union1d(i1, i2)
b1 = bo1["index","morton_index"]
b1.sort()
b2 = bo2["index","morton_index"]
b2.sort()
b3 = bo3["index","morton_index"]
b3.sort()
assert_array_equal(b1, line)
assert_array_equal(b2, sheet_minus_line)
assert_array_equal(b3, sheet)
b4 = bo4["index","morton_index"]
b4.sort()
b5 = bo5["index","morton_index"]
b5.sort()
assert_array_equal(b3, i1)
assert_array_equal(b3, b4)
assert_array_equal(b1, b5)
bo6 = sl ^ ra
b6 = bo6["index", "morton_index"]
b6.sort()
assert_array_equal(b6, np.setxor1d(i1, i2))
评论列表
文章目录