# Buggy code
def tile(cls, op):
    from ..datasource import arange

    in_tensor = op.input

    flattened = in_tensor.astype(bool).flatten()
    recursive_tile(flattened)
    indices = arange(flattened.size, dtype=np.intp, chunk_size=flattened.nsplits)
    indices = indices[flattened]
    dim_indices = unravel_index(indices, in_tensor.shape)
    [recursive_tile(ind) for ind in dim_indices]

    kws = [
        {"nsplits": ind.nsplits, "chunks": ind.chunks, "shape": o.shape}
        for ind, o in zip(dim_indices, op.outputs)
    ]
    new_op = op.copy()
    return new_op.new_tensors(op.inputs, kws=kws, output_limit=len(kws))


# Traceback (TypeError)
runfile('C:/Users/Lenovo/Desktop/test/mars/test.py', wdir='C:/Users/Lenovo/Desktop/test/mars')
Traceback (most recent call last):

File "C:\Users\Lenovo\Desktop\test\mars\test.py", line 25, in <module>
sess.run(mt.where( x > 5 ))

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\session.py", line 183, in run
result = self._sess.run(*tileables, **kw)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\session.py", line 90, in run
res = self._executor.execute_tileables(tileables, **kw)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\utils.py", line 392, in _wrapped
return func(*args, **kwargs)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\utils.py", line 480, in inner
return func(*args, **kwargs)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\executor.py", line 745, in execute_tileables
tileables, tileable_graph=tileable_graph)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\utils.py", line 392, in _wrapped
return func(*args, **kwargs)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\utils.py", line 480, in inner
return func(*args, **kwargs)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\tiles.py", line 342, in build
tileables, tileable_graph=tileable_graph)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\utils.py", line 392, in _wrapped
return func(*args, **kwargs)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\utils.py", line 480, in inner
return func(*args, **kwargs)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\tiles.py", line 256, in build
self._on_tile_failure(tileable_data.op, exc_info)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\tiles.py", line 294, in inner
six.reraise(*exc_info)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\lib\six.py", line 703, in reraise
raise value

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\tiles.py", line 236, in build
tiled = self._tile(tileable_data, tileable_graph)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\tiles.py", line 330, in _tile
return super(IterativeChunkGraphBuilder, self)._tile(tileable_data, tileable_graph)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\tiles.py", line 194, in _tile
tds[0]._inplace_tile()

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\core.py", line 162, in _inplace_tile
return handler.inplace_tile(self)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\tiles.py", line 128, in inplace_tile
dispatched = self.dispatch(to_tile.op)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\utils.py", line 392, in _wrapped
return func(*args, **kwargs)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\tiles.py", line 116, in dispatch
return op_cls.tile(op)

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\tensor\indexing\nonzero.py", line 52, in tile
flattened = in_tensor.astype(bool).flatten()

File "D:\ProgramData\Anaconda3\lib\site-packages\mars\tensor\base\astype.py", line 146, in _astype
return tensor if not copy else tensor.copy(order=order)

TypeError: copy() got an unexpected keyword argument 'order'

# Fixed code
def tile(cls, op):
    from ..datasource import arange

    in_tensor = astensor(op.input)

    flattened = in_tensor.astype(bool).flatten()
    recursive_tile(flattened)
    indices = arange(flattened.size, dtype=np.intp, chunk_size=flattened.nsplits)
    indices = indices[flattened]
    dim_indices = unravel_index(indices, in_tensor.shape)
    [recursive_tile(ind) for ind in dim_indices]

    kws = [
        {"nsplits": ind.nsplits, "chunks": ind.chunks, "shape": o.shape}
        for ind, o in zip(dim_indices, op.outputs)
    ]
    new_op = op.copy()
    return new_op.new_tensors(op.inputs, kws=kws, output_limit=len(kws))