#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 1999-2018 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

import numpy as np
import scipy.sparse as sps

from mars.tensor.execution.core import Executor
from mars import tensor as mt
from mars.tensor.expressions.datasource import tensor, ones, zeros, arange
from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, \
    expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, \
    hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, \
    flip, flipud, fliplr, repeat, tile, isin
from mars.tensor.expressions.merge import stack
from mars.tensor.expressions.reduction import all as tall


class Test(unittest.TestCase):
    def setUp(self):
        self.executor = Executor('numpy')

    def testRechunkExecution(self):
        raw = np.random.random((11, 8))
        arr = tensor(raw, chunks=3)
        arr2 = arr.rechunk(4)

        res = self.executor.execute_tensor(arr2)

        self.assertTrue(np.array_equal(res[0], raw[:4, :4]))
        self.assertTrue(np.array_equal(res[1], raw[:4, 4:]))
        self.assertTrue(np.array_equal(res[2], raw[4:8, :4]))
        self.assertTrue(np.array_equal(res[3], raw[4:8, 4:]))
        self.assertTrue(np.array_equal(res[4], raw[8:, :4]))
        self.assertTrue(np.array_equal(res[5], raw[8:, 4:]))

    def testCopytoExecution(self):
        a = ones((2, 3), chunks=1)
        b = tensor([3, -1, 3], chunks=2)

        copyto(a, b, where=b > 1)

        res = self.executor.execute_tensor(a, concat=True)[0]
        expected = np.array([[3, 1, 3], [3, 1, 3]])

        np.testing.assert_equal(res, expected)

    def testAstypeExecution(self):
        raw = np.random.random((10, 5))
        arr = tensor(raw, chunks=3)
        arr2 = arr.astype('i8')

        res = self.executor.execute_tensor(arr2, concat=True)
        self.assertTrue(np.array_equal(res[0], raw.astype('i8')))

        raw = sps.random(10, 5, density=.2)
        arr = tensor(raw, chunks=3)
        arr2 = arr.astype('i8')

        res = self.executor.execute_tensor(arr2, concat=True)
        self.assertTrue(np.array_equal(res[0].toarray(), raw.astype('i8').toarray()))

    def testTransposeExecution(self):
        raw = np.random.random((11, 8, 5))
        arr = tensor(raw, chunks=3)
        arr2 = transpose(arr)

        res = self.executor.execute_tensor(arr2, concat=True)

        self.assertTrue(np.array_equal(res[0], raw.T))

        arr3 = transpose(arr, axes=(-2, -1, -3))

        res = self.executor.execute_tensor(arr3, concat=True)

        self.assertTrue(np.array_equal(res[0], raw.transpose(1, 2, 0)))

        raw = sps.random(11, 8)
        arr = tensor(raw, chunks=3)
        arr2 = transpose(arr)

        self.assertTrue(arr2.issparse())

        res = self.executor.execute_tensor(arr2, concat=True)

        self.assertTrue(np.array_equal(res[0].toarray(), raw.T.toarray()))

    def testSwapaxesExecution(self):
        raw = np.random.random((11, 8, 5))
        arr = tensor(raw, chunks=3)
        arr2 = arr.swapaxes(2, 0)

        res = self.executor.execute_tensor(arr2, concat=True)

        self.assertTrue(np.array_equal(res[0], raw.swapaxes(2, 0)))

        raw = sps.random(11, 8, density=.2)
        arr = tensor(raw, chunks=3)
        arr2 = arr.swapaxes(1, 0)

        res = self.executor.execute_tensor(arr2, concat=True)

        self.assertTrue(np.array_equal(res[0].toarray(), raw.toarray().swapaxes(1, 0)))

    def testMoveaxisExecution(self):
        x = zeros((3, 4, 5), chunks=2)

        t = moveaxis(x, 0, -1)

        res = self.executor.execute_tensor(t, concat=True)[0]
        self.assertEqual(res.shape, (4, 5, 3))

        t = moveaxis(x, -1, 0)

        res = self.executor.execute_tensor(t, concat=True)[0]
        self.assertEqual(res.shape, (5, 3, 4))

        t = moveaxis(x, [0, 1], [-1, -2])

        res = self.executor.execute_tensor(t, concat=True)[0]
        self.assertEqual(res.shape, (5, 4, 3))

        t = moveaxis(x, [0, 1, 2], [-1, -2, -3])

        res = self.executor.execute_tensor(t, concat=True)[0]
        self.assertEqual(res.shape, (5, 4, 3))

    def testBroadcastToExecution(self):
        raw = np.random.random((10, 5, 1))
        arr = tensor(raw, chunks=2)
        arr2 = broadcast_to(arr, (5, 10, 5, 6))

        res = self.executor.execute_tensor(arr2, concat=True)

        self.assertTrue(np.array_equal(res[0], np.broadcast_to(raw, (5, 10, 5, 6))))

    def testBroadcastArraysExecutions(self):
        x_data = [[1, 2, 3]]
        x = tensor(x_data, chunks=1)
        y_data = [[1], [2], [3]]
        y = tensor(y_data, chunks=2)

        a = broadcast_arrays(x, y)

        res = [self.executor.execute_tensor(arr, concat=True)[0] for arr in a]
        expected = np.broadcast_arrays(x_data, y_data)

        for r, e in zip(res, expected):
            np.testing.assert_equal(r, e)

    def testWhereExecution(self):
        raw_cond = np.random.randint(0, 2, size=(4, 4), dtype='?')
        raw_x = np.random.rand(4, 1)
        raw_y = np.random.rand(4, 4)

        cond, x, y = tensor(raw_cond, chunks=2), tensor(raw_x, chunks=2), tensor(raw_y, chunks=2)

        arr = where(cond, x, y)
        res = self.executor.execute_tensor(arr, concat=True)
        self.assertTrue(np.array_equal(res[0], np.where(raw_cond, raw_x, raw_y)))

        raw_cond = sps.csr_matrix(np.random.randint(0, 2, size=(4, 4), dtype='?'))
        raw_x = sps.random(4, 1, density=.1)
        raw_y = sps.random(4, 4, density=.1)

        cond, x, y = tensor(raw_cond, chunks=2), tensor(raw_x, chunks=2), tensor(raw_y, chunks=2)

        arr = where(cond, x, y)
        res = self.executor.execute_tensor(arr, concat=True)[0]
        self.assertTrue(np.array_equal(res.toarray(),
                                       np.where(raw_cond.toarray(), raw_x.toarray(), raw_y.toarray())))

    def testReshapeExecution(self):
        raw_data = np.random.rand(10, 20, 30)
        x = tensor(raw_data, chunks=6)

        y = x.reshape(-1, 30)

        res = self.executor.execute_tensor(y, concat=True)
        self.assertTrue(np.array_equal(res[0], raw_data.reshape(-1, 30)))

        y2 = x.reshape(10, -1)

        res = self.executor.execute_tensor(y2, concat=True)
        self.assertTrue(np.array_equal(res[0], raw_data.reshape(10, -1)))

        y3 = x.reshape(-1)

        res = self.executor.execute_tensor(y3, concat=True)
        self.assertTrue(np.array_equal(res[0], raw_data.reshape(-1)))

        y4 = x.ravel()

        res = self.executor.execute_tensor(y4, concat=True)
        self.assertTrue(np.array_equal(res[0], raw_data.ravel()))

        raw_data = np.random.rand(30, 100, 20)
        x = tensor(raw_data, chunks=6)

        y = x.reshape(-1, 20, 5, 5, 4)

        res = self.executor.execute_tensor(y, concat=True)
        self.assertTrue(np.array_equal(res[0], raw_data.reshape(-1, 20, 5, 5, 4)))

        y2 = x.reshape(3000, 10, 2)

        res = self.executor.execute_tensor(y2, concat=True)
        self.assertTrue(np.array_equal(res[0], raw_data.reshape(3000, 10, 2)))

        y3 = x.reshape(60, 25, 40)

        res = self.executor.execute_tensor(y3, concat=True)
        self.assertTrue(np.array_equal(res[0], raw_data.reshape(60, 25, 40)))

    def testExpandDimsExecution(self):
        raw_data = np.random.rand(10, 20, 30)
        x = tensor(raw_data, chunks=6)

        y = expand_dims(x, 1)

        res = self.executor.execute_tensor(y, concat=True)
        self.assertTrue(np.array_equal(res[0], np.expand_dims(raw_data, 1)))

        y = expand_dims(x, 0)

        res = self.executor.execute_tensor(y, concat=True)
        self.assertTrue(np.array_equal(res[0], np.expand_dims(raw_data, 0)))

        y = expand_dims(x, 3)

        res = self.executor.execute_tensor(y, concat=True)
        self.assertTrue(np.array_equal(res[0], np.expand_dims(raw_data, 3)))

        y = expand_dims(x, -1)

        res = self.executor.execute_tensor(y, concat=True)
        self.assertTrue(np.array_equal(res[0], np.expand_dims(raw_data, -1)))

        y = expand_dims(x, -4)

        res = self.executor.execute_tensor(y, concat=True)
        self.assertTrue(np.array_equal(res[0], np.expand_dims(raw_data, -4)))

        with self.assertRaises(np.AxisError):
            expand_dims(x, -5)

        with self.assertRaises(np.AxisError):
            expand_dims(x, 4)

    def testRollAxisExecution(self):
        x = ones((3, 4, 5, 6), chunks=1)
        y = rollaxis(x, 3, 1)

        res = self.executor.execute_tensor(y, concat=True)
        self.assertTrue(np.array_equal(res[0], np.rollaxis(np.ones((3, 4, 5, 6)), 3, 1)))

    def testAtleast1dExecution(self):
        x = 1
        y = ones(3, chunks=2)
        z = ones((3, 4), chunks=2)

        t = atleast_1d(x, y, z)

        res = [self.executor.execute_tensor(i, concat=True)[0] for i in t]

        self.assertTrue(np.array_equal(res[0], np.array([1])))
        self.assertTrue(np.array_equal(res[1], np.ones(3)))
        self.assertTrue(np.array_equal(res[2], np.ones((3, 4))))

    def testAtleast2dExecution(self):
        x = 1
        y = ones(3, chunks=2)
        z = ones((3, 4), chunks=2)

        t = atleast_2d(x, y, z)

        res = [self.executor.execute_tensor(i, concat=True)[0] for i in t]

        self.assertTrue(np.array_equal(res[0], np.array([[1]])))
        self.assertTrue(np.array_equal(res[1], np.atleast_2d(np.ones(3))))
        self.assertTrue(np.array_equal(res[2], np.ones((3, 4))))

    def testAtleast3dExecution(self):
        x = 1
        y = ones(3, chunks=2)
        z = ones((3, 4), chunks=2)

        t = atleast_3d(x, y, z)

        res = [self.executor.execute_tensor(i, concat=True)[0] for i in t]

        self.assertTrue(np.array_equal(res[0], np.atleast_3d(x)))
        self.assertTrue(np.array_equal(res[1], np.atleast_3d(np.ones(3))))
        self.assertTrue(np.array_equal(res[2], np.atleast_3d(np.ones((3, 4)))))

    def testArgwhereExecution(self):
        x = arange(6, chunks=2).reshape(2, 3)
        t = argwhere(x > 1)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.argwhere(np.arange(6).reshape(2, 3) > 1)

        self.assertTrue(np.array_equal(res, expected))

    def testArraySplitExecution(self):
        x = arange(48, chunks=3).reshape(2, 3, 8)
        ss = array_split(x, 3, axis=2)

        res = [self.executor.execute_tensor(i, concat=True)[0] for i in ss]
        expected = np.array_split(np.arange(48).reshape(2, 3, 8), 3, axis=2)
        self.assertEqual(len(res), len(expected))
        [np.testing.assert_equal(r, e) for r, e in zip(res, expected)]

        ss = array_split(x, [3, 5, 6, 10], axis=2)

        res = [self.executor.execute_tensor(i, concat=True)[0] for i in ss]
        expected = np.array_split(np.arange(48).reshape(2, 3, 8), [3, 5, 6, 10], axis=2)
        self.assertEqual(len(res), len(expected))
        [np.testing.assert_equal(r, e) for r, e in zip(res, expected)]

    def testSplitExecution(self):
        x = arange(48, chunks=3).reshape(2, 3, 8)
        ss = split(x, 4, axis=2)

        res = [self.executor.execute_tensor(i, concat=True)[0] for i in ss]
        expected = np.split(np.arange(48).reshape(2, 3, 8), 4, axis=2)
        self.assertEqual(len(res), len(expected))
        [np.testing.assert_equal(r, e) for r, e in zip(res, expected)]

        ss = split(x, [3, 5, 6, 10], axis=2)

        res = [self.executor.execute_tensor(i, concat=True)[0] for i in ss]
        expected = np.split(np.arange(48).reshape(2, 3, 8), [3, 5, 6, 10], axis=2)
        self.assertEqual(len(res), len(expected))
        [np.testing.assert_equal(r, e) for r, e in zip(res, expected)]

        # hsplit
        x = arange(120, chunks=3).reshape(2, 12, 5)
        ss = hsplit(x, 4)

        res = [self.executor.execute_tensor(i, concat=True)[0] for i in ss]
        expected = np.hsplit(np.arange(120).reshape(2, 12, 5), 4)
        self.assertEqual(len(res), len(expected))
        [np.testing.assert_equal(r, e) for r, e in zip(res, expected)]

        # vsplit
        x = arange(48, chunks=3).reshape(8, 3, 2)
        ss = vsplit(x, 4)

        res = [self.executor.execute_tensor(i, concat=True)[0] for i in ss]
        expected = np.vsplit(np.arange(48).reshape(8, 3, 2), 4)
        self.assertEqual(len(res), len(expected))
        [np.testing.assert_equal(r, e) for r, e in zip(res, expected)]

        # dsplit
        x = arange(48, chunks=3).reshape(2, 3, 8)
        ss = dsplit(x, 4)

        res = [self.executor.execute_tensor(i, concat=True)[0] for i in ss]
        expected = np.dsplit(np.arange(48).reshape(2, 3, 8), 4)
        self.assertEqual(len(res), len(expected))
        [np.testing.assert_equal(r, e) for r, e in zip(res, expected)]

        x_data = sps.random(12, 8, density=.1)
        x = tensor(x_data, chunks=3)
        ss = split(x, 4, axis=0)

        res = [self.executor.execute_tensor(i, concat=True)[0] for i in ss]
        expected = np.split(x_data.toarray(), 4, axis=0)
        self.assertEqual(len(res), len(expected))
        [np.testing.assert_equal(r.toarray(), e) for r, e in zip(res, expected)]

    def testRollExecution(self):
        x = arange(10, chunks=2)

        t = roll(x, 2)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.roll(np.arange(10), 2)
        np.testing.assert_equal(res, expected)

        x2 = x.reshape(2, 5)

        t = roll(x2, 1)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.roll(np.arange(10).reshape(2, 5), 1)
        np.testing.assert_equal(res, expected)

        t = roll(x2, 1, axis=0)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.roll(np.arange(10).reshape(2, 5), 1, axis=0)
        np.testing.assert_equal(res, expected)

        t = roll(x2, 1, axis=1)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.roll(np.arange(10).reshape(2, 5), 1, axis=1)
        np.testing.assert_equal(res, expected)

    def testSqueezeExecution(self):
        data = np.array([[[0], [1], [2]]])
        x = tensor(data, chunks=1)

        t = squeeze(x)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.squeeze(data)
        np.testing.assert_equal(res, expected)

        t = squeeze(x, axis=2)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.squeeze(data, axis=2)
        np.testing.assert_equal(res, expected)

    def testPtpExecution(self):
        x = arange(4, chunks=1).reshape(2, 2)

        t = ptp(x, axis=0)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.ptp(np.arange(4).reshape(2, 2), axis=0)
        np.testing.assert_equal(res, expected)

        t = ptp(x, axis=1)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.ptp(np.arange(4).reshape(2, 2), axis=1)
        np.testing.assert_equal(res, expected)

        t = ptp(x)

        res = self.executor.execute_tensor(t)[0]
        expected = np.ptp(np.arange(4).reshape(2, 2))
        np.testing.assert_equal(res, expected)

    def testDiffExecution(self):
        data = np.array([1, 2, 4, 7, 0])
        x = tensor(data, chunks=2)

        t = diff(x)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.diff(data)
        np.testing.assert_equal(res, expected)

        t = diff(x, n=2)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.diff(data, n=2)
        np.testing.assert_equal(res, expected)

        data = np.array([[1, 3, 6, 10], [0, 5, 6, 8]])
        x = tensor(data, chunks=2)

        t = diff(x)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.diff(data)
        np.testing.assert_equal(res, expected)

        t = diff(x, axis=0)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.diff(data, axis=0)
        np.testing.assert_equal(res, expected)

        x = mt.arange('1066-10-13', '1066-10-16', dtype=mt.datetime64)
        t = diff(x)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.diff(np.arange('1066-10-13', '1066-10-16', dtype=np.datetime64))
        np.testing.assert_equal(res, expected)

    def testEdiff1d(self):
        data = np.array([1, 2, 4, 7, 0])
        x = tensor(data, chunks=2)

        t = ediff1d(x)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.ediff1d(data)
        np.testing.assert_equal(res, expected)

        to_begin = tensor(-99, chunks=2)
        to_end = tensor([88, 99], chunks=2)
        t = ediff1d(x, to_begin=to_begin, to_end=to_end)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.ediff1d(data, to_begin=-99, to_end=np.array([88, 99]))
        np.testing.assert_equal(res, expected)

        data = [[1, 2, 4], [1, 6, 24]]

        t = ediff1d(tensor(data, chunks=2))

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.ediff1d(data)
        np.testing.assert_equal(res, expected)

    def testDigitizeExecution(self):
        data = np.array([0.2, 6.4, 3.0, 1.6])
        x = tensor(data, chunks=2)
        bins = np.array([0.0, 1.0, 2.5, 4.0, 10.0])
        inds = digitize(x, bins)

        res = self.executor.execute_tensor(inds, concat=True)[0]
        expected = np.digitize(data, bins)
        np.testing.assert_equal(res, expected)

        b = tensor(bins, chunks=2)
        inds = digitize(x, b)

        res = self.executor.execute_tensor(inds, concat=True)[0]
        expected = np.digitize(data, bins)
        np.testing.assert_equal(res, expected)

        data = np.array([1.2, 10.0, 12.4, 15.5, 20.])
        x = tensor(data, chunks=2)
        bins = np.array([0, 5, 10, 15, 20])
        inds = digitize(x, bins, right=True)

        res = self.executor.execute_tensor(inds, concat=True)[0]
        expected = np.digitize(data, bins, right=True)
        np.testing.assert_equal(res, expected)

        inds = digitize(x, bins, right=False)

        res = self.executor.execute_tensor(inds, concat=True)[0]
        expected = np.digitize(data, bins, right=False)
        np.testing.assert_equal(res, expected)

        data = sps.random(10, 1, density=.1) * 12
        x = tensor(data, chunks=2)
        bins = np.array([1.0, 2.0, 2.5, 4.0, 10.0])
        inds = digitize(x, bins)

        res = self.executor.execute_tensor(inds, concat=True)[0]
        expected = np.digitize(data.toarray(), bins, right=False)
        np.testing.assert_equal(res.toarray(), expected)

    def testAverageExecution(self):
        data = arange(1, 5, chunks=1)
        t = average(data)

        res = self.executor.execute_tensor(t)[0]
        expected = np.average(np.arange(1, 5))
        self.assertEqual(res, expected)

        t = average(arange(1, 11, chunks=2), weights=arange(10, 0, -1, chunks=2))

        res = self.executor.execute_tensor(t)[0]
        expected = np.average(range(1, 11), weights=range(10, 0, -1))
        self.assertEqual(res, expected)

        data = arange(6, chunks=2).reshape((3, 2))
        t = average(data, axis=1, weights=tensor([1./4, 3./4], chunks=2))

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.average(np.arange(6).reshape(3, 2), axis=1, weights=(1./4, 3./4))
        np.testing.assert_equal(res, expected)

        with self.assertRaises(TypeError):
            average(data, weights=tensor([1./4, 3./4], chunks=2))

    def testCovExecution(self):
        data = np.array([[0, 2], [1, 1], [2, 0]]).T
        x = tensor(data, chunks=1)

        t = cov(x)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.cov(data)
        np.testing.assert_equal(res, expected)

        data_x = [-2.1, -1, 4.3]
        data_y = [3,  1.1,  0.12]
        x = tensor(data_x, chunks=1)
        y = tensor(data_y, chunks=1)

        X = stack((x, y), axis=0)
        t = cov(x, y)
        r = tall(t == cov(X))
        self.assertTrue(self.executor.execute_tensor(r)[0])

    def testCorrcoefExecution(self):
        data_x = [-2.1, -1, 4.3]
        data_y = [3, 1.1, 0.12]
        x = tensor(data_x, chunks=1)
        y = tensor(data_y, chunks=1)

        t = corrcoef(x, y)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.corrcoef(data_x, data_y)
        np.testing.assert_equal(res, expected)

    def testFlipExecution(self):
        a = arange(8, chunks=2).reshape((2, 2, 2))

        t = flip(a, 0)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.flip(np.arange(8).reshape(2, 2, 2), 0)
        np.testing.assert_equal(res, expected)

        t = flip(a, 1)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.flip(np.arange(8).reshape(2, 2, 2), 1)
        np.testing.assert_equal(res, expected)

        t = flipud(a)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.flipud(np.arange(8).reshape(2, 2, 2))
        np.testing.assert_equal(res, expected)

        t = fliplr(a)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.fliplr(np.arange(8).reshape(2, 2, 2))
        np.testing.assert_equal(res, expected)

    def testRepeatExecution(self):
        a = repeat(3, 4)

        res = self.executor.execute_tensor(a)[0]
        expected = np.repeat(3, 4)
        np.testing.assert_equal(res, expected)

        x_data = np.random.randn(20, 30)
        x = tensor(x_data, chunks=(3, 4))

        t = repeat(x, 2)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.repeat(x_data, 2)
        np.testing.assert_equal(res, expected)

        t = repeat(x, 3, axis=1)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.repeat(x_data, 3, axis=1)
        np.testing.assert_equal(res, expected)

        t = repeat(x, np.arange(20), axis=0)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.repeat(x_data, np.arange(20), axis=0)
        np.testing.assert_equal(res, expected)

        t = repeat(x, arange(20, chunks=5), axis=0)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.repeat(x_data, np.arange(20), axis=0)
        np.testing.assert_equal(res, expected)

        x_data = sps.random(20, 30, density=.1)
        x = tensor(x_data, chunks=(3, 4))

        t = repeat(x, 2, axis=1)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.repeat(x_data.toarray(), 2, axis=1)
        np.testing.assert_equal(res.toarray(), expected)

    def testTileExecution(self):
        a_data = np.array([0, 1, 2])
        a = tensor(a_data, chunks=2)

        t = tile(a, 2)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.tile(a_data, 2)
        np.testing.assert_equal(res, expected)

        t = tile(a, (2, 2))

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.tile(a_data, (2, 2))
        np.testing.assert_equal(res, expected)

        t = tile(a, (2, 1, 2))

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.tile(a_data, (2, 1, 2))
        np.testing.assert_equal(res, expected)

        b_data = np.array([[1, 2], [3, 4]])
        b = tensor(b_data, chunks=1)

        t = tile(b, 2)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.tile(b_data, 2)
        np.testing.assert_equal(res, expected)

        t = tile(b, (2, 1))

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.tile(b_data, (2, 1))
        np.testing.assert_equal(res, expected)

        c_data = np.array([1, 2, 3, 4])
        c = tensor(c_data, chunks=3)

        t = tile(c, (4, 1))

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.tile(c_data, (4, 1))
        np.testing.assert_equal(res, expected)

    def testIsInExecution(self):
        element = 2 * arange(4, chunks=1).reshape((2, 2))
        test_elements = [1, 2, 4, 8]

        mask = isin(element, test_elements)

        res = self.executor.execute_tensor(mask, concat=True)[0]
        expected = np.isin(2 * np.arange(4).reshape((2, 2)), test_elements)
        np.testing.assert_equal(res, expected)

        res = self.executor.execute_tensor(element[mask], concat=True)[0]
        expected = np.array([2, 4])
        np.testing.assert_equal(res, expected)

        mask = isin(element, test_elements, invert=True)

        res = self.executor.execute_tensor(mask, concat=True)[0]
        expected = np.isin(2 * np.arange(4).reshape((2, 2)), test_elements, invert=True)
        np.testing.assert_equal(res, expected)

        res = self.executor.execute_tensor(element[mask], concat=True)[0]
        expected = np.array([0, 6])
        np.testing.assert_equal(res, expected)

        test_set = {1, 2, 4, 8}
        mask = isin(element, test_set)

        res = self.executor.execute_tensor(mask, concat=True)[0]
        expected = np.isin(2 * np.arange(4).reshape((2, 2)), test_set)
        np.testing.assert_equal(res, expected)

