# Buggy code
def tile(cls, op):
    ctx = get_context()
    try:
        type_true = ctx.get_chunk_results([op.type_true.chunks[0].key])[0]
    except KeyError:
        raise TilesError("type_true needed to be executed first")

    y_true, y_pred = op.y_true, op.y_pred
    if type_true.item().startswith("multilabel"):
        differing_labels = mt.count_nonzero(y_true - y_pred, axis=1)
        score = mt.equal(differing_labels, 0)
    else:
        score = mt.equal(y_true, y_pred)

    result = _weighted_sum(score, op.sample_weight, op.normalize)
    return [recursive_tile(result)]


# Traceback (ValueError)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-52-f2912f2e33a0> in <module>
1 from mars.learn.metrics import accuracy_score
----> 2 accuracy_score(y_test,y_pred).execute()

/home/tops/lib/python3.6/site-packages/mars/learn/metrics/_classification.py in accuracy_score(y_true, y_pred, normalize, sample_weight, session, run_kwargs)
178     op = AccuracyScore(y_true=y_true, y_pred=y_pred, normalize=normalize,
179                        sample_weight=sample_weight)
--> 180     score = op(y_true, y_pred)
181     return score.execute(session=session, **(run_kwargs or dict()))

/home/tops/lib/python3.6/site-packages/mars/utils.py in _inner(*args, **kwargs)
455         def _inner(*args, **kwargs):
456             with self:
--> 457                 return func(*args, **kwargs)
458
459         return _inner

/home/tops/lib/python3.6/site-packages/mars/learn/metrics/_classification.py in __call__(self, y_true, y_pred)
76
77     def __call__(self, y_true, y_pred):
---> 78         type_true, y_true, y_pred = _check_targets(y_true, y_pred)
79         self._type_true = type_true
80         inputs = [y_true, y_pred, type_true]

/home/tops/lib/python3.6/site-packages/mars/learn/metrics/_check_targets.py in _check_targets(y_true, y_pred)
193     """
194     op = CheckTargets(y_true=y_true, y_pred=y_pred)
--> 195     return op(y_true, y_pred)

/home/tops/lib/python3.6/site-packages/mars/utils.py in _inner(*args, **kwargs)
455         def _inner(*args, **kwargs):
456             with self:
--> 457                 return func(*args, **kwargs)
458
459         return _inner

/home/tops/lib/python3.6/site-packages/mars/learn/metrics/_check_targets.py in __call__(self, y_true, y_pred)
82         if isinstance(y_pred, (Base, Entity)):
83             inputs.append(y_pred)
---> 84         self._type_true = type_of_target(y_true)
85         self._type_pred = type_of_target(y_pred)
86         inputs.extend([self._type_true, self._type_pred])

/home/tops/lib/python3.6/site-packages/mars/learn/utils/multiclass.py in type_of_target(y)
403
404     if not valid:
--> 405         raise ValueError(f'Expected array-like (array or non-string sequence), got {y}')
406
407     sparse_pandas = (y.__class__.__name__ in ['SparseSeries', 'SparseArray'])

ValueError: Expected array-like (array or non-string sequence), got 159615    0
134010    0
199100    0
137756    0
200050    0
..
219880    0
82326     0
184439    0
198518    0
109959    0
Name: label_bigint, Length: 1146788, dtype: int64

# Fixed code
def tile(cls, op):
    ctx = get_context()
    try:
        type_true = ctx.get_chunk_results([op.type_true.chunks[0].key])[0]
    except (KeyError, AttributeError):
        raise TilesError("type_true needed to be executed first")

    y_true, y_pred = op.y_true, op.y_pred
    if type_true.item().startswith("multilabel"):
        differing_labels = mt.count_nonzero(y_true - y_pred, axis=1)
        score = mt.equal(differing_labels, 0)
    else:
        score = mt.equal(y_true, y_pred)

    result = _weighted_sum(score, op.sample_weight, op.normalize)
    return [recursive_tile(result)]