提交 16e7d3bf 编写于 作者: G gsq7474741

add utils.plot_density_graph v0.2

上级 136cb1fa
......@@ -1758,8 +1758,8 @@ def plot_density_graph(density_matrix: Union[paddle.Tensor, np.ndarray],
real = real.reshape(-1)
imag = imag.reshape(-1)
ax_real.bar3d(xx, yy, np.zeros_like(real), size, size, real)
ax_imag.bar3d(xx, yy, np.zeros_like(imag), size, size, imag)
ax_real.bar3d(xx, yy, np.zeros_like(real), size, size, np.abs(real))
ax_imag.bar3d(xx, yy, np.zeros_like(imag), size, size, np.abs(imag))
return figure
......
from paddle_quantum.circuit import UAnsatz
from paddle import kron
from paddle_quantum.state import vec,density_op
import matplotlib.pyplot as plt
from paddle_quantum.utils import plot_density_graph
import numpy as np
import paddle
import unittest
......@@ -35,7 +36,7 @@ def test_state_vector():
class TestPlotDensityGraph(unittest.TestCase):
def setUp(self):
self.func = plot_density_graph
self.x_np = np.random.rand(4, 4) + np.random.rand(4, 4) * 1j
self.x_np = (np.random.rand(8, 8) + np.random.rand(8, 8) * 1j)-0.5-0.5j
self.x_tensor = paddle.to_tensor(self.x_np)
def test_input_type(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册