Skip to content

Commit 570adf4

Browse files
committed
Skeleton updates
1 parent 23064e7 commit 570adf4

File tree

11 files changed

+189
-110
lines changed

11 files changed

+189
-110
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "Documentation"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags: '*'
8+
pull_request:
9+
schedule:
10+
- cron: '1 4 * * 4'
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch || github.ref != 'refs/tags/v*' }}
15+
16+
jobs:
17+
build-and-deploy-docs:
18+
name: "Documentation"
19+
uses: "ITensor/ITensorActions/.github/workflows/Documentation.yml@main"
20+
with:
21+
localregistry: https://github.com/ITensor/ITensorRegistry.git
22+
secrets:
23+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/FormatCheck.yml

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,13 @@
1-
name: Format check
1+
name: "Format Check"
2+
23
on:
34
push:
4-
branches: [main]
5-
tags: [v*]
5+
branches:
6+
- 'main'
7+
tags: '*'
68
pull_request:
79

810
jobs:
9-
format:
11+
format-check:
1012
name: "Format Check"
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v4
14-
- uses: julia-actions/setup-julia@v2
15-
with:
16-
version: 1
17-
- name: Install JuliaFormatter and format
18-
run: |
19-
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
20-
julia -e 'using JuliaFormatter; format(".", verbose=true)'
21-
- name: Check format
22-
run: |
23-
julia -e '
24-
out = Cmd(`git diff --name-only`) |> read |> String
25-
if out == ""
26-
exit(0)
27-
else
28-
@error "The following files have not been formatted:"
29-
write(stdout, out)
30-
out_diff = Cmd(`git diff`) |> read |> String
31-
@error "Diff:"
32-
write(stdout, out_diff)
33-
exit(1)
34-
@error ""
35-
end'
13+
uses: "ITensor/ITensorActions/.github/workflows/FormatCheck.yml@main"
Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,15 @@
1-
name: Literate check
1+
name: "Literate Check"
2+
23
on:
34
push:
4-
branches: [main]
5-
tags: [v*]
5+
branches:
6+
- 'main'
7+
tags: '*'
68
pull_request:
79

810
jobs:
911
literate:
1012
name: "Literate Check"
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v4
14-
- uses: julia-actions/setup-julia@v2
15-
with:
16-
version: 1
17-
- name: Install Literate and generate docs
18-
run: |
19-
julia -e '
20-
using Pkg
21-
# TODO: Delete these once they are registered.
22-
Pkg.add(url="https://github.com/ITensor/TypeParameterAccessors.jl")
23-
Pkg.add(url="https://github.com/ITensor/BroadcastMapConversion.jl")
24-
Pkg.add(url="https://github.com/ITensor/NestedPermutedDimsArrays.jl")
25-
Pkg.add(url="https://github.com/ITensor/LabelledNumbers.jl")
26-
Pkg.add(url="https://github.com/ITensor/GradedUnitRanges.jl")
27-
Pkg.add(url="https://github.com/ITensor/SparseArraysBase.jl")
28-
Pkg.add(url="https://github.com/ITensor/TensorAlgebra.jl")
29-
Pkg.develop(PackageSpec(path=pwd()))
30-
Pkg.instantiate()
31-
Pkg.add(PackageSpec(name="Literate"))'
32-
julia -e 'include("docs/make_readme.jl")'
33-
- name: Check if docs need to be updated
34-
run: |
35-
julia -e '
36-
out = Cmd(`git diff --name-only`) |> read |> String
37-
if out == ""
38-
exit(0)
39-
else
40-
@error "The docs are outdated, rerun Literate to regenerate them."
41-
write(stdout, out)
42-
out_diff = Cmd(`git diff`) |> read |> String
43-
@error "Diff:"
44-
write(stdout, out_diff)
45-
exit(1)
46-
@error ""
47-
end'
13+
uses: "ITensor/ITensorActions/.github/workflows/LiterateCheck.yml@main"
14+
with:
15+
localregistry: https://github.com/ITensor/ITensorRegistry.git

