Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skeleton update #5

Merged
merged 8 commits into from
Dec 12, 2024
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
79 changes: 0 additions & 79 deletions .github/workflows/CI.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Documentation"

on:
push:
branches:
- main
tags: '*'
pull_request:
schedule:
- cron: '1 4 * * 4'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch || github.ref != 'refs/tags/v*' }}

jobs:
build-and-deploy-docs:
name: "Documentation"
uses: "ITensor/ITensorActions/.github/workflows/Documentation.yml@main"
with:
localregistry: https://github.com/ITensor/ITensorRegistry.git
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
36 changes: 7 additions & 29 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
name: Format check
name: "Format Check"

on:
push:
branches: [main]
tags: [v*]
branches:
- 'main'
tags: '*'
pull_request:

jobs:
format:
format-check:
name: "Format Check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: 1
- name: Install JuliaFormatter and format
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia -e 'using JuliaFormatter; format(".", verbose=true)'
- name: Check format
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "The following files have not been formatted:"
write(stdout, out)
out_diff = Cmd(`git diff`) |> read |> String
@error "Diff:"
write(stdout, out_diff)
exit(1)
@error ""
end'
uses: "ITensor/ITensorActions/.github/workflows/FormatCheck.yml@main"
46 changes: 8 additions & 38 deletions .github/workflows/LiterateCheck.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,15 @@
name: Literate check
name: "Literate Check"

on:
push:
branches: [main]
tags: [v*]
branches:
- 'main'
tags: '*'
pull_request:

jobs:
literate:
name: "Literate Check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: 1
- name: Install Literate and generate docs
run: |
julia -e '
using Pkg
# TODO: Delete these once they are registered.
Pkg.add(url="https://github.com/ITensor/TypeParameterAccessors.jl")
Pkg.add(url="https://github.com/ITensor/BroadcastMapConversion.jl")
Pkg.add(url="https://github.com/ITensor/NestedPermutedDimsArrays.jl")
Pkg.add(url="https://github.com/ITensor/SparseArraysBase.jl")
Pkg.add(url="https://github.com/ITensor/TensorAlgebra.jl")
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
Pkg.add(PackageSpec(name="Literate"))'
julia -e 'include("docs/make_readme.jl")'
- name: Check if docs need to be updated
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "The docs are outdated, rerun Literate to regenerate them."
write(stdout, out)
out_diff = Cmd(`git diff`) |> read |> String
@error "Diff:"
write(stdout, out_diff)
exit(1)
@error ""
end'
uses: "ITensor/ITensorActions/.github/workflows/LiterateCheck.yml@main"
with:
localregistry: https://github.com/ITensor/ITensorRegistry.git
42 changes: 42 additions & 0 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tests
on:
push:
branches:
- 'master'
- 'main'
- 'release-'
tags: '*'
paths-ignore:
- 'docs/**'
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# Cancel intermediate builds: only if it is a pull request build.
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
tests:
name: "Tests"
strategy:
fail-fast: false
matrix:
version:
- 'lts' # minimal supported version
- '1' # latest released Julia version
# group:
# - 'core'
# - 'optional'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
uses: "ITensor/ITensorActions/.github/workflows/Tests.yml@main"
with:
group: "${{ matrix.group }}"
julia-version: "${{ matrix.version }}"
os: "${{ matrix.os }}"
localregistry: https://github.com/ITensor/ITensorRegistry.git
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
exclude_types: [markdown] # incompatible with Literate.jl
- repo: https://github.com/qiaojunfeng/pre-commit-julia-format
rev: v0.2.0

- repo: "https://github.com/domluna/JuliaFormatter.jl"
rev: v1.0.62
hooks:
- id: julia-format
- id: "julia-formatter"
21 changes: 5 additions & 16 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,13 @@ SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

[sources]
BroadcastMapConversion = {url = "https://github.com/ITensor/BroadcastMapConversion.jl"}
NestedPermutedDimsArrays = {url = "https://github.com/ITensor/NestedPermutedDimsArrays.jl"}
SparseArraysBase = {url = "https://github.com/ITensor/SparseArraysBase.jl"}
TensorAlgebra = {url = "https://github.com/ITensor/TensorAlgebra.jl"}
TypeParameterAccessors = {url = "https://github.com/ITensor/TypeParameterAccessors.jl"}

