# Buggy code
def tile(cls, op):
    check_chunks_unknown_shape(op.inputs, TilesError)

    tensor = astensor(op.input)
    chunk_size = get_nsplits(tensor, op.chunk_size, tensor.dtype.itemsize)
    if chunk_size == tensor.nsplits:
        return [tensor]

    new_chunk_size = op.chunk_size
    steps = plan_rechunks(
        op.inputs[0],
        new_chunk_size,
        op.inputs[0].dtype.itemsize,
        threshold=op.threshold,
        chunk_size_limit=op.chunk_size_limit,
    )
    tensor = op.outputs[0]
    for c in steps:
        tensor = compute_rechunk(tensor.inputs[0], c)

    if op.reassign_worker:
        for c in tensor.chunks:
            c.op._reassign_worker = True

    return [tensor]


# Traceback (ValueError)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/mars/scheduler/graph.py", line 411, in _execute_graph
self.prepare_graph(compose=compose)
File "/usr/local/lib/python3.6/dist-packages/mars/utils.py", line 383, in _wrapped
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/scheduler/graph.py", line 666, in prepare_graph
self._target_tileable_datas + fetch_tileables, tileable_graph)
File "/usr/local/lib/python3.6/dist-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 348, in build
tileables, tileable_graph=tileable_graph)
File "/usr/local/lib/python3.6/dist-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 262, in build
self._on_tile_failure(tileable_data.op, exc_info)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 301, in inner
raise exc_info[1].with_traceback(exc_info[2]) from None
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 242, in build
tiled = self._tile(tileable_data, tileable_graph)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 337, in _tile
return super()._tile(tileable_data, tileable_graph)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 203, in _tile
tds = on_tile(tileable_data.op.outputs, tds)
File "/usr/local/lib/python3.6/dist-packages/mars/scheduler/graph.py", line 648, in on_tile
return self.context.wraps(handler.dispatch)(first.op)
File "/usr/local/lib/python3.6/dist-packages/mars/context.py", line 72, in h
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 119, in dispatch
tiled = op_cls.tile(op)
File "/usr/local/lib/python3.6/dist-packages/mars/dataframe/window/rolling/aggregation.py", line 308, in tile
inp = cls._check_can_be_tiled(op, is_window_int)
File "/usr/local/lib/python3.6/dist-packages/mars/dataframe/window/rolling/aggregation.py", line 167, in _check_can_be_tiled
inp = inp.rechunk({1: inp.shape[1]})._inplace_tile()
File "/usr/local/lib/python3.6/dist-packages/mars/core.py", line 168, in _inplace_tile
return handler.inplace_tile(self)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 136, in inplace_tile
dispatched = self.dispatch(to_tile.op)
File "/usr/local/lib/python3.6/dist-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 119, in dispatch
tiled = op_cls.tile(op)
File "/usr/local/lib/python3.6/dist-packages/mars/dataframe/base/rechunk.py", line 82, in tile
out = compute_rechunk(out.inputs[0], c)
File "/usr/local/lib/python3.6/dist-packages/mars/dataframe/base/rechunk.py", line 176, in compute_rechunk
index_value, columns_value, dtypes = _concat_dataframe_meta(to_merge)
File "/usr/local/lib/python3.6/dist-packages/mars/dataframe/base/rechunk.py", line 112, in _concat_dataframe_meta
columns_value = merge_index_value(idx_to_columns_value, store_data=True)
File "/usr/local/lib/python3.6/dist-packages/mars/dataframe/utils.py", line 730, in merge_index_value
if min_val is None or min_val > chunk_index_value.min_val:
ValueError: invalid literal for int() with base 10: 'minus'

# Fixed code
def tile(cls, op):
    check_chunks_unknown_shape(op.inputs, TilesError)

    tensor = astensor(op.input)
    chunk_size = get_nsplits(tensor, op.chunk_size, tensor.dtype.itemsize)
    if chunk_size == tensor.nsplits:
        return [tensor]

    new_chunk_size = chunk_size
    steps = plan_rechunks(
        op.inputs[0],
        new_chunk_size,
        op.inputs[0].dtype.itemsize,
        threshold=op.threshold,
        chunk_size_limit=op.chunk_size_limit,
    )
    tensor = op.outputs[0]
    for c in steps:
        tensor = compute_rechunk(tensor.inputs[0], c)

    if op.reassign_worker:
        for c in tensor.chunks:
            c.op._reassign_worker = True

    return [tensor]