Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive visualization of AbstractTensorNetwork with Vega #261

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
KeywordDispatch = "5888135b-5456-5c80-a1b6-c91ef8180460"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OMEinsum = "ebe7aa44-baf0-506c-a96f-8464559b3922"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Expand Down Expand Up @@ -76,6 +77,7 @@ KrylovKit = "0.7, 0.8"
LinearAlgebra = "1.10"
Makie = "0.18,0.19,0.20, 0.21"
OMEinsum = "0.7, 0.8"
OrderedCollections = "1.6.3"
PythonCall = "0.9"
Quac = "0.3"
Random = "1.10"
Expand Down
340 changes: 340 additions & 0 deletions demo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,340 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"using Tenet"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"istextmime(MIME\"application/vnd.vegalite.v3+json\"())"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.vegalite.v3+json": {
"$schema": "https://vega.github.io/schema/vega-lite/v3.json",
"data": {
"values": [
{
"a": "A",
"b": 28
},
{
"a": "B",
"b": 55
},
{
"a": "C",
"b": 43
},
{
"a": "D",
"b": 91
},
{
"a": "E",
"b": 81
},
{
"a": "F",
"b": 53
},
{
"a": "G",
"b": 19
},
{
"a": "H",
"b": 87
},
{
"a": "I",
"b": 52
}
]
},
"description": "A simple bar chart with embedded data.",
"encoding": {
"x": {
"axis": {
"labelAngle": 0
},
"field": "a",
"type": "nominal"
},
"y": {
"field": "b",
"type": "quantitative"
}
},
"mark": "bar"
},
"text/plain": [
"TensorNetwork (#tensors=10, #inds=25)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"tn = rand(TensorNetwork, 10, 5)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"showable(MIME\"application/vnd.vegalite.v3+json\"(), tn)"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [],
"source": [
"struct E end\n",
"\n",
"function Base.show(io::IO, ::MIME\"application/vnd.vegalite.v3+json\", ::E)\n",
" println(io, \"\"\"{\n",
" \"\\$schema\": \"https://vega.github.io/schema/vega-lite/v3.json\",\n",
" \"data\": {\n",
" \"values\": [\n",
" {\"a\": \"C\", \"b\": 2},\n",
" {\"a\": \"C\", \"b\": 7},\n",
" {\"a\": \"C\", \"b\": 4},\n",
" {\"a\": \"D\", \"b\": 1},\n",
" {\"a\": \"D\", \"b\": 2},\n",
" {\"a\": \"D\", \"b\": 6},\n",
" {\"a\": \"E\", \"b\": 8},\n",
" {\"a\": \"E\", \"b\": 4},\n",
" {\"a\": \"E\", \"b\": 7}\n",
" ]\n",
" },\n",
" \"mark\": \"point\",\n",
" \"encoding\": {}\n",
" }\"\"\")\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"showable(MIME\"application/vnd.vegalite.v3+json\"(), E())"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.vegalite.v3+json": {
"$schema": "https://vega.github.io/schema/vega-lite/v3.json",
"data": {
"values": [
{
"a": "C",
"b": 2
},
{
"a": "C",
"b": 7
},
{
"a": "C",
"b": 4
},
{
"a": "D",
"b": 1
},
{
"a": "D",
"b": 2
},
{
"a": "D",
"b": 6
},
{
"a": "E",
"b": 8
},
{
"a": "E",
"b": 4
},
{
"a": "E",
"b": 7
}
]
},
"encoding": {},
"mark": "point"
},
"text/plain": [
"E()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"E()"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.vegalite.v3+json": {
"$schema": "https://vega.github.io/schema/vega-lite/v3.json",
"data": {
"values": [
{
"a": "A",
"b": 28
},
{
"a": "B",
"b": 55
},
{
"a": "C",
"b": 43
},
{
"a": "D",
"b": 91
},
{
"a": "E",
"b": 81
},
{
"a": "F",
"b": 53
},
{
"a": "G",
"b": 19
},
{
"a": "H",
"b": 87
},
{
"a": "I",
"b": 52
}
]
},
"description": "A simple bar chart with embedded data.",
"encoding": {
"x": {
"axis": {
"labelAngle": 0
},
"field": "a",
"type": "nominal"
},
"y": {
"field": "b",
"type": "quantitative"
}
},
"mark": "bar"
},
"text/plain": [
"TensorNetwork (#tensors=10, #inds=25)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"tn"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.10.5",
"language": "julia",
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.10.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
EinExprs = "b1794770-133b-4de1-afb4-526377e9f4c5"
GraphMakie = "1ecd5474-83a3-4783-bb4f-06765db800d2"
Kroki = "b3565e16-c1f2-4fe9-b4ab-221c88942068"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
NetworkLayout = "46757867-2c16-5918-afeb-47bfcb05e46a"
Tenet = "85d41934-b9cd-44e1-8730-56d86f15f3ec"
Expand Down
3 changes: 1 addition & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ using Documenter
using DocumenterVitepress
using DocumenterCitations
using Tenet
using CairoMakie
using GraphMakie
using Makie
using LinearAlgebra

DocMeta.setdocmeta!(Tenet, :DocTestSetup, :(using Tenet); recursive=true)
Expand Down
2 changes: 2 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"docs:preview": "vitepress preview build/.documenter"
},
"dependencies": {
"@kazumatu981/markdown-it-kroki": "^1.3.5",
"@shikijs/transformers": "^1.1.7",
"markdown-it": "^14.1.0",
"markdown-it-abbr": "^2.0.0",
"markdown-it-footnote": "^4.0.0",
"markdown-it-mathjax3": "^4.3.2",
"vitepress": "^1.1.4",
Expand Down
Loading
Loading