Skip to content

Commit c4a9f88

Browse files
Automatic Runic.jl run (#49)
Co-authored-by: mtfishman <[email protected]> Co-authored-by: mtfishman <[email protected]>
1 parent 105941a commit c4a9f88

26 files changed

+2277
-2271
lines changed

.JuliaFormatter.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/FormatCheck.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
name: "Format Check"
22

33
on:
4-
push:
5-
branches:
6-
- 'main'
7-
tags: '*'
8-
pull_request:
4+
pull_request_target:
5+
paths: ['**/*.jl']
6+
types: [opened, synchronize, reopened, ready_for_review]
7+
8+
permissions:
9+
contents: read
10+
actions: write
11+
pull-requests: write
912

1013
jobs:
1114
format-check:

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
.vscode/
1010
Manifest.toml
1111
benchmark/*.json
12+
dev/
13+
docs/LocalPreferences.toml
1214
docs/Manifest.toml
1315
docs/build/
1416
docs/src/index.md
17+
examples/LocalPreferences.toml
18+
test/LocalPreferences.toml

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ci:
2-
skip: [julia-formatter]
2+
skip: [runic]
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -11,7 +11,7 @@ repos:
1111
- id: end-of-file-fixer
1212
exclude_types: [markdown] # incompatible with Literate.jl
1313

14-
- repo: "https://github.com/domluna/JuliaFormatter.jl"
15-
rev: v2.1.6
14+
- repo: https://github.com/fredrikekre/runic-pre-commit
15+
rev: v2.0.1
1616
hooks:
17-
- id: "julia-formatter"
17+
- id: runic

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "KroneckerArrays"
22
uuid = "05d0b138-81bc-4ff7-84be-08becefb1ccc"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.2.3"
4+
version = "0.2.4"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

docs/make.jl

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

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

88
include("make_index.jl")
99

1010
makedocs(;
11-
modules=[KroneckerArrays],
12-
authors="ITensor developers <[email protected]> and contributors",
13-
sitename="KroneckerArrays.jl",
14-
format=Documenter.HTML(;
15-
canonical="https://itensor.github.io/KroneckerArrays.jl",
16-
edit_link="main",
17-
assets=["assets/favicon.ico", "assets/extras.css"],
18-
),
19-
pages=["Home" => "index.md", "Reference" => "reference.md"],
11+
modules = [KroneckerArrays],
12+
authors = "ITensor developers <[email protected]> and contributors",
13+
sitename = "KroneckerArrays.jl",
14+
format = Documenter.HTML(;
15+
canonical = "https://itensor.github.io/KroneckerArrays.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/KroneckerArrays.jl", devbranch="main", push_preview=true
23+
repo = "github.com/ITensor/KroneckerArrays.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 KroneckerArrays: KroneckerArrays
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(KroneckerArrays), "examples", "README.jl"),
17-
joinpath(pkgdir(KroneckerArrays), "docs", "src");
18-
flavor=Literate.DocumenterFlavor(),
19-
name="index",
20-
postprocess=ccq_logo,
16+
joinpath(pkgdir(KroneckerArrays), "examples", "README.jl"),
17+
joinpath(pkgdir(KroneckerArrays), "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 KroneckerArrays: KroneckerArrays
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(KroneckerArrays), "examples", "README.jl"),
17-
joinpath(pkgdir(KroneckerArrays));
18-
flavor=Literate.CommonMarkFlavor(),
19-
name="README",
20-
postprocess=ccq_logo,
16+
joinpath(pkgdir(KroneckerArrays), "examples", "README.jl"),
17+
joinpath(pkgdir(KroneckerArrays));
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
# # KroneckerArrays.jl
2-
#
2+
#
33
# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://itensor.github.io/KroneckerArrays.jl/stable/)
44
# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://itensor.github.io/KroneckerArrays.jl/dev/)
55
# [![Build Status](https://github.com/ITensor/KroneckerArrays.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/KroneckerArrays.jl/actions/workflows/Tests.yml?query=branch%3Amain)

ext/KroneckerArraysBlockSparseArraysExt/KroneckerArraysBlockSparseArraysExt.jl

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ using BlockArrays: Block
44
using BlockSparseArrays: BlockIndexVector, GenericBlockIndex
55
using KroneckerArrays: CartesianPair, CartesianProduct
66
function Base.getindex(
7-
b::Block,
8-
I1::Union{CartesianPair,CartesianProduct},
9-
Irest::Union{CartesianPair,CartesianProduct}...,
10-
)
11-
return GenericBlockIndex(b, (I1, Irest...))
7+
b::Block,
8+
I1::Union{CartesianPair, CartesianProduct},
9+
Irest::Union{CartesianPair, CartesianProduct}...,
10+
)
11+
return GenericBlockIndex(b, (I1, Irest...))
1212
end
1313
function Base.getindex(b::Block, I1::CartesianProduct, Irest::CartesianProduct...)
14-
return BlockIndexVector(b, (I1, Irest...))
14+
return BlockIndexVector(b, (I1, Irest...))
1515
end
1616

1717
using BlockSparseArrays: BlockSparseArrays, blockrange
1818
using KroneckerArrays: CartesianPair, CartesianProduct, cartesianrange
1919
function BlockSparseArrays.blockrange(bs::Vector{<:CartesianPair})
20-
return blockrange(map(cartesianrange, bs))
20+
return blockrange(map(cartesianrange, bs))
2121
end
2222
function BlockSparseArrays.blockrange(bs::Vector{<:CartesianProduct})
23-
return blockrange(map(cartesianrange, bs))
23+
return blockrange(map(cartesianrange, bs))
2424
end
2525

2626
using BlockArrays: BlockArrays, mortar
@@ -31,56 +31,56 @@ using KroneckerArrays: CartesianProductUnitRange
3131
# This is helpful when indexing `BlockUnitRange`, for example:
3232
# https://github.com/JuliaArrays/BlockArrays.jl/blob/v1.7.1/src/blockaxis.jl#L540-L547
3333
function BlockArrays.mortar(blocks::AbstractVector{<:CartesianProductUnitRange})
34-
return mortar(blocks, (blockrange(map(Base.axes1, blocks)),))
34+
return mortar(blocks, (blockrange(map(Base.axes1, blocks)),))
3535
end
3636

3737
using BlockArrays: AbstractBlockedUnitRange
3838
using BlockSparseArrays: Block, ZeroBlocks, eachblockaxis, mortar_axis
3939
using KroneckerArrays: KroneckerArrays, KroneckerArray, , arg1, arg2, isactive
4040

4141
function KroneckerArrays.arg1(r::AbstractBlockedUnitRange)
42-
return mortar_axis(arg1.(eachblockaxis(r)))
42+
return mortar_axis(arg1.(eachblockaxis(r)))
4343
end
4444
function KroneckerArrays.arg2(r::AbstractBlockedUnitRange)
45-
return mortar_axis(arg2.(eachblockaxis(r)))
45+
return mortar_axis(arg2.(eachblockaxis(r)))
4646
end
4747

4848
function block_axes(
49-
ax::NTuple{N,AbstractUnitRange{<:Integer}}, I::Vararg{Block{1},N}
50-
) where {N}
51-
return ntuple(N) do d
52-
return only(axes(ax[d][I[d]]))
53-
end
49+
ax::NTuple{N, AbstractUnitRange{<:Integer}}, I::Vararg{Block{1}, N}
50+
) where {N}
51+
return ntuple(N) do d
52+
return only(axes(ax[d][I[d]]))
53+
end
5454
end
55-
function block_axes(ax::NTuple{N,AbstractUnitRange{<:Integer}}, I::Block{N}) where {N}
56-
return block_axes(ax, Tuple(I)...)
55+
function block_axes(ax::NTuple{N, AbstractUnitRange{<:Integer}}, I::Block{N}) where {N}
56+
return block_axes(ax, Tuple(I)...)
5757
end
5858

5959
using DiagonalArrays: ShapeInitializer
6060

6161
## TODO: Is this needed?
6262
function Base.getindex(
63-
a::ZeroBlocks{N,KroneckerArray{T,N,A1,A2}}, I::Vararg{Int,N}
64-
) where {T,N,A1<:AbstractArray{T,N},A2<:AbstractArray{T,N}}
65-
ax_a1 = map(arg1, a.parentaxes)
66-
ax_a2 = map(arg2, a.parentaxes)
67-
block_ax_a1 = arg1.(block_axes(a.parentaxes, Block(I)))
68-
block_ax_a2 = arg2.(block_axes(a.parentaxes, Block(I)))
69-
# TODO: Is this a good definition? It is similar to
70-
# the definition of `similar` and `adapt_structure`.
71-
return if isactive(A1) == isactive(A2)
72-
ZeroBlocks{N,A1}(ax_a1)[I...] ZeroBlocks{N,A2}(ax_a2)[I...]
73-
elseif isactive(A1)
74-
ZeroBlocks{N,A1}(ax_a1)[I...] A2(ShapeInitializer(), block_ax_a2)
75-
elseif isactive(A2)
76-
A1(ShapeInitializer(), block_ax_a1) ZeroBlocks{N,A2}(ax_a2)[I...]
77-
end
63+
a::ZeroBlocks{N, KroneckerArray{T, N, A1, A2}}, I::Vararg{Int, N}
64+
) where {T, N, A1 <: AbstractArray{T, N}, A2 <: AbstractArray{T, N}}
65+
ax_a1 = map(arg1, a.parentaxes)
66+
ax_a2 = map(arg2, a.parentaxes)
67+
block_ax_a1 = arg1.(block_axes(a.parentaxes, Block(I)))
68+
block_ax_a2 = arg2.(block_axes(a.parentaxes, Block(I)))
69+
# TODO: Is this a good definition? It is similar to
70+
# the definition of `similar` and `adapt_structure`.
71+
return if isactive(A1) == isactive(A2)
72+
ZeroBlocks{N, A1}(ax_a1)[I...] ZeroBlocks{N, A2}(ax_a2)[I...]
73+
elseif isactive(A1)
74+
ZeroBlocks{N, A1}(ax_a1)[I...] A2(ShapeInitializer(), block_ax_a2)
75+
elseif isactive(A2)
76+
A1(ShapeInitializer(), block_ax_a1) ZeroBlocks{N, A2}(ax_a2)[I...]
77+
end
7878
end
7979

8080
using BlockSparseArrays: BlockSparseArrays
8181
using KroneckerArrays: KroneckerArrays, KroneckerVector
8282
function BlockSparseArrays.to_truncated_indices(values::KroneckerVector, I)
83-
return KroneckerArrays.to_truncated_indices(values, I)
83+
return KroneckerArrays.to_truncated_indices(values, I)
8484
end
8585

8686
end

0 commit comments

Comments
 (0)