Skip to content

Commit 83964d8

Browse files
mtfishmangithub-actions[bot]
authored andcommitted
Format .jl files (Runic)
1 parent 995052f commit 83964d8

File tree

9 files changed

+123
-121
lines changed

9 files changed

+123
-121
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "VisualizationBase"
22
uuid = "19e8930c-b694-45c7-b48f-ae1a17da5712"
3+
version = "0.1.1"
34
authors = ["ITensor developers <support@itensor.org> and contributors"]
4-
version = "0.1.0"
55

66
[deps]
77
BackendSelection = "680c2d7c-f67a-4cc9-ae9c-da132b1447a5"

docs/make.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ using VisualizationBase: VisualizationBase
22
using Documenter: Documenter, DocMeta, deploydocs, makedocs
33

44
DocMeta.setdocmeta!(
5-
VisualizationBase, :DocTestSetup, :(using VisualizationBase); recursive=true
5+
VisualizationBase, :DocTestSetup, :(using VisualizationBase); recursive = true
66
)
77

88
include("make_index.jl")
99

1010
makedocs(;
11-
modules=[VisualizationBase],
12-
authors="ITensor developers <support@itensor.org> and contributors",
13-
sitename="VisualizationBase.jl",
14-
format=Documenter.HTML(;
15-
canonical="https://itensor.github.io/VisualizationBase.jl",
16-
edit_link="main",
17-
assets=["assets/favicon.ico", "assets/extras.css"],
18-
),
19-
pages=["Home" => "index.md", "Reference" => "reference.md"],
11+
modules = [VisualizationBase],
12+
authors = "ITensor developers <support@itensor.org> and contributors",
13+
sitename = "VisualizationBase.jl",
14+
format = Documenter.HTML(;
15+
canonical = "https://itensor.github.io/VisualizationBase.jl",
16+
edit_link = "main",
17+
assets = ["assets/favicon.ico", "assets/extras.css"],
18+
),
19+
pages = ["Home" => "index.md", "Reference" => "reference.md"],
2020
)
2121

2222
deploydocs(;
23-
repo="github.com/ITensor/VisualizationBase.jl", devbranch="main", push_preview=true
23+
repo = "github.com/ITensor/VisualizationBase.jl", devbranch = "main", push_preview = true
2424
)

docs/make_index.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ using Literate: Literate
22
using VisualizationBase: VisualizationBase
33

44
function ccq_logo(content)
5-
include_ccq_logo = """
5+
include_ccq_logo = """
66
```@raw html
77
<img class="display-light-only" src="assets/CCQ.png" width="20%" alt="Flatiron Center for Computational Quantum Physics logo."/>
88
<img class="display-dark-only" src="assets/CCQ-dark.png" width="20%" alt="Flatiron Center for Computational Quantum Physics logo."/>
99
```
1010
"""
11-
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
12-
return content
11+
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
12+
return content
1313
end
1414

1515
Literate.markdown(
16-
joinpath(pkgdir(VisualizationBase), "examples", "README.jl"),
17-
joinpath(pkgdir(VisualizationBase), "docs", "src");
18-
flavor=Literate.DocumenterFlavor(),
19-
name="index",
20-
postprocess=ccq_logo,
16+
joinpath(pkgdir(VisualizationBase), "examples", "README.jl"),
17+
joinpath(pkgdir(VisualizationBase), "docs", "src");
18+
flavor = Literate.DocumenterFlavor(),
19+
name = "index",
20+
postprocess = ccq_logo,
2121
)

docs/make_readme.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ using Literate: Literate
22
using VisualizationBase: VisualizationBase
33

44
function ccq_logo(content)
5-
include_ccq_logo = """
5+
include_ccq_logo = """
66
<picture>
77
<source media="(prefers-color-scheme: dark)" width="20%" srcset="docs/src/assets/CCQ-dark.png">
88
<img alt="Flatiron Center for Computational Quantum Physics logo." width="20%" src="docs/src/assets/CCQ.png">
99
</picture>
1010
"""
11-
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
12-
return content
11+
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
12+
return content
1313
end
1414

1515
Literate.markdown(
16-
joinpath(pkgdir(VisualizationBase), "examples", "README.jl"),
17-
joinpath(pkgdir(VisualizationBase));
18-
flavor=Literate.CommonMarkFlavor(),
19-
name="README",
20-
postprocess=ccq_logo,
16+
joinpath(pkgdir(VisualizationBase), "examples", "README.jl"),
17+
joinpath(pkgdir(VisualizationBase));
18+
flavor = Literate.CommonMarkFlavor(),
19+
name = "README",
20+
postprocess = ccq_logo,
2121
)

examples/README.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# # VisualizationBase.jl
2-
#
2+
#
33
# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://itensor.github.io/VisualizationBase.jl/stable/)
44
# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://itensor.github.io/VisualizationBase.jl/dev/)
55
# [![Build Status](https://github.com/ITensor/VisualizationBase.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/VisualizationBase.jl/actions/workflows/Tests.yml?query=branch%3Amain)

src/VisualizationBase.jl

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,71 +5,71 @@ using BackendSelection: @Backend_str, AbstractBackend, Backend
55
export @visualize, visualize
66

