Skip to content
Merged
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: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ITensorVisualizationBase"
uuid = "cd2553d2-8bef-4d93-8a38-c62f17d5ad23"
version = "0.1.16"
version = "0.1.17"
authors = ["Matthew Fishman <mfishman@flatironinstitute.org> and contributors"]

[workspace]
Expand Down
29 changes: 8 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,15 @@ or `ITensorGLMakie`. The main purpose is to use it with the
[ITensors.jl](https://github.com/ITensor/ITensors.jl) package to view and debug tensor
network contractions, for example:

Load a visualization backend (such as `using ITensorUnicodePlots`) to actually render
the diagrams; without one, the `@visualize` macro is a no-op so that the example below
still runs in test environments that do not have a backend installed.
`ITensorVisualizationBase` handles the logic of switching between backends.

````julia
using ITensorVisualizationBase: ITensorVisualizationBase, @visualize
using ITensors: Index, random_itensor
````

Load a visualization backend, which will reexport the interface of
`ITensorVisualizationBase` automatically:
```julia
using ITensorUnicodePlots
```

(we leave the `using ITensorUnicodePlots` line out of this example so it can run in
test environments that do not have the backend installed.)

`ITensorVisualizationBase` handles the logic of switching between backends:

````julia
@show ITensorVisualizationBase.get_backend()

i = Index(2, "i")
j = Index(10, "j")
k = Index(40, "k")
Expand All @@ -77,9 +67,10 @@ A = random_itensor(i, j, k)
B = random_itensor(i, j, l, m)
C = random_itensor(k, l)
ABC = @visualize A * B * C
ABC_tags = @visualize A * B * C edge_labels = (tags = true,)
````

With the `ITensorUnicodePlots` backend loaded, this outputs:
With `ITensorUnicodePlots` loaded, the first `@visualize` call outputs:

```julia
ITensorVisualizationBase.get_backend() = ITensorVisualizationBase.Backend{:UnicodePlots}()⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Expand All @@ -106,11 +97,7 @@ ITensorVisualizationBase.get_backend() = ITensorVisualizationBase.Backend{:Unico
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
```

You can show the visualization with tags with:

````julia
ABC_tags = @visualize A * B * C edge_labels = (tags = true,)
````
And the second `@visualize` call (with `edge_labels = (tags = true,)`) outputs:

```julia
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Expand Down
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ITensorFormatter = "b6bf39f1-c9d3-4bad-aad8-593d802f65fd"
ITensorVisualizationBase = "cd2553d2-8bef-4d93-8a38-c62f17d5ad23"
ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"

[sources.ITensorVisualizationBase]
path = ".."
Expand All @@ -10,3 +11,4 @@ path = ".."
Documenter = "1"
ITensorFormatter = "0.2.27"
ITensorVisualizationBase = "0.1"
ITensors = "0.7, 0.8, 0.9"
27 changes: 8 additions & 19 deletions examples/README.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,14 @@ julia> Pkg.add("ITensorVisualizationBase")
# [ITensors.jl](https://github.com/ITensor/ITensors.jl) package to view and debug tensor
# network contractions, for example:

# Load a visualization backend (such as `using ITensorUnicodePlots`) to actually render
# the diagrams; without one, the `@visualize` macro is a no-op so that the example below
# still runs in test environments that do not have a backend installed.
# `ITensorVisualizationBase` handles the logic of switching between backends.

using ITensorVisualizationBase: ITensorVisualizationBase, @visualize
using ITensors: Index, random_itensor

# Load a visualization backend, which will reexport the interface of
# `ITensorVisualizationBase` automatically:
#=
```julia
using ITensorUnicodePlots
```
=#

# (we leave the `using ITensorUnicodePlots` line out of this example so it can run in
# test environments that do not have the backend installed.)

# `ITensorVisualizationBase` handles the logic of switching between backends:

@show ITensorVisualizationBase.get_backend()

i = Index(2, "i")
j = Index(10, "j")
k = Index(40, "k")
Expand All @@ -78,8 +68,9 @@ A = random_itensor(i, j, k)
B = random_itensor(i, j, l, m)
C = random_itensor(k, l)
ABC = @visualize A * B * C
ABC_tags = @visualize A * B * C edge_labels = (tags = true,)

# With the `ITensorUnicodePlots` backend loaded, this outputs:
# With `ITensorUnicodePlots` loaded, the first `@visualize` call outputs:

#=
```julia
Expand Down Expand Up @@ -108,9 +99,7 @@ ITensorVisualizationBase.get_backend() = ITensorVisualizationBase.Backend{:Unico
```
=#

# You can show the visualization with tags with:

ABC_tags = @visualize A * B * C edge_labels = (tags = true,)
# And the second `@visualize` call (with `edge_labels = (tags = true,)`) outputs:

#=
```julia
Expand Down
Loading