Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Azzaare committed May 30, 2024
2 parents b8c7d03 + cf9a3a8 commit 525465e
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 33 deletions.
1 change: 1 addition & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
style = "sciml"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.jl.mem
/Manifest.toml
/docs/build/
/docs/Manifest.toml
11 changes: 5 additions & 6 deletions src/automata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ abstract type AbstractAutomaton end
A minimal implementation of a deterministic automaton structure.
"""
struct Automaton{S,T,F<:Union{S,Vector{S},Set{S}}} <: AbstractAutomaton
states::Dict{Tuple{S,T},S}
struct Automaton{S, T, F <: Union{S, Vector{S}, Set{S}}} <: AbstractAutomaton
states::Dict{Tuple{S, T}, S}
start::S
finish::F
end
Expand All @@ -22,11 +22,10 @@ end
Internal method used by `accept` with `Automaton`.
"""
at_end(a::Automaton{S,T,S}, s) where {S,T} = s == a.finish
at_end(a::Automaton{S, T, S}, s) where {S, T} = s == a.finish

at_end(a, s) = s a.finish


"""
accept(a::Union{Automaton, MDD}, w)
Expand All @@ -42,15 +41,15 @@ function accept(a::Automaton, w)
end

# SECTION - Test Items for Automata
@testitem "Automata" tags = [:automata] begin
@testitem "Automata" tags=[:automata] begin
states = Dict(
(:a, 0) => :a,
(:a, 1) => :b,
(:b, 1) => :c,
(:c, 0) => :d,
(:d, 0) => :d,
(:d, 1) => :e,
(:e, 0) => :e,
(:e, 0) => :e
)
start = :a
finish_a = :e
Expand Down
14 changes: 7 additions & 7 deletions src/diagrams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ abstract type AbstractMultivaluedDecisionDiagram end
A minimal implementation of a multivalued decision diagram structure.
"""
struct MDD{S,T} <: AbstractMultivaluedDecisionDiagram
states::Vector{Dict{Tuple{S,T},S}}
struct MDD{S, T} <: AbstractMultivaluedDecisionDiagram
states::Vector{Dict{Tuple{S, T}, S}}
end

function accept(a::MDD, w)
Expand All @@ -39,22 +39,22 @@ end
# end

# SECTION - Test Items for Automata
@testitem "MDD" tags = [:automata, :mdd] begin
@testitem "MDD" tags=[:automata, :mdd] begin
states = [
Dict( # level x1
(:r, 0) => :n1,
(:r, 1) => :n2,
(:r, 2) => :n3,
(:r, 2) => :n3
),
Dict( # level x2
(:n1, 2) => :n4,
(:n2, 2) => :n4,
(:n3, 0) => :n5,
(:n3, 0) => :n5
),
Dict( # level x3
(:n4, 0) => :t,
(:n5, 0) => :t,
),
(:n5, 0) => :t
)
]
a = MDD(states)

Expand Down
13 changes: 6 additions & 7 deletions src/dictionaries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ function incsert!(d::AbstractDict, ind, val = 1)
end

# SECTION - Test Items for inscert
@testitem "Dictionary" tags = [:dictionary, :incsert] default_imports = false begin
@testitem "Dictionary" tags=[:dictionary, :incsert] default_imports=false begin
using ConstraintCommons, Dictionaries, Test

counters_dict = Dictionary{Symbol,Int}()
witness_dict = Dictionary{Symbol,Int}([:a, :b], [2, 42])
counters_dict = Dictionary{Symbol, Int}()
witness_dict = Dictionary{Symbol, Int}([:a, :b], [2, 42])

incsert!(counters_dict, :a)
incsert!(counters_dict, :a)
Expand All @@ -27,10 +27,9 @@ end
@test witness_dict !== counters_dict
end

@testitem "Dict" tags = [:dict, :incsert] begin