77
macro visualize(x, kwargs...)
8-
all(kwarg -> Meta.isexpr(kwarg, :(=)), kwargs) ||
9-
throw(ArgumentError("All keyword arguments must be of the form `kw=value`."))
10-
kwargs′ = if all(kwarg -> kwarg.args[1] :name, kwargs)
11-
(kwargs..., :(name=$(string(x))))
12-
else
13-
kwargs
14-
end
15-
return :(visualize($(esc(x)); $(esc.(kwargs′)...)); $(esc(x)))
8+
all(kwarg -> Meta.isexpr(kwarg, :(=)), kwargs) ||
9+
throw(ArgumentError("All keyword arguments must be of the form `kw=value`."))
10+
kwargs′ = if all(kwarg -> kwarg.args[1] :name, kwargs)
11+
(kwargs..., :(name = $(string(x))))
12+
else
13+
kwargs
14+
end
15+
return :(visualize($(esc(x)); $(esc.(kwargs′)...)); $(esc(x)))
1616
end
1717

18-
function visualize(io::IO, x; backend=Backend"Default", name=nothing, kwargs...)
19-
return visualize(io, to_backend(backend; kwargs...), x; name)
18+
function visualize(io::IO, x; backend = Backend"Default", name = nothing, kwargs...)
19+
return visualize(io, to_backend(backend; kwargs...), x; name)
2020
end
2121

22-
function visualize(x; backend=Backend"Default", name=nothing, io::IO=stdout, kwargs...)
23-
return visualize(io, to_backend(backend; kwargs...), x; name)
22+
function visualize(x; backend = Backend"Default", name = nothing, io::IO = stdout, kwargs...)
23+
return visualize(io, to_backend(backend; kwargs...), x; name)
2424
end
2525

26-
function visualize(io::IO, backend::AbstractBackend, x; name=nothing)
27-
name = get(backend, :name, name)
28-
if isnothing(name)
29-
visualize_unnamed(io, backend, x)
26+
function visualize(io::IO, backend::AbstractBackend, x; name = nothing)
27+
name = get(backend, :name, name)
28+
if isnothing(name)
29+
visualize_unnamed(io, backend, x)
30+
return nothing
31+
end
32+
visualize_named(io, backend, name, x)
3033
return nothing
31-
end
32-
visualize_named(io, backend, name, x)
33-
return nothing
3434
end
3535

36-
function visualize(backend::Backend"Default", x; name=nothing)
37-
io = get(backend, :io, stdout)
38-
visualize(io, backend, x; name)
39-
return nothing
36+
function visualize(backend::Backend"Default", x; name = nothing)
37+
io = get(backend, :io, stdout)
38+
visualize(io, backend, x; name)
39+
return nothing
4040
end
4141

4242
function visualize_named(io::IO, backend::Backend"Default", name, x)
43-
mime = get(backend, :mime, MIME"text/plain"())
44-
println(io, name, " = ")
45-
show_indented(io, mime, x)
46-
println(io)
47-
return nothing
43+
mime = get(backend, :mime, MIME"text/plain"())
44+
println(io, name, " = ")
45+
show_indented(io, mime, x)
46+
println(io)
47+
return nothing
4848
end
4949

5050
function visualize_unnamed(io::IO, ::Backend"Default", x)
51-
show(io, MIME"text/plain"(), x)
52-
println(io)
53-
return nothing
51+
show(io, MIME"text/plain"(), x)
52+
println(io)
53+
return nothing
5454
end
5555

56-
function show_indented(io::IO, mime::MIME, x; indent=" ")
57-
str = sprint(show, mime, x)
58-
str = join((indent * s for s in split(str, '\n')), '\n')
59-
print(io, str)
60-
return nothing
56+
function show_indented(io::IO, mime::MIME, x; indent = " ")
57+
str = sprint(show, mime, x)
58+
str = join((indent * s for s in split(str, '\n')), '\n')
59+
print(io, str)
60+
return nothing
6161
end
6262

6363
function to_backend(::Type{B}; kwargs...) where {B}
64-
return B(; kwargs...)
64+
return B(; kwargs...)
6565
end
66-
function to_backend(backend::Union{Symbol,String}; kwargs...)
67-
return Backend(backend; kwargs...)
66+
function to_backend(backend::Union{Symbol, String}; kwargs...)
67+
return Backend(backend; kwargs...)
6868
end
6969
function to_backend(backend::AbstractBackend; kwargs...)
70-
isempty(kwargs) ||
71-
throw(ArgumentError("Keyword arguments must be passed as part of the backend object."))
72-
return backend
70+
isempty(kwargs) ||
71+
throw(ArgumentError("Keyword arguments must be passed as part of the backend object."))
72+
return backend
7373
end
7474

7575
end

test/runtests.jl

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,60 +6,62 @@ using Suppressor: Suppressor
66
const pat = r"(?:--group=)(\w+)"
77
arg_id = findfirst(contains(pat), ARGS)
88
const GROUP = uppercase(
9-
if isnothing(arg_id)
10-
get(ENV, "GROUP", "ALL")
11-
else
12-
only(match(pat, ARGS[arg_id]).captures)
13-
end,
9+
if isnothing(arg_id)
10+
get(ENV, "GROUP", "ALL")
11+
else
12+
only(match(pat, ARGS[arg_id]).captures)
13+
end,
1414
)
1515

