コード例 #1
0
    def testArgwhereExecution(self):
        x = arange(6, chunk_size=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))
コード例 #2
0
ファイル: test_base.py プロジェクト: qinxuye/mars
def test_argwhere():
    cond = tensor([[True, False], [False, True]], chunk_size=1)
    indices = argwhere(cond)

    assert np.isnan(indices.shape[0])
    assert indices.shape[1] == 2

    indices = tile(indices)

    assert indices.nsplits[1] == (1, 1)
コード例 #3
0
ファイル: test_base.py プロジェクト: tomzhang/mars-1
    def testArgwhere(self):
        cond = tensor([[True, False], [False, True]], chunk_size=1)
        indices = argwhere(cond)

        self.assertTrue(np.isnan(indices.shape[0]))
        self.assertEqual(indices.shape[1], 2)

        indices = indices.tiles()

        self.assertEqual(indices.nsplits[1], (1, 1))
コード例 #4
0
    def testArgwhereExecution(self):
        x = arange(6, chunk_size=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)

        np.testing.assert_array_equal(res, expected)

        data = np.asfortranarray(np.random.rand(10, 20))
        x = tensor(data, chunk_size=10)

        t = argwhere(x > 0.5)

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.argwhere(data > 0.5)

        np.testing.assert_array_equal(res, expected)
        self.assertTrue(res.flags['F_CONTIGUOUS'])
        self.assertFalse(res.flags['C_CONTIGUOUS'])
コード例 #5
0
ファイル: test_base.py プロジェクト: qinxuye/mars
def test_argwhere_order():
    data = np.asfortranarray([[True, False], [False, True]])
    cond = tensor(data, chunk_size=1)
    indices = argwhere(cond)

    assert indices.flags['F_CONTIGUOUS'] is True
    assert indices.flags['C_CONTIGUOUS'] is False

    indices = tile(indices)

    assert indices.chunks[0].order.value == 'F'
コード例 #6
0
ファイル: test_base.py プロジェクト: tomzhang/mars-1
    def testArgwhereOrder(self):
        data = np.asfortranarray([[True, False], [False, True]])
        cond = tensor(data, chunk_size=1)
        indices = argwhere(cond)

        self.assertTrue(indices.flags['F_CONTIGUOUS'])
        self.assertFalse(indices.flags['C_CONTIGUOUS'])

        indices = indices.tiles()

        self.assertEqual(indices.chunks[0].order.value, 'F')