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 = "QuantumOperatorDefinitions"
uuid = "826dd319-6fd5-459a-a990-3a4f214664bf"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.2.8"
version = "0.2.9"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ using Test: @test
@test Matrix(OpName("Y")) == [0 -im; im 0]
@test Matrix(OpName("Z")) == [1 0; 0 -1]

@test Matrix(OpName("Rx"; θ=π / 3)) ≈ [sin(π / 3) -cos(π / 3)*im; -cos(π / 3)*im sin(π / 3)]
@test Matrix(OpName("Rx"; θ = π / 3)) ≈ [sin(π / 3) -cos(π / 3) * im; -cos(π / 3) * im sin(π / 3)]
````

---
Expand Down
32 changes: 16 additions & 16 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ using QuantumOperatorDefinitions: QuantumOperatorDefinitions
using Documenter: Documenter, DocMeta, deploydocs, makedocs

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

include("make_index.jl")

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

deploydocs(;
repo="github.com/ITensor/QuantumOperatorDefinitions.jl",
devbranch="main",
push_preview=true,
repo = "github.com/ITensor/QuantumOperatorDefinitions.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 QuantumOperatorDefinitions: QuantumOperatorDefinitions

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(QuantumOperatorDefinitions), "examples", "README.jl"),
joinpath(pkgdir(QuantumOperatorDefinitions), "docs", "src");
flavor=Literate.DocumenterFlavor(),
name="index",
postprocess=ccq_logo,
joinpath(pkgdir(QuantumOperatorDefinitions), "examples", "README.jl"),
joinpath(pkgdir(QuantumOperatorDefinitions), "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 QuantumOperatorDefinitions: QuantumOperatorDefinitions

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(QuantumOperatorDefinitions), "examples", "README.jl"),
joinpath(pkgdir(QuantumOperatorDefinitions));
flavor=Literate.CommonMarkFlavor(),
name="README",
postprocess=ccq_logo,
joinpath(pkgdir(QuantumOperatorDefinitions), "examples", "README.jl"),
joinpath(pkgdir(QuantumOperatorDefinitions));
flavor = Literate.CommonMarkFlavor(),
name = "README",
postprocess = ccq_logo,
)
4 changes: 2 additions & 2 deletions examples/README.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# # QuantumOperatorDefinitions.jl
#
#
# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://itensor.github.io/QuantumOperatorDefinitions.jl/stable/)
# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://itensor.github.io/QuantumOperatorDefinitions.jl/dev/)
# [![Build Status](https://github.com/ITensor/QuantumOperatorDefinitions.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/QuantumOperatorDefinitions.jl/actions/workflows/Tests.yml?query=branch%3Amain)
Expand Down Expand Up @@ -83,4 +83,4 @@ using Test: @test
@test Matrix(OpName("Y")) == [0 -im; im 0]
@test Matrix(OpName("Z")) == [1 0; 0 -1]

@test Matrix(OpName("Rx"; θ=π / 3)) ≈ [sin(π / 3) -cos(π / 3)*im; -cos(π / 3)*im sin(π / 3)]
@test Matrix(OpName("Rx"; θ = π / 3)) ≈ [sin(π / 3) -cos(π / 3) * im; -cos(π / 3) * im sin(π / 3)]
Original file line number Diff line number Diff line change
Expand Up @@ -2,97 +2,103 @@ module QuantumOperatorDefinitionsGradedArraysExt

using BlockArrays: blocklasts, blocklength, blocklengths
using GradedArrays:
AbstractGradedUnitRange, GradedOneTo, SectorProduct, U1, Z, ×, dual, gradedrange, sectors
AbstractGradedUnitRange, GradedOneTo, SectorProduct, U1, Z, ×, dual, gradedrange, sectors
using QuantumOperatorDefinitions:
QuantumOperatorDefinitions,
@GradingType_str,
@SiteType_str,
GradingType,
OpName,
SiteType,
name
QuantumOperatorDefinitions,
@GradingType_str,
@SiteType_str,
GradingType,
OpName,
SiteType,
name

function Base.axes(::OpName, domain::Tuple{Vararg{AbstractGradedUnitRange}})
return (domain..., dual.(domain)...)
return (domain..., dual.(domain)...)
end

sortedunion(a, b) = sort(union(a, b))
function QuantumOperatorDefinitions.combine_axes(a1::GradedOneTo, a2::GradedOneTo)
blocklength(a1) == blocklength(a2) ||
throw(ArgumentError("Axes must have the same number of blocks."))
nblocks = blocklength(a1)
return gradedrange(
map(Base.OneTo(nblocks)) do i
l1 = blocklengths(a1)[i]
l2 = blocklengths(a2)[i]
l1 == l2 || throw(ArgumentError("Blocks must have the same length."))
return sectors(a1)[i] × sectors(a2)[i] => l1
end,
)
blocklength(a1) == blocklength(a2) ||
throw(ArgumentError("Axes must have the same number of blocks."))
nblocks = blocklength(a1)
return gradedrange(
map(Base.OneTo(nblocks)) do i
l1 = blocklengths(a1)[i]
l2 = blocklengths(a2)[i]
l1 == l2 || throw(ArgumentError("Blocks must have the same length."))
return sectors(a1)[i] × sectors(a2)[i] => l1
end,
)
end
QuantumOperatorDefinitions.combine_axes(a::GradedOneTo, b::Base.OneTo) = a
QuantumOperatorDefinitions.combine_axes(a::Base.OneTo, b::GradedOneTo) = b

