def unprepare(data, shape): """ Inverses the manipulations in prepare(). :param data: numpy.ndarray :param shape: The original shape of collapsed dimensions returned as a second item of the tuple from prepare(). :return numpy.ndarray """ return reshape(transpose(data), (data.shape[1], ) + shape)
def unprepare(data, shape): """ Inverses the manipulations in prepare(). :param data: numpy.ndarray :param shape: The original shape of collapsed dimensions returned as a second item of the tuple from prepare(). :return numpy.ndarray """ return reshape(transpose(data), (data.shape[1],) + shape)
def prepare(data): """ Manipulates with the array's shape, collapsing all the dimensions but the first and transposing the resulting 2D matrix. :param data: numpy.ndarray :return tuple (the reshaped and transposed data, the original shape of collapsed dimensions) """ shape = data.shape[1:] old_data = data new_data = transpose( reshape(data, (data.shape[0], data.size // data.shape[0]))) assert_addr(old_data, new_data) return new_data, shape
def prepare(data): """ Manipulates with the array's shape, collapsing all the dimensions but the first and transposing the resulting 2D matrix. :param data: numpy.ndarray :return tuple (the reshaped and transposed data, the original shape of collapsed dimensions) """ shape = data.shape[1:] old_data = data new_data = transpose(reshape(data, (data.shape[0], data.size // data.shape[0]))) assert_addr(old_data, new_data) return new_data, shape