def test_strides(): real = numpy.zeros((20, 20))[::10, ::10] pos = [ [1., 0], ] CIC.paint(real, pos) assert_array_equal(real, [[0, 0], [1, 0]])
def test_scale(): affine = Affine(ndim=2, translate=[-1, 0], scale=0.1) real = numpy.zeros((2, 2)) pos = [ [10., 0], ] CIC.paint(real, pos, transform=affine) assert_array_equal(real, [[1., 0.], [0, 0.]])
def test_anisotropic(): real = numpy.zeros((2, 4)) pos = [ [0., 0], [1., 0], [0., 1], [0., 2], [0., 3], ] CIC.paint(real, pos) assert_array_equal(real, [[1, 1, 1, 1], [1, 0, 0, 0]])
def test_unweighted(): real = numpy.zeros((4, 4)) pos = [ [0, 0], [1, 1], [2, 2], [3, 3], ] CIC.paint(real, pos) assert_array_equal(real, [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]])
def test_diff(): real = numpy.zeros((2, 2)) pos = [ [0., 0], ] CIC.paint(real, pos, diffdir=0) assert_array_equal(real, [[-1, 0], [1, 0]]) real = numpy.zeros((2, 2)) CIC.paint(real, pos, diffdir=1) assert_array_equal(real, [[-1, 1], [0, 0]])
def test_weighted(): real = numpy.zeros((4, 4)) pos = [ [0, 0], [1, 1], [2, 2], [3, 3], ] mass = [0, 1, 2, 3] CIC.paint(real, pos, mass=mass) assert_array_equal(real, [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 2, 0], [0, 0, 0, 3]])
def test_affine(): affine = Affine(ndim=2) real = numpy.zeros((4, 4)) pos = [ [.5, .5], ] CIC.paint(real, pos, transform=affine) translate = numpy.zeros((4, 4)) pos = [ [0., 0.], ] shift = affine.shift CIC.paint(translate, pos, transform=affine.shift(0.5)) assert_array_equal(translate, real)
def test_scale_hsml(): affine = Affine(ndim=1, translate=[0], scale=0.1) real = numpy.zeros(10) pos = [ [50., 0], ] CIC.paint(real, pos, hsml=1., transform=affine) assert_array_equal(real, [ 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.]) affine = Affine(ndim=1, translate=[0], scale=1.) real = numpy.zeros(10) pos = [ [5., 0], ] CIC.paint(real, pos, hsml=None, transform=affine) assert_array_equal(real, [ 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.])
def test_diff(): real = numpy.zeros((2, 2)) pos = [ [0.5, 0], ] CIC.paint(real, pos, diffdir=0) assert_array_equal(real, [[-1, 0], [1, 0]]) pos = [ [0, 0.5], ] real = numpy.zeros((2, 2)) CIC.paint(real, pos, diffdir=1) assert_array_equal(real, [[-1, 1], [0, 0]])
def test_cic_tuned(): assert CIC.support == 2 assert LINEAR.support == 2 real = numpy.zeros((4, 4, 4)) pos = [ [1.1, 1.3, 2.5], ] CIC.paint(real, pos) real2 = numpy.zeros((4, 4, 4)) LINEAR.paint(real2, pos) assert_array_equal(real, real2) for d in range(3): d1 = numpy.zeros((4, 4, 4)) d2 = numpy.zeros((4, 4, 4)) CIC.paint(d1, pos, diffdir=d) LINEAR.paint(d2, pos, diffdir=d) assert_array_equal(d1, d2)
def test_wrap(): affine = Affine(ndim=2, period=2) real = numpy.zeros((2, 2)) pos = [ [-.5, -.5], ] CIC.paint(real, pos, transform=affine) assert_array_equal(real, [[0.25, 0.25], [0.25, 0.25]]) real = numpy.zeros((2, 2)) pos = [ [-.5, .5], ] CIC.paint(real, pos, transform=affine) assert_array_equal(real, [[0.25, 0.25], [0.25, 0.25]]) real = numpy.zeros((2, 2)) pos = [ [-.5, 1.5], ] CIC.paint(real, pos, transform=affine) assert_array_equal(real, [[0.25, 0.25], [0.25, 0.25]])
def test_compensation(): comp1 = CIC.get_fwindow([0, 2 * numpy.pi]) assert_allclose(comp1, [1, 0.0], atol=1e-9)