JuliaApproximation / DomainSets.jl

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

Complete set operations for domainlike types #37

Closed daanhb closed 5 years ago

daanhb commented 5 years ago

This pull request implements changes to IntersectionDomain and DifferenceDomain so that they also support domain-like types, and adds some tests for this case.

The union function is only extended for actual Domain types. Domainlike types can only be grouped by explicitly invoking the UnionDomain constructor, because we can't hijack union with duck typing in this package.

I looked into making the domains in UnionDomain into a Set, but there is a tradeoff: the Set would preserve types only if all domains have the same type. Currently, since the domains field can be a tuple, it is at least possible to preserve all type information. The disadvantage is that a large union will be demanding for the compiler, presumably.

Todo: do performance tests on the constructor and, if necessary, make some special cases more efficient.

daanhb commented 5 years ago

Tests pass, I'll merge so that we can quickly identify (and fix) any problems.

dlfivefifty commented 5 years ago

Yeah I think using a Set was not necessary: a union domain should be able to wrap any collection