diff --git a/Project.toml b/Project.toml index deea278..6a452b5 100644 --- a/Project.toml +++ b/Project.toml @@ -5,7 +5,6 @@ version = "0.3.12" [deps] ConstraintCommons = "e37357d9-0691-492f-a822-e5ea6a920954" -Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4" Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5" PatternFolds = "c18a7f1d-76ad-4ce4-950d-5419b888513b" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" @@ -13,7 +12,6 @@ TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe" [compat] ConstraintCommons = "0.2" -Dictionaries = "0.4" Intervals = "1" PatternFolds = "0.2" StatsBase = "0.34" @@ -23,8 +21,10 @@ julia = "1.8" [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", "TestItemRunner"] +test = ["Aqua", "ExplicitImports", "JET", "Test", "TestItemRunner"] diff --git a/src/ConstraintDomains.jl b/src/ConstraintDomains.jl index 04a608e..efcefb9 100644 --- a/src/ConstraintDomains.jl +++ b/src/ConstraintDomains.jl @@ -1,19 +1,19 @@ module ConstraintDomains # SECTION - Imports -using ConstraintCommons -using Dictionaries -using PatternFolds -using StatsBase -using TestItems +import ConstraintCommons: ConstraintCommons, δ_extrema +# import Dictionaries +import PatternFolds: PatternFolds, Interval, Closed +import StatsBase: sample +import TestItems: @testitem # Exports export AbstractDomain export ContinuousDomain export DiscreteDomain -# export DiscreteSet # not defined export ExploreSettings export RangeDomain +export SetDomain export add! export delete! diff --git a/src/continuous.jl b/src/continuous.jl index fa42182..c631c2b 100644 --- a/src/continuous.jl +++ b/src/continuous.jl @@ -27,7 +27,7 @@ domain(intervals::Vector{I}) where {I<:Interval} = Intervals(intervals) Base.length(itv::Intervals) Return the sum of the length of each interval in `itv`. """ -Base.length(itv::Intervals) = sum(size, get_domain(itv); init = 0) +Base.length(itv::Intervals) = sum(size, get_domain(itv); init=0) """ Base.rand(itv::Intervals) diff --git a/src/general.jl b/src/general.jl index a63b006..2f30dc1 100644 --- a/src/general.jl +++ b/src/general.jl @@ -13,7 +13,7 @@ Extends `Base.convert` for domains. """ function Base.convert(::Type{Intervals}, d::RangeDomain{T}) where {T<:Real} a, b = extrema(get_domain(d)) - return domain(Float64(a) .. Float64(b)) + return domain(Interval{T,Closed,Closed}(a, b)) end function Base.convert(::Type{RangeDomain}, d::Intervals{T}) where {T<:Real} @@ -23,6 +23,6 @@ function Base.convert(::Type{RangeDomain}, d::Intervals{T}) where {T<:Real} return domain(a:b) end -function Base.convert(::Type{RangeDomain}, d::SetDomain{T}) where {T<:Integer} +function Base.convert(::Type{RangeDomain}, d::SetDomain) return domain(collect(get_domain(d))) end diff --git a/test/Aqua.jl b/test/Aqua.jl index 06b8cb1..4ab57d0 100644 --- a/test/Aqua.jl +++ b/test/Aqua.jl @@ -1,14 +1,10 @@ @testset "Aqua.jl" begin - import Aqua - import ConstraintDomains - import Dictionaries - # TODO: Fix the broken tests and remove the `broken = true` flag Aqua.test_all( ConstraintDomains; - ambiguities = (broken = true,), - deps_compat = false, - piracies = (broken = false,), + ambiguities=(broken=true,), + deps_compat=false, + piracies=(broken=false,), ) @testset "Ambiguities: ConstraintDomains" begin @@ -22,7 +18,7 @@ @testset "Dependencies compatibility (no extras)" begin Aqua.test_deps_compat( ConstraintDomains; - check_extras = false, # ignore = [:Random] + check_extras=false, ) end end diff --git a/test/ExplicitImports.jl b/test/ExplicitImports.jl new file mode 100644 index 0000000..c6c9908 --- /dev/null +++ b/test/ExplicitImports.jl @@ -0,0 +1,3 @@ +@testset "Look for Explicit Imports" begin + @test check_no_implicit_imports(ConstraintDomains) === nothing +end diff --git a/test/JET.jl b/test/JET.jl new file mode 100644 index 0000000..471a9cc --- /dev/null +++ b/test/JET.jl @@ -0,0 +1,3 @@ +@testset "Code linting (JET.jl)" begin + JET.test_package(ConstraintDomains; target_defined_modules=true) +end diff --git a/test/runtests.jl b/test/runtests.jl index decf9df..6029b07 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,14 @@ +using ConstraintDomains + +using Aqua +using ExplicitImports +using JET using Test using TestItemRunner -@testset "Package tests: ConstraintDomains" begin +@testset "Package tests: ConstraintCommons" begin include("Aqua.jl") + include("ExplicitImports.jl") + include("JET.jl") include("TestItemRunner.jl") end