# Buggy code
def _calc_properties(cls, x1, x2):
    dtypes = columns = index = None
    index_shape = column_shape = np.nan
    if x1.dtypes is not None and x2.dtypes is not None:
        dtypes = infer_dtypes(x1.dtypes, x2.dtypes, cls._operator)
        column_shape = len(dtypes)
        columns = parse_index(dtypes.index, store_data=True)
        columns.value.should_be_monotonic = True
    if x1.index_value is not None and x2.index_value is not None:
        index = infer_index_value(x1.index_value, x2.index_value, cls._operator)
        index.value.should_be_monotonic = True
        if index.key == x1.index_value.key == x2.index_value.key and (
            not np.isnan(x1.shape[0]) or not np.isnan(x2.shape[0])
        ):
            index_shape = x1.shape[0] if not np.isnan(x1.shape[0]) else x2.shape[0]

    return {
        "shape": (index_shape, column_shape),
        "dtypes": dtypes,
        "columns_value": columns,
        "index_value": index,
    }


# Traceback (KeyError)
Traceback (most recent call last):
File "/Users/hetao/mars/mars/tiles.py", line 111, in _dispatch
handler = self._handlers[op_cls]
KeyError: <class 'mars.dataframe.expressions.arithmetic.add.DataFrameAdd'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/hetao/mars/mars/core.py", line 554, in execute
return session.run(self, **kw)
File "/Users/hetao/mars/mars/session.py", line 115, in run
result = self._sess.run(*tileables, **kw)
File "/Users/hetao/mars/mars/session.py", line 56, in run
res = self._executor.execute_tileables(tileables, **kw)
File "/Users/hetao/mars/mars/utils.py", line 364, in _wrapped
return func(*args, **kwargs)
File "/Users/hetao/mars/mars/executor.py", line 499, in execute_tileables
tileable.tiles()
File "/Users/hetao/mars/mars/core.py", line 474, in tiles
return handler.tiles(self)
File "/Users/hetao/mars/mars/tiles.py", line 174, in tiles
tiled = self._dispatch(node.op)
File "/Users/hetao/mars/mars/utils.py", line 364, in _wrapped
return func(*args, **kwargs)
File "/Users/hetao/mars/mars/tiles.py", line 116, in _dispatch
return op_cls.tile(op)
File "/Users/hetao/mars/mars/dataframe/expressions/arithmetic/core.py", line 527, in tile
return cls._tile_both_dataframes(op)
File "/Users/hetao/mars/mars/dataframe/expressions/arithmetic/core.py", line 516, in _tile_both_dataframes
out_chunks = cls._gen_out_chunks_with_all_shuffle(op, out_shape, left, right)
File "/Users/hetao/mars/mars/dataframe/expressions/arithmetic/core.py", line 461, in _gen_out_chunks_with_all_shuffle
reduce_op.new_chunk([proxy_chunk], shape=(np.nan, np.nan), index=out_idx))
File "/Users/hetao/mars/mars/core.py", line 650, in new_chunk
return self.new_chunks(inputs, kws=kws, **kw)[0]
File "/Users/hetao/mars/mars/core.py", line 644, in new_chunks
return self._new_chunks(inputs, kws=kws, **kwargs)
File "/Users/hetao/mars/mars/core.py", line 618, in _new_chunks
chunk = self._create_chunk(j, index, **create_chunk_kw)
File "/Users/hetao/mars/mars/dataframe/expressions/arithmetic/core.py", line 188, in _create_chunk
all_dtypes = [c.op.column_shuffle_segments[index[1]] for c in index_align_map_chunks
File "/Users/hetao/mars/mars/dataframe/expressions/arithmetic/core.py", line 189, in <listcomp>
if c.index[0] == index_align_map_chunks[0].index[0]]
IndexError: list index out of range


# Fixed code
def _calc_properties(cls, x1, x2):
    dtypes = columns = index = None
    index_shape = column_shape = np.nan

    if x1.columns.key == x2.columns.key:
        dtypes = x1.dtypes
        column_shape = len(dtypes)
        columns = copy.copy(x1.columns)
        columns.value.should_be_monotonic = True
    elif x1.dtypes is not None and x2.dtypes is not None:
        dtypes = infer_dtypes(x1.dtypes, x2.dtypes, cls._operator)
        column_shape = len(dtypes)
        columns = parse_index(dtypes.index, store_data=True)
        columns.value.should_be_monotonic = True

    if x1.index_value.key == x2.index_value.key:
        index = copy.copy(x1.index_value)
        index.value.should_be_monotonic = True
        index_shape = x1.shape[0]
    elif x1.index_value is not None and x2.index_value is not None:
        index = infer_index_value(x1.index_value, x2.index_value, cls._operator)
        index.value.should_be_monotonic = True
        if index.key == x1.index_value.key == x2.index_value.key and (
            not np.isnan(x1.shape[0]) or not np.isnan(x2.shape[0])
        ):
            index_shape = x1.shape[0] if not np.isnan(x1.shape[0]) else x2.shape[0]

    return {
        "shape": (index_shape, column_shape),
        "dtypes": dtypes,
        "columns_value": columns,
        "index_value": index,
    }