Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct set documentation #197

Merged
merged 5 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 11 additions & 22 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,21 @@ This package defines:
## Sets

A single interval can be used to represent a contiguous set within a domain but cannot be
used to represent a disjoint set. Due to this restriction all set-based operations that
return an interval will always return a vector of intervals. These operations will combine
any intervals which are overlapping or touching into a single continuous interval and never
return an interval instance which itself is empty.
used to represent a disjoint set. For general purpose set operations you need to use the `IntervalSet` type.

```julia
julia> union([1..10], [5..15])
1-element Vector{Interval{Int64, Closed, Closed}}:
Interval{Int64, Closed, Closed}(1, 15)

julia> intersect([1..10], [5..15])
1-element Vector{Interval{Int64, Closed, Closed}}:
Interval{Int64, Closed, Closed}(5, 10)
```@docs
IntervalSet
```

julia> setdiff([1..10], [5..15])
1-element Vector{Interval{Int64, Closed, Open}}:
Interval{Int64, Closed, Open}(1, 5)
If you wish to instead treat each interval as an *element* of a set, you can operate over vectors or `Set`s of intervals.

julia> symdiff([1..10], [5..15])
2-element Vector{Interval{Int64}}:
Interval{Int64, Closed, Open}(1, 5)
Interval{Int64, Open, Closed}(10, 15)
For example:

julia> intersect([1..5], [10..15])
Interval[]
```julia
julia> intersect([1..2, 2..3, 3..4, 4..5], [2..3, 3..4])
2-element Vector{Interval{Int64, Closed, Closed}}:
Interval{Int64, Closed, Closed}(2, 3)
Interval{Int64, Closed, Closed}(3, 4)
```

## Example Usage
Expand Down Expand Up @@ -268,7 +258,6 @@ In the plot, inclusive boundaries are marked with a vertical bar, whereas exclus
```@docs
Interval
AnchoredInterval
IntervalSet
HourEnding
HourBeginning
HE
Expand Down
4 changes: 2 additions & 2 deletions src/interval_sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

A set of points represented by a sequence of intervals. Set operations over interval sets
return a new IntervalSet, with the fewest number of intervals possible. Unbounded intervals
are not supported. The individual intervals in the set can be accessed using the iteration
API or by passing the set to `Array`.
are not supported. The individual intervals in the set can be accessed by calling
`convert(Array, interval_set)`.

see also: https://en.wikipedia.org/wiki/Interval_arithmetic#Interval_operators

Expand Down