示例#1
0
def test_rotate_tree():

    m = gtr.rotate(TREE, TEST_UVEC, TEST_ANGLE)

    R = gtr._rodriguesToRotationMatrix(TEST_UVEC, TEST_ANGLE)

    # rotation matrix inverse equals its transpose
    Rinv = R.transpose()

    # check that if the inverse rotation on the rotated result returns
    # the initial coordinates
    _evaluate(TREE, m, lambda x, y: np.allclose(np.dot(Rinv, y), x) )


    # check with origin
    new_orig = np.array([-50., 45., 30.])

    m = gtr.rotate(TREE, TEST_UVEC, TEST_ANGLE, origin=new_orig)
    m = gtr.rotate(m, TEST_UVEC, -TEST_ANGLE, origin=new_orig)

    _evaluate(TREE, m, lambda x, y: np.allclose(x, y) )
示例#2
0
def test_rotate_bad_type_raises():
    gtr.rotate("hello", [1,0,0], math.pi)
示例#3
0
def test_rotate_neurite_h5():
    nrn_a = load_neuron(H5_NRN_PATH)
    nrt_a = nrn_a.neurites[0]
    nrt_b = gtr.rotate(nrt_a, [0,0,1], math.pi/2.0)
    rot = gtr._rodrigues_to_dcm([0,0,1], math.pi/2.0)
    _check_fst_neurite_rotate(nrt_a, nrt_b, rot)
示例#4
0
def test_rotate_neuron_swc():
    nrn_a = load_neuron(SWC_NRN_PATH)
    nrn_b = gtr.rotate(nrn_a, [0,0,1], math.pi/2.0)
    rot = gtr._rodrigues_to_dcm([0,0,1], math.pi/2.0)
    _check_fst_nrn_rotate(nrn_a, nrn_b, rot)
示例#5
0
def test_rotate_bad_type_raises():
    with pytest.raises(NotImplementedError):
        gtr.rotate("hello", [1, 0, 0], math.pi)
示例#6
0
def test_rotate_neuron_h5():
    nrn_a = load_neuron(H5_NRN_PATH)
    nrn_b = gtr.rotate(nrn_a, [0, 0, 1], math.pi/2.0)
    rot = gtr._rodrigues_to_dcm([0, 0, 1], math.pi/2.0)
    _check_fst_nrn_rotate(nrn_a, nrn_b, rot)
示例#7
0
def test_rotate_bad_type_raises():
    gtr.rotate("hello", [1,0,0], math.pi)
示例#8
0
def test_rotate_neurite_swc():
    nrn_a = load_neuron(SWC_NRN_PATH)
    nrt_a = nrn_a.neurites[0]
    nrt_b = gtr.rotate(nrt_a, [0,0,1], math.pi/2.0)
    rot = gtr._rodrigues_to_dcm([0,0,1], math.pi/2.0)
    _check_fst_neurite_rotate(nrt_a, nrt_b, rot)
示例#9
0
def test_rotate_dispatch():

    nt.assert_true(isinstance(gtr.rotate(NEURON, TEST_UVEC, np.pi), Neuron))
    nt.assert_true(isinstance(gtr.rotate(TREE, TEST_UVEC, np.pi), Tree))