#!/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, 24, 35, 41), 'mars.tensor.execution.core.Executor', 'Executor', ({(35, 33, 35, 40): '"""numpy"""'}, {}), "('numpy')", False, 'from mars.tensor.execution.core import Executor\n'), ((38, 14, 38, 39), 'numpy.random.random', 'np.random.random', ({(38, 31, 38, 38): '(11, 8)'}, {}), '((11, 8))', True, 'import numpy as np\n'), ((39, 14, 39, 35), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((52, 12, 52, 34), 'mars.tensor.expressions.datasource.ones', 'ones', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((53, 12, 53, 40), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((55, 8, 55, 33), '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, 19, 58, 51), 'numpy.array', 'np.array', ({(58, 28, 58, 50): '[[3, 1, 3], [3, 1, 3]]'}, {}), '([[3, 1, 3], [3, 1, 3]])', True, 'import numpy as np\n'), ((60, 8, 60, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(60, 32, 60, 35): 'res', (60, 37, 60, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((63, 14, 63, 39), 'numpy.random.random', 'np.random.random', ({(63, 31, 63, 38): '(10, 5)'}, {}), '((10, 5))', True, 'import numpy as np\n'), ((64, 14, 64, 35), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((70, 14, 70, 43), 'scipy.sparse.random', 'sps.random', (), '', True, 'import scipy.sparse as sps\n'), ((71, 14, 71, 35), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((78, 14, 78, 42), 'numpy.random.random', 'np.random.random', ({(78, 31, 78, 41): '(11, 8, 5)'}, {}), '((11, 8, 5))', True, 'import numpy as np\n'), ((79, 14, 79, 35), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((80, 15, 80, 29), 'mars.tensor.expressions.base.transpose', 'transpose', ({(80, 25, 80, 28): 'arr'}, {}), '(arr)', 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, 15, 86, 48), '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, 14, 92, 31), 'scipy.sparse.random', 'sps.random', ({(92, 25, 92, 27): '11', (92, 29, 92, 30): '8'}, {}), '(11, 8)', True, 'import scipy.sparse as sps\n'), ((93, 14, 93, 35), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((94, 15, 94, 29), 'mars.tensor.expressions.base.transpose', 'transpose', ({(94, 25, 94, 28): 'arr'}, {}), '(arr)', 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, 14, 103, 42), 'numpy.random.random', 'np.random.random', ({(103, 31, 103, 41): '(11, 8, 5)'}, {}), '((11, 8, 5))', True, 'import numpy as np\n'), ((104, 14, 104, 35), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((111, 14, 111, 43), 'scipy.sparse.random', 'sps.random', (), '', True, 'import scipy.sparse as sps\n'), ((112, 14, 112, 35), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((120, 12, 120, 38), 'mars.tensor.expressions.datasource.zeros', 'zeros', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((122, 12, 122, 30), 'mars.tensor.expressions.base.moveaxis', 'moveaxis', ({(122, 21, 122, 22): 'x', (122, 24, 122, 25): '0', (122, 27, 122, 29): '-1'}, {}), '(x, 0, -1)', 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, 12, 127, 30), 'mars.tensor.expressions.base.moveaxis', 'moveaxis', ({(127, 21, 127, 22): 'x', (127, 24, 127, 26): '-1', (127, 28, 127, 29): '0'}, {}), '(x, -1, 0)', 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, 12, 132, 41), 'mars.tensor.expressions.base.moveaxis', 'moveaxis', ({(132, 21, 132, 22): 'x', (132, 24, 132, 30): '[0, 1]', (132, 32, 132, 40): '[-1, -2]'}, {}), '(x, [0, 1], [-1, -2])', 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, 12, 137, 48), 'mars.tensor.expressions.base.moveaxis', 'moveaxis', ({(137, 21, 137, 22): 'x', (137, 24, 137, 33): '[0, 1, 2]', (137, 35, 137, 47): '[-1, -2, -3]'}, {}), '(x, [0, 1, 2], [-1, -2, -3])', 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, 14, 143, 42), 'numpy.random.random', 'np.random.random', ({(143, 31, 143, 41): '(10, 5, 1)'}, {}), '((10, 5, 1))', True, 'import numpy as np\n'), ((144, 14, 144, 35), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((145, 15, 145, 47), 'mars.tensor.expressions.base.broadcast_to', 'broadcast_to', ({(145, 28, 145, 31): 'arr', (145, 33, 145, 46): '(5, 10, 5, 6)'}, {}), '(arr, (5, 10, 5, 6))', 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, 12, 153, 36), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((155, 12, 155, 36), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((157, 12, 157, 34), 'mars.tensor.expressions.base.broadcast_arrays', 'broadcast_arrays', ({(157, 29, 157, 30): 'x', (157, 32, 157, 33): 'y'}, {}), '(x, y)', 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, 19, 160, 54), 'numpy.broadcast_arrays', 'np.broadcast_arrays', ({(160, 39, 160, 45): 'x_data', (160, 47, 160, 53): 'y_data'}, {}), '(x_data, y_data)', True, 'import numpy as np\n'), ((166, 19, 166, 66), 'numpy.random.randint', 'np.random.randint', (), '', True, 'import numpy as np\n'), ((167, 16, 167, 36), 'numpy.random.rand', 'np.random.rand', ({(167, 31, 167, 32): '4', (167, 34, 167, 35): '1'}, {}), '(4, 1)', True, 'import numpy as np\n'), ((168, 16, 168, 36), 'numpy.random.rand', 'np.random.rand', ({(168, 31, 168, 32): '4', (168, 34, 168, 35): '4'}, {}), '(4, 4)', True, 'import numpy as np\n'), ((172, 14, 172, 31), 'mars.tensor.expressions.base.where', 'where', ({(172, 20, 172, 24): 'cond', (172, 26, 172, 27): 'x', (172, 29, 172, 30): 'y'}, {}), '(cond, x, y)', 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, 16, 177, 44), 'scipy.sparse.random', 'sps.random', (), '', True, 'import scipy.sparse as sps\n'), ((178, 16, 178, 44), 'scipy.sparse.random', 'sps.random', (), '', True, 'import scipy.sparse as sps\n'), ((182, 14, 182, 31), 'mars.tensor.expressions.base.where', 'where', ({(182, 20, 182, 24): 'cond', (182, 26, 182, 27): 'x', (182, 29, 182, 30): 'y'}, {}), '(cond, x, y)', 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, 19, 188, 45), 'numpy.random.rand', 'np.random.rand', ({(188, 34, 188, 36): '10', (188, 38, 188, 40): '20', (188, 42, 188, 44): '30'}, {}), '(10, 20, 30)', True, 'import numpy as np\n'), ((189, 12, 189, 38), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((211, 19, 211, 46), 'numpy.random.rand', 'np.random.rand', ({(211, 34, 211, 36): '30', (211, 38, 211, 41): '100', (211, 43, 211, 45): '20'}, {}), '(30, 100, 20)', True, 'import numpy as np\n'), ((212, 12, 212, 38), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((230, 19, 230, 45), 'numpy.random.rand', 'np.random.rand', ({(230, 34, 230, 36): '10', (230, 38, 230, 40): '20', (230, 42, 230, 44): '30'}, {}), '(10, 20, 30)', True, 'import numpy as np\n'), ((231, 12, 231, 38), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((233, 12, 233, 29), 'mars.tensor.expressions.base.expand_dims', 'expand_dims', ({(233, 24, 233, 25): 'x', (233, 27, 233, 28): '1'}, {}), '(x, 1)', 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, 12, 238, 29), 'mars.tensor.expressions.base.expand_dims', 'expand_dims', ({(238, 24, 238, 25): 'x', (238, 27, 238, 28): '0'}, {}), '(x, 0)', 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, 12, 243, 29), 'mars.tensor.expressions.base.expand_dims', 'expand_dims', ({(243, 24, 243, 25): 'x', (243, 27, 243, 28): '3'}, {}), '(x, 3)', 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, 12, 248, 30), 'mars.tensor.expressions.base.expand_dims', 'expand_dims', ({(248, 24, 248, 25): 'x', (248, 27, 248, 29): '-1'}, {}), '(x, -1)', 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, 12, 253, 30), 'mars.tensor.expressions.base.expand_dims', 'expand_dims', ({(253, 24, 253, 25): 'x', (253, 27, 253, 29): '-4'}, {}), '(x, -4)', 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, 12, 265, 40), 'mars.tensor.expressions.datasource.ones', 'ones', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((266, 12, 266, 29), 'mars.tensor.expressions.base.rollaxis', 'rollaxis', ({(266, 21, 266, 22): 'x', (266, 24, 266, 25): '3', (266, 27, 266, 28): '1'}, {}), '(x, 3, 1)', 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, 12, 273, 29), 'mars.tensor.expressions.datasource.ones', 'ones', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((274, 12, 274, 34), 'mars.tensor.expressions.datasource.ones', 'ones', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((276, 12, 276, 31), 'mars.tensor.expressions.base.atleast_1d', 'atleast_1d', ({(276, 23, 276, 24): 'x', (276, 26, 276, 27): 'y', (276, 29, 276, 30): 'z'}, {}), '(x, y, z)', 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, 12, 286, 29), 'mars.tensor.expressions.datasource.ones', 'ones', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((287, 12, 287, 34), 'mars.tensor.expressions.datasource.ones', 'ones', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((289, 12, 289, 31), 'mars.tensor.expressions.base.atleast_2d', 'atleast_2d', ({(289, 23, 289, 24): 'x', (289, 26, 289, 27): 'y', (289, 29, 289, 30): 'z'}, {}), '(x, y, z)', 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, 12, 299, 29), 'mars.tensor.expressions.datasource.ones', 'ones', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((300, 12, 300, 34), 'mars.tensor.expressions.datasource.ones', 'ones', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((302, 12, 302, 31), 'mars.tensor.expressions.base.atleast_3d', 'atleast_3d', ({(302, 23, 302, 24): 'x', (302, 26, 302, 27): 'y', (302, 29, 302, 30): 'z'}, {}), '(x, y, z)', 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, 12, 312, 27), 'mars.tensor.expressions.base.argwhere', 'argwhere', ({(312, 21, 312, 26): 'x > 1'}, {}), '(x > 1)', 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, 13, 321, 38), '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, 13, 328, 50), '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, 13, 337, 32), '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, 13, 344, 44), '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, 13, 353, 25), 'mars.tensor.expressions.base.hsplit', 'hsplit', ({(353, 20, 353, 21): 'x', (353, 23, 353, 24): '4'}, {}), '(x, 4)', 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, 13, 362, 25), 'mars.tensor.expressions.base.vsplit', 'vsplit', ({(362, 20, 362, 21): 'x', (362, 23, 362, 24): '4'}, {}), '(x, 4)', 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, 13, 371, 25), 'mars.tensor.expressions.base.dsplit', 'dsplit', ({(371, 20, 371, 21): 'x', (371, 23, 371, 24): '4'}, {}), '(x, 4)', 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, 17, 378, 46), 'scipy.sparse.random', 'sps.random', (), '', True, 'import scipy.sparse as sps\n'), ((379, 12, 379, 36), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((380, 13, 380, 32), '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, 12, 388, 32), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((390, 12, 390, 22), 'mars.tensor.expressions.base.roll', 'roll', ({(390, 17, 390, 18): 'x', (390, 20, 390, 21): '2'}, {}), '(x, 2)', 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, 8, 394, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(394, 32, 394, 35): 'res', (394, 37, 394, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((398, 12, 398, 23), 'mars.tensor.expressions.base.roll', 'roll', ({(398, 17, 398, 19): 'x2', (398, 21, 398, 22): '1'}, {}), '(x2, 1)', 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, 8, 402, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(402, 32, 402, 35): 'res', (402, 37, 402, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((404, 12, 404, 31), '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, 8, 408, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(408, 32, 408, 35): 'res', (408, 37, 408, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((410, 12, 410, 31), '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, 8, 414, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(414, 32, 414, 35): 'res', (414, 37, 414, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((417, 15, 417, 42), 'numpy.array', 'np.array', ({(417, 24, 417, 41): '[[[0], [1], [2]]]'}, {}), '([[[0], [1], [2]]])', True, 'import numpy as np\n'), ((418, 12, 418, 34), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((420, 12, 420, 22), 'mars.tensor.expressions.base.squeeze', 'squeeze', ({(420, 20, 420, 21): 'x'}, {}), '(x)', 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, 19, 423, 35), 'numpy.squeeze', 'np.squeeze', ({(423, 30, 423, 34): 'data'}, {}), '(data)', True, 'import numpy as np\n'), ((424, 8, 424, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(424, 32, 424, 35): 'res', (424, 37, 424, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((426, 12, 426, 30), '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, 19, 429, 43), 'numpy.squeeze', 'np.squeeze', (), '', True, 'import numpy as np\n'), ((430, 8, 430, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(430, 32, 430, 35): 'res', (430, 37, 430, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((435, 12, 435, 26), '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, 8, 439, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(439, 32, 439, 35): 'res', (439, 37, 439, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((441, 12, 441, 26), '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, 8, 445, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(445, 32, 445, 35): 'res', (445, 37, 445, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((447, 12, 447, 18), 'mars.tensor.expressions.base.ptp', 'ptp', ({(447, 16, 447, 17): 'x'}, {}), '(x)', 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, 8, 451, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(451, 32, 451, 35): 'res', (451, 37, 451, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((454, 15, 454, 40), 'numpy.array', 'np.array', ({(454, 24, 454, 39): '[1, 2, 4, 7, 0]'}, {}), '([1, 2, 4, 7, 0])', True, 'import numpy as np\n'), ((455, 12, 455, 34), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((457, 12, 457, 19), 'mars.tensor.expressions.base.diff', 'diff', ({(457, 17, 457, 18): 'x'}, {}), '(x)', 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, 19, 460, 32), 'numpy.diff', 'np.diff', ({(460, 27, 460, 31): 'data'}, {}), '(data)', True, 'import numpy as np\n'), ((461, 8, 461, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(461, 32, 461, 35): 'res', (461, 37, 461, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((463, 12, 463, 24), '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, 19, 466, 37), 'numpy.diff', 'np.diff', (), '', True, 'import numpy as np\n'), ((467, 8, 467, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(467, 32, 467, 35): 'res', (467, 37, 467, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((469, 15, 469, 54), 'numpy.array', 'np.array', ({(469, 24, 469, 53): '[[1, 3, 6, 10], [0, 5, 6, 8]]'}, {}), '([[1, 3, 6, 10], [0, 5, 6, 8]])', True, 'import numpy as np\n'), ((470, 12, 470, 34), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((472, 12, 472, 19), 'mars.tensor.expressions.base.diff', 'diff', ({(472, 17, 472, 18): 'x'}, {}), '(x)', 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, 19, 475, 32), 'numpy.diff', 'np.diff', ({(475, 27, 475, 31): 'data'}, {}), '(data)', True, 'import numpy as np\n'), ((476, 8, 476, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(476, 32, 476, 35): 'res', (476, 37, 476, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((478, 12, 478, 27), '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, 19, 481, 40), 'numpy.diff', 'np.diff', (), '', True, 'import numpy as np\n'), ((482, 8, 482, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(482, 32, 482, 35): 'res', (482, 37, 482, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((484, 12, 484, 70), 'mars.tensor.arange', 'mt.arange', (), '', True, 'from mars import tensor as mt\n'), ((485, 12, 485, 19), 'mars.tensor.expressions.base.diff', 'diff', ({(485, 17, 485, 18): 'x'}, {}), '(x)', 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, 8, 489, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(489, 32, 489, 35): 'res', (489, 37, 489, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((492, 15, 492, 40), 'numpy.array', 'np.array', ({(492, 24, 492, 39): '[1, 2, 4, 7, 0]'}, {}), '([1, 2, 4, 7, 0])', True, 'import numpy as np\n'), ((493, 12, 493, 34), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((495, 12, 495, 22), 'mars.tensor.expressions.base.ediff1d', 'ediff1d', ({(495, 20, 495, 21): 'x'}, {}), '(x)', 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, 19, 498, 35), 'numpy.ediff1d', 'np.ediff1d', ({(498, 30, 498, 34): 'data'}, {}), '(data)', True, 'import numpy as np\n'), ((499, 8, 499, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(499, 32, 499, 35): 'res', (499, 37, 499, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((501, 19, 501, 40), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((502, 17, 502, 43), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((503, 12, 503, 56), '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, 8, 507, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(507, 32, 507, 35): 'res', (507, 37, 507, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((514, 19, 514, 35), 'numpy.ediff1d', 'np.ediff1d', ({(514, 30, 514, 34): 'data'}, {}), '(data)', True, 'import numpy as np\n'), ((515, 8, 515, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(515, 32, 515, 35): 'res', (515, 37, 515, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((518, 15, 518, 45), 'numpy.array', 'np.array', ({(518, 24, 518, 44): '[0.2, 6.4, 3.0, 1.6]'}, {}), '([0.2, 6.4, 3.0, 1.6])', True, 'import numpy as np\n'), ((519, 12, 519, 34), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((520, 15, 520, 51), 'numpy.array', 'np.array', ({(520, 24, 520, 50): '[0.0, 1.0, 2.5, 4.0, 10.0]'}, {}), '([0.0, 1.0, 2.5, 4.0, 10.0])', True, 'import numpy as np\n'), ((521, 15, 521, 32), 'mars.tensor.expressions.base.digitize', 'digitize', ({(521, 24, 521, 25): 'x', (521, 27, 521, 31): 'bins'}, {}), '(x, bins)', 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, 19, 524, 42), 'numpy.digitize', 'np.digitize', ({(524, 31, 524, 35): 'data', (524, 37, 524, 41): 'bins'}, {}), '(data, bins)', True, 'import numpy as np\n'), ((525, 8, 525, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(525, 32, 525, 35): 'res', (525, 37, 525, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((527, 12, 527, 34), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((528, 15, 528, 29), 'mars.tensor.expressions.base.digitize', 'digitize', ({(528, 24, 528, 25): 'x', (528, 27, 528, 28): 'b'}, {}), '(x, b)', 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, 19, 531, 42), 'numpy.digitize', 'np.digitize', ({(531, 31, 531, 35): 'data', (531, 37, 531, 41): 'bins'}, {}), '(data, bins)', True, 'import numpy as np\n'), ((532, 8, 532, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(532, 32, 532, 35): 'res', (532, 37, 532, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((534, 15, 534, 53), 'numpy.array', 'np.array', ({(534, 24, 534, 52): '[1.2, 10.0, 12.4, 15.5, 20.0]'}, {}), '([1.2, 10.0, 12.4, 15.5, 20.0])', True, 'import numpy as np\n'), ((535, 12, 535, 34), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((536, 15, 536, 43), 'numpy.array', 'np.array', ({(536, 24, 536, 42): '[0, 5, 10, 15, 20]'}, {}), '([0, 5, 10, 15, 20])', True, 'import numpy as np\n'), ((537, 15, 537, 44), '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, 19, 540, 54), 'numpy.digitize', 'np.digitize', (), '', True, 'import numpy as np\n'), ((541, 8, 541, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(541, 32, 541, 35): 'res', (541, 37, 541, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((543, 15, 543, 45), '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, 19, 546, 55), 'numpy.digitize', 'np.digitize', (), '', True, 'import numpy as np\n'), ((547, 8, 547, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(547, 32, 547, 35): 'res', (547, 37, 547, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((550, 12, 550, 34), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((551, 15, 551, 51), 'numpy.array', 'np.array', ({(551, 24, 551, 50): '[1.0, 2.0, 2.5, 4.0, 10.0]'}, {}), '([1.0, 2.0, 2.5, 4.0, 10.0])', True, 'import numpy as np\n'), ((552, 15, 552, 32), 'mars.tensor.expressions.base.digitize', 'digitize', ({(552, 24, 552, 25): 'x', (552, 27, 552, 31): 'bins'}, {}), '(x, bins)', 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, 15, 559, 37), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((560, 12, 560, 25), 'mars.tensor.expressions.base.average', 'average', ({(560, 20, 560, 24): 'data'}, {}), '(data)', 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, 8, 577, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(577, 32, 577, 35): 'res', (577, 37, 577, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((584, 12, 584, 34), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((586, 12, 586, 18), 'mars.tensor.expressions.base.cov', 'cov', ({(586, 16, 586, 17): 'x'}, {}), '(x)', 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, 19, 589, 31), 'numpy.cov', 'np.cov', ({(589, 26, 589, 30): 'data'}, {}), '(data)', True, 'import numpy as np\n'), ((590, 8, 590, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(590, 32, 590, 35): 'res', (590, 37, 590, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((594, 12, 594, 36), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((595, 12, 595, 36), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((597, 12, 597, 33), 'mars.tensor.expressions.merge.stack', 'stack', (), '', False, 'from mars.tensor.expressions.merge import stack\n'), ((598, 12, 598, 21), 'mars.tensor.expressions.base.cov', 'cov', ({(598, 16, 598, 17): 'x', (598, 19, 598, 20): 'y'}, {}), '(x, y)', 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, 12, 605, 36), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((606, 12, 606, 36), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((608, 12, 608, 26), 'mars.tensor.expressions.base.corrcoef', 'corrcoef', ({(608, 21, 608, 22): 'x', (608, 24, 608, 25): 'y'}, {}), '(x, y)', 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, 19, 611, 46), 'numpy.corrcoef', 'np.corrcoef', ({(611, 31, 611, 37): 'data_x', (611, 39, 611, 45): 'data_y'}, {}), '(data_x, data_y)', True, 'import numpy as np\n'), ((612, 8, 612, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(612, 32, 612, 35): 'res', (612, 37, 612, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((617, 12, 617, 22), 'mars.tensor.expressions.base.flip', 'flip', ({(617, 17, 617, 18): 'a', (617, 20, 617, 21): '0'}, {}), '(a, 0)', 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, 8, 621, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(621, 32, 621, 35): 'res', (621, 37, 621, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((623, 12, 623, 22), 'mars.tensor.expressions.base.flip', 'flip', ({(623, 17, 623, 18): 'a', (623, 20, 623, 21): '1'}, {}), '(a, 1)', 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, 8, 627, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(627, 32, 627, 35): 'res', (627, 37, 627, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((629, 12, 629, 21), 'mars.tensor.expressions.base.flipud', 'flipud', ({(629, 19, 629, 20): 'a'}, {}), '(a)', 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, 8, 633, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(633, 32, 633, 35): 'res', (633, 37, 633, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((635, 12, 635, 21), 'mars.tensor.expressions.base.fliplr', 'fliplr', ({(635, 19, 635, 20): 'a'}, {}), '(a)', 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, 8, 639, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(639, 32, 639, 35): 'res', (639, 37, 639, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((642, 12, 642, 24), 'mars.tensor.expressions.base.repeat', 'repeat', ({(642, 19, 642, 20): '3', (642, 22, 642, 23): '4'}, {}), '(3, 4)', 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, 19, 645, 34), 'numpy.repeat', 'np.repeat', ({(645, 29, 645, 30): '3', (645, 32, 645, 33): '4'}, {}), '(3, 4)', True, 'import numpy as np\n'), ((646, 8, 646, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(646, 32, 646, 35): 'res', (646, 37, 646, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((648, 17, 648, 40), 'numpy.random.randn', 'np.random.randn', ({(648, 33, 648, 35): '20', (648, 37, 648, 39): '30'}, {}), '(20, 30)', True, 'import numpy as np\n'), ((649, 12, 649, 41), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((651, 12, 651, 24), 'mars.tensor.expressions.base.repeat', 'repeat', ({(651, 19, 651, 20): 'x', (651, 22, 651, 23): '2'}, {}), '(x, 2)', 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, 19, 654, 39), 'numpy.repeat', 'np.repeat', ({(654, 29, 654, 35): 'x_data', (654, 37, 654, 38): '2'}, {}), '(x_data, 2)', True, 'import numpy as np\n'), ((655, 8, 655, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(655, 32, 655, 35): 'res', (655, 37, 655, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((657, 12, 657, 32), '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, 19, 660, 47), 'numpy.repeat', 'np.repeat', (), '', True, 'import numpy as np\n'), ((661, 8, 661, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(661, 32, 661, 35): 'res', (661, 37, 661, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((667, 8, 667, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(667, 32, 667, 35): 'res', (667, 37, 667, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((673, 8, 673, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(673, 32, 673, 35): 'res', (673, 37, 673, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((675, 17, 675, 47), 'scipy.sparse.random', 'sps.random', (), '', True, 'import scipy.sparse as sps\n'), ((676, 12, 676, 41), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((678, 12, 678, 32), '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, 17, 685, 36), 'numpy.array', 'np.array', ({(685, 26, 685, 35): '[0, 1, 2]'}, {}), '([0, 1, 2])', True, 'import numpy as np\n'), ((686, 12, 686, 36), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((688, 12, 688, 22), 'mars.tensor.expressions.base.tile', 'tile', ({(688, 17, 688, 18): 'a', (688, 20, 688, 21): '2'}, {}), '(a, 2)', 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, 19, 691, 37), 'numpy.tile', 'np.tile', ({(691, 27, 691, 33): 'a_data', (691, 35, 691, 36): '2'}, {}), '(a_data, 2)', True, 'import numpy as np\n'), ((692, 8, 692, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(692, 32, 692, 35): 'res', (692, 37, 692, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((694, 12, 694, 27), 'mars.tensor.expressions.base.tile', 'tile', ({(694, 17, 694, 18): 'a', (694, 20, 694, 26): '(2, 2)'}, {}), '(a, (2, 2))', 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, 19, 697, 42), 'numpy.tile', 'np.tile', ({(697, 27, 697, 33): 'a_data', (697, 35, 697, 41): '(2, 2)'}, {}), '(a_data, (2, 2))', True, 'import numpy as np\n'), ((698, 8, 698, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(698, 32, 698, 35): 'res', (698, 37, 698, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((700, 12, 700, 30), 'mars.tensor.expressions.base.tile', 'tile', ({(700, 17, 700, 18): 'a', (700, 20, 700, 29): '(2, 1, 2)'}, {}), '(a, (2, 1, 2))', 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, 19, 703, 45), 'numpy.tile', 'np.tile', ({(703, 27, 703, 33): 'a_data', (703, 35, 703, 44): '(2, 1, 2)'}, {}), '(a_data, (2, 1, 2))', True, 'import numpy as np\n'), ((704, 8, 704, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(704, 32, 704, 35): 'res', (704, 37, 704, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((706, 17, 706, 43), 'numpy.array', 'np.array', ({(706, 26, 706, 42): '[[1, 2], [3, 4]]'}, {}), '([[1, 2], [3, 4]])', True, 'import numpy as np\n'), ((707, 12, 707, 36), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((709, 12, 709, 22), 'mars.tensor.expressions.base.tile', 'tile', ({(709, 17, 709, 18): 'b', (709, 20, 709, 21): '2'}, {}), '(b, 2)', 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, 19, 712, 37), 'numpy.tile', 'np.tile', ({(712, 27, 712, 33): 'b_data', (712, 35, 712, 36): '2'}, {}), '(b_data, 2)', True, 'import numpy as np\n'), ((713, 8, 713, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(713, 32, 713, 35): 'res', (713, 37, 713, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((715, 12, 715, 27), 'mars.tensor.expressions.base.tile', 'tile', ({(715, 17, 715, 18): 'b', (715, 20, 715, 26): '(2, 1)'}, {}), '(b, (2, 1))', 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, 19, 718, 42), 'numpy.tile', 'np.tile', ({(718, 27, 718, 33): 'b_data', (718, 35, 718, 41): '(2, 1)'}, {}), '(b_data, (2, 1))', True, 'import numpy as np\n'), ((719, 8, 719, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(719, 32, 719, 35): 'res', (719, 37, 719, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((721, 17, 721, 39), 'numpy.array', 'np.array', ({(721, 26, 721, 38): '[1, 2, 3, 4]'}, {}), '([1, 2, 3, 4])', True, 'import numpy as np\n'), ((722, 12, 722, 36), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((724, 12, 724, 27), 'mars.tensor.expressions.base.tile', 'tile', ({(724, 17, 724, 18): 'c', (724, 20, 724, 26): '(4, 1)'}, {}), '(c, (4, 1))', 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, 19, 727, 42), 'numpy.tile', 'np.tile', ({(727, 27, 727, 33): 'c_data', (727, 35, 727, 41): '(4, 1)'}, {}), '(c_data, (4, 1))', True, 'import numpy as np\n'), ((728, 8, 728, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(728, 32, 728, 35): 'res', (728, 37, 728, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((734, 15, 734, 43), 'mars.tensor.expressions.base.isin', 'isin', ({(734, 20, 734, 27): 'element', (734, 29, 734, 42): 'test_elements'}, {}), '(element, test_elements)', 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, 8, 738, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(738, 32, 738, 35): 'res', (738, 37, 738, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((741, 19, 741, 35), 'numpy.array', 'np.array', ({(741, 28, 741, 34): '[2, 4]'}, {}), '([2, 4])', True, 'import numpy as np\n'), ((742, 8, 742, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(742, 32, 742, 35): 'res', (742, 37, 742, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((744, 15, 744, 56), '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, 8, 748, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(748, 32, 748, 35): 'res', (748, 37, 748, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((751, 19, 751, 35), 'numpy.array', 'np.array', ({(751, 28, 751, 34): '[0, 6]'}, {}), '([0, 6])', True, 'import numpy as np\n'), ((752, 8, 752, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(752, 32, 752, 35): 'res', (752, 37, 752, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((755, 15, 755, 38), 'mars.tensor.expressions.base.isin', 'isin', ({(755, 20, 755, 27): 'element', (755, 29, 755, 37): 'test_set'}, {}), '(element, test_set)', 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, 8, 759, 46), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(759, 32, 759, 35): 'res', (759, 37, 759, 45): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((44, 24, 44, 59), 'numpy.array_equal', 'np.array_equal', ({(44, 39, 44, 45): 'res[0]', (44, 47, 44, 58): 'raw[:4, :4]'}, {}), '(res[0], raw[:4, :4])', True, 'import numpy as np\n'), ((45, 24, 45, 59), 'numpy.array_equal', 'np.array_equal', ({(45, 39, 45, 45): 'res[1]', (45, 47, 45, 58): 'raw[:4, 4:]'}, {}), '(res[1], raw[:4, 4:])', True, 'import numpy as np\n'), ((46, 24, 46, 60), 'numpy.array_equal', 'np.array_equal', ({(46, 39, 46, 45): 'res[2]', (46, 47, 46, 59): 'raw[4:8, :4]'}, {}), '(res[2], raw[4:8, :4])', True, 'import numpy as np\n'), ((47, 24, 47, 60), 'numpy.array_equal', 'np.array_equal', ({(47, 39, 47, 45): 'res[3]', (47, 47, 47, 59): 'raw[4:8, 4:]'}, {}), '(res[3], raw[4:8, 4:])', True, 'import numpy as np\n'), ((48, 24, 48, 59), 'numpy.array_equal', 'np.array_equal', ({(48, 39, 48, 45): 'res[4]', (48, 47, 48, 58): 'raw[8:, :4]'}, {}), '(res[4], raw[8:, :4])', True, 'import numpy as np\n'), ((49, 24, 49, 59), 'numpy.array_equal', 'np.array_equal', ({(49, 39, 49, 45): 'res[5]', (49, 47, 49, 58): 'raw[8:, 4:]'}, {}), '(res[5], raw[8:, 4:])', True, 'import numpy as np\n'), ((84, 24, 84, 53), 'numpy.array_equal', 'np.array_equal', ({(84, 39, 84, 45): 'res[0]', (84, 47, 84, 52): 'raw.T'}, {}), '(res[0], raw.T)', True, 'import numpy as np\n'), ((163, 12, 163, 41), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(163, 36, 163, 37): 'r', (163, 39, 163, 40): 'e'}, {}), '(r, e)', True, 'import numpy as np\n'), ((170, 21, 170, 47), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((170, 49, 170, 72), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((170, 74, 170, 97), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((176, 34, 176, 81), 'numpy.random.randint', 'np.random.randint', (), '', True, 'import numpy as np\n'), ((180, 21, 180, 47), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((180, 49, 180, 72), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((180, 74, 180, 97), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((259, 12, 259, 30), 'mars.tensor.expressions.base.expand_dims', 'expand_dims', ({(259, 24, 259, 25): 'x', (259, 27, 259, 29): '(-5)'}, {}), '(x, -5)', 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, 12, 262, 29), 'mars.tensor.expressions.base.expand_dims', 'expand_dims', ({(262, 24, 262, 25): 'x', (262, 27, 262, 28): '(4)'}, {}), '(x, 4)', 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, 24, 317, 53), 'numpy.array_equal', 'np.array_equal', ({(317, 39, 317, 42): 'res', (317, 44, 317, 52): 'expected'}, {}), '(res, expected)', True, 'import numpy as np\n'), ((326, 9, 326, 38), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(326, 33, 326, 34): 'r', (326, 36, 326, 37): 'e'}, {}), '(r, e)', True, 'import numpy as np\n'), ((333, 9, 333, 38), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(333, 33, 333, 34): 'r', (333, 36, 333, 37): 'e'}, {}), '(r, e)', True, 'import numpy as np\n'), ((342, 9, 342, 38), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(342, 33, 342, 34): 'r', (342, 36, 342, 37): 'e'}, {}), '(r, e)', True, 'import numpy as np\n'), ((349, 9, 349, 38), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(349, 33, 349, 34): 'r', (349, 36, 349, 37): 'e'}, {}), '(r, e)', True, 'import numpy as np\n'), ((358, 9, 358, 38), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(358, 33, 358, 34): 'r', (358, 36, 358, 37): 'e'}, {}), '(r, e)', True, 'import numpy as np\n'), ((367, 9, 367, 38), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(367, 33, 367, 34): 'r', (367, 36, 367, 37): 'e'}, {}), '(r, e)', True, 'import numpy as np\n'), ((376, 9, 376, 38), 'numpy.testing.assert_equal', 'np.testing.assert_equal', ({(376, 33, 376, 34): 'r', (376, 36, 376, 37): 'e'}, {}), '(r, e)', True, 'import numpy as np\n'), ((393, 27, 393, 40), 'numpy.arange', 'np.arange', ({(393, 37, 393, 39): '10'}, {}), '(10)', True, 'import numpy as np\n'), ((488, 27, 488, 85), 'numpy.arange', 'np.arange', (), '', True, 'import numpy as np\n'), ((511, 20, 511, 42), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((549, 15, 549, 44), 'scipy.sparse.random', 'sps.random', (), '', True, 'import scipy.sparse as sps\n'), ((563, 30, 563, 45), 'numpy.arange', 'np.arange', ({(563, 40, 563, 41): '1', (563, 43, 563, 44): '5'}, {}), '(1, 5)', True, 'import numpy as np\n'), ((566, 20, 566, 43), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((583, 15, 583, 49), 'numpy.array', 'np.array', ({(583, 24, 583, 48): '[[0, 2], [1, 1], [2, 0]]'}, {}), '([[0, 2], [1, 1], [2, 0]])', True, 'import numpy as np\n'), ((663, 22, 663, 35), 'numpy.arange', 'np.arange', ({(663, 32, 663, 34): '20'}, {}), '(20)', True, 'import numpy as np\n'), ((666, 37, 666, 50), 'numpy.arange', 'np.arange', ({(666, 47, 666, 49): '20'}, {}), '(20)', True, 'import numpy as np\n'), ((669, 22, 669, 42), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((672, 37, 672, 50), 'numpy.arange', 'np.arange', ({(672, 47, 672, 49): '20'}, {}), '(20)', True, 'import numpy as np\n'), ((149, 47, 149, 82), 'numpy.broadcast_to', 'np.broadcast_to', ({(149, 63, 149, 66): 'raw', (149, 68, 149, 81): '(5, 10, 5, 6)'}, {}), '(raw, (5, 10, 5, 6))', True, 'import numpy as np\n'), ((174, 47, 174, 79), 'numpy.where', 'np.where', ({(174, 56, 174, 64): 'raw_cond', (174, 66, 174, 71): 'raw_x', (174, 73, 174, 78): 'raw_y'}, {}), '(raw_cond, raw_x, raw_y)', True, 'import numpy as np\n'), ((236, 47, 236, 74), 'numpy.expand_dims', 'np.expand_dims', ({(236, 62, 236, 70): 'raw_data', (236, 72, 236, 73): '(1)'}, {}), '(raw_data, 1)', True, 'import numpy as np\n'), ((241, 47, 241, 74), 'numpy.expand_dims', 'np.expand_dims', ({(241, 62, 241, 70): 'raw_data', (241, 72, 241, 73): '(0)'}, {}), '(raw_data, 0)', True, 'import numpy as np\n'), ((246, 47, 246, 74), 'numpy.expand_dims', 'np.expand_dims', ({(246, 62, 246, 70): 'raw_data', (246, 72, 246, 73): '(3)'}, {}), '(raw_data, 3)', True, 'import numpy as np\n'), ((251, 47, 251, 75), 'numpy.expand_dims', 'np.expand_dims', ({(251, 62, 251, 70): 'raw_data', (251, 72, 251, 74): '(-1)'}, {}), '(raw_data, -1)', True, 'import numpy as np\n'), ((256, 47, 256, 75), 'numpy.expand_dims', 'np.expand_dims', ({(256, 62, 256, 70): 'raw_data', (256, 72, 256, 74): '(-4)'}, {}), '(raw_data, -4)', True, 'import numpy as np\n'), ((280, 47, 280, 60), 'numpy.array', 'np.array', ({(280, 56, 280, 59): '[1]'}, {}), '([1])', True, 'import numpy as np\n'), ((281, 47, 281, 57), 'numpy.ones', 'np.ones', ({(281, 55, 281, 56): '(3)'}, {}), '(3)', True, 'import numpy as np\n'), ((282, 47, 282, 62), 'numpy.ones', 'np.ones', ({(282, 55, 282, 61): '(3, 4)'}, {}), '((3, 4))', True, 'import numpy as np\n'), ((293, 47, 293, 62), 'numpy.array', 'np.array', ({(293, 56, 293, 61): '[[1]]'}, {}), '([[1]])', True, 'import numpy as np\n'), ((295, 47, 295, 62), 'numpy.ones', 'np.ones', ({(295, 55, 295, 61): '(3, 4)'}, {}), '((3, 4))', True, 'import numpy as np\n'), ((306, 47, 306, 63), 'numpy.atleast_3d', 'np.atleast_3d', ({(306, 61, 306, 62): 'x'}, {}), '(x)', True, 'import numpy as np\n'), ((311, 12, 311, 31), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((320, 12, 320, 32), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((336, 12, 336, 32), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((352, 12, 352, 33), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((361, 12, 361, 32), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((370, 12, 370, 32), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((433, 12, 433, 31), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((506, 57, 506, 75), 'numpy.array', 'np.array', ({(506, 66, 506, 74): '[88, 99]'}, {}), '([88, 99])', True, 'import numpy as np\n'), ((566, 53, 566, 80), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((572, 15, 572, 34), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((573, 42, 573, 72), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((599, 22, 599, 28), 'mars.tensor.expressions.base.cov', 'cov', ({(599, 26, 599, 27): 'X'}, {}), '(X)', 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, 12, 615, 31), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((269, 59, 269, 80), 'numpy.ones', 'np.ones', ({(269, 67, 269, 79): '(3, 4, 5, 6)'}, {}), '((3, 4, 5, 6))', True, 'import numpy as np\n'), ((294, 61, 294, 71), 'numpy.ones', 'np.ones', ({(294, 69, 294, 70): '(3)'}, {}), '(3)', True, 'import numpy as np\n'), ((307, 61, 307, 71), 'numpy.ones', 'np.ones', ({(307, 69, 307, 70): '(3)'}, {}), '(3)', True, 'import numpy as np\n'), ((308, 61, 308, 76), 'numpy.ones', 'np.ones', ({(308, 69, 308, 75): '(3, 4)'}, {}), '((3, 4))', True, 'import numpy as np\n'), ((324, 34, 324, 47), 'numpy.arange', 'np.arange', ({(324, 44, 324, 46): '48'}, {}), '(48)', True, 'import numpy as np\n'), ((331, 34, 331, 47), 'numpy.arange', 'np.arange', ({(331, 44, 331, 46): '48'}, {}), '(48)', True, 'import numpy as np\n'), ((340, 28, 340, 41), 'numpy.arange', 'np.arange', ({(340, 38, 340, 40): '48'}, {}), '(48)', True, 'import numpy as np\n'), ((347, 28, 347, 41), 'numpy.arange', 'np.arange', ({(347, 38, 347, 40): '48'}, {}), '(48)', True, 'import numpy as np\n'), ((356, 29, 356, 43), 'numpy.arange', 'np.arange', ({(356, 39, 356, 42): '120'}, {}), '(120)', True, 'import numpy as np\n'), ((365, 29, 365, 42), 'numpy.arange', 'np.arange', ({(365, 39, 365, 41): '48'}, {}), '(48)', True, 'import numpy as np\n'), ((374, 29, 374, 42), 'numpy.arange', 'np.arange', ({(374, 39, 374, 41): '48'}, {}), '(48)', True, 'import numpy as np\n'), ((401, 27, 401, 40), 'numpy.arange', 'np.arange', ({(401, 37, 401, 39): '10'}, {}), '(10)', True, 'import numpy as np\n'), ((407, 27, 407, 40), 'numpy.arange', 'np.arange', ({(407, 37, 407, 39): '10'}, {}), '(10)', True, 'import numpy as np\n'), ((413, 27, 413, 40), 'numpy.arange', 'np.arange', ({(413, 37, 413, 39): '10'}, {}), '(10)', True, 'import numpy as np\n'), ((438, 26, 438, 38), 'numpy.arange', 'np.arange', ({(438, 36, 438, 37): '4'}, {}), '(4)', True, 'import numpy as np\n'), ((444, 26, 444, 38), 'numpy.arange', 'np.arange', ({(444, 36, 444, 37): '4'}, {}), '(4)', True, 'import numpy as np\n'), ((450, 26, 450, 38), 'numpy.arange', 'np.arange', ({(450, 36, 450, 37): '4'}, {}), '(4)', True, 'import numpy as np\n'), ((576, 30, 576, 42), 'numpy.arange', 'np.arange', ({(576, 40, 576, 41): '6'}, {}), '(6)', True, 'import numpy as np\n'), ((580, 34, 580, 64), 'mars.tensor.expressions.datasource.tensor', 'tensor', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((620, 27, 620, 39), 'numpy.arange', 'np.arange', ({(620, 37, 620, 38): '8'}, {}), '(8)', True, 'import numpy as np\n'), ((626, 27, 626, 39), 'numpy.arange', 'np.arange', ({(626, 37, 626, 38): '8'}, {}), '(8)', True, 'import numpy as np\n'), ((632, 29, 632, 41), 'numpy.arange', 'np.arange', ({(632, 39, 632, 40): '8'}, {}), '(8)', True, 'import numpy as np\n'), ((638, 29, 638, 41), 'numpy.arange', 'np.arange', ({(638, 39, 638, 40): '8'}, {}), '(8)', True, 'import numpy as np\n'), ((731, 22, 731, 41), 'mars.tensor.expressions.datasource.arange', 'arange', (), '', False, 'from mars.tensor.expressions.datasource import tensor, ones, zeros, arange\n'), ((315, 31, 315, 43), 'numpy.arange', 'np.arange', ({(315, 41, 315, 42): '6'}, {}), '(6)', True, 'import numpy as np\n'), ((737, 31, 737, 43), 'numpy.arange', 'np.arange', ({(737, 41, 737, 42): '4'}, {}), '(4)', True, 'import numpy as np\n'), ((747, 31, 747, 43), 'numpy.arange', 'np.arange', ({(747, 41, 747, 42): '4'}, {}), '(4)', True, 'import numpy as np\n'), ((758, 31, 758, 43), 'numpy.arange', 'np.arange', ({(758, 41, 758, 42): '4'}, {}), '(4)', True, 'import numpy as np\n')]