diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml index 08f664c..4c49a86 100644 --- a/.JuliaFormatter.toml +++ b/.JuliaFormatter.toml @@ -1,2 +1,3 @@ +# See https://domluna.github.io/JuliaFormatter.jl/stable/ for a list of options style = "blue" indent = 2 diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md new file mode 100644 index 0000000..b4fe2d9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.md @@ -0,0 +1,62 @@ +--- +name: BroadcastMapConversion.jl bug report +about: Create a bug report to help us improve BroadcastMapConversion.jl +title: "[BUG] YOUR SHORT DESCRIPTION OF THE BUG HERE" +labels: ["bug"] +assignees: '' + +--- + +**Description of bug** + +Please give a brief description of the bug or unexpected behavior here. + +**Minimal code demonstrating the bug or unexpected behavior** + +If applicable, provide a minimal code that can be run to demonstrate the bug or unexpected behavior. + +If you are unable to construct a minimal code that demonstrates the bug or unexpected behavior, provide detailed steps for how to reproduce the behavior you are seeing. + +
Minimal runnable code

+ +```julia +[YOUR MINIMAL RUNNABLE CODE HERE] +``` + +

+ + +**Expected output or behavior** + +Describe what you expected to happen. + +If you provided a minimal code that can be run to demonstrate the bug or unexpected behavior, describe what you expected the output would be. + + +**Actual output or behavior** + +Describe what actually happened. + +If you provided a minimal code that demonstrates the bug or unexpected behavior, provide the output you get from that code. If the code leads to an error or warning, include the full error or warning below. + +
Output of minimal runnable code

+ +```julia +[OUTPUT OF YOUR MINIMAL RUNNABLE CODE HERE] +``` + +

+ + +**Version information** + + - Output from `versioninfo()`: +```julia +julia> versioninfo() +[YOUR OUTPUT HERE] +``` + - Output from `using Pkg; Pkg.status("BroadcastMapConversion")`: +```julia +julia> using Pkg; Pkg.status("BroadcastMapConversion") +[YOUR OUTPUT HERE] +``` diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md new file mode 100644 index 0000000..b785dc9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md @@ -0,0 +1,24 @@ +--- +name: BroadcastMapConversion.jl feature request +about: Suggest an idea for BroadcastMapConversion.jl +title: "[ENHANCEMENT] YOUR SHORT DESCRIPTION OF THE FEATURE REQUEST HERE" +labels: ["enhancement"] +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** + +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** + +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** + +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** + +Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..cc55944 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,42 @@ +# Description + +Please include a summary of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies that are required for this change. + +Fixes #(issue) + +If practical and applicable, please include a minimal demonstration of the previous behavior and new behavior below. + +
Minimal demonstration of previous behavior

+ +```julia +[YOUR MINIMAL DEMONSTRATION OF PREVIOUS BEHAVIOR] +``` + +

+ +
Minimal demonstration of new behavior

+ +```julia +[YOUR MINIMAL DEMONSTRATION OF NEW BEHAVIOR] +``` + +