[(35, 'mars.tensor.execution.core.Executor', 'Executor', False, 'from mars.tensor.execution.core import Executor\n'), (38, 'numpy.random.random', 'np.random.random', True, 'import numpy as np\n'), (39, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (52, 'mars.tensor.expressions.datasource.ones', 'ones', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (53, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (55, 'mars.tensor.expressions.base.copyto', 'copyto', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (58, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (60, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (63, 'numpy.random.random', 'np.random.random', True, 'import numpy as np\n'), (64, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (70, 'scipy.sparse.random', 'sps.random', True, 'import scipy.sparse as sps\n'), (71, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (78, 'numpy.random.random', 'np.random.random', True, 'import numpy as np\n'), (79, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (80, 'mars.tensor.expressions.base.transpose', 'transpose', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (86, 'mars.tensor.expressions.base.transpose', 'transpose', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (92, 'scipy.sparse.random', 'sps.random', True, 'import scipy.sparse as sps\n'), (93, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (94, 'mars.tensor.expressions.base.transpose', 'transpose', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (103, 'numpy.random.random', 'np.random.random', True, 'import numpy as np\n'), (104, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (111, 'scipy.sparse.random', 'sps.random', True, 'import scipy.sparse as sps\n'), (112, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (120, 'mars.tensor.expressions.datasource.zeros', 'zeros', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (122, 'mars.tensor.expressions.base.moveaxis', 'moveaxis', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (127, 'mars.tensor.expressions.base.moveaxis', 'moveaxis', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (132, 'mars.tensor.expressions.base.moveaxis', 'moveaxis', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (137, 'mars.tensor.expressions.base.moveaxis', 'moveaxis', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (143, 'numpy.random.random', 'np.random.random', True, 'import numpy as np\n'), (144, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (145, 'mars.tensor.expressions.base.broadcast_to', 'broadcast_to', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (153, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (155, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (157, 'mars.tensor.expressions.base.broadcast_arrays', 'broadcast_arrays', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (160, 'numpy.broadcast_arrays', 'np.broadcast_arrays', True, 'import numpy as np\n'), (166, 'numpy.random.randint', 'np.random.randint', True, 'import numpy as np\n'), (167, 'numpy.random.rand', 'np.random.rand', True, 'import numpy as np\n'), (168, 'numpy.random.rand', 'np.random.rand', True, 'import numpy as np\n'), (172, 'mars.tensor.expressions.base.where', 'where', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (177, 'scipy.sparse.random', 'sps.random', True, 'import scipy.sparse as sps\n'), (178, 'scipy.sparse.random', 'sps.random', True, 'import scipy.sparse as sps\n'), (182, 'mars.tensor.expressions.base.where', 'where', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (188, 'numpy.random.rand', 'np.random.rand', True, 'import numpy as np\n'), (189, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (211, 'numpy.random.rand', 'np.random.rand', True, 'import numpy as np\n'), (212, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (230, 'numpy.random.rand', 'np.random.rand', True, 'import numpy as np\n'), (231, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (233, 'mars.tensor.expressions.base.expand_dims', 'expand_dims', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (238, 'mars.tensor.expressions.base.expand_dims', 'expand_dims', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (243, 'mars.tensor.expressions.base.expand_dims', 'expand_dims', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (248, 'mars.tensor.expressions.base.expand_dims', 'expand_dims', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (253, 'mars.tensor.expressions.base.expand_dims', 'expand_dims', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (265, 'mars.tensor.expressions.datasource.ones', 'ones', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (266, 'mars.tensor.expressions.base.rollaxis', 'rollaxis', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (273, 'mars.tensor.expressions.datasource.ones', 'ones', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (274, 'mars.tensor.expressions.datasource.ones', 'ones', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (276, 'mars.tensor.expressions.base.atleast_1d', 'atleast_1d', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (286, 'mars.tensor.expressions.datasource.ones', 'ones', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (287, 'mars.tensor.expressions.datasource.ones', 'ones', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (289, 'mars.tensor.expressions.base.atleast_2d', 'atleast_2d', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (299, 'mars.tensor.expressions.datasource.ones', 'ones', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (300, 'mars.tensor.expressions.datasource.ones', 'ones', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (302, 'mars.tensor.expressions.base.atleast_3d', 'atleast_3d', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (312, 'mars.tensor.expressions.base.argwhere', 'argwhere', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (321, 'mars.tensor.expressions.base.array_split', 'array_split', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (328, 'mars.tensor.expressions.base.array_split', 'array_split', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (337, 'mars.tensor.expressions.base.split', 'split', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (344, 'mars.tensor.expressions.base.split', 'split', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (353, 'mars.tensor.expressions.base.hsplit', 'hsplit', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (362, 'mars.tensor.expressions.base.vsplit', 'vsplit', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (371, 'mars.tensor.expressions.base.dsplit', 'dsplit', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (378, 'scipy.sparse.random', 'sps.random', True, 'import scipy.sparse as sps\n'), (379, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (380, 'mars.tensor.expressions.base.split', 'split', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (388, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (390, 'mars.tensor.expressions.base.roll', 'roll', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (394, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (398, 'mars.tensor.expressions.base.roll', 'roll', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (402, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (404, 'mars.tensor.expressions.base.roll', 'roll', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (408, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (410, 'mars.tensor.expressions.base.roll', 'roll', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (414, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (417, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (418, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (420, 'mars.tensor.expressions.base.squeeze', 'squeeze', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (423, 'numpy.squeeze', 'np.squeeze', True, 'import numpy as np\n'), (424, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (426, 'mars.tensor.expressions.base.squeeze', 'squeeze', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (429, 'numpy.squeeze', 'np.squeeze', True, 'import numpy as np\n'), (430, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (435, 'mars.tensor.expressions.base.ptp', 'ptp', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (439, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (441, 'mars.tensor.expressions.base.ptp', 'ptp', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (445, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (447, 'mars.tensor.expressions.base.ptp', 'ptp', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (451, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (454, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (455, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (457, 'mars.tensor.expressions.base.diff', 'diff', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (460, 'numpy.diff', 'np.diff', True, 'import numpy as np\n'), (461, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (463, 'mars.tensor.expressions.base.diff', 'diff', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (466, 'numpy.diff', 'np.diff', True, 'import numpy as np\n'), (467, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (469, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (470, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (472, 'mars.tensor.expressions.base.diff', 'diff', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (475, 'numpy.diff', 'np.diff', True, 'import numpy as np\n'), (476, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (478, 'mars.tensor.expressions.base.diff', 'diff', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (481, 'numpy.diff', 'np.diff', True, 'import numpy as np\n'), (482, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (484, 'mars.tensor.arange', 'mt.arange', True, 'from mars import tensor as mt\n'), (485, 'mars.tensor.expressions.base.diff', 'diff', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (489, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (492, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (493, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (495, 'mars.tensor.expressions.base.ediff1d', 'ediff1d', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (498, 'numpy.ediff1d', 'np.ediff1d', True, 'import numpy as np\n'), (499, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (501, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (502, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (503, 'mars.tensor.expressions.base.ediff1d', 'ediff1d', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (507, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (514, 'numpy.ediff1d', 'np.ediff1d', True, 'import numpy as np\n'), (515, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (518, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (519, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (520, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (521, 'mars.tensor.expressions.base.digitize', 'digitize', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (524, 'numpy.digitize', 'np.digitize', True, 'import numpy as np\n'), (525, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (527, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (528, 'mars.tensor.expressions.base.digitize', 'digitize', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (531, 'numpy.digitize', 'np.digitize', True, 'import numpy as np\n'), (532, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (534, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (535, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (536, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (537, 'mars.tensor.expressions.base.digitize', 'digitize', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (540, 'numpy.digitize', 'np.digitize', True, 'import numpy as np\n'), (541, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (543, 'mars.tensor.expressions.base.digitize', 'digitize', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (546, 'numpy.digitize', 'np.digitize', True, 'import numpy as np\n'), (547, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (550, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (551, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (552, 'mars.tensor.expressions.base.digitize', 'digitize', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (559, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (560, 'mars.tensor.expressions.base.average', 'average', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (577, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (584, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (586, 'mars.tensor.expressions.base.cov', 'cov', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (589, 'numpy.cov', 'np.cov', True, 'import numpy as np\n'), (590, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (594, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (595, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (597, 'mars.tensor.expressions.merge.stack', 'stack', False, 'from mars.tensor.expressions.merge import stack\n'), (598, 'mars.tensor.expressions.base.cov', 'cov', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (605, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (606, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (608, 'mars.tensor.expressions.base.corrcoef', 'corrcoef', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (611, 'numpy.corrcoef', 'np.corrcoef', True, 'import numpy as np\n'), (612, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (617, 'mars.tensor.expressions.base.flip', 'flip', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (621, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (623, 'mars.tensor.expressions.base.flip', 'flip', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (627, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (629, 'mars.tensor.expressions.base.flipud', 'flipud', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (633, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (635, 'mars.tensor.expressions.base.fliplr', 'fliplr', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (639, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (642, 'mars.tensor.expressions.base.repeat', 'repeat', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (645, 'numpy.repeat', 'np.repeat', True, 'import numpy as np\n'), (646, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (648, 'numpy.random.randn', 'np.random.randn', True, 'import numpy as np\n'), (649, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (651, 'mars.tensor.expressions.base.repeat', 'repeat', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (654, 'numpy.repeat', 'np.repeat', True, 'import numpy as np\n'), (655, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (657, 'mars.tensor.expressions.base.repeat', 'repeat', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (660, 'numpy.repeat', 'np.repeat', True, 'import numpy as np\n'), (661, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (667, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (673, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (675, 'scipy.sparse.random', 'sps.random', True, 'import scipy.sparse as sps\n'), (676, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (678, 'mars.tensor.expressions.base.repeat', 'repeat', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (685, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (686, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (688, 'mars.tensor.expressions.base.tile', 'tile', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (691, 'numpy.tile', 'np.tile', True, 'import numpy as np\n'), (692, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (694, 'mars.tensor.expressions.base.tile', 'tile', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (697, 'numpy.tile', 'np.tile', True, 'import numpy as np\n'), (698, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (700, 'mars.tensor.expressions.base.tile', 'tile', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (703, 'numpy.tile', 'np.tile', True, 'import numpy as np\n'), (704, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (706, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (707, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (709, 'mars.tensor.expressions.base.tile', 'tile', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (712, 'numpy.tile', 'np.tile', True, 'import numpy as np\n'), (713, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (715, 'mars.tensor.expressions.base.tile', 'tile', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (718, 'numpy.tile', 'np.tile', True, 'import numpy as np\n'), (719, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (721, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (722, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (724, 'mars.tensor.expressions.base.tile', 'tile', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (727, 'numpy.tile', 'np.tile', True, 'import numpy as np\n'), (728, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (734, 'mars.tensor.expressions.base.isin', 'isin', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (738, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (741, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (742, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (744, 'mars.tensor.expressions.base.isin', 'isin', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (748, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (751, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (752, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (755, 'mars.tensor.expressions.base.isin', 'isin', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (759, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (44, 'numpy.array_equal', 'np.array_equal', True, 'import numpy as np\n'), (45, 'numpy.array_equal', 'np.array_equal', True, 'import numpy as np\n'), (46, 'numpy.array_equal', 'np.array_equal', True, 'import numpy as np\n'), (47, 'numpy.array_equal', 'np.array_equal', True, 'import numpy as np\n'), (48, 'numpy.array_equal', 'np.array_equal', True, 'import numpy as np\n'), (49, 'numpy.array_equal', 'np.array_equal', True, 'import numpy as np\n'), (84, 'numpy.array_equal', 'np.array_equal', True, 'import numpy as np\n'), (163, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (170, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (170, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (170, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (176, 'numpy.random.randint', 'np.random.randint', True, 'import numpy as np\n'), (180, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (180, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (180, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (259, 'mars.tensor.expressions.base.expand_dims', 'expand_dims', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (262, 'mars.tensor.expressions.base.expand_dims', 'expand_dims', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (317, 'numpy.array_equal', 'np.array_equal', True, 'import numpy as np\n'), (326, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (333, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (342, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (349, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (358, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (367, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (376, 'numpy.testing.assert_equal', 'np.testing.assert_equal', True, 'import numpy as np\n'), (393, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (488, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (511, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (549, 'scipy.sparse.random', 'sps.random', True, 'import scipy.sparse as sps\n'), (563, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (566, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (583, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (663, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (666, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (669, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (672, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (149, 'numpy.broadcast_to', 'np.broadcast_to', True, 'import numpy as np\n'), (174, 'numpy.where', 'np.where', True, 'import numpy as np\n'), (236, 'numpy.expand_dims', 'np.expand_dims', True, 'import numpy as np\n'), (241, 'numpy.expand_dims', 'np.expand_dims', True, 'import numpy as np\n'), (246, 'numpy.expand_dims', 'np.expand_dims', True, 'import numpy as np\n'), (251, 'numpy.expand_dims', 'np.expand_dims', True, 'import numpy as np\n'), (256, 'numpy.expand_dims', 'np.expand_dims', True, 'import numpy as np\n'), (280, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (281, 'numpy.ones', 'np.ones', True, 'import numpy as np\n'), (282, 'numpy.ones', 'np.ones', True, 'import numpy as np\n'), (293, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (295, 'numpy.ones', 'np.ones', True, 'import numpy as np\n'), (306, 'numpy.atleast_3d', 'np.atleast_3d', True, 'import numpy as np\n'), (311, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (320, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (336, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (352, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (361, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (370, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (433, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (506, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (566, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (572, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (573, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (599, 'mars.tensor.expressions.base.cov', 'cov', False, 'from mars.tensor.expressions.base import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, ptp, diff, ediff1d, digitize, average, cov, corrcoef, flip, flipud, fliplr, repeat, tile, isin\n'), (615, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (269, 'numpy.ones', 'np.ones', True, 'import numpy as np\n'), (294, 'numpy.ones', 'np.ones', True, 'import numpy as np\n'), (307, 'numpy.ones', 'np.ones', True, 'import numpy as np\n'), (308, 'numpy.ones', 'np.ones', True, 'import numpy as np\n'), (324, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (331, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (340, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (347, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (356, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (365, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (374, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (401, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (407, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (413, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (438, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (444, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (450, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (576, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (580, 'mars.tensor.expressions.datasource.tensor', 'tensor', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (620, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (626, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (632, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (638, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (731, 'mars.tensor.expressions.datasource.arange', 'arange', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), (315, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (737, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (747, 'numpy.arange', 'np.arange', True, 'import numpy as np\n'), (758, 'numpy.arange', 'np.arange', True, 'import numpy as np\n')]