counters_dict = Dict{Int,Int}()
witness_dict = Dict{Int,Int}(23 => 2, 42 => 42)
@testitem "Dict" tags=[:dict, :incsert] begin
counters_dict = Dict{Int, Int}()
witness_dict = Dict{Int, Int}(23 => 2, 42 => 42)

incsert!(counters_dict, 23)
incsert!(counters_dict, 23)
Expand Down
2 changes: 1 addition & 1 deletion src/extrema.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function δ_extrema(X...)
end

# SECTION - Test Items for δ_extrema
@testitem "δ_extrema" tags = [:δ_extrema] begin
@testitem "δ_extrema" tags=[:δ_extrema] begin
X = map(_ -> rand(1:100, 100), 1:3)

@test 0 δ_extrema(X[1]) 100
Expand Down
2 changes: 1 addition & 1 deletion src/nothing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Extends `Base.isempty` when the set is `nothing`. Returns `true`.
consisempty(::Nothing) = true
consisempty(items) = isempty(items)

@testitem "Set: nothing" tags = [:set, :nothing] begin
@testitem "Set: nothing" tags=[:set, :nothing] begin
@test !(ConstraintCommons.consin(42, nothing))
@test ConstraintCommons.consisempty(nothing)
end
12 changes: 6 additions & 6 deletions src/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const USUAL_CONSTRAINT_PARAMETERS = [
]
```
"""
const USUAL_CONSTRAINT_PARAMETERS =
[:bool, :dim, :id, :language, :op, :pair_vars, :val, :vals]
const USUAL_CONSTRAINT_PARAMETERS = [
:bool, :dim, :id, :language, :op, :pair_vars, :val, :vals]

"""
extract_parameters(m::Union{Method, Function}; parameters)
Expand All @@ -28,13 +28,13 @@ function extract_parameters(m::Method; parameters = USUAL_CONSTRAINT_PARAMETERS)
end

function extract_parameters(
f::F;
parameters = USUAL_CONSTRAINT_PARAMETERS,
) where {F<:Function}
f::F;
parameters = USUAL_CONSTRAINT_PARAMETERS
) where {F <: Function}
return filter(!isempty, map(m -> extract_parameters(m; parameters), methods(f)))
end

@testitem "Parameters" tags = [:parameters] begin
@testitem "Parameters" tags=[:parameters] begin
import ConstraintCommons: USUAL_CONSTRAINT_PARAMETERS

f(x; bool, dim, id, language, op, pair_vars, val, vals) = true
Expand Down
3 changes: 1 addition & 2 deletions src/sampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function oversample(X, f)
return Z
end

@testitem "Oversampling" tags = [:sampling, :oversampling] begin
@testitem "Oversampling" tags=[:sampling, :oversampling] begin
X = [[0, 1, 1], [0, 1, 2], [0, 0, 0]]

O = oversample(X, allunique)
Expand All @@ -34,5 +34,4 @@ end
@test count(x -> x == [0, 1, 1], O) == 1
@test count(x -> x == [0, 0, 0], O) == 1
@test length(O) == 4

end
2 changes: 1 addition & 1 deletion src/symbols.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ function symcon(s1::Symbol, s2::Symbol, connector::AbstractString = "_")
return Symbol(string(s1) * connector * string(s2))
end

@testitem "Symbols" tags = [:symbols] begin
@testitem "Symbols" tags=[:symbols] begin
@test ConstraintCommons.symcon(:a, :b) === :a_b
end
4 changes: 2 additions & 2 deletions test/Aqua.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ConstraintCommons;
ambiguities = (broken = false,),
deps_compat = false,
piracies = (broken = false,),
piracies = (broken = false,)
)

@testset "Ambiguities: ConstraintCommons" begin
Expand All @@ -22,7 +22,7 @@
@testset "Dependencies compatibility (no extras)" begin
Aqua.test_deps_compat(
ConstraintCommons;
check_extras = false, # ignore = [:Random]
check_extras = false # ignore = [:Random]
)
end
end

0 comments on commit 525465e

Please sign in to comment.