def test_mat_one(self):
o = Identity()
S = sdiag(np.r_[2, 3])
def check(exp, ans):
assert np.all((exp).todense() == ans)
check(S * o, [[2, 0], [0, 3]])
check(o * S, [[2, 0], [0, 3]])
check(S * -o, [[-2, 0], [0, -3]])
check(-o * S, [[-2, 0], [0, -3]])
check(S/o, [[2, 0], [0, 3]])
check(S/-o, [[-2, 0], [0, -3]])
self.assertRaises(NotImplementedError, lambda: o/S)
check(S + o, [[3, 0], [0, 4]])
check(o + S, [[3, 0], [0, 4]])
check(S - o, [[1, 0], [0, 2]])
check(S + - o, [[1, 0], [0, 2]])
check(- o + S, [[1, 0], [0, 2]])
评论列表
文章目录