# Buggy code
def __call__(self, input_tensor, index, columns):
    if index is not None or columns is not None:
        if input_tensor.shape != (len(index), len(columns)):
            raise ValueError(
                "({0},{1}) should have the same shape with tensor: {2}".format(
                    index, columns, input_tensor.shape
                )
            )
    if input_tensor.ndim == 1:
        # convert to 1-d DataFrame
        index_value = parse_index(pd.RangeIndex(start=0, stop=input_tensor.shape[0]))
        columns_value = parse_index(pd.RangeIndex(start=0, stop=1))
    elif input_tensor.ndim != 2:
        raise ValueError("Must pass 1-d or 2-d input")
    else:
        # convert to DataFrame
        index_value = parse_index(pd.RangeIndex(start=0, stop=input_tensor.shape[0]))
        columns_value = parse_index(pd.RangeIndex(start=0, stop=input_tensor.shape[1]))

    # overwrite index_value and columns_value if user has set them
    if index is not None:
        index_value = parse_index(index, store_data=True)
    if columns is not None:
        columns_value = parse_index(columns, store_data=True)

    return self.new_dataframe(
        [input_tensor],
        input_tensor.shape,
        dtypes=self.dtypes,
        index_value=index_value,
        columns_value=columns_value,
    )


# Traceback (TypeError)
In [1]: import mars.dataframe as md

In [2]: import mars.tensor as mt

In [3]: df = md.DataFrame(mt.random.rand(10, 3), columns=list('abc'))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-8015891094de> in <module>
----> 1 df = md.DataFrame(mt.random.rand(10, 3), columns=list('abc'))

~/Workspace/mars/mars/dataframe/initializer.py in __init__(self, data, index, columns, dtype, copy, chunk_size, gpu, sparse)
29                  chunk_size=None, gpu=None, sparse=None):
30         if isinstance(data, TENSOR_TYPE):
---> 31             df = from_tensor(data, index=index, columns=columns, gpu=gpu, sparse=sparse)
32         elif isinstance(data, DATAFRAME_TYPE):
33             df = data

~/Workspace/mars/mars/dataframe/datasource/from_tensor.py in from_tensor(tensor, index, columns, gpu, sparse)
135     gpu = tensor.op.gpu if gpu is None else gpu
136     op = DataFrameFromTensor(dtypes=pd.Series([tensor.dtype] * col_num), gpu=gpu, sparse=sparse)
--> 137     return op(tensor, index, columns)

~/Workspace/mars/mars/dataframe/datasource/from_tensor.py in __call__(self, input_tensor, index, columns)
51     def __call__(self, input_tensor, index, columns):
52         if index is not None or columns is not None:
---> 53             if input_tensor.shape != (len(index), len(columns)):
54                 raise ValueError(
55                     '({0},{1}) should have the same shape with tensor: {2}'.format(index, columns, input_tensor.shape))

TypeError: object of type 'NoneType' has no len()

# Fixed code
def __call__(self, input_tensor, index, columns):
    if input_tensor.ndim != 1 and input_tensor.ndim != 2:
        raise ValueError("Must pass 1-d or 2-d input")

    if index is not None:
        if input_tensor.shape[0] != len(index):
            raise ValueError(
                "index {0} should have the same shape with tensor: {1}".format(
                    index, input_tensor.shape[0]
                )
            )
        if not isinstance(index, pd.Index):
            if isinstance(index, Base):
                raise NotImplementedError("The index value cannot be a tileable")
            index = pd.Index(index)
        index_value = parse_index(index, store_data=True)
    else:
        index_value = parse_index(pd.RangeIndex(start=0, stop=input_tensor.shape[0]))

    if columns is not None:
        if input_tensor.shape[1] != len(columns):
            raise ValueError(
                "columns {0} should have the same shape with tensor: {1}".format(
                    columns, input_tensor.shape[1]
                )
            )
        if not isinstance(columns, pd.Index):
            if isinstance(index, Base):
                raise NotImplementedError("The index value cannot be a tileable")
            columns = pd.Index(columns)
        columns_value = parse_index(columns, store_data=True)
    else:
        if input_tensor.ndim == 1:
            # convert to 1-d DataFrame
            columns_value = parse_index(pd.RangeIndex(start=0, stop=1), store_data=True)
        else:
            columns_value = parse_index(
                pd.RangeIndex(start=0, stop=input_tensor.shape[1]), store_data=True
            )

    return self.new_dataframe(
        [input_tensor],
        input_tensor.shape,
        dtypes=self.dtypes,
        index_value=index_value,
        columns_value=columns_value,
    )