def testUnravelIndex(self): indices = tensor([22, 41, 37], chunk_size=1) t = unravel_index(indices, (7, 6)) self.assertEqual(len(t), 2) [r.tiles() for r in t] self.assertEqual(len(t[0].chunks), 3) self.assertEqual(len(t[1].chunks), 3) with self.assertRaises(TypeError): unravel_index([22, 41, 37], (7, 6), order='B')
def test_unravel_index(): indices = tensor([22, 41, 37], chunk_size=1) t = unravel_index(indices, (7, 6)) assert len(t) == 2 t = [tile(r) for r in t] assert len(t[0].chunks) == 3 assert len(t[1].chunks) == 3 with pytest.raises(TypeError): unravel_index([22, 41, 37], (7, 6), order='B')
def testUnravelExecution(self): a = tensor([22, 41, 37], chunk_size=1) t = stack(unravel_index(a, (7, 6))) res = self.executor.execute_tensor(t, concat=True)[0] expected = np.stack(np.unravel_index([22, 41, 37], (7, 6))) np.testing.assert_array_equal(res, expected)
def test_unravel_execution(setup): a = tensor([22, 41, 37], chunk_size=1) t = stack(unravel_index(a, (7, 6))) res = t.execute().fetch() expected = np.stack(np.unravel_index([22, 41, 37], (7, 6))) np.testing.assert_array_equal(res, expected)
def testUnravelIndex(self): indices = tensor([22, 41, 37], chunk_size=1) t = unravel_index(indices, (7, 6)) self.assertEqual(len(t), 2) [r.tiles() for r in t] self.assertEqual(len(t[0].chunks), 3) self.assertEqual(len(t[1].chunks), 3)