跳转到主要内容

未提供项目描述

项目描述

Q# 小部件

Q# 小部件是使用AnyWidget包(https://anywidget.dev/)构建的Jupyter小部件。

使用 ./build.py --widgets 构建。

通过以下方式安装编译好的wheel文件:

pip install --force-reinstall ./target/wheels/qsharp_widgets-0.0.0-py2.py3-none-any.whl

对于开发,请在测试环境中使用 pip install -e ./widgets 执行“可编辑”安装。对包所做的任何更改都将立即反映出来。

如果正在开发Web代码(JS和CSS),则在测试环境中也安装 pip install watchfiles,并在 ./widgets 目录中运行 npm run dev 以在监视模式下构建。这将使用AnyWidget的模块热重载功能,在做出更改时自动更新Python包。(见 https://anywidget.dev/blog/anywidget-02/)。

完成以上步骤后,可以通过 import qsharp_widgets 在Python测试环境中使用Q# 小部件。

使用方法

在笔记本中,生成程序的估计值并使用如下代码显示小部件:

# Cell-1 : Import the modules and generate some estimates
import qsharp
from qsharp_widgets import SpaceChart, EstimateDetails

with open("sample.qs", "r") as f:
    contents = f.read()
qsharp.eval(contents)
result1 = qsharp.estimate("Sample.Main()")

# Cell-2 : Display the details in table form
EstimateDetails(result1)

# Cell-3 : Display the space chart
SpaceChart(result1)

# Cell-4 : Use the logical counts to get estimates for a different qubit
result2 = qsharp.physical_estimates_from_logical_counts(
    result1.get("logicalCounts"),
    {
        "qubitParams": { "name": "qubit_maj_ns_e6" },
        "qecScheme": { "name": "floquet_code" }
    }
)
SpaceChart(result2)

项目详情


发布历史 发布通知 | RSS源

下载文件

下载适合您平台的文件。如果您不确定该选择哪个,请了解更多关于安装包的信息。

源代码分发

本发布版本没有可用的源代码分发文件。请参阅生成分发存档的教程

构建分发

qsharp_widgets-1.9.0-py2.py3-none-any.whl (170.1 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下支持