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
3 changes: 0 additions & 3 deletions .JuliaFormatter.toml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "CompatHelper"

on:
schedule:
- cron: 0 0 * * *
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
contents: write
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: "Format Check"

on:
push:
branches:
- 'main'
tags: '*'
pull_request:
pull_request_target:
paths: ['**/*.jl']
types: [opened, synchronize, reopened, ready_for_review]

permissions:
contents: read
actions: write
pull-requests: write

jobs:
format-check:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
.vscode/
Manifest.toml
benchmark/*.json
dev/
docs/LocalPreferences.toml
docs/Manifest.toml
docs/build/
docs/src/index.md
examples/LocalPreferences.toml
test/LocalPreferences.toml
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ci:
skip: [julia-formatter]
skip: [runic]

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

- repo: "https://github.com/domluna/JuliaFormatter.jl"
rev: v2.1.6
- repo: https://github.com/fredrikekre/runic-pre-commit
rev: v2.0.1
hooks:
- id: "julia-formatter"
- id: runic
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DiagonalArrays"
uuid = "74fd4be6-21e2-4f6f-823a-4360d37c7a77"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.3.21"
version = "0.3.22"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
110 changes: 55 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,67 +45,67 @@ julia> Pkg.add("DiagonalArrays")

````julia
using DiagonalArrays:
DiagonalArray, DiagonalMatrix, DiagIndex, DiagIndices, diaglength, isdiagindex
DiagonalArray, DiagonalMatrix, DiagIndex, DiagIndices, diaglength, isdiagindex
using Test: @test

function main()
d = DiagonalMatrix([1.0, 2.0, 3.0])
@test eltype(d) == Float64
@test diaglength(d) == 3
@test size(d) == (3, 3)
@test d[1, 1] == 1
@test d[2, 2] == 2
@test d[3, 3] == 3
@test d[1, 2] == 0

d = DiagonalArray([1.0, 2.0, 3.0], 3, 4, 5)
@test eltype(d) == Float64
@test diaglength(d) == 3
@test d[1, 1, 1] == 1
@test d[2, 2, 2] == 2
@test d[3, 3, 3] == 3
@test d[1, 2, 1] == 0

d[2, 2, 2] = 22
@test d[2, 2, 2] == 22

d_r = reshape(d, 3, 20)
@test size(d_r) == (3, 20)
@test all(I -> d_r[I] == d[I], LinearIndices(d))

@test length(d[DiagIndices(:)]) == 3
@test Array(d) == d
@test d[DiagIndex(2)] == d[2, 2, 2]

d[DiagIndex(2)] = 222
@test d[2, 2, 2] == 222

a = randn(3, 4, 5)
new_diag = randn(3)
a[DiagIndices(:)] = new_diag
d[DiagIndices(:)] = a[DiagIndices(:)]

@test a[DiagIndices(:)] == new_diag
@test d[DiagIndices(:)] == new_diag

permuted_d = permutedims(d, (3, 2, 1))
@test permuted_d isa DiagonalArray
@test permuted_d[DiagIndices(:)] == d[DiagIndices(:)]
@test size(d) == (3, 4, 5)
@test size(permuted_d) == (5, 4, 3)
for I in eachindex(d)
if !isdiagindex(d, I)
@test iszero(d[I])
else
@test !iszero(d[I])
d = DiagonalMatrix([1.0, 2.0, 3.0])
@test eltype(d) == Float64
@test diaglength(d) == 3
@test size(d) == (3, 3)
@test d[1, 1] == 1
@test d[2, 2] == 2
@test d[3, 3] == 3
@test d[1, 2] == 0

d = DiagonalArray([1.0, 2.0, 3.0], 3, 4, 5)
@test eltype(d) == Float64
@test diaglength(d) == 3
@test d[1, 1, 1] == 1
@test d[2, 2, 2] == 2
@test d[3, 3, 3] == 3
@test d[1, 2, 1] == 0

d[2, 2, 2] = 22
@test d[2, 2, 2] == 22

d_r = reshape(d, 3, 20)
@test size(d_r) == (3, 20)
@test all(I -> d_r[I] == d[I], LinearIndices(d))

@test length(d[DiagIndices(:)]) == 3
@test Array(d) == d
@test d[DiagIndex(2)] == d[2, 2, 2]

d[DiagIndex(2)] = 222
@test d[2, 2, 2] == 222

a = randn(3, 4, 5)
new_diag = randn(3)
a[DiagIndices(:)] = new_diag
d[DiagIndices(:)] = a[DiagIndices(:)]

@test a[DiagIndices(:)] == new_diag
@test d[DiagIndices(:)] == new_diag

permuted_d = permutedims(d, (3, 2, 1))
@test permuted_d isa DiagonalArray
@test permuted_d[DiagIndices(:)] == d[DiagIndices(:)]
@test size(d) == (3, 4, 5)
@test size(permuted_d) == (5, 4, 3)
for I in eachindex(d)
if !isdiagindex(d, I)
@test iszero(d[I])
else
@test !iszero(d[I])
end
end
end

mapped_d = map(x -> 2x, d)
@test mapped_d isa DiagonalArray
@test mapped_d == map(x -> 2x, Array(d))
mapped_d = map(x -> 2x, d)
@test mapped_d isa DiagonalArray
@test mapped_d == map(x -> 2x, Array(d))

return nothing
return nothing
end

main()
Expand Down
22 changes: 11 additions & 11 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using DiagonalArrays: DiagonalArrays
using Documenter: Documenter, DocMeta, deploydocs, makedocs

DocMeta.setdocmeta!(DiagonalArrays, :DocTestSetup, :(using DiagonalArrays); recursive=true)
DocMeta.setdocmeta!(DiagonalArrays, :DocTestSetup, :(using DiagonalArrays); recursive = true)

include("make_index.jl")

makedocs(;
modules=[DiagonalArrays],
authors="ITensor developers <[email protected]> and contributors",
sitename="DiagonalArrays.jl",
format=Documenter.HTML(;
canonical="https://itensor.github.io/DiagonalArrays.jl",
edit_link="main",
assets=["assets/favicon.ico", "assets/extras.css"],
),
pages=["Home" => "index.md", "Reference" => "reference.md"],
modules = [DiagonalArrays],
authors = "ITensor developers <[email protected]> and contributors",
sitename = "DiagonalArrays.jl",
format = Documenter.HTML(;
canonical = "https://itensor.github.io/DiagonalArrays.jl",
edit_link = "main",
assets = ["assets/favicon.ico", "assets/extras.css"],
),
pages = ["Home" => "index.md", "Reference" => "reference.md"],
)

deploydocs(;
repo="github.com/ITensor/DiagonalArrays.jl", devbranch="main", push_preview=true
repo = "github.com/ITensor/DiagonalArrays.jl", devbranch = "main", push_preview = true
)
16 changes: 8 additions & 8 deletions docs/make_index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ using Literate: Literate
using DiagonalArrays: DiagonalArrays

function ccq_logo(content)
include_ccq_logo = """
include_ccq_logo = """
```@raw html
<img class="display-light-only" src="assets/CCQ.png" width="20%" alt="Flatiron Center for Computational Quantum Physics logo."/>
<img class="display-dark-only" src="assets/CCQ-dark.png" width="20%" alt="Flatiron Center for Computational Quantum Physics logo."/>
```
"""
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
end

Literate.markdown(
joinpath(pkgdir(DiagonalArrays), "examples", "README.jl"),
joinpath(pkgdir(DiagonalArrays), "docs", "src");
flavor=Literate.DocumenterFlavor(),
name="index",
postprocess=ccq_logo,
joinpath(pkgdir(DiagonalArrays), "examples", "README.jl"),
joinpath(pkgdir(DiagonalArrays), "docs", "src");
flavor = Literate.DocumenterFlavor(),
name = "index",
postprocess = ccq_logo,
)
16 changes: 8 additions & 8 deletions docs/make_readme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ using Literate: Literate
using DiagonalArrays: DiagonalArrays

function ccq_logo(content)
include_ccq_logo = """
include_ccq_logo = """
<picture>
<source media="(prefers-color-scheme: dark)" width="20%" srcset="docs/src/assets/CCQ-dark.png">
<img alt="Flatiron Center for Computational Quantum Physics logo." width="20%" src="docs/src/assets/CCQ.png">
</picture>
"""
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
end

Literate.markdown(
joinpath(pkgdir(DiagonalArrays), "examples", "README.jl"),
joinpath(pkgdir(DiagonalArrays));
flavor=Literate.CommonMarkFlavor(),
name="README",
postprocess=ccq_logo,
joinpath(pkgdir(DiagonalArrays), "examples", "README.jl"),
joinpath(pkgdir(DiagonalArrays));
flavor = Literate.CommonMarkFlavor(),
name = "README",
postprocess = ccq_logo,
)
Loading
Loading