.github/workflows/Tests.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Tests
2+
on:
3+
push:
4+
branches:
5+
- 'master'
6+
- 'main'
7+
- 'release-'
8+
tags: '*'
9+
paths-ignore:
10+
- 'docs/**'
11+
pull_request:
12+
workflow_dispatch:
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
# Cancel intermediate builds: only if it is a pull request build.
17+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
18+
19+
jobs:
20+
tests:
21+
name: "Tests"
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
version:
26+
- 'lts' # minimal supported version
27+
- '1' # latest released Julia version
28+
# group:
29+
# - 'core'
30+
# - 'optional'
31+
os:
32+
- ubuntu-latest
33+
- macOS-latest
34+
- windows-latest
35+
uses: "ITensor/ITensorActions/.github/workflows/Tests.yml@main"
36+
with:
37+
group: "${{ matrix.group }}"
38+
julia-version: "${{ matrix.version }}"
39+
os: "${{ matrix.os }}"
40+
localregistry: https://github.com/ITensor/ITensorRegistry.git
41+
secrets:
42+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.pre-commit-config.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ repos:
77
- id: check-yaml
88
- id: end-of-file-fixer
99
exclude_types: [markdown] # incompatible with Literate.jl
10-
- repo: https://github.com/qiaojunfeng/pre-commit-julia-format
11-
rev: v0.2.0
10+
11+
- repo: "https://github.com/domluna/JuliaFormatter.jl"
12+
rev: v1.0.62
1213
hooks:
13-
- id: julia-format
14+
- id: "julia-formatter"

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/BlockSparseArrays.jl/stable/)
44
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/BlockSparseArrays.jl/dev/)
5-
[![Build Status](https://github.com/ITensor/BlockSparseArrays.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/BlockSparseArrays.jl/actions/workflows/CI.yml?query=branch%3Amain)
5+
[![Build Status](https://github.com/ITensor/BlockSparseArrays.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/BlockSparseArrays.jl/actions/workflows/Tests.yml?query=branch%3Amain)
66
[![Coverage](https://codecov.io/gh/ITensor/BlockSparseArrays.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/BlockSparseArrays.jl)
77
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
88
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
@@ -11,31 +11,31 @@ A block sparse array type in Julia based on the [`BlockArrays.jl`](https://githu
1111

1212
## Installation instructions
1313

14+
This package resides in the `ITensor/ITensorRegistry` local registry.
15+
In order to install, simply add that registry through your package manager.
16+
This step is only required once.
1417
```julia
1518
julia> using Pkg: Pkg
1619

17-
julia> Pkg.add(url="https://github.com/ITensor/BroadcastMapConversion.jl")
18-
19-
julia> Pkg.add(url="https://github.com/ITensor/NestedPermutedDimsArrays.jl")
20-
21-
julia> Pkg.add(url="https://github.com/ITensor/TypeParameterAccessors.jl")
22-
23-
julia> Pkg.add(url="https://github.com/ITensor/LabelledNumbers.jl")
24-
25-
julia> Pkg.add(url="https://github.com/ITensor/GradedUnitRanges.jl")
26-
27-
julia> Pkg.add(url="https://github.com/ITensor/SparseArraysBase.jl")
20+
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
21+
```
22+
or:
23+
```julia
24+
julia> Pkg.Registry.add(url="[email protected]:ITensor/ITensorRegistry.git")
25+
```
26+
if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.
2827

29-
julia> Pkg.add(url="https://github.com/ITensor/TensorAlgebra.jl")
28+
Then, the package can be added as usual through the package manager:
3029

31-
julia> Pkg.add(url="https://github.com/ITensor/BlockSparseArrays.jl")
30+
```julia
31+
julia> Pkg.add("BlockSparseArrays")
3232
```
3333

3434
## Examples
3535

3636
````julia
3737
using BlockArrays: BlockArrays, BlockedVector, Block, blockedrange
38-
using BlockSparseArrays: BlockSparseArray, block_stored_length
38+
using BlockSparseArrays: BlockSparseArray, block_storedlength
3939
using Test: @test, @test_broken
4040

4141
function main()
@@ -62,13 +62,13 @@ function main()
6262
]
6363
b = BlockSparseArray(nz_blocks, d_blocks, i_axes)
6464

65-
@test block_stored_length(b) == 2
65+
@test block_storedlength(b) == 2
6666

6767
# Blocks with discontiguous underlying data
6868
d_blocks = randn.(nz_block_sizes)
6969
b = BlockSparseArray(nz_blocks, d_blocks, i_axes)
7070

71-
@test block_stored_length(b) == 2
71+
@test block_storedlength(b) == 2
7272

7373
# Access a block
7474
@test b[Block(1, 1)] == d_blocks[1]
@@ -92,7 +92,7 @@ function main()
9292
@test b + b Array(b) + Array(b)
9393
@test b + b isa BlockSparseArray
9494
# TODO: Fix this, broken.
95-
@test_broken block_stored_length(b + b) == 2
95+
@test_broken block_storedlength(b + b) == 2
9696

9797
scaled_b = 2b
9898
@test scaled_b 2Array(b)

examples/README.jl

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/BlockSparseArrays.jl/stable/)
44
# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/BlockSparseArrays.jl/dev/)
5-
# [![Build Status](https://github.com/ITensor/BlockSparseArrays.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/BlockSparseArrays.jl/actions/workflows/CI.yml?query=branch%3Amain)
5+
# [![Build Status](https://github.com/ITensor/BlockSparseArrays.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/BlockSparseArrays.jl/actions/workflows/Tests.yml?query=branch%3Amain)
66
# [![Coverage](https://codecov.io/gh/ITensor/BlockSparseArrays.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/BlockSparseArrays.jl)
77
# [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
88
# [![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
@@ -11,25 +11,29 @@
1111

1212
# ## Installation instructions
1313

14+
# This package resides in the `ITensor/ITensorRegistry` local registry.
15+
# In order to install, simply add that registry through your package manager.
16+
# This step is only required once.
1417
#=
1518
```julia
1619
julia> using Pkg: Pkg
1720
18-
julia> Pkg.add(url="https://github.com/ITensor/BroadcastMapConversion.jl")
19-
20-
julia> Pkg.add(url="https://github.com/ITensor/NestedPermutedDimsArrays.jl")
21-
22-
julia> Pkg.add(url="https://github.com/ITensor/TypeParameterAccessors.jl")
23-
24-
julia> Pkg.add(url="https://github.com/ITensor/LabelledNumbers.jl")
25-
26-
julia> Pkg.add(url="https://github.com/ITensor/GradedUnitRanges.jl")
27-
28-
julia> Pkg.add(url="https://github.com/ITensor/SparseArraysBase.jl")
21+
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
22+
```
23+
=#
24+
# or:
25+
#=
26+
```julia
27+
julia> Pkg.Registry.add(url="[email protected]:ITensor/ITensorRegistry.git")
28+
```
29+
=#
30+
# if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.
2931

30-
julia> Pkg.add(url="https://github.com/ITensor/TensorAlgebra.jl")
32+
# Then, the package can be added as usual through the package manager:
3133

32-
julia> Pkg.add(url="https://github.com/ITensor/BlockSparseArrays.jl")
34+
#=
35+
```julia
36+
julia> Pkg.add("BlockSparseArrays")
3337
```
3438
=#
3539

test/test_basics.jl renamed to test/basics/test_basics.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@eval module $(gensym())
21
using BlockArrays:
32
Block,
43
BlockIndexRange,
@@ -1028,4 +1027,3 @@ using .NDTensorsTestUtils: devices_list, is_supported_eltype
10281027
@test storedlength(b) == 17
10291028
end
10301029
end
1031-
end

test/basics/test_extensions.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include("../../ext/BlockSparseArraysTensorAlgebraExt/test/runtests.jl")
2+
include("../../ext/BlockSparseArraysGradedUnitRangesExt/test/runtests.jl")

test/runtests.jl

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,61 @@
1-
@eval module $(gensym())
2-
include("test_basics.jl")
3-
include("../ext/BlockSparseArraysTensorAlgebraExt/test/runtests.jl")
4-
include("../ext/BlockSparseArraysGradedUnitRangesExt/test/runtests.jl")
1+
using SafeTestsets: @safetestset
2+
using Suppressor: Suppressor
3+
4+
# check for filtered groups
5+
# either via `--group=ALL` or through ENV["GROUP"]
6+
const pat = r"(?:--group=)(\w+)"
7+
arg_id = findfirst(contains(pat), ARGS)
8+
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,
14+
)
15+
16+
"match files of the form `test_*.jl`, but exclude `*setup*.jl`"
17+
istestfile(fn) =
18+
endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup")
19+
"match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`"
20+
isexamplefile(fn) =
21+
endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup")
22+
23+
@time begin
24+
# tests in groups based on folder structure
25+
for testgroup in filter(isdir, readdir(@__DIR__))
26+
if GROUP == "ALL" || GROUP == uppercase(testgroup)
27+
for file in filter(istestfile, readdir(joinpath(@__DIR__, testgroup); join=true))
28+
@eval @safetestset $file begin
29+
include($file)
30+
end
31+
end
32+
end
33+
end
34+
35+
# single files in top folder
36+
for file in filter(istestfile, readdir(@__DIR__))
37+
(file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion
38+
@eval @safetestset $file begin
39+
include($file)
40+
end
41+
end
42+
43+
# test examples
44+
examplepath = joinpath(@__DIR__, "..", "examples")
45+
for (root, _, files) in walkdir(examplepath)
46+
contains(chopprefix(root, @__DIR__), "setup") && continue
47+
for file in filter(isexamplefile, files)
48+
filename = joinpath(root, file)
49+
@eval begin
50+
@safetestset $file begin
51+
$(Expr(
52+
:macrocall,
53+
GlobalRef(Suppressor, Symbol("@suppress")),
54+
LineNumberNode(@__LINE__, @__FILE__),
55+
:(include($filename)),
56+
))
57+
end
58+
end
59+
end
60+
end
561
end

0 commit comments

Comments
 (0)