def test_max_mean_photon_deprecated(self, tol): """This test verifies that the maximum amount of squeezing used to encode the graph is indeed capped by the parameter max_mean_photon""" max_mean_photon = 2 A = np.random.random([6, 6]) + 1j * np.random.random([6, 6]) A += A.T sc, _ = dec.graph_embed_deprecated(A, max_mean_photon=max_mean_photon) res_mean_photon = np.sinh(np.max(np.abs(sc)))**2 assert np.allclose(res_mean_photon, max_mean_photon, atol=tol, rtol=0)
def test_make_traceless_deprecated(self, monkeypatch, tol): """Test that A is properly made traceless""" A = np.random.random([6, 6]) + 1j * np.random.random([6, 6]) A += A.T assert not np.allclose(np.trace(A), 0, atol=tol, rtol=0) with monkeypatch.context() as m: # monkeypatch the takagi function to simply return A, # so that we can inspect it and make sure it is now traceless m.setattr(dec, "takagi", lambda A, tol: (np.ones([6]), A)) _, A_out = dec.graph_embed_deprecated(A, make_traceless=True) assert np.allclose(np.trace(A_out), 0, atol=tol, rtol=0)