+ +# How Has This Been Tested? + +Please add tests that verify your changes to a file in the `test` directory. + +Please give a summary of the tests that you added to verify your changes. + +- [ ] Test A +- [ ] Test B + +# Checklist: + +- [ ] My code follows the style guidelines of this project. Please run `using JuliaFormatter; format(".")` in the base directory of the repository (`~/.julia/dev/BroadcastMapConversion`) to format your code according to our style guidelines. +- [ ] I have performed a self-review of my own code. +- [ ] I have commented my code, particularly in hard-to-understand areas. +- [ ] I have added tests that verify the behavior of the changes I made. +- [ ] I have made corresponding changes to the documentation. +- [ ] My changes generate no new warnings. +- [ ] Any dependent changes have been merged and published in downstream modules. diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..700707c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..6f4ad81 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,79 @@ +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' + - '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 BroadcastMapConversion + DocMeta.setdocmeta!(BroadcastMapConversion, :DocTestSetup, :(using BroadcastMapConversion); recursive=true) + doctest(BroadcastMapConversion) diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..cba9134 --- /dev/null +++ b/.github/workflows/CompatHelper.yml @@ -0,0 +1,16 @@ +name: CompatHelper +on: + schedule: + - cron: 0 0 * * * + workflow_dispatch: +jobs: + CompatHelper: + runs-on: ubuntu-latest + steps: + - name: Pkg.add("CompatHelper") + run: julia -e 'using Pkg; Pkg.add("CompatHelper")' + - name: CompatHelper.main() + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} + run: julia -e 'using CompatHelper; CompatHelper.main()' diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml new file mode 100644 index 0000000..bb6d933 --- /dev/null +++ b/.github/workflows/FormatCheck.yml @@ -0,0 +1,35 @@ +name: Format check +on: + push: + branches: [main] + tags: [v*] + pull_request: + +jobs: + format: + 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' diff --git a/.github/workflows/LiterateCheck.yml b/.github/workflows/LiterateCheck.yml new file mode 100644 index 0000000..ade2453 --- /dev/null +++ b/.github/workflows/LiterateCheck.yml @@ -0,0 +1,39 @@ +name: Literate check +on: + push: + branches: [main] + tags: [v*] + 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 + 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' diff --git a/.github/workflows/Register.yml b/.github/workflows/Register.yml new file mode 100644 index 0000000..5b7cd3b --- /dev/null +++ b/.github/workflows/Register.yml @@ -0,0 +1,16 @@ +name: Register Package +on: + workflow_dispatch: + inputs: + version: + description: Version to register or component to bump + required: true +jobs: + register: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: julia-actions/RegisterAction@latest + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml new file mode 100644 index 0000000..0cd3114 --- /dev/null +++ b/.github/workflows/TagBot.yml @@ -0,0 +1,31 @@ +name: TagBot +on: + issue_comment: + types: + - created + workflow_dispatch: + inputs: + lookback: + default: "3" +permissions: + actions: read + checks: read + contents: write + deployments: read + issues: read + discussions: read + packages: read + pages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read +jobs: + TagBot: + if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + ssh: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10593a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.jl.*.cov +*.jl.cov +*.jl.mem +*.o +*.swp +.DS_Store +.benchmarkci +.tmp +.vscode/ +Manifest.toml +benchmark/*.json +docs/Manifest.toml +docs/build/ +docs/src/index.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..bff1fb7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-merge-conflict + - id: check-toml + - 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 + hooks: + - id: julia-format diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7f5c8c6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 ITensor developers + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Project.toml b/Project.toml new file mode 100644 index 0000000..e3eb551 --- /dev/null +++ b/Project.toml @@ -0,0 +1,16 @@ +name = "BroadcastMapConversion" +uuid = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2" +authors = ["ITensor developers and contributors"] +version = "0.1.0" + +[compat] +Aqua = "0.8.9" +Test = "1.10" +julia = "1.10" + +[extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets] +test = ["Aqua", "Test"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..2f0416a --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# BroadcastMapConversion.jl + +[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/BroadcastMapConversion.jl/stable/) +[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/BroadcastMapConversion.jl/dev/) +[![Build Status](https://github.com/ITensor/BroadcastMapConversion.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/BroadcastMapConversion.jl/actions/workflows/CI.yml?query=branch%3Amain) +[![Coverage](https://codecov.io/gh/ITensor/BroadcastMapConversion.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/BroadcastMapConversion.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) + +## Installation instructions + +```julia +julia> using Pkg: Pkg + +julia> Pkg.add("https://github.com/ITensor/BroadcastMapConversion.jl") +``` + +## Examples + +````julia +using BroadcastMapConversion: BroadcastMapConversion +```` + +Examples go here. + +--- + +*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).* + diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl new file mode 100644 index 0000000..23ab873 --- /dev/null +++ b/benchmark/benchmarks.jl @@ -0,0 +1,7 @@ +using BroadcastMapConversion +using BenchmarkTools + +SUITE = BenchmarkGroup() +SUITE["rand"] = @benchmarkable rand(10) + +# Write your benchmarks here. diff --git a/docs/Project.toml b/docs/Project.toml new file mode 100644 index 0000000..b841d6f --- /dev/null +++ b/docs/Project.toml @@ -0,0 +1,4 @@ +[deps] +BroadcastMapConversion = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2" +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" diff --git a/docs/make.jl b/docs/make.jl new file mode 100644 index 0000000..097f474 --- /dev/null +++ b/docs/make.jl @@ -0,0 +1,24 @@ +using BroadcastMapConversion: BroadcastMapConversion +using Documenter: Documenter, DocMeta, deploydocs, makedocs + +DocMeta.setdocmeta!( + BroadcastMapConversion, :DocTestSetup, :(using BroadcastMapConversion); recursive=true +) + +include("make_index.jl") + +makedocs(; + modules=[BroadcastMapConversion], + authors="ITensor developers and contributors", + sitename="BroadcastMapConversion.jl", + format=Documenter.HTML(; + canonical="https://ITensor.github.io/BroadcastMapConversion.jl", + edit_link="main", + assets=String[], + ), + pages=["Home" => "index.md"], +) + +deploydocs(; + repo="github.com/ITensor/BroadcastMapConversion.jl", devbranch="main", push_preview=true +) diff --git a/docs/make_index.jl b/docs/make_index.jl new file mode 100644 index 0000000..e2d72cc --- /dev/null +++ b/docs/make_index.jl @@ -0,0 +1,9 @@ +using Literate: Literate +using BroadcastMapConversion: BroadcastMapConversion + +Literate.markdown( + joinpath(pkgdir(BroadcastMapConversion), "examples", "README.jl"), + joinpath(pkgdir(BroadcastMapConversion), "docs", "src"); + flavor=Literate.DocumenterFlavor(), + name="index", +) diff --git a/docs/make_readme.jl b/docs/make_readme.jl new file mode 100644 index 0000000..dc3b477 --- /dev/null +++ b/docs/make_readme.jl @@ -0,0 +1,9 @@ +using Literate: Literate +using BroadcastMapConversion: BroadcastMapConversion + +Literate.markdown( + joinpath(pkgdir(BroadcastMapConversion), "examples", "README.jl"), + joinpath(pkgdir(BroadcastMapConversion)); + flavor=Literate.CommonMarkFlavor(), + name="README", +) diff --git a/examples/Project.toml b/examples/Project.toml new file mode 100644 index 0000000..7491928 --- /dev/null +++ b/examples/Project.toml @@ -0,0 +1,2 @@ +[deps] +BroadcastMapConversion = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2" diff --git a/examples/README.jl b/examples/README.jl new file mode 100644 index 0000000..44c4717 --- /dev/null +++ b/examples/README.jl @@ -0,0 +1,23 @@ +# # BroadcastMapConversion.jl +# +# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/BroadcastMapConversion.jl/stable/) +# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/BroadcastMapConversion.jl/dev/) +# [![Build Status](https://github.com/ITensor/BroadcastMapConversion.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/BroadcastMapConversion.jl/actions/workflows/CI.yml?query=branch%3Amain) +# [![Coverage](https://codecov.io/gh/ITensor/BroadcastMapConversion.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/BroadcastMapConversion.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) + +# ## Installation instructions + +#= +```julia +julia> using Pkg: Pkg + +julia> Pkg.add("https://github.com/ITensor/BroadcastMapConversion.jl") +``` +=# + +# ## Examples + +using BroadcastMapConversion: BroadcastMapConversion +# Examples go here. diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 0000000..06a9b32 --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,3 @@ +[deps] +BroadcastMapConversion = "4a4adec5-520f-4750-bb37-d5e66b4ddeb2" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/runtests.jl b/test/runtests.jl index 92e5d6a..fc921ec 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,8 +1,8 @@ @eval module $(gensym()) +using Base.Broadcast: Broadcasted +using BroadcastMapConversion: map_function, map_args using Test: @test, @testset -using NDTensors.BroadcastMapConversion: map_function, map_args @testset "BroadcastMapConversion" begin - using Base.Broadcast: Broadcasted c = 2.2 a = randn(2, 3) b = randn(2, 3)