diff --git a/Project.toml b/Project.toml index 415e9d8..a6d6530 100644 --- a/Project.toml +++ b/Project.toml @@ -1,27 +1,27 @@ 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" 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/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