function Base.AbstractUnitRange(::GradingType"N", t::SiteType)
return gradedrange(map(i -> SectorProduct((; N=U1(i - 1))) => 1, 1:length(t)))
return gradedrange(map(i -> SectorProduct((; N = U1(i - 1))) => 1, 1:length(t)))
end
function Base.AbstractUnitRange(::GradingType"Sz", t::SiteType)
return gradedrange(map(i -> SectorProduct((; Sz=U1(i - 1))) => 1, 1:length(t)))
return gradedrange(map(i -> SectorProduct((; Sz = U1(i - 1))) => 1, 1:length(t)))
end
function Base.AbstractUnitRange(::GradingType"Sz↑", t::SiteType)
return AbstractUnitRange(GradingType"Sz"(), t)
return AbstractUnitRange(GradingType"Sz"(), t)
end
function Base.AbstractUnitRange(::GradingType"Sz↓", t::SiteType)
return gradedrange(map(i -> SectorProduct((; Sz=U1(-(i - 1)))) => 1, 1:length(t)))
return gradedrange(map(i -> SectorProduct((; Sz = U1(-(i - 1)))) => 1, 1:length(t)))
end

function sector(gradingtype::GradingType, sec)
sectorname = Symbol(get(gradingtype, :name, name(gradingtype)))
return SectorProduct(NamedTuple{(sectorname,)}((sec,)))
sectorname = Symbol(get(gradingtype, :name, name(gradingtype)))
return SectorProduct(NamedTuple{(sectorname,)}((sec,)))
end

function Base.AbstractUnitRange(s::GradingType"Nf", t::SiteType"Fermion")
return gradedrange([sector(s, U1(0)) => 1, sector(s, U1(1)) => 1])
return gradedrange([sector(s, U1(0)) => 1, sector(s, U1(1)) => 1])
end
# TODO: Write in terms of `GradingType"Nf"` definition.
function Base.AbstractUnitRange(s::GradingType"NfParity", t::SiteType"Fermion")
return gradedrange([sector(s, Z{2}(0)) => 1, sector(s, Z{2}(1)) => 1])
return gradedrange([sector(s, Z{2}(0)) => 1, sector(s, Z{2}(1)) => 1])
end
function Base.AbstractUnitRange(s::GradingType"Sz", t::SiteType"Fermion")
return gradedrange([sector(s, U1(0)) => 1, sector(s, U1(1)) => 1])
return gradedrange([sector(s, U1(0)) => 1, sector(s, U1(1)) => 1])
end
function Base.AbstractUnitRange(s::GradingType"Sz↑", t::SiteType"Fermion")
return gradedrange([sector(s, U1(0)) => 1, sector(s, U1(1)) => 1])
return gradedrange([sector(s, U1(0)) => 1, sector(s, U1(1)) => 1])
end
function Base.AbstractUnitRange(s::GradingType"Sz↓", t::SiteType"Fermion")
return gradedrange([sector(s, U1(0)) => 1, sector(s, U1(-1)) => 1])
return gradedrange([sector(s, U1(0)) => 1, sector(s, U1(-1)) => 1])
end

# TODO: Write in terms of `SiteType"Fermion"` definitions.
function Base.AbstractUnitRange(s::GradingType"Nf", t::SiteType"Electron")
return gradedrange([
sector(s, U1(0)) => 1,
sector(s, U1(1)) => 1,
sector(s, U1(1)) => 1,
sector(s, U1(2)) => 1,
])
return gradedrange(
[
sector(s, U1(0)) => 1,
sector(s, U1(1)) => 1,
sector(s, U1(1)) => 1,
sector(s, U1(2)) => 1,
]
)
end
# TODO: Write in terms of `GradingType"Nf"` definition.
function Base.AbstractUnitRange(s::GradingType"NfParity", t::SiteType"Electron")
return gradedrange([
sector(s, Z{2}(0)) => 1,
sector(s, Z{2}(1)) => 1,
sector(s, Z{2}(1)) => 1,
sector(s, Z{2}(0)) => 1,
])
return gradedrange(
[
sector(s, Z{2}(0)) => 1,
sector(s, Z{2}(1)) => 1,
sector(s, Z{2}(1)) => 1,
sector(s, Z{2}(0)) => 1,
]
)
end
function Base.AbstractUnitRange(s::GradingType"Sz", t::SiteType"Electron")
return gradedrange([
sector(s, U1(0)) => 1,
sector(s, U1(1)) => 1,
sector(s, U1(-1)) => 1,
sector(s, U1(0)) => 1,
])
return gradedrange(
[
sector(s, U1(0)) => 1,
sector(s, U1(1)) => 1,
sector(s, U1(-1)) => 1,
sector(s, U1(0)) => 1,
]
)
end

end
Loading
Loading