Closed daanhb closed 9 months ago
I think these changes are almost completely backwards compatible with the 0.6 version of DomainSets, because functionality has mostly been added. However, the internal change is quite substantial, and I'm pretty sure that I've changed the default behaviour of ==
and issubset
for domains, so a version upgrade is called for.
Also, a note on eltype
. Both IntervalSets.jl and Intervals.jl implement eltype
because they see intervals as sets. However, both can have an Int
eltype when the interval has integer endpoints. This creates funny situations in computations. The domains in GeometryBasics.jl and in Meshes.jl do not have an eltype (their eltype
is Any
), but they all implicitly work with vectors of fixed length DIM and element type T
. Finally, the sets in LazySets.jl
have an eltype of Float64
even when they describe sets of vectors of floats.
The only solution is to create a new function, which I've called domaineltype
. It has a sensible definition for all domains in the packages mentioned above. For now, internally this PR still uses eltype
for variables of type Domain{T}
and that eltype is T. It uses domaineltype
(abbreviated to deltype
internally) for variables which represent domains but whose type may be something else.
Patch coverage: 79.90%
and project coverage change: -4.81%
:warning:
Comparison is base (
f9638be
) 85.70% compared to head (1162e66
) 80.90%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Probably the behaviour that makes most logical sense is eltype(0..1) == Real
. But then there could be boundaryeltype(0..1) == Int
. (Probably needs a more general name…)
then wherever is calling eltype
now could call float(boundaryeltype(d))
In the current design I'd say that float(boundaryeltype(d))
is a good candidate implementation for eltype
or domaineltype
of intervals with numeric types.
Yes, eltype
being Real
makes conceptual sense, but it does not convey any useful information. For example, if rand
for an interval returns a point in the interval, which will be the type of that point? That is what T
is for <:Domain{T}
and what domaineltype
is for other objects satisfying the domain interface.
Okay to merge this? It only adds behaviour, which we can test in more cases before making other changes (like moving the definition of Domain).
What was breaking in this release?
Syntactically, normally nothing. A lot of the internals changed though, which mainly results in more functionality (as opposed to functionality changing) for types that do not inherit from the main Domain type.
There were some nuances in the decision whether two domains are equal which may have changed and which prompted a new series, out of caution. I would expect 0.7 to work as is for most people who had been using 0.6.x (and I'm assuming you're asking because you didn't notice a difference).
I think this is a candidate for becoming 0.7.
It mostly implements the idea of a domain as an interface (#14, #120) and addresses some related issues ( https://github.com/JuliaMath/IntervalSets.jl/issues/115, https://github.com/JuliaMath/IntervalSets.jl/issues/136). The main goal is to improve interoperability with other packages.
Among other things this PR includes a copy of the contents of a newly proposed DomainSetsCore.jl package, with the exception of the definition of
Domain{T}
which remains in IntervalSets.jl for now. See core.jl for the code and the README of DomainSetsCore for a formal definition of the "domain interface". If this works well, we can still register DomainSetsCore and move the definitions there.Most importantly this PR implements all operations of DomainSets for any type, whether it inherits from Domain or not, except for functions that have a standard name outside of DomainSets. In that case, those functions are only implemented for variables of type Domain or variables which are passed "as a domain" (using the
AsDomain(d)
) syntax. A prominent example iseltype
. An alternative function which is "owned" by DomainSets isdomaineltype
.As an example of interoperability, see here for a package extension to make domains co-exist with types of GeometryBasics.jl. No changes to either packages are required, hence it could be an extension in either of the two packages. I've illustrated here what it takes for intervals of IntervalSets.jl and Intervals.jl to interact with each other.
An example of the usefulness is that in a package like DomainIntegrals.jl one can specify the integral domain as any domain (an interval from IntervalSets.jl, or from Intervals.jl, or a rectangle from GeometryBasics.jl) and it "just works". (Up to possible bugs and missing functionality for now, of course....)