Cirq的基于Web的3D可视化工具。
项目描述
Cirq 是一个Python库,用于编写、操作和优化量子线路,并可以在量子计算机和模拟器上运行。
此模块是 cirq-web,允许用户利用基于浏览器的3D可视化工具和Cirq中的功能。cirq-web还提供了一个开发环境,供贡献者创建并添加自己的可视化到模块中。
文档
cirq-web的文档可以在本模块子目录中的README文件中找到。
以下是如何使用cirq-web生成可移植的布洛赫球3D渲染的快速示例
import cirq
from cirq_web import BlochSphere
# Prepare a state
zero_state = [1+0j, 0+0j]
state_vector = cirq.to_valid_state_vector(zero_state)
# Create and display the Bloch sphere
sphere = BlochSphere(state_vector=state_vector)
sphere.generate_html_file()
这将创建当前工作目录中的文件。还有其他选项可以指定输出目录或打开浏览器中的可视化等。
您还可以使用以下方式在Colab或Jupyter笔记本设置中查看和交互布洛赫球
import cirq
from cirq_web import BlochSphere
# Prepare a state
zero_state = [1+0j, 0+0j]
state_vector = cirq.to_valid_state_vector(zero_state)
# Create and display the Bloch sphere
sphere = BlochSphere(state_vector=state_vector)
display(sphere)
请参阅此目录中的示例Jupyter笔记本,了解更多有关如何使用cirq-web的信息。
安装
cirq-web目前处于开发阶段,因此只能通过预发布版本获得。
要安装仅限 cirq-web 的预发布版本,请使用 pip install cirq-web~=1.0.dev。
注意,这将安装cirq-web和cirq-core。
要安装所有可选模块,您需要使用 pip install cirq 或 pip install cirq~=1.0.dev 安装预发布版本。
项目详情
下载文件
下载适用于您的平台文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源代码分布
本版本没有可用的源代码分布文件。请参阅 生成分布存档 的教程。
构建分布
cirq_web-1.4.1-py3-none-any.whl (596.5 kB 查看哈希值)