def test_diagonal(self): a0 = ctf.astensor(numpy.arange(9).reshape(3,3)) a1 = a0.diagonal() self.assertTrue(ctf.all(a1 == ctf.astensor([0,4,8]))) self.assertTrue(ctf.all(a1 == ctf.diagonal(numpy.arange(9).reshape(3,3)))) try: a1.diagonal() except ValueError: # a1 needs to be 2d array pass
def test_diagonal(self): a0 = ctf.astensor(numpy.arange(9).reshape(3,3)) a1 = a0.diagonal() self.assertTrue(ctf.all(a1 == ctf.astensor([0,4,8]))) self.assertTrue(ctf.all(a1 == ctf.diagonal(numpy.arange(9).reshape(3,3)))) try: a1.diagonal() except ValueError: # a1 needs to be 2d array pass