diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml deleted file mode 100644 index 7d5b5b5..0000000 --- a/.github/workflows/CI.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: CI -on: - push: - branches: - - main - tags: ['*'] - pull_request: - workflow_dispatch: -concurrency: - # Skip intermediate builds: always. - # Cancel intermediate builds: only if it is a pull request build. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} -jobs: - test: - name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - runs-on: ${{ matrix.os }} - timeout-minutes: 60 - permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created - actions: write - contents: read - strategy: - fail-fast: false - matrix: - version: - # - 'lts' # TODO: Add this back once dependencies are registered. - - '1' - os: - - ubuntu-latest - - macOS-latest - - windows-latest - arch: - - x64 - steps: - - uses: actions/checkout@v4 - - uses: julia-actions/setup-julia@v2 - with: - version: ${{ matrix.version }} - arch: ${{ matrix.arch }} - - uses: julia-actions/cache@v2 - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-runtest@v1 - - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v5 - with: - files: lcov.info - token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: false - docs: - name: Documentation - runs-on: ubuntu-latest - permissions: - actions: write # needed to allow julia-actions/cache to proactively delete old caches that it has created - contents: write - statuses: write - steps: - - uses: actions/checkout@v4 - - uses: julia-actions/setup-julia@v2 - with: - version: '1' - - uses: julia-actions/cache@v2 - - name: Configure doc environment - shell: julia --project=docs --color=yes {0} - run: | - using Pkg - Pkg.develop(PackageSpec(path=pwd())) - Pkg.instantiate() - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-docdeploy@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} - - name: Run doctests - shell: julia --project=docs --color=yes {0} - run: | - using Documenter: DocMeta, doctest - using UnallocatedArrays - DocMeta.setdocmeta!(UnallocatedArrays, :DocTestSetup, :(using UnallocatedArrays); recursive=true) - doctest(UnallocatedArrays) diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml new file mode 100644 index 0000000..01a7f7a --- /dev/null +++ b/.github/workflows/Documentation.yml @@ -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 }} diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml index bb6d933..3f78afc 100644 --- a/.github/workflows/FormatCheck.yml +++ b/.github/workflows/FormatCheck.yml @@ -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" diff --git a/.github/workflows/LiterateCheck.yml b/.github/workflows/LiterateCheck.yml index 8b1dae7..2ca5f27 100644 --- a/.github/workflows/LiterateCheck.yml +++ b/.github/workflows/LiterateCheck.yml @@ -1,42 +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 once they are registered. - Pkg.add(url="https://github.com/ITensor/TypeParameterAccessors.jl") - Pkg.add(url="https://github.com/ITensor/UnspecifiedTypes.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 diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml new file mode 100644 index 0000000..46e03b4 --- /dev/null +++ b/.github/workflows/Tests.yml @@ -0,0 +1,39 @@ +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 + 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 }} diff --git a/Project.toml b/Project.toml index ec74d2c..ca22b96 100644 --- a/Project.toml +++ b/Project.toml @@ -9,21 +9,26 @@ FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138" UnspecifiedTypes = "42b3faec-625b-4613-8ddc-352bf9672b8d" -[sources] -TypeParameterAccessors = {url = "https://github.com/ITensor/TypeParameterAccessors.jl"} -UnspecifiedTypes = {url = "https://github.com/ITensor/UnspecifiedTypes.jl"} - [compat] Adapt = "4.1.1" Aqua = "0.8.9" FillArrays = "1.13.0" +JLArrays = "0.2" +NDTensors = "0.3" +SafeTestsets = "0.1" +Suppressor = "0.2" Test = "1.10" +TypeParameterAccessors = "0.1.0" UnspecifiedTypes = "0.1.0" julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" +JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb" +NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" [targets] -test = ["Aqua", "Test"] +test = ["Aqua", "Test", "Suppressor", "SafeTestsets", "JLArrays", "NDTensors"] diff --git a/README.md b/README.md index 020fdf6..ac9ff32 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/UnallocatedArrays.jl/stable/) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/UnallocatedArrays.jl/dev/) -[![Build Status](https://github.com/ITensor/UnallocatedArrays.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/UnallocatedArrays.jl/actions/workflows/CI.yml?query=branch%3Amain) +[![Build Status](https://github.com/ITensor/UnallocatedArrays.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/UnallocatedArrays.jl/actions/workflows/Tests.yml?query=branch%3Amain) [![Coverage](https://codecov.io/gh/ITensor/UnallocatedArrays.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/UnallocatedArrays.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) @@ -12,14 +12,24 @@ tensors and allocating as little data as possible. ## Installation instructions +This package resides in the `ITensor/ITensorRegistry` local registry. +In order to install, simply add that registry through your package manager. +This step is only required once. ```julia julia> using Pkg: Pkg -julia> Pkg.add(url="https://github.com/ITensor/TypeParameterAccessors.jl") +julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry") +``` +or: +```julia +julia> Pkg.Registry.add(url="git@github.com:ITensor/ITensorRegistry.git") +``` +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. -julia> Pkg.add(url="https://github.com/ITensor/UnspecifiedTypes.jl") +Then, the package can be added as usual through the package manager: -julia> Pkg.add(url="https://github.com/ITensor/UnallocatedArrays.jl") +```julia +julia> Pkg.add("UnallocatedArrays") ``` ## Examples @@ -28,8 +38,6 @@ julia> Pkg.add(url="https://github.com/ITensor/UnallocatedArrays.jl") using UnallocatedArrays: UnallocatedArrays ```` -Examples go here. - --- *This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).* diff --git a/docs/Project.toml b/docs/Project.toml index 1a3b3e8..47b84f2 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -4,7 +4,3 @@ Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138" UnallocatedArrays = "43c9e47c-e622-40fb-bf18-a09fc8c466b6" UnspecifiedTypes = "42b3faec-625b-4613-8ddc-352bf9672b8d" - -[sources] -TypeParameterAccessors = {url = "https://github.com/ITensor/TypeParameterAccessors.jl"} -UnspecifiedTypes = {url = "https://github.com/ITensor/UnspecifiedTypes.jl"} diff --git a/examples/Project.toml b/examples/Project.toml index 624f56b..23a349e 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -2,7 +2,3 @@ TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138" UnallocatedArrays = "43c9e47c-e622-40fb-bf18-a09fc8c466b6" UnspecifiedTypes = "42b3faec-625b-4613-8ddc-352bf9672b8d" - -[sources] -TypeParameterAccessors = {url = "https://github.com/ITensor/TypeParameterAccessors.jl"} -UnspecifiedTypes = {url = "https://github.com/ITensor/UnspecifiedTypes.jl"} diff --git a/examples/README.jl b/examples/README.jl index 45529d9..3939124 100644 --- a/examples/README.jl +++ b/examples/README.jl @@ -2,7 +2,7 @@ # # [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/UnallocatedArrays.jl/stable/) # [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/UnallocatedArrays.jl/dev/) -# [![Build Status](https://github.com/ITensor/UnallocatedArrays.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/UnallocatedArrays.jl/actions/workflows/CI.yml?query=branch%3Amain) +# [![Build Status](https://github.com/ITensor/UnallocatedArrays.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/UnallocatedArrays.jl/actions/workflows/Tests.yml?query=branch%3Amain) # [![Coverage](https://codecov.io/gh/ITensor/UnallocatedArrays.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/UnallocatedArrays.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) @@ -12,19 +12,32 @@ # ## Installation instructions +# This package resides in the `ITensor/ITensorRegistry` local registry. +# In order to install, simply add that registry through your package manager. +# This step is only required once. #= ```julia julia> using Pkg: Pkg -julia> Pkg.add(url="https://github.com/ITensor/TypeParameterAccessors.jl") +julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry") +``` +=# +# or: +#= +```julia +julia> Pkg.Registry.add(url="git@github.com:ITensor/ITensorRegistry.git") +``` +=# +# 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. -julia> Pkg.add(url="https://github.com/ITensor/UnspecifiedTypes.jl") +# Then, the package can be added as usual through the package manager: -julia> Pkg.add(url="https://github.com/ITensor/UnallocatedArrays.jl") +#= +```julia +julia> Pkg.add("UnallocatedArrays") ``` =# # ## Examples using UnallocatedArrays: UnallocatedArrays -# Examples go here. diff --git a/src/abstractfill/abstractfill.jl b/src/abstractfill/abstractfill.jl index 3bf7460..a11c939 100644 --- a/src/abstractfill/abstractfill.jl +++ b/src/abstractfill/abstractfill.jl @@ -17,6 +17,9 @@ set_axestype(T::Type{<:AbstractFill}, ax::Type) = s(T, axestype, ax) TypeParameterAccessors.position(::Type{<:AbstractFill}, ::typeof(alloctype)) = Position(4) TypeParameterAccessors.position(::Type{<:AbstractFill}, ::typeof(axestype)) = Position(3) + +# this is type piracy (Aqua.jl complains) and should be moved to TypeParameterAccessors, +# possibly via package extension function TypeParameterAccessors.default_type_parameters(::Type{<:AbstractFill}) return (Float64, 0, Tuple{}) end diff --git a/src/broadcast.jl b/src/broadcast.jl index c5e98e7..6224903 100644 --- a/src/broadcast.jl +++ b/src/broadcast.jl @@ -13,6 +13,17 @@ function Broadcast.broadcasted(style::Broadcast.DefaultArrayStyle, f, a::Unalloc return _broadcasted(style, f, ZeroPreserving(f), a) end +# disambiguation: +for f in (:real, :imag, :conj, :(+), :(-)) + @eval function Broadcast.broadcasted( + style::Broadcast.DefaultArrayStyle, f::typeof($f), a::UnallocatedZeros + ) + return @invoke Broadcats.broadcasted( + style::Broadcast.DefaultArrayStyle, f::Any, a::UnallocatedZeros + ) + end +end + function _broadcasted( style::Broadcast.DefaultArrayStyle, f, ::IsZeroPreserving, a::UnallocatedZeros ) diff --git a/src/unallocatedfill.jl b/src/unallocatedfill.jl index c84d2e0..47c27ed 100644 --- a/src/unallocatedfill.jl +++ b/src/unallocatedfill.jl @@ -40,10 +40,6 @@ end function FillArrays.broadcasted_fill(f, a::UnallocatedFill, val, ax) return UnallocatedFill(Fill(val, ax), alloctype(a)) end -function FillArrays.broadcasted_fill(f, a::UnallocatedFill, b::UnallocatedFill, val, ax) - @assert alloctype(a) == alloctype(b) - return UnallocatedFill(Fill(val, ax), alloctype(a)) -end function FillArrays.broadcasted_fill(f, a::UnallocatedFill, b, val, ax) return UnallocatedFill(Fill(val, ax), alloctype(a)) diff --git a/src/unallocatedzeros.jl b/src/unallocatedzeros.jl index 39752e2..4c8e5c6 100644 --- a/src/unallocatedzeros.jl +++ b/src/unallocatedzeros.jl @@ -67,11 +67,18 @@ end function FillArrays.broadcasted_fill(f, a::UnallocatedZeros, b, val, ax) return UnallocatedFill(Fill(val, ax), alloctype(a)) end - function FillArrays.broadcasted_fill(f, a, b::UnallocatedZeros, val, ax) return broadcasted_fill(f, b, a, val, ax) end +# disambiguate +for TA in (:UnallocatedZeros, :UnallocatedFill), TB in (:UnallocatedZeros, :UnallocatedFill) + @eval function FillArrays.broadcasted_fill(f, a::$TA, b::$TB, val, ax) + @assert alloctype(a) == alloctype(b) + return UnallocatedFill(Fill(val, ax), alloctype(a)) + end +end + function FillArrays.kron_zeros(a::UnallocatedZeros, b::UnallocatedZeros, elt, ax) @assert alloctype(a) == alloctype(b) return UnallocatedZeros(Zeros{elt}(ax), alloctype(a)) diff --git a/test/Project.toml b/test/Project.toml deleted file mode 100644 index 1d54f1b..0000000 --- a/test/Project.toml +++ /dev/null @@ -1,8 +0,0 @@ -[deps] -Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" -FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" -JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb" -LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/runtests.jl b/test/runtests.jl index 5a96d53..bb62115 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,12 +1,49 @@ -@eval module $(gensym()) -using Test: @testset +using SafeTestsets: @safetestset +using Suppressor: @suppress -@testset "UnallocatedArrays.jl" begin - filenames = filter(readdir(@__DIR__)) do f - startswith("test_")(f) && endswith(".jl")(f) +# check for filtered groups +# either via `--group=ALL` or through ENV["GROUP"] +const pat = r"(?:--group=)(\w+)" +arg_id = findfirst(contains(pat), ARGS) +const GROUP = uppercase( + if isnothing(arg_id) + get(ENV, "GROUP", "ALL") + else + only(match(pat, ARGS[arg_id]).captures) + end, +) + +function istestfile(filename) + return isfile(filename) && + endswith(filename, ".jl") && + startswith(basename(filename), "test") +end + +@time begin + # tests in groups based on folder structure + for testgroup in filter(isdir, readdir(@__DIR__)) + if GROUP == "ALL" || GROUP == uppercase(testgroup) + for file in filter(istestfile, readdir(joinpath(@__DIR__, testgroup); join=true)) + @eval @safetestset $file begin + include($file) + end + end + end end - @testset "Test $filename" for filename in filenames - include(filename) + + # single files in top folder + for file in filter(istestfile, readdir(@__DIR__)) + (file == basename(@__FILE__)) && continue + @eval @safetestset $file begin + include($file) + end + end + + # test examples + examplepath = joinpath(@__DIR__, "..", "examples") + for file in filter(endswith(".jl"), readdir(examplepath; join=true)) + @suppress @eval @safetestset $file begin + include($file) + end end -end end diff --git a/test/test_aqua.jl b/test/test_aqua.jl index 4b703bb..1174acd 100644 --- a/test/test_aqua.jl +++ b/test/test_aqua.jl @@ -1,11 +1,7 @@ -@eval module $(gensym()) using UnallocatedArrays: UnallocatedArrays using Aqua: Aqua using Test: @testset @testset "Code quality (Aqua.jl)" begin - # TODO: This is broken, it seems to struggle with packages - # that have unregistered dependencies. Add this back. - # Aqua.test_all(UnallocatedArrays) -end + Aqua.test_all(UnallocatedArrays) end diff --git a/test/test_basics.jl b/test/test_basics.jl index 7f625ed..5002de8 100644 --- a/test/test_basics.jl +++ b/test/test_basics.jl @@ -1,4 +1,3 @@ -@eval module $(gensym()) using FillArrays: FillArrays, AbstractFill, Fill, Zeros using UnallocatedArrays: UnallocatedFill, UnallocatedZeros, allocate, alloctype, set_alloctype @@ -324,4 +323,3 @@ end ## @test nparameters(ft) == 4 ## end ## end -end