JuliaApproximation / DomainSets.jl

A Julia package for describing domains as continuous sets of elements
MIT License
72 stars 12 forks source link

UnionDomain and Set don't agree #57

Closed daanhb closed 4 years ago

daanhb commented 4 years ago

The way a domain is constructed from a set is currently inconsistent:

julia> s = Set([ [2,3], [4,5]])
Set(Array{Int64,1}[[2, 3], [4, 5]])

julia> d = Domain(s)
a union of 2 domains:
    1.  : DomainSets.WrappedDomain{Array{Int64,1},Int64}([2, 3])
    2.  : DomainSets.WrappedDomain{Array{Int64,1},Int64}([4, 5])

julia> 2 ∈ d
true

julia> 2 ∈ s
false

julia> [2,3] ∈ s
true

julia> [2,3] ∈ d
ERROR: MethodError: Cannot `convert` an object of type Array{Int64,1} to an object of type Int64

It seems safer to wrap a set into a wrapped domain as a whole, rather than to make a union of wrapped domains out of it. An alternative is to wrap each element of a set into a Point domain.