# Buggy code
def tile(cls, op):
    in_df = op.inputs[0]
    out_val = op.outputs[0]

    # See Note [Fancy Index of Numpy and Pandas]
    tensor0 = empty(in_df.shape[0], chunk_size=(in_df.nsplits[0],))[
        op.indexes[0]
    ].tiles()
    tensor1 = empty(in_df.shape[1], chunk_size=(in_df.nsplits[1],))[
        op.indexes[1]
    ].tiles()

    integral_index_on_index = isinstance(op.indexes[0], Integral)
    integral_index_on_column = isinstance(op.indexes[1], Integral)

    out_chunks = []
    for index_chunk, column_chunk in itertools.product(tensor0.chunks, tensor1.chunks):
        in_chunk = in_df.cix[index_chunk.inputs[0].index + column_chunk.inputs[0].index]

        chunk_op = op.copy().reset_key()
        chunk_op._indexes = (index_chunk.op.indexes[0], column_chunk.op.indexes[0])

        if integral_index_on_column:
            shape = index_chunk.shape
            index = index_chunk.index
            index_value = indexing_index_value(
                in_chunk.index_value, index_chunk.op.indexes[0]
            )
            out_chunk = chunk_op.new_chunk(
                [in_chunk],
                shape=shape,
                index=index,
                dtype=out_val.dtype,
                index_value=index_value,
            )
        elif integral_index_on_index:
            shape = column_chunk.shape
            index = column_chunk.index
            index_value = indexing_index_value(
                in_chunk.columns, column_chunk.op.indexes[0]
            )
            out_chunk = chunk_op.new_chunk(
                [in_chunk],
                shape=shape,
                index=index,
                dtype=out_val.dtype,
                index_value=index_value,
            )
        else:
            index_value = indexing_index_value(
                in_chunk.index_value, index_chunk.op.indexes[0]
            )
            columns_value = indexing_index_value(
                in_chunk.columns, column_chunk.op.indexes[0], store_data=True
            )
            dtypes = in_chunk.dtypes.iloc[column_chunk.op.indexes[0]]
            out_chunk = chunk_op.new_chunk(
                [in_chunk],
                shape=index_chunk.shape + column_chunk.shape,
                index=index_chunk.index + column_chunk.index,
                dtypes=dtypes,
                index_value=index_value,
                columns_value=columns_value,
            )
        out_chunks.append(out_chunk)

    new_op = op.copy()
    if integral_index_on_column or integral_index_on_index:
        if integral_index_on_column:
            nsplits = tensor0.nsplits
        else:
            nsplits = tensor1.nsplits
        return new_op.new_seriess(
            op.inputs,
            out_val.shape,
            dtype=out_val.dtype,
            index_value=out_val.index_value,
            chunks=out_chunks,
            nsplits=nsplits,
        )
    else:
        nsplits = tensor0.nsplits + tensor1.nsplits
        return new_op.new_dataframes(
            op.inputs,
            out_val.shape,
            dtypes=out_val.dtypes,
            index_value=out_val.index_value,
            columns_value=out_val.columns,
            chunks=out_chunks,
            nsplits=nsplits,
        )


# Traceback (Exception)
In [28]: df = md.DataFrame(np.random.rand(10, 2))

In [29]: df + np.random.rand(10, 2)
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-29-4a212df011a8> in <module>
----> 1 df + np.random.rand(10, 2)

~/Documents/mars_dev/mars/mars/dataframe/utils.py in wrapper(*args, **kwargs)
613     def wrapper(*args, **kwargs):
614         try:
--> 615             return func(*args, **kwargs)
616         except NotImplementedError:
617             return NotImplemented

~/Documents/mars_dev/mars/mars/dataframe/arithmetic/add.py in add(df, other, axis, level, fill_value)
33
34 def add(df, other, axis='columns', level=None, fill_value=None):
---> 35     other = wrap_sequence(other)
36     op = DataFrameAdd(axis=axis, level=level, fill_value=fill_value, lhs=df, rhs=other)
37     return op(df, other)

~/Documents/mars_dev/mars/mars/dataframe/utils.py in wrap_sequence(seq)
606
607     if isinstance(seq, (list, tuple, np.ndarray, TENSOR_TYPE)):
--> 608         seq = Series(seq)
609     return seq
610

