Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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