1616
"match files of the form `test_*.jl`, but exclude `*setup*.jl`"
1717
function istestfile(fn)
18-
return endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup")
18+
return endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup")
1919
end
2020
"match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`"
2121
function isexamplefile(fn)
22-
return endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup")
22+
return endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup")
2323
end
2424

2525
@time begin
26-
# tests in groups based on folder structure
27-
for testgroup in filter(isdir, readdir(@__DIR__))
28-
if GROUP == "ALL" || GROUP == uppercase(testgroup)
29-
groupdir = joinpath(@__DIR__, testgroup)
30-
for file in filter(istestfile, readdir(groupdir))
31-
filename = joinpath(groupdir, file)
32-
@eval @safetestset $file begin
33-
include($filename)
26+
# tests in groups based on folder structure
27+
for testgroup in filter(isdir, readdir(@__DIR__))
28+
if GROUP == "ALL" || GROUP == uppercase(testgroup)
29+
groupdir = joinpath(@__DIR__, testgroup)
30+
for file in filter(istestfile, readdir(groupdir))
31+
filename = joinpath(groupdir, file)
32+
@eval @safetestset $file begin
33+
include($filename)
34+
end
35+
end
3436
end
35-
end
3637
end
37-
end
3838

39-
# single files in top folder
40-
for file in filter(istestfile, readdir(@__DIR__))
41-
(file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion
42-
@eval @safetestset $file begin
43-
include($file)
39+
# single files in top folder
40+
for file in filter(istestfile, readdir(@__DIR__))
41+
(file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion
42+
@eval @safetestset $file begin
43+
include($file)
44+
end
4445
end
45-
end
4646

47-
# test examples
48-
examplepath = joinpath(@__DIR__, "..", "examples")
49-
for (root, _, files) in walkdir(examplepath)
50-
contains(chopprefix(root, @__DIR__), "setup") && continue
51-
for file in filter(isexamplefile, files)
52-
filename = joinpath(root, file)
53-
@eval begin
54-
@safetestset $file begin
55-
$(Expr(
56-
:macrocall,
57-
GlobalRef(Suppressor, Symbol("@suppress")),
58-
LineNumberNode(@__LINE__, @__FILE__),
59-
:(include($filename)),
60-
))
47+
# test examples
48+
examplepath = joinpath(@__DIR__, "..", "examples")
49+
for (root, _, files) in walkdir(examplepath)
50+
contains(chopprefix(root, @__DIR__), "setup") && continue
51+
for file in filter(isexamplefile, files)
52+
filename = joinpath(root, file)
53+
@eval begin
54+
@safetestset $file begin
55+
$(
56+
Expr(
57+
:macrocall,
58+
GlobalRef(Suppressor, Symbol("@suppress")),
59+
LineNumberNode(@__LINE__, @__FILE__),
60+
:(include($filename)),
61+
)
62+
)
63+
end
64+
end
6165
end
62-
end
6366
end
64-
end
6567
end

test/test_aqua.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ using Aqua: Aqua
33
using Test: @testset
44

55
@testset "Code quality (Aqua.jl)" begin
6-
Aqua.test_all(VisualizationBase)
6+
Aqua.test_all(VisualizationBase)
77
end

test/test_basics.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ using VisualizationBase: VisualizationBase, @visualize, visualize
22
using Test: @test, @testset
33

44
@testset "VisualizationBase" begin
5-
x = [2, 3]
6-
@test sprint(visualize, x) ==
7-
"2-element Vector{Int64}:\n 2\n 3\n" ==
8-
sprint((io, x) -> display(TextDisplay(io), x), x)
9-
@test sprint((io, x) -> visualize(io, x; name="y"), x) ==
10-
"y = \n 2-element Vector{Int64}:\n 2\n 3\n"
11-
@test sprint((io, x) -> @visualize(x, io=io), x) ==
12-
"x = \n 2-element Vector{Int64}:\n 2\n 3\n"
13-
@test sprint((io, x) -> @visualize(x, io=io, name="y"), x) ==
14-
"y = \n 2-element Vector{Int64}:\n 2\n 3\n"
5+
x = [2, 3]
6+
@test sprint(visualize, x) ==
7+
"2-element Vector{Int64}:\n 2\n 3\n" ==
8+
sprint((io, x) -> display(TextDisplay(io), x), x)
9+
@test sprint((io, x) -> visualize(io, x; name = "y"), x) ==
10+
"y = \n 2-element Vector{Int64}:\n 2\n 3\n"
11+
@test sprint((io, x) -> @visualize(x, io = io), x) ==
12+
"x = \n 2-element Vector{Int64}:\n 2\n 3\n"
13+
@test sprint((io, x) -> @visualize(x, io = io, name = "y"), x) ==
14+
"y = \n 2-element Vector{Int64}:\n 2\n 3\n"
1515
end

0 commit comments

Comments
 (0)