Transpose array or list of arrays if they are 2D.
6841
def _check_and_flip(arr):
    """"""
    if hasattr(arr, 'ndim'):
        if arr.ndim >= 2:
            return arr.T
        else:
            return arr
    elif not is_string_like(arr) and iterable(arr):
        return tuple(_check_and_flip(a) for a in arr)
    else:
        return arr
857869
def trans_from_matrix(matrix):
    
    t = np.zeros((4, 4))
    for i in range(4):
        for j in range(4):
            t[i, j] = matrix.GetElement(i, j)
    return t
1316854
def transpose(table):
    
    t = []
    for i in range(0, len(table[0])):
        t.append([row[i] for row in table])
    return t
612824
def _concatenate_virtual_arrays(arrs, cols=None, scaling=None):
    """"""
    return None if not len(arrs) else ConcatenatedArrays(arrs, cols,
                                                         scaling=scaling)
1056643
def fromarray(A):
    """"""
    subs = np.nonzero(A)
    vals = A[subs]
    return sptensor(subs, vals, shape=A.shape, dtype=A.dtype)
1214964
def _array_2d_repr(self):
        """"""

        sc_array = np.zeros((self.nmax + 1, 2 * self.mmax + 1),
                            dtype=np.complex128)

        lst = self._reshape_n_vecs()
        sc_array[0:self.nmax + 1, self.mmax] = lst[0]
        for m in xrange(1, self.mmax + 1):
            sc_array[m:self.nmax + 1, self.mmax - m] = lst[2 * m - 1]
            sc_array[m:self.nmax + 1, self.mmax + m] = lst[2 * m]

        return sc_array
440128
def _pack(cls, tensors):
    """"""
    if not tensors:
      return None
    elif len(tensors) == 1:
      return array_ops.reshape(tensors[0], [-1])
    else:
      flattened = [array_ops.reshape(tensor, [-1]) for tensor in tensors]
      return array_ops.concat(flattened, 0)
1062377
def flatten(in_list):
    """"""
    out_list = []
    for val in in_list:
        if isinstance(val, list):
            out_list.extend(val)
        else:
            out_list.append(val)

    return out_list
883959
def make2d(array, cols=None, dtype=None):
    '''
    

    '''
    if not len(array):
        if cols is None or dtype is None:
            raise RuntimeError(
                "cols and dtype must be specified for empty array"
            )
        return _np.empty((0, cols), dtype=dtype)
    return _np.vstack(array)
285152
def _maybe_to_sparse(array):
    
    if isinstance(array, ABCSparseSeries):
        array = array.values.copy()
    return array
381549
def _possibly_convert_objects(values):
    
    return np.asarray(pd.Series(values.ravel())).reshape(values.shape)
4684
def reshape_to_2d(arr):
  '''
  

  '''
  return arr.reshape((arr.shape[0], arr.shape[1]*arr.shape[2]))
117095
def column_stack_2d(data):
    """"""
    return list(list(itt.chain.from_iterable(_)) for _ in zip(*data))
623725
def matrix(self, _):
        """"""
        x, y, z = self.coord
        return np.array([
            [1., 0., 0., x],
            [0., 1., 0., y],
            [0., 0., 1., z],
            [0., 0., 0., 1.]
        ])
1201972
def index_2d(seqs: List[List[Any]], target: Any) -> Tuple[int, int]:
    
    for i in range(len(seqs)):
        for j in range(len(seqs[i])):
            if seqs[i][j] == target:
                return i, j
    raise ValueError('Item not present.')
229448
public static Object[][] matrixTransform(Object[][] datas) {
        if (datas.length == 0 || datas[0].length == 0) {
            return datas;
        }
        int column = datas.length;
        int row = datas[0].length;

        Object[][] newData = new Object[row][column];

        for (int i = 0; i < row; i++) {
            Object[] list = new Object[column];
            for (int j = 0; j < column; j++) {
                list[j] = datas[j][i];
            }
            newData[i] = list;
        }
        return newData;
    }
899572
def _vector_or_scalar(x, type='row'):
    """"""
    if isinstance(x, (list, tuple)):
        x = np.array(x)
    if isinstance(x, np.ndarray):
        assert x.ndim == 1
        if type == 'column':
            x = x[:, None]
    return x