From 4eb579eb02403a97914ccc23c26541041eb4287b Mon Sep 17 00:00:00 2001 From: Jean-Francois Baffier Date: Thu, 25 Apr 2024 15:57:52 +0900 Subject: [PATCH 1/8] Auto sciml format with JuliaFormatter (#34) --- .JuliaFormatter.toml | 1 + docs/make.jl | 28 ++++++++++++------------- perf/allocs.jl | 4 ++-- perf/bench.jl | 6 +++--- src/common.jl | 4 ++-- src/immutable_vector.jl | 36 ++++++++++++++++---------------- src/intervals.jl | 46 ++++++++++++++++++++--------------------- src/vector.jl | 40 +++++++++++++++++------------------ 8 files changed, 83 insertions(+), 82 deletions(-) create mode 100644 .JuliaFormatter.toml diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 0000000..453925c --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1 @@ +style = "sciml" \ No newline at end of file diff --git a/docs/make.jl b/docs/make.jl index a36be8a..a23bdd2 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,24 +1,24 @@ using PatternFolds using Documenter -DocMeta.setdocmeta!(PatternFolds, :DocTestSetup, :(using PatternFolds); recursive=true) +DocMeta.setdocmeta!(PatternFolds, :DocTestSetup, :(using PatternFolds); recursive = true) makedocs(; - modules=[PatternFolds], - authors="Jean-Francois Baffier", - repo="https://github.com/Humans-of-Julia/PatternFolds.jl/blob/{commit}{path}#{line}", - sitename="PatternFolds.jl", - format=Documenter.HTML(; - prettyurls=get(ENV, "CI", "false") == "true", - canonical="https://Humans-of-Julia.github.io/PatternFolds.jl", - assets=String[], + modules = [PatternFolds], + authors = "Jean-Francois Baffier", + repo = "https://github.com/Humans-of-Julia/PatternFolds.jl/blob/{commit}{path}#{line}", + sitename = "PatternFolds.jl", + format = Documenter.HTML(; + prettyurls = get(ENV, "CI", "false") == "true", + canonical = "https://Humans-of-Julia.github.io/PatternFolds.jl", + assets = String[] ), - pages=[ - "Home" => "index.md", - ], + pages = [ + "Home" => "index.md" + ] ) deploydocs(; - repo="github.com/Humans-of-Julia/PatternFolds.jl", - devbranch="main", + repo = "github.com/Humans-of-Julia/PatternFolds.jl", + devbranch = "main" ) diff --git a/perf/allocs.jl b/perf/allocs.jl index 36acf13..2a0ea31 100644 --- a/perf/allocs.jl +++ b/perf/allocs.jl @@ -15,7 +15,7 @@ using PatternFolds function alloc() # 0.2.x # Intervals - itv = Interval{Open,Closed}(0.0, 1.0) + itv = Interval{Open, Closed}(0.0, 1.0) i = IntervalsFold(itv, 2.0, 1000) @info "Checking IntervalsFold" i pattern(i) gap(i) folds(i) size(i) length(i) @@ -62,5 +62,5 @@ using PatternFolds # end # Actual call to PerfChecker - alloc_check(title, dependencies, targets, alloc, alloc; path=@__DIR__) + alloc_check(title, dependencies, targets, alloc, alloc; path = @__DIR__) end diff --git a/perf/bench.jl b/perf/bench.jl index 6476f5f..cc4cd98 100644 --- a/perf/bench.jl +++ b/perf/bench.jl @@ -7,7 +7,7 @@ target = PatternFolds function bench() # 0.2.x # Intervals - itv = Interval{Open,Closed}(0.0, 1.0) + itv = Interval{Open, Closed}(0.0, 1.0) i = IntervalsFold(itv, 2.0, 1000) unfold(i) @@ -52,7 +52,7 @@ end # return nothing # end -t = @benchmark bench() evals = 1 samples = 1000 seconds = 3600 +t = @benchmark bench() evals=1 samples=1000 seconds=3600 # Actual call to PerfChecker -store_benchmark(t, target; path=@__DIR__) +store_benchmark(t, target; path = @__DIR__) diff --git a/src/common.jl b/src/common.jl index a833dac..8942029 100644 --- a/src/common.jl +++ b/src/common.jl @@ -79,7 +79,7 @@ function fold(v::V, depth = 0; kind = :mutable) where {T <: Real, V <: AbstractV for i in 1:(l ÷ 2) gap = v[i + 1] - v[1] fold, r = divrem(l, i) - if r == 0 && check_pattern(v, i, gap, fold) + if r == 0 && check_pattern(v, i, gap, fold) # return VectorFold(fold(v[1:i], depth + 1), gap, fold) return make_vector_fold(v[1:i], gap, fold, kind) end @@ -102,7 +102,7 @@ end function make_vector_fold(isf; kind = :mutable) vf = kind == :mutable ? "VectorFold" : "IVectorFold" str = "The pattern of the interval is not a point." * - " The IntervalsFold cannot be converted to a $vf" + " The IntervalsFold cannot be converted to a $vf" @assert is_points(isf) str return make_vector_fold([value(pattern(isf), :a)], gap(isf), folds(isf), kind) diff --git a/src/immutable_vector.jl b/src/immutable_vector.jl index 2774519..ea80d38 100644 --- a/src/immutable_vector.jl +++ b/src/immutable_vector.jl @@ -2,7 +2,7 @@ VectorFold{T,V <: AbstractVector{T}} A folded vector structure that extends the methods of AbstractVector to a folded structure. """ -struct IVectorFold{T,V <: AbstractVector{T}} <: AbstractVectorFold{T} +struct IVectorFold{T, V <: AbstractVector{T}} <: AbstractVectorFold{T} pattern::V gap::T folds::Int @@ -20,7 +20,7 @@ pattern(vf, index) = pattern(vf)[index] unfold(vf::VectorFold; from=1, to=folds(vf)) Construct the unfolded version of `vf` (with the same type as `pattern(vf)`) based. Please note that using an iterator on `vf` avoid memory allocation, which is not the case of `unfold`. """ -function unfold(vf::IVectorFold; from=1, to=folds(vf)) +function unfold(vf::IVectorFold; from = 1, to = folds(vf)) pl = pattern_length(vf) ul = (to - from + 1) * pl v = typeof(pattern(vf))(undef, ul) @@ -45,38 +45,38 @@ Base.iterate(iter::IVectorFold) = (pattern(iter, 1), 1) # Base case iterate meth function Base.iterate(iter::IVectorFold, state::Int) state ≥ length(iter) && return nothing - next_state = state + 1 + next_state = state + 1 pl = pattern_length(iter) - pattern_counter = mod1(next_state, pl) - fold_counter = state ÷ pl - elem = pattern(iter, pattern_counter) + (fold_counter * gap(iter)) + pattern_counter = mod1(next_state, pl) + fold_counter = state ÷ pl + elem = pattern(iter, pattern_counter) + (fold_counter * gap(iter)) - return elem, next_state + return elem, next_state end # Reverse iterate method -function Base.iterate(r_iter::Base.Iterators.Reverse{IVectorFold{T,V}}, - state::Int = length(r_iter.itr) -) where {T,V} - state < 1 && return nothing +function Base.iterate(r_iter::Base.Iterators.Reverse{IVectorFold{T, V}}, + state::Int = length(r_iter.itr) +) where {T, V} + state < 1 && return nothing - next_state = state - 1 - iter = r_iter.itr + next_state = state - 1 + iter = r_iter.itr pl = pattern_length(iter) - pattern_counter = mod1(state, pl) - fold_counter = next_state ÷ pl - elem = pattern(iter, pattern_counter) + (fold_counter * gap(iter)) + pattern_counter = mod1(state, pl) + fold_counter = next_state ÷ pl + elem = pattern(iter, pattern_counter) + (fold_counter * gap(iter)) - return elem, next_state + return elem, next_state end # Folding a vector to give a suitable VectorFold check_pattern(v, w, gap) = all(i -> i == gap, w - v) function check_pattern(v, i, gap, fold) - for j in 1:(fold -1) + for j in 1:(fold - 1) v_start, v_end = (j - 1) * i + 1, j * i w_start, w_end = j * i + 1, (j + 1) * i !check_pattern(v[v_start:v_end], v[w_start:w_end], gap) && return false diff --git a/src/intervals.jl b/src/intervals.jl index 81031b8..083e9bc 100644 --- a/src/intervals.jl +++ b/src/intervals.jl @@ -3,7 +3,7 @@ Base.ndims(::Interval) = 1 -function Base.rand(i::Interval{T,L,R}) where {T,L,R} +function Base.rand(i::Interval{T, L, R}) where {T, L, R} # α = max(_minfloat(T), first(i)) # β = min(_maxfloat(T), last(i)) μ = maxintfloat(T, Int) @@ -12,7 +12,7 @@ function Base.rand(i::Interval{T,L,R}) where {T,L,R} δ = β - α # if δ === Inf if δ > μ - return rand(rand() < 0.5 ? α..zero(T) : zero(T)..β) + return rand(rand() < 0.5 ? α .. zero(T) : zero(T) .. β) else # r = α + exp10(log10(δ) * rand()) r = α + δ * rand() @@ -22,14 +22,14 @@ function Base.rand(i::Interval{T,L,R}) where {T,L,R} end # TODO - Optimise the type of Intervals.Bound (currently abstract super type) -mutable struct IntervalsFold{T<:AbstractFloat,L<:Intervals.Bound,R<:Intervals.Bound} - pattern::Interval{T,L,R} +mutable struct IntervalsFold{T <: AbstractFloat, L <: Intervals.Bound, R <: Intervals.Bound} + pattern::Interval{T, L, R} gap::T folds::Int current::Int end -IntervalsFold(p, g, f, c=1) = IntervalsFold(p, g, f, c) +IntervalsFold(p, g, f, c = 1) = IntervalsFold(p, g, f, c) @forward IntervalsFold.pattern Base.isempty, Base.ndims @@ -42,16 +42,16 @@ function pattern(isf::IntervalsFold) return isf.pattern + (-distortion) end -function unfold(isf::IntervalsFold{T,L,R}) where {T,L,R} +function unfold(isf::IntervalsFold{T, L, R}) where {T, L, R} reset_pattern!(isf) x = first(pattern(isf)) y = last(pattern(isf)) g = gap(isf) f = folds(isf) - return [Interval{T,L,R}(x + g * i, y + g * i) for i in 0:(f - 1)] + return [Interval{T, L, R}(x + g * i, y + g * i) for i in 0:(f - 1)] end -function set_fold!(isf::IntervalsFold, new_fold=isf.current + 1) +function set_fold!(isf::IntervalsFold, new_fold = isf.current + 1) if new_fold != isf.current && 0 < new_fold ≤ isf.folds distortion = gap(isf) * (new_fold - isf.current) isf.pattern += distortion @@ -78,7 +78,7 @@ end # Reverse iterate method function Base.iterate( - r_iter::Base.Iterators.Reverse{<:IntervalsFold}, state::Int=length(r_iter.itr) + r_iter::Base.Iterators.Reverse{<:IntervalsFold}, state::Int = length(r_iter.itr) ) state < 1 && return nothing iter = r_iter.itr @@ -96,7 +96,7 @@ Base.size(isf::IntervalsFold) = span(isf.pattern) * folds(isf) Base.length(isf::IntervalsFold) = folds(isf) -Base.eltype(::Type{<:IntervalsFold{T,L,R}}) where {T,L,R} = Interval{T,L,R} +Base.eltype(::Type{<:IntervalsFold{T, L, R}}) where {T, L, R} = Interval{T, L, R} is_points(isf) = is_point(pattern(isf)) @@ -123,21 +123,21 @@ function Base.rand(v::V) where {V <: Set{<:IntervalsFold}} end @testitem "IntervalsFold" tags=[:intervals] begin - i01 = Interval{Open,Closed}(0.0, 1.0) - i23 = Interval{Open,Closed}(2.0, 3.0) - i45 = Interval{Open,Closed}(4.0, 5.0) - i67 = Interval{Open,Closed}(6.0, 7.0) - i89 = Interval{Open,Closed}(8.0, 9.0) + i01 = Interval{Open, Closed}(0.0, 1.0) + i23 = Interval{Open, Closed}(2.0, 3.0) + i45 = Interval{Open, Closed}(4.0, 5.0) + i67 = Interval{Open, Closed}(6.0, 7.0) + i89 = Interval{Open, Closed}(8.0, 9.0) isf_dict = Dict([ IntervalsFold(i01, 2.0, 5) => Dict( - :pattern => i01, - :gap => 2.0, - :folds => 5, - :length => 5, - :size => 5.0, - :unfold => [i01, i23, i45, i67, i89], - :reverse => reverse([i01, i23, i45, i67, i89]), - ), + :pattern => i01, + :gap => 2.0, + :folds => 5, + :length => 5, + :size => 5.0, + :unfold => [i01, i23, i45, i67, i89], + :reverse => reverse([i01, i23, i45, i67, i89]) + ) ]) for (isf, results) in isf_dict diff --git a/src/vector.jl b/src/vector.jl index bdf5832..4a5f547 100644 --- a/src/vector.jl +++ b/src/vector.jl @@ -3,14 +3,14 @@ A mutable structure for folded vector that extends the methods of AbstractVector. Compared to `IVectorFold`, this tructure is about 20% faster using iterators. Note that this structure keep an active pointer to the `current` *unfolded* pattern. However, its external behavior is similar to `IVectorFold`. """ -mutable struct VectorFold{T,V<:AbstractVector{T}} <: AbstractVectorFold{T} +mutable struct VectorFold{T, V <: AbstractVector{T}} <: AbstractVectorFold{T} pattern::V gap::T folds::Int current::Int end -VectorFold(p, g, f; c=1) = VectorFold(p, g, f, c) +VectorFold(p, g, f; c = 1) = VectorFold(p, g, f, c) pattern_length(mvf::VectorFold) = length(mvf.pattern) @@ -25,7 +25,7 @@ pattern(mvf::VectorFold, index) = pattern(mvf)[index] set_fold!(mvf::VectorFold, new_fold = mvf.current + 1) Set the *unfolded* pattern to `new_fold`. By default move the next *fold* after `current`. """ -function set_fold!(mvf, new_fold=mvf.current + 1) +function set_fold!(mvf, new_fold = mvf.current + 1) if new_fold != mvf.current && 0 < new_fold ≤ mvf.folds distortion = gap(mvf) * (new_fold - mvf.current) mvf.pattern .+= distortion @@ -55,8 +55,8 @@ end # Reverse iterate method function Base.iterate( - r_iter::Base.Iterators.Reverse{VectorFold{T,V}}, state::Int=length(r_iter.itr) -) where {T,V} + r_iter::Base.Iterators.Reverse{VectorFold{T, V}}, state::Int = length(r_iter.itr) +) where {T, V} state < 1 && return nothing iter = r_iter.itr @@ -81,7 +81,7 @@ end Base.rand(mvf::VectorFold, n::Int) = map(_ -> rand(mvf), 1:n) # Specific dispatch for MVectorFold -function unfold(mvf::VectorFold; from=1, to=folds(mvf)) +function unfold(mvf::VectorFold; from = 1, to = folds(mvf)) pl = pattern_length(mvf) ul = (to - from + 1) * pl v = typeof(mvf.pattern)(undef, ul) @@ -101,22 +101,22 @@ make_vector_fold(pattern, gap, fold, ::Val{:mutable}) = VectorFold(pattern, gap, @testitem "VectorFold" tags=[:vectors] begin vf_dict = Dict([ - make_vector_fold([1,2], 10, 5, :immutable) => Dict( - :pattern => [1,2], + make_vector_fold([1, 2], 10, 5, :immutable) => Dict( + :pattern => [1, 2], :gap => 10, :folds => 5, :length => 10, - :unfold => [1,2,11,12,21,22,31,32,41,42], - :reverse => reverse([1,2,11,12,21,22,31,32,41,42]), + :unfold => [1, 2, 11, 12, 21, 22, 31, 32, 41, 42], + :reverse => reverse([1, 2, 11, 12, 21, 22, 31, 32, 41, 42]) ), - make_vector_fold([1,2], 10, 5, :mutable) => Dict( - :pattern => [1,2], + make_vector_fold([1, 2], 10, 5, :mutable) => Dict( + :pattern => [1, 2], :gap => 10, :folds => 5, :length => 10, - :unfold => [1,2,11,12,21,22,31,32,41,42], - :reverse => reverse([1,2,11,12,21,22,31,32,41,42]), - ), + :unfold => [1, 2, 11, 12, 21, 22, 31, 32, 41, 42], + :reverse => reverse([1, 2, 11, 12, 21, 22, 31, 32, 41, 42]) + ) ]) for (vf, results) in vf_dict @@ -131,22 +131,22 @@ make_vector_fold(pattern, gap, fold, ::Val{:mutable}) = VectorFold(pattern, gap, @test collect(Iterators.reverse(vf)) == results[:reverse] @test reverse(collect(vf)) == results[:reverse] end - @test isempty(make_vector_fold(Vector(),1,1,:immutable)) - @test isempty(make_vector_fold(Vector(),1,1)) + @test isempty(make_vector_fold(Vector(), 1, 1, :immutable)) + @test isempty(make_vector_fold(Vector(), 1, 1)) - v1 = make_vector_fold([42,3,45,6],13,4) + v1 = make_vector_fold([42, 3, 45, 6], 13, 4) w1 = unfold(v1) v11 = fold(w1) @test unfold(v11) == w1 - v2 = make_vector_fold([34,34,43,43],10,3) + v2 = make_vector_fold([34, 34, 43, 43], 10, 3) w2 = unfold(v2) v22 = fold(w2) @test unfold(v22) == w2 - v3 = make_vector_fold([42,3,45,6],13,4,:immutable) + v3 = make_vector_fold([42, 3, 45, 6], 13, 4, :immutable) w3 = unfold(v3) v33 = fold(w3) From 5a689175798ea55d2f3896401c4a66c1b42e138e Mon Sep 17 00:00:00 2001 From: Jean-Francois Baffier Date: Sat, 27 Apr 2024 16:08:05 +0900 Subject: [PATCH 2/8] Update CIs (#35) * Update compat helper * Update compat helper 2 * Update tag bot * Add format (and format yml files * Add a spell check action * Update CI to include format * Update CI to include format 2 * Fix a typo from the new github action * Update CI * Adds Aqua.jl * Fix Aqua errors (but 2 to broken tests) * Fix format --- .github/workflows/CI.yml | 69 ++++++++++++++++++++++++------ .github/workflows/CompatHelper.yml | 37 +++++++++++++--- .github/workflows/SpellCheck.yml | 13 ++++++ .github/workflows/TagBot.yml | 16 +++++++ Project.toml | 5 ++- src/PatternFolds.jl | 3 +- src/common.jl | 2 +- src/intervals.jl | 3 +- test/Aqua.jl | 30 +++++++++++++ test/TestItemRunner.jl | 3 ++ test/runtests.jl | 6 ++- 11 files changed, 164 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/SpellCheck.yml create mode 100644 test/Aqua.jl create mode 100644 test/TestItemRunner.jl diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3946caf..2733de7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,8 +1,48 @@ name: CI on: - - push - - pull_request + pull_request: + branches: + - main + - dev + paths-ignore: + - "docs/**" + push: + branches: + - main + paths-ignore: + - "docs/**" jobs: + formatter: + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: [1] + julia-arch: [x86] + os: [ubuntu-latest] + steps: + - uses: julia-actions/setup-julia@latest + with: + version: ${{ matrix.julia-version }} + + - uses: actions/checkout@v4 + - name: Install JuliaFormatter and format + # This will use the latest version by default but you can set the version like so: + # + # julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))' + run: | + julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="1.0.50"))' + julia -e 'using JuliaFormatter; format(".", verbose=true)' + - name: Format check + run: | + julia -e ' + out = Cmd(`git diff`) |> read |> String + if out == "" + exit(0) + else + @error "Some files have not been formatted !!!" + write(stdout, out) + exit(1) + end' test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} @@ -10,27 +50,32 @@ jobs: fail-fast: false matrix: version: - - "1.8" - - 'nightly' + - "1.6" + - "1" # automatically expands to the latest stable 1.x release of Julia + - nightly os: - ubuntu-latest - - macOS-latest - - windows-latest arch: - x64 - x86 - exclude: + include: + # test macOS and Windows with latest Julia only - os: macOS-latest - arch: x86 + arch: x64 + version: 1 + - os: windows-latest + arch: x64 + version: 1 - os: windows-latest arch: x86 + version: 1 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: actions/cache@v1 + - uses: actions/cache@v4 env: cache-name: cache-artifacts with: @@ -43,14 +88,14 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v4 with: file: lcov.info docs: name: Documentation runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v1 with: version: "1" diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index cba9134..5577817 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -1,16 +1,43 @@ -name: CompatHelper on: schedule: - cron: 0 0 * * * workflow_dispatch: +permissions: + contents: write + pull-requests: write jobs: CompatHelper: runs-on: ubuntu-latest steps: - - name: Pkg.add("CompatHelper") - run: julia -e 'using Pkg; Pkg.add("CompatHelper")' - - name: CompatHelper.main() + - name: Check if Julia is already available in the PATH + id: julia_in_path + run: which julia + continue-on-error: true + - name: Install Julia, but only if it is not already available in the PATH + uses: julia-actions/setup-julia@v1 + with: + version: "1" + arch: ${{ runner.arch }} + if: steps.julia_in_path.outcome != 'success' + - name: "Add the General registry via Git" + run: | + import Pkg + ENV["JULIA_PKG_SERVER"] = "" + Pkg.Registry.add("General") + shell: julia --color=yes {0} + - name: "Install CompatHelper" + run: | + import Pkg + name = "CompatHelper" + uuid = "aa819f21-2bde-4658-8897-bab36330d9b7" + version = "3" + Pkg.add(; name, uuid, version) + shell: julia --color=yes {0} + - name: "Run CompatHelper" + run: | + import CompatHelper + CompatHelper.main() + shell: julia --color=yes {0} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} - run: julia -e 'using CompatHelper; CompatHelper.main()' diff --git a/.github/workflows/SpellCheck.yml b/.github/workflows/SpellCheck.yml new file mode 100644 index 0000000..ed4fe17 --- /dev/null +++ b/.github/workflows/SpellCheck.yml @@ -0,0 +1,13 @@ +name: Spell Check + +on: [pull_request] + +jobs: + typos-check: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v4 + - name: Check spelling + uses: crate-ci/typos@v1.18.0 diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml index f49313b..0cd3114 100644 --- a/.github/workflows/TagBot.yml +++ b/.github/workflows/TagBot.yml @@ -4,6 +4,22 @@ on: 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' diff --git a/Project.toml b/Project.toml index 5c0d359..b0e15ac 100644 --- a/Project.toml +++ b/Project.toml @@ -17,10 +17,11 @@ Lazy = "0.15" Reexport = "1" TestItemRunner = "0.2" TestItems = "0.1" -julia = "1.8" +julia = "1.6" [extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test"] +test = ["Aqua", "Test"] diff --git a/src/PatternFolds.jl b/src/PatternFolds.jl index 9e7898d..6816c8a 100644 --- a/src/PatternFolds.jl +++ b/src/PatternFolds.jl @@ -6,8 +6,9 @@ using Reexport # Import @reexport using Intervals using Lazy -using Random +# using Random using TestItems +using TestItemRunner # exports export IntervalsFold diff --git a/src/common.jl b/src/common.jl index 8942029..684c67d 100644 --- a/src/common.jl +++ b/src/common.jl @@ -24,7 +24,7 @@ PatternFold = Union{AbstractVectorFold, IntervalsFold} """ pattern(<:PatternFold) -Return the *pattern* of any `PatternFold`. The pattern defines the occurences of the first fold. +Return the *pattern* of any `PatternFold`. The pattern defines the occurrences of the first fold. """ pattern(pf) = pf.pattern diff --git a/src/intervals.jl b/src/intervals.jl index 083e9bc..6526206 100644 --- a/src/intervals.jl +++ b/src/intervals.jl @@ -109,7 +109,8 @@ function Base.rand(isf::IntervalsFold) end """ - Base.rand(::Vector{IntervalsFold}) + Base.rand(::Vector{IntervalsFold}) + Extend the `Base.rand` function to `Vector{IntervalsFold}`. """ function Base.rand(v::V) where {V <: Set{<:IntervalsFold}} diff --git a/test/Aqua.jl b/test/Aqua.jl new file mode 100644 index 0000000..01a6663 --- /dev/null +++ b/test/Aqua.jl @@ -0,0 +1,30 @@ +@testset "Aqua.jl" begin + import Aqua + import Intervals + import PatternFolds + + # TODO: Fix the broken tests and remove the `broken = true` flag + Aqua.test_all( + PatternFolds; + ambiguities = (broken = true,), + deps_compat = false, + piracies = (broken = true,) + ) + + @testset "Ambiguities: PatternFolds" begin + Aqua.test_ambiguities(PatternFolds) + end + + @testset "Piracies: PatternFolds" begin + Aqua.test_piracies(PatternFolds; + treat_as_own = [Intervals.Interval] + ) + end + + @testset "Dependencies compatibility (no extras)" begin + Aqua.test_deps_compat(PatternFolds; + check_extras = false, + ignore = [:Random] + ) + end +end diff --git a/test/TestItemRunner.jl b/test/TestItemRunner.jl new file mode 100644 index 0000000..cf86c5a --- /dev/null +++ b/test/TestItemRunner.jl @@ -0,0 +1,3 @@ +@testset "TestItemRunner" begin + @run_package_tests +end diff --git a/test/runtests.jl b/test/runtests.jl index b9e874d..e6bbe89 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,3 +1,7 @@ +using Test using TestItemRunner -@run_package_tests +@testset "Package tests: PatternFolds" begin + include("Aqua.jl") + include("TestItemRunner.jl") +end From 031ac524741efa4be304ad71800461bbd8a0e647 Mon Sep 17 00:00:00 2001 From: Jean-Francois Baffier Date: Tue, 14 May 2024 04:29:47 +0200 Subject: [PATCH 3/8] Update sciml badge (#37) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b5aac69..bf4d8cd 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,6 @@ [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://Humans-of-Julia.github.io/PatternFolds.jl/dev) [![Build Status](https://github.com/Humans-of-Julia/PatternFolds.jl/workflows/CI/badge.svg)](https://github.com/Humans-of-Julia/PatternFolds.jl/actions) [![codecov](https://codecov.io/gh/Humans-of-Julia/PatternFolds.jl/branch/main/graph/badge.svg?token=XCWI9E6NK7)](https://codecov.io/gh/Humans-of-Julia/PatternFolds.jl) -[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) +[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle) [![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac) [![Discord chat](https://img.shields.io/discord/762167454973296644.svg?logo=discord&colorB=7289DA&style=flat-square)](https://discord.gg/7KC28q98nP) From d4a69837bb7aab0c5e97e6baf9d9026cf9fab69b Mon Sep 17 00:00:00 2001 From: Azzaare Date: Tue, 14 May 2024 02:31:52 +0000 Subject: [PATCH 4/8] Version Patch to update doc --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index b0e15ac..5ffe705 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PatternFolds" uuid = "c18a7f1d-76ad-4ce4-950d-5419b888513b" authors = ["Jean-Francois Baffier"] -version = "0.2.3" +version = "0.2.4" [deps] Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5" From 73df3e71f7cfd71977a058ad10e0dc5359c86b91 Mon Sep 17 00:00:00 2001 From: Jean-Francois Baffier Date: Wed, 10 Jul 2024 04:52:08 +0200 Subject: [PATCH 5/8] Update CI 1/? (#41) --- .github/workflows/CI.yml | 8 ++++---- Project.toml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2733de7..2b86423 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -50,9 +50,9 @@ jobs: fail-fast: false matrix: version: - - "1.6" - - "1" # automatically expands to the latest stable 1.x release of Julia - - nightly + - "lts" + - "1" + - "pre" os: - ubuntu-latest arch: @@ -71,7 +71,7 @@ jobs: version: 1 steps: - uses: actions/checkout@v4 - - uses: julia-actions/setup-julia@v1 + - uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} diff --git a/Project.toml b/Project.toml index 5ffe705..415e9d8 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PatternFolds" uuid = "c18a7f1d-76ad-4ce4-950d-5419b888513b" authors = ["Jean-Francois Baffier"] -version = "0.2.4" +version = "0.2.5" [deps] Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5" @@ -15,8 +15,8 @@ TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe" Intervals = "1" Lazy = "0.15" Reexport = "1" -TestItemRunner = "0.2" -TestItems = "0.1" +TestItemRunner = "0.2, 1" +TestItems = "0.1, 1" julia = "1.6" [extras] From 76b1b82283d782f3496bd566097d565eb6b3b4e7 Mon Sep 17 00:00:00 2001 From: Azzaare Date: Wed, 10 Jul 2024 13:47:14 +0900 Subject: [PATCH 6/8] Update makedoc --- docs/make.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/make.jl b/docs/make.jl index a23bdd2..cf15eb7 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -6,7 +6,6 @@ DocMeta.setdocmeta!(PatternFolds, :DocTestSetup, :(using PatternFolds); recursiv makedocs(; modules = [PatternFolds], authors = "Jean-Francois Baffier", - repo = "https://github.com/Humans-of-Julia/PatternFolds.jl/blob/{commit}{path}#{line}", sitename = "PatternFolds.jl", format = Documenter.HTML(; prettyurls = get(ENV, "CI", "false") == "true", From 4e0ef0f97a04ade4271d940f423994eef9453f02 Mon Sep 17 00:00:00 2001 From: Jean-Francois Baffier Date: Wed, 9 Oct 2024 16:43:12 +0900 Subject: [PATCH 7/8] Update to match JuliaConstraints CI/CD flow (#45) * New release (#42) * Auto sciml format with JuliaFormatter (#34) * Update CIs (#35) * Update compat helper * Update compat helper 2 * Update tag bot * Add format (and format yml files * Add a spell check action * Update CI to include format * Update CI to include format 2 * Fix a typo from the new github action * Update CI * Adds Aqua.jl * Fix Aqua errors (but 2 to broken tests) * Fix format * Update sciml badge (#37) * Version Patch to update doc * Update CI 1/? (#41) * Dev (#43) * Auto sciml format with JuliaFormatter (#34) * Update CIs (#35) * Update compat helper * Update compat helper 2 * Update tag bot * Add format (and format yml files * Add a spell check action * Update CI to include format * Update CI to include format 2 * Fix a typo from the new github action * Update CI * Adds Aqua.jl * Fix Aqua errors (but 2 to broken tests) * Fix format * Update sciml badge (#37) * Version Patch to update doc * Update CI 1/? (#41) * Update makedoc * Fix to deployment (#44) * Auto sciml format with JuliaFormatter (#34) * Update CIs (#35) * Update compat helper * Update compat helper 2 * Update tag bot * Add format (and format yml files * Add a spell check action * Update CI to include format * Update CI to include format 2 * Fix a typo from the new github action * Update CI * Adds Aqua.jl * Fix Aqua errors (but 2 to broken tests) * Fix format * Update sciml badge (#37) * Version Patch to update doc * Update CI 1/? (#41) * Update makedoc * Small doc update for deployment * Updated tests to match JuliaConstraints' --- Project.toml | 14 +++++++------- docs/src/index.md | 2 ++ src/PatternFolds.jl | 11 +++-------- src/common.jl | 2 +- src/intervals.jl | 15 +++++++++++---- test/ExplicitImports.jl | 3 +++ test/JET.jl | 3 +++ test/runtests.jl | 7 +++++++ 8 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 test/ExplicitImports.jl create mode 100644 test/JET.jl diff --git a/Project.toml b/Project.toml index 415e9d8..89ee258 100644 --- a/Project.toml +++ b/Project.toml @@ -7,21 +7,21 @@ version = "0.2.5" Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5" Lazy = "50d2b5c4-7a5e-59d5-8109-a42b560f39c0" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -Reexport = "189a3867-3050-52da-a836-e630ba90ab69" -TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe" [compat] Intervals = "1" Lazy = "0.15" -Reexport = "1" -TestItemRunner = "0.2, 1" -TestItems = "0.1, 1" -julia = "1.6" +TestItemRunner = "1" +TestItems = "1" +julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" +JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" [targets] -test = ["Aqua", "Test"] +test = ["Aqua", "ExplicitImports", "JET", "Test", "TestItemRunner"] diff --git a/docs/src/index.md b/docs/src/index.md index 4c2aa3b..e3548f4 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -4,6 +4,8 @@ CurrentModule = PatternFolds # PatternFolds +`PatternFolds` needs a more advanced documentation. Contribution are wlecome. + ```@index ``` diff --git a/src/PatternFolds.jl b/src/PatternFolds.jl index 6816c8a..1616a04 100644 --- a/src/PatternFolds.jl +++ b/src/PatternFolds.jl @@ -1,14 +1,9 @@ module PatternFolds -# Reexporr -using Reexport - # Import -@reexport using Intervals -using Lazy -# using Random -using TestItems -using TestItemRunner +import Intervals: Intervals, Interval, span, Open, Closed +import Lazy: @forward +import TestItems: @testitem # exports export IntervalsFold diff --git a/src/common.jl b/src/common.jl index 684c67d..f065adf 100644 --- a/src/common.jl +++ b/src/common.jl @@ -105,7 +105,7 @@ function make_vector_fold(isf; kind = :mutable) " The IntervalsFold cannot be converted to a $vf" @assert is_points(isf) str - return make_vector_fold([value(pattern(isf), :a)], gap(isf), folds(isf), kind) + return make_vector_fold([value(isf)], gap(isf), folds(isf), kind) end function Base.print_array(io::IO, X::AbstractVectorFold) diff --git a/src/intervals.jl b/src/intervals.jl index 6526206..99532e5 100644 --- a/src/intervals.jl +++ b/src/intervals.jl @@ -12,7 +12,8 @@ function Base.rand(i::Interval{T, L, R}) where {T, L, R} δ = β - α # if δ === Inf if δ > μ - return rand(rand() < 0.5 ? α .. zero(T) : zero(T) .. β) + return rand(rand() < 0.5 ? Interval{T, Closed, Closed}(α, zero(T)) : + Interval{T, Closed, Closed}(zero(T), β)) else # r = α + exp10(log10(δ) * rand()) r = α + δ * rand() @@ -31,8 +32,6 @@ end IntervalsFold(p, g, f, c = 1) = IntervalsFold(p, g, f, c) -@forward IntervalsFold.pattern Base.isempty, Base.ndims - Base.lastindex(isf::IntervalsFold) = folds(isf) Base.getindex(isf::IntervalsFold, key...) = map(k -> get_fold!(isf, k), key) @@ -98,6 +97,10 @@ Base.length(isf::IntervalsFold) = folds(isf) Base.eltype(::Type{<:IntervalsFold{T, L, R}}) where {T, L, R} = Interval{T, L, R} +is_point(i::Interval) = first(i) == last(i) !== nothing + +value(isf::IntervalsFold) = pattern(isf) |> first + is_points(isf) = is_point(pattern(isf)) pattern_length(isf::IntervalsFold) = span(pattern(isf)) @@ -123,7 +126,11 @@ function Base.rand(v::V) where {V <: Set{<:IntervalsFold}} end end -@testitem "IntervalsFold" tags=[:intervals] begin +@testitem "IntervalsFold" tags=[:intervals] default_imports=false begin + using Intervals + using Test + using PatternFolds + i01 = Interval{Open, Closed}(0.0, 1.0) i23 = Interval{Open, Closed}(2.0, 3.0) i45 = Interval{Open, Closed}(4.0, 5.0) diff --git a/test/ExplicitImports.jl b/test/ExplicitImports.jl new file mode 100644 index 0000000..2163220 --- /dev/null +++ b/test/ExplicitImports.jl @@ -0,0 +1,3 @@ +@testset "Look for Explicit Imports" begin + @test check_no_implicit_imports(PatternFolds) === nothing +end diff --git a/test/JET.jl b/test/JET.jl new file mode 100644 index 0000000..9cd1e5d --- /dev/null +++ b/test/JET.jl @@ -0,0 +1,3 @@ +@testset "Code linting (JET.jl)" begin + JET.test_package(PatternFolds; target_defined_modules = true) +end diff --git a/test/runtests.jl b/test/runtests.jl index e6bbe89..704848c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,14 @@ +using PatternFolds + +using Aqua +using ExplicitImports +using JET using Test using TestItemRunner @testset "Package tests: PatternFolds" begin include("Aqua.jl") + include("ExplicitImports.jl") + include("JET.jl") include("TestItemRunner.jl") end From 4d91fb7ba23c8d436582f57eded87495d1251977 Mon Sep 17 00:00:00 2001 From: Jean-Francois Baffier Date: Wed, 9 Oct 2024 16:43:43 +0900 Subject: [PATCH 8/8] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 89ee258..a6d6530 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PatternFolds" uuid = "c18a7f1d-76ad-4ce4-950d-5419b888513b" authors = ["Jean-Francois Baffier"] -version = "0.2.5" +version = "0.2.6" [deps] Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5"