~/Documents/mars_dev/mars/mars/dataframe/initializer.py in __init__(self, data, index, dtype, name, copy, chunk_size, gpu, sparse)
46             series = data
47         else:
---> 48             pd_series = pd.Series(data, index=index, dtype=dtype, name=name, copy=copy)
49             series = from_pandas_series(pd_series, chunk_size=chunk_size, gpu=gpu, sparse=sparse)
50         super(Series, self).__init__(series.data)

~/miniconda3/lib/python3.7/site-packages/pandas/core/series.py in __init__(self, data, index, dtype, name, copy, fastpath)
312                     data = data.copy()
313             else:
--> 314                 data = sanitize_array(data, index, dtype, copy, raise_cast_failure=True)
315
316                 data = SingleBlockManager(data, index, fastpath=True)

~/miniconda3/lib/python3.7/site-packages/pandas/core/internals/construction.py in sanitize_array(data, index, dtype, copy, raise_cast_failure)
727     elif subarr.ndim > 1:
728         if isinstance(data, np.ndarray):
--> 729             raise Exception("Data must be 1-dimensional")
730         else:
731             subarr = com.asarray_tuplesafe(data, dtype=dtype)

Exception: Data must be 1-dimensional

# Fixed code
def tile(cls, op):
    in_df = op.inputs[0]
    out_val = op.outputs[0]

    # See Note [Fancy Index of Numpy and Pandas]
    tensor0 = empty(in_df.shape[0], chunk_size=(in_df.nsplits[0],))[
        op.indexes[0]
    ].tiles()
    tensor1 = empty(in_df.shape[1], chunk_size=(in_df.nsplits[1],))[
        op.indexes[1]
    ].tiles()

    integral_index_on_index = isinstance(op.indexes[0], Integral)
    integral_index_on_column = isinstance(op.indexes[1], Integral)

    out_chunks = []
    for index_chunk, column_chunk in itertools.product(tensor0.chunks, tensor1.chunks):
        in_chunk = in_df.cix[index_chunk.inputs[0].index + column_chunk.inputs[0].index]

        chunk_op = op.copy().reset_key()
        chunk_op._indexes = (index_chunk.op.indexes[0], column_chunk.op.indexes[0])

        if integral_index_on_column:
            shape = index_chunk.shape
            index = index_chunk.index
            index_value = indexing_index_value(
                in_chunk.index_value, index_chunk.op.indexes[0]
            )
            out_chunk = chunk_op.new_chunk(
                [in_chunk],
                shape=shape,
                index=index,
                dtype=out_val.dtype,
                index_value=index_value,
            )
        elif integral_index_on_index:
            shape = column_chunk.shape
            index = column_chunk.index
            index_value = indexing_index_value(
                in_chunk.columns_value, column_chunk.op.indexes[0]
            )
            out_chunk = chunk_op.new_chunk(
                [in_chunk],
                shape=shape,
                index=index,
                dtype=out_val.dtype,
                index_value=index_value,
            )
        else:
            index_value = indexing_index_value(
                in_chunk.index_value, index_chunk.op.indexes[0]
            )
            columns_value = indexing_index_value(
                in_chunk.columns_value, column_chunk.op.indexes[0], store_data=True
            )
            dtypes = in_chunk.dtypes.iloc[column_chunk.op.indexes[0]]
            out_chunk = chunk_op.new_chunk(
                [in_chunk],
                shape=index_chunk.shape + column_chunk.shape,
                index=index_chunk.index + column_chunk.index,
                dtypes=dtypes,
                index_value=index_value,
                columns_value=columns_value,
            )
        out_chunks.append(out_chunk)

    new_op = op.copy()
    if integral_index_on_column or integral_index_on_index:
        if integral_index_on_column:
            nsplits = tensor0.nsplits
        else:
            nsplits = tensor1.nsplits
        return new_op.new_seriess(
            op.inputs,
            out_val.shape,
            dtype=out_val.dtype,
            index_value=out_val.index_value,
            chunks=out_chunks,
            nsplits=nsplits,
        )
    else:
        nsplits = tensor0.nsplits + tensor1.nsplits
        return new_op.new_dataframes(
            op.inputs,
            out_val.shape,
            dtypes=out_val.dtypes,
            index_value=out_val.index_value,
            columns_value=out_val.columns_value,
            chunks=out_chunks,
            nsplits=nsplits,
        )