def permutation_matrix(orig_vec, per_vec):
    if not isinstance(orig_vec, (list, tuple)):
        orig_vec = flatten(orig_vec)
    if not isinstance(per_vec, (list, tuple)):
        per_vec = flatten(per_vec)
    if set(orig_vec) != set(per_vec):
        raise ValueError("orig_vec and per_vec must be the same length, " +
                "and contain the same symbols.")
    ind_list = [orig_vec.index(i) for i in per_vec]
    p_matrix = zeros(len(orig_vec))
    for i, j in enumerate(ind_list):
        p_matrix[i, j] = 1
    return p_matrix
Testing sandboxing ReviewRequestDropdownActionHook when
dataset/ETHPy150Open sympy/sympy/sympy/physics/mechanics/linearize.py/permutation_matrix--crossover with--dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/extensions/tests.py/SandboxTests.test_action_hooks_review_request_dropdown_hook