def test_select(): s = Sphere(n=xr.DataArray([1.5, 1.7], dims='ill', coords={'ill': ['r', 'g']}), center=[0, 0, 0], r=0.5) assert_equal(s.select({'ill': 'g'}), Sphere(n=1.7, center=[0, 0, 0], r=0.5)) ss = Spheres([s, s.translated([1, 1, 1])]) assert_equal( ss.select({'ill': 'g'}), Spheres([ Sphere(n=1.7, center=[0, 0, 0], r=0.5), Sphere(n=1.7, center=[1, 1, 1], r=0.5) ]))
def test_translate(): s = Sphere(n=1.59, r=.5, center=(0, 0, 0)) s2 = s.translated(1, 1, 1) assert_equal(s.r, s2.r) assert_equal(s.n, s2.n) assert_allclose(s2.center, (1, 1, 1))