Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
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]])
Esempio n. 4
0
def test_tsc_tuned():
    affine = Affine(ndim=3, translate=[2, 1, 2], scale=[0.5, 2.0, 1.1], period=[8, 8, 8])
    assert TSC.support == 3
    assert QUADRATIC.support == 3
    real = numpy.zeros((8, 8, 8))
    real2 = numpy.zeros((8, 8, 8))
    numpy.random.seed(1234)
    field = numpy.random.uniform(size=real.shape)

    pos = [
        [1.1, 1.3, 2.9],
    ]
    TSC.paint(real, pos, transform=affine)
    QUADRATIC.paint(real2, pos, transform=affine)
    v = TSC.readout(field, pos, transform=affine)
    v2 = QUADRATIC.readout(field, pos, transform=affine)

    assert_array_equal(real, real2)
    assert_array_equal(v, v2)

    for d in range(3):
        d1 = numpy.zeros((8, 8, 8))
        d2 = numpy.zeros((8, 8, 8))
        TSC.paint(d1, pos, diffdir=d, transform=affine)
        QUADRATIC.paint(d2, pos, diffdir=d, transform=affine)
        v = TSC.readout(field, pos, transform=affine)
        v2 = QUADRATIC.readout(field, pos, transform=affine)
        assert_array_equal(d1, d2)
        assert_array_equal(v, v2)
Esempio n. 5
0
def test_tsc():
    real = numpy.zeros((4))
    pos = [
        [1.5],
    ]
    TSC.paint(real, pos)
    assert_array_equal(real, [0, 0.5, 0.5, 0])

    real = numpy.zeros((4))
    pos = [
        [1.8],
    ]
    TSC.paint(real, pos)
    # this is special for odd support kernels. #10
    assert_almost_equal(real, [ 0.   ,  0.245,  0.71 ,  0.045])

    real = numpy.zeros((5))
    pos = [
        [2],
    ]
    TSC.paint(real, pos)
    assert_array_equal(real, [0, 0.125, 0.75, 0.125, 0])

    real = numpy.zeros((5))
    pos = [
        [0],
    ]
    affine = Affine(ndim=1, period=5)
    TSC.paint(real, pos, transform=affine)
    assert_array_equal(real, [0.75, 0.125, 0, 0, 0.125])
Esempio n. 6
0
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.])
Esempio n. 7
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.]])