[compat]
Adapt = "4.1.1"
Aqua = "0.8.9"
BroadcastMapConversion = "0.1"
LinearAlgebra = "1.10"
NestedPermutedDimsArrays = "0.1"
Random = "1.10"
Test = "1.10"
SparseArraysBase = "0.1"
TensorAlgebra = "0.1"
TypeParameterAccessors = "0.1"
julia = "1.10"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "Test"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/NamedDimsArrays.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/NamedDimsArrays.jl/dev/)
[![Build Status](https://github.com/ITensor/NamedDimsArrays.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/NamedDimsArrays.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Build Status](https://github.com/ITensor/NamedDimsArrays.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/NamedDimsArrays.jl/actions/workflows/Tests.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/ITensor/NamedDimsArrays.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/NamedDimsArrays.jl)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
Expand Down
8 changes: 0 additions & 8 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ NestedPermutedDimsArrays = "2c2a8ec4-3cfc-4276-aa3e-1307b4294e58"
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

[sources]
BroadcastMapConversion = {url = "https://github.com/ITensor/BroadcastMapConversion.jl"}
NamedDimsArrays = {path = ".."}
NestedPermutedDimsArrays = {url = "https://github.com/ITensor/NestedPermutedDimsArrays.jl"}
SparseArraysBase = {url = "https://github.com/ITensor/SparseArraysBase.jl"}
TensorAlgebra = {url = "https://github.com/ITensor/TensorAlgebra.jl"}
TypeParameterAccessors = {url = "https://github.com/ITensor/TypeParameterAccessors.jl"}
8 changes: 0 additions & 8 deletions examples/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,3 @@ NestedPermutedDimsArrays = "2c2a8ec4-3cfc-4276-aa3e-1307b4294e58"
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

[sources]
BroadcastMapConversion = {url = "https://github.com/ITensor/BroadcastMapConversion.jl"}
NamedDimsArrays = {path = ".."}
NestedPermutedDimsArrays = {url = "https://github.com/ITensor/NestedPermutedDimsArrays.jl"}
SparseArraysBase = {url = "https://github.com/ITensor/SparseArraysBase.jl"}
TensorAlgebra = {url = "https://github.com/ITensor/TensorAlgebra.jl"}
TypeParameterAccessors = {url = "https://github.com/ITensor/TypeParameterAccessors.jl"}
2 changes: 1 addition & 1 deletion examples/README.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/NamedDimsArrays.jl/stable/)
# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/NamedDimsArrays.jl/dev/)
# [![Build Status](https://github.com/ITensor/NamedDimsArrays.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/NamedDimsArrays.jl/actions/workflows/CI.yml?query=branch%3Amain)
# [![Build Status](https://github.com/ITensor/NamedDimsArrays.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/NamedDimsArrays.jl/actions/workflows/Tests.yml?query=branch%3Amain)
# [![Coverage](https://codecov.io/gh/ITensor/NamedDimsArrays.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/NamedDimsArrays.jl)
# [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
# [![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
Expand Down
6 changes: 6 additions & 0 deletions src/abstractnamedint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
return promote_type(unname(type1), type2)
end
(type::Type{<:Integer})(i::AbstractNamedInt) = type(unname(i))

# ambiguity fix
for T in (:Bool, :BigInt, :Integer)
@eval Base.$T(i::AbstractNamedInt) = $T(unname(i))

Check warning on line 37 in src/abstractnamedint.jl

View check run for this annotation

Codecov / codecov/patch

src/abstractnamedint.jl#L37

Added line #L37 was not covered by tests
end

# TODO: Use conversion from `AbstractNamedInt` to `AbstractNamedUnitRange`
# instead of general `named`.
function Base.oftype(i1::AbstractNamedInt, i2::Integer)
Expand Down
5 changes: 3 additions & 2 deletions src/abstractnamedunitrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
Base.length(i::AbstractNamedUnitRange) = named(length(unname(i)), name(i))

# TODO: Use `isnamed` trait?
dimnames(a::Tuple{Vararg{AbstractNamedUnitRange}}) = name.(a)
dimnames(a::Tuple{AbstractNamedUnitRange,Vararg{AbstractNamedUnitRange}}) = name.(a)
dimnames(::Tuple{}) = ()

Check warning on line 18 in src/abstractnamedunitrange.jl

View check run for this annotation

Codecov / codecov/patch

src/abstractnamedunitrange.jl#L18

Added line #L18 was not covered by tests

unname(a::Tuple{Vararg{AbstractNamedUnitRange}}) = unname.(a)
unname(a::Tuple{Vararg{AbstractNamedUnitRange}}, names) = unname(align(a, names))
Expand All @@ -29,7 +30,7 @@

# Permute into a certain order.
# align(a, (:j, :k, :i))
function align(a::Tuple{Vararg{AbstractNamedUnitRange}}, names)
function align(a::Tuple{AbstractNamedUnitRange,Vararg{AbstractNamedUnitRange}}, names)
perm = get_name_perm(a, names)
return map(j -> a[j], perm)
end
4 changes: 2 additions & 2 deletions src/namedint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
named(i::Integer, name) = NamedInt(i, name)

# TODO: Use `isnamed` trait?
dimnames(a::Tuple{Vararg{AbstractNamedInt}}) = name.(a)
dimnames(a::Tuple{AbstractNamedInt,Vararg{AbstractNamedInt}}) = name.(a)

Check warning on line 17 in src/namedint.jl

View check run for this annotation

Codecov / codecov/patch

src/namedint.jl#L17

Added line #L17 was not covered by tests

function get_name_perm(a::Tuple{Vararg{AbstractNamedInt}}, names::Tuple)
function get_name_perm(a::Tuple{AbstractNamedInt,Vararg{AbstractNamedInt}}, names::Tuple)

Check warning on line 19 in src/namedint.jl

View check run for this annotation

Codecov / codecov/patch

src/namedint.jl#L19

Added line #L19 was not covered by tests
return getperm(dimnames(a), names)
end

Expand Down
15 changes: 8 additions & 7 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ NamedDimsArrays = "60cbd0c0-df58-4cb7-918c-6f5607b73fde"
NestedPermutedDimsArrays = "2c2a8ec4-3cfc-4276-aa3e-1307b4294e58"
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

[sources]
BroadcastMapConversion = {url = "https://github.com/ITensor/BroadcastMapConversion.jl"}
NamedDimsArrays = {path = ".."}
NestedPermutedDimsArrays = {url = "https://github.com/ITensor/NestedPermutedDimsArrays.jl"}
SparseArraysBase = {url = "https://github.com/ITensor/SparseArraysBase.jl"}
TensorAlgebra = {url = "https://github.com/ITensor/TensorAlgebra.jl"}
TypeParameterAccessors = {url = "https://github.com/ITensor/TypeParameterAccessors.jl"}
[compat]
Aqua = "0.8.9"
SafeTestsets = "0.1"
Suppressor = "0.2"
Test = "1.10"
Loading
Loading