This is a proposal for a restructuring of the Sets folder. Essentially, I propose to have a module for each set type T, and to add the operations regarding only T there. This PR starts with Interval.
Issues
While working on it, I realized a couple of issues, leading to these modules not being totally independent:
(minor) A module needs at least one interface (e.g., LazySet) as supertype of the struct. And the interfaces define many default implementations, which we really want to keep. So the modules will not be independent of LazySets itself.
A module typically also needs a few other basic set types (EmptySet, HalfSpace (for constraints_list); in this case, I also needed UnionSet). This may eventually become a problem when hiding all set types in modules. One solution could be to load the required set types as optional dependencies. But I suggest to delay this decoupling (to when we use extensions, instead of doing a lot of work with Requires). I also still have to see whether there are cyclic dependencies. If there are, we may have to separate the struct from the operations anyway.
While this is supposed to be a pure refactoring without changing the behavior downstream, it is easy to forget to import all used symbols. This means we have to be extra careful. I see this as a motivation to add tests for each method. Hence, this will be a longer project :snail:
Summary of commits
Below I summarize the commits, with an indication of how significant the changes are. :one: = main change; :two: = splitting/merging of operations for the new module; :three: = minor.
The first commit just renames/moves Sets/Interval.jl to a subfolder Sets/Interval/IntervalModule.jl (separate commit to simplify the diff):
:three: move Interval.jl to subfolder
The next commit is the main change. It adds the module and all required imports:
:one: add IntervalModule
The next three commits outsource all API functions from the big module file to its own files and also add the convert methods and binary Interval operations:
:two: move convert methods
:two: outsource struct and operations to files
:two: move binary Interval operations to module
The last commit is necessary to accommodate for the previous commit (moving UnionSet earlier in the loading order):
Overview
This is a proposal for a restructuring of the
Sets
folder. Essentially, I propose to have a module for each set typeT
, and to add the operations regarding onlyT
there. This PR starts withInterval
.Issues
While working on it, I realized a couple of issues, leading to these modules not being totally independent:
LazySet
) as supertype of the struct. And the interfaces define many default implementations, which we really want to keep. So the modules will not be independent ofLazySets
itself.EmptySet
,HalfSpace
(forconstraints_list
); in this case, I also neededUnionSet
). This may eventually become a problem when hiding all set types in modules. One solution could be to load the required set types as optional dependencies. But I suggest to delay this decoupling (to when we use extensions, instead of doing a lot of work withRequires
). I also still have to see whether there are cyclic dependencies. If there are, we may have to separate the struct from the operations anyway.Summary of commits
Below I summarize the commits, with an indication of how significant the changes are. :one: = main change; :two: = splitting/merging of operations for the new module; :three: = minor.
The first commit just renames/moves
Sets/Interval.jl
to a subfolderSets/Interval/IntervalModule.jl
(separate commit to simplify the diff):Interval.jl
to subfolderThe next commit is the main change. It adds the module and all required imports:
IntervalModule
The next three commits outsource all
API
functions from the big module file to its own files and also add theconvert
methods and binaryInterval
operations:convert
methodsInterval
operations to moduleThe last commit is necessary to accommodate for the previous commit (moving
UnionSet
earlier in the loading order):