def test_axis_angles_from_matrices_output_variable():
    random_state = np.random.RandomState(84)
    A = random_state.randn(2, 3, 3)
    A /= np.linalg.norm(A, axis=-1)[..., np.newaxis]
    A *= random_state.rand(2, 3, 1) * np.pi
    A[0, 0, :] = 0.0

    Rs = np.empty((2, 3, 3, 3))
    pbr.matrices_from_compact_axis_angles(A, out=Rs)
    A2 = np.empty((2, 3, 4))
    pbr.axis_angles_from_matrices(Rs, out=A2)
    A2_compact = A2[..., :3] * A2[..., 3, np.newaxis]
    assert_array_almost_equal(A, A2_compact)
def test_axis_angles_from_matrices_0dims():
    random_state = np.random.RandomState(84)
    A = random_state.randn(3)
    A /= np.linalg.norm(A, axis=-1)[..., np.newaxis]
    A *= random_state.rand() * np.pi

    Rs = pbr.matrices_from_compact_axis_angles(A)
    A2 = pbr.axis_angles_from_matrices(Rs)
    A2_compact = A2[:3] * A2[3]
    assert_array_almost_equal(A, A2_compact)