def arrangeDim(oldDim, newDim, arrangeFront):
    """
    return the transpose index for oldDim -> newDim as well as the full newDim with len(oldDim)==len(newDim)
    arrangeFront (if true) stance excess dimension to the back of newDim
    newDim must be a subset of oldDim
    """
    oldDimCopy = oldDim[:]
    oldIndex = list(range(len(oldDimCopy)))
    transposeIndex = []
    if type(newDim) != list:
        newDim = [newDim]
    for axis in newDim:
        index = oldDim.index(axis)
        transposeIndex.append(index)
        oldDimCopy.remove(axis)
        oldIndex.remove(index)
    if arrangeFront:
        currentDim = newDim[:] + oldDimCopy
        transposeIndex = transposeIndex + oldIndex
    else:
        currentDim = oldDimCopy + newDim[:]
        transposeIndex = oldIndex + transposeIndex
    return transposeIndex, currentDim
