Skip to content

Commit d0c0100

Browse files
authored
Update docs (#164)
* fix link in index.md * copy docs from README.md * update index.md * simplify README * fix mod (LaTeX)
1 parent 61f18ec commit d0c0100

File tree

3 files changed

+74
-81
lines changed

3 files changed

+74
-81
lines changed

README.md

Lines changed: 7 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -7,94 +7,22 @@ Interval Sets for Julia
77
[![Coverage](https://codecov.io/gh/JuliaMath/IntervalSets.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaMath/IntervalSets.jl)
88
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
99

10-
This package represents intervals of an ordered set. For an interval
11-
spanning from `a` to `b`, all values `x` that lie between `a` and `b`
12-
are defined as being members of the interval.
13-
14-
Currently this package defines one concrete type, `Interval`.
15-
These define the set spanning from `a` to `b`, meaning the
16-
interval is defined as the set `{x}` satisfying `a ≤ x ≤ b`. This is
17-
sometimes written `[a,b]` (mathematics syntax, not Julia syntax) or
18-
`a..b`.
19-
20-
Optionally, `Interval{L,R}` can represent open and half-open intervals. The type
21-
parameters `L` and `R` correspond to the left and right endpoint respectively.
22-
The notation `ClosedInterval` is short for `Interval{:closed,:closed}`, while `OpenInterval` is short for `Interval{:open,:open}`. For example, the interval `Interval{:open,:closed}` corresponds to the set `{x}` satisfying `a < x ≤ b`.
23-
24-
## Usage
25-
26-
You can construct `ClosedInterval`s in a variety of ways:
10+
## Quick start
2711

2812
```julia
2913
julia> using IntervalSets
3014

31-
julia> ClosedInterval{Float64}(1,3)
15+
julia> i1 = 1.0 .. 3.0
3216
1.0 .. 3.0
3317

34-
julia> 0.5..2.5
35-
0.5 .. 2.5
36-
37-
julia> 1.5±1
38-
0.5 .. 2.5
39-
```
40-
41-
Similarly, you can construct `OpenInterval`s and `Interval{:open,:closed}`s, and `Interval{:closed,:open}`:
42-
```julia
43-
julia> OpenInterval{Float64}(1,3)
44-
1.0 .. 3.0 (open)
45-
46-
julia> OpenInterval(0.5..2.5)
47-
0.5 .. 2.5 (open)
48-
49-
julia> Interval{:open,:closed}(1,3)
50-
1 .. 3 (open-closed)
51-
```
52-
53-
The `±` operator may be typed as `\pm<TAB>` (using Julia's LaTeX
54-
syntax tab-completion).
55-
56-
Intervals also support the expected set operations:
57-
58-
```julia
59-
julia> 1.75 1.5±1 # \in<TAB>; can also use `in`
60-
true
61-
62-
julia> 0 1.5±1
63-
false
64-
65-
julia> 1 OpenInterval(0..1)
66-
false
67-
68-
julia> intersect(1..5, 3..7) # can also use `a ∩ b`, where the symbol is \cap<TAB>
69-
3 .. 5
18+
julia> i2 = OpenInterval(0..4)
19+
0 .. 4 (open)
7020

71-
julia> isempty(intersect(1..5, 10..11))
21+
julia> i1 i2
7222
true
7323

74-
julia> (0.25..5) (3..7.4) # \cup<TAB>; can also use union()
75-
0.25 .. 7.4
76-
77-
julia> isclosedset(0.5..2.0)
78-
true
79-
80-
julia> isopenset(OpenInterval(0.5..2.5))
81-
true
82-
83-
julia> isleftopen(2..3)
24+
julia> i2 i1
8425
false
8526
```
8627

87-
When computing the union, the result must also be an interval:
88-
```julia
89-
julia> (0.25..5) (6..7.4)
90-
ERROR: ArgumentError: Cannot construct union of disjoint sets.
91-
Stacktrace:
92-
[1] union(d1::ClosedInterval{Float64}, d2::ClosedInterval{Float64})
93-
@ IntervalSets ~/.julia/dev/IntervalSets/src/interval.jl:127
94-
[2] top-level scope
95-
@ REPL[2]:1
96-
```
97-
98-
### Importing the .. operator
99-
100-
To import the `..` operator, use `import IntervalSets: (..)`. The parantheses are necessary to avoid parsing issues.
28+
Please refer to the [documentation](https://JuliaMath.github.io/IntervalSets.jl/stable) for comprehensive guides and examples.

docs/src/index.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# IntervalSets.jl
22

3-
A Julia package implementing [IntervalSets](https://en.wikipedia.org/wiki/Quaternion).
3+
A Julia package implementing [interval sets](https://en.wikipedia.org/wiki/Interval_(mathematics)).
4+
5+
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaMath.github.io/IntervalSets.jl/stable)
6+
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaMath.github.io/IntervalSets.jl/dev)
7+
[![Build Status](https://github.com/JuliaMath/IntervalSets.jl/workflows/CI/badge.svg)](https://github.com/JuliaMath/IntervalSets.jl/actions)
8+
[![Coverage](https://codecov.io/gh/JuliaMath/IntervalSets.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaMath/IntervalSets.jl)
9+
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
410

511
!!! note "Documentation"
612
The documentation is still work in progress.
@@ -13,3 +19,62 @@ A Julia package implementing [IntervalSets](https://en.wikipedia.org/wiki/Quater
1319
```
1420
pkg> add IntervalSets
1521
```
22+
23+
## Quick start
24+
25+
```@repl
26+
using IntervalSets
27+
i1 = 1.0 .. 3.0
28+
i2 = OpenInterval(0..4)
29+
i1 ⊆ i2
30+
i2 ⊆ i1
31+
```
32+
33+
Currently this package defines one concrete type, [`Interval`](@ref).
34+
These define the set spanning from `a` to `b`, meaning the interval is defined as the set ``\{x \ | \ a ≤ x ≤ b\}``.
35+
This is sometimes written ``[a,b]`` (mathematics syntax, not Julia syntax) or ``a..b``.
36+
37+
Optionally, `Interval{L,R}` can represent open and half-open intervals.
38+
The type parameters `L` and `R` correspond to the left and right endpoint respectively.
39+
The notation [`ClosedInterval`](@ref) is short for `Interval{:closed,:closed}`,
40+
while [`OpenInterval`](@ref) is short for `Interval{:open,:open}`.
41+
For example, the interval `Interval{:open,:closed}` corresponds to the set ``\{x \ | \ a < x ≤ b\}``.
42+
43+
## More examples
44+
45+
```@setup more
46+
using IntervalSets
47+
```
48+
49+
### Constructors
50+
```@repl more
51+
ClosedInterval{Float64}(1,3)
52+
OpenInterval{Float64}(1,3)
53+
Interval{:open, :closed}(1,3)
54+
0.5..2.5
55+
1.5 ± 1
56+
Interval{:open,:closed}(1,3)
57+
OpenInterval(0.5..2.5) # construct `OpenInterval` from `ClosedInterval`
58+
```
59+
60+
The [`±`](@ref) operator may be typed as `\pm<TAB>` (using Julia's LaTeX syntax tab-completion).
61+
62+
### Set operations
63+
64+
```@repl
65+
1.75 ∈ 1.5±1 # \in<TAB>; can also use `in`
66+
0 ∈ 1.5±1
67+
1 ∈ OpenInterval(0..1)
68+
intersect(1..5, 3..7) # can also use `a ∩ b`, where the symbol is \cap<TAB>
69+
isempty(intersect(1..5, 10..11))
70+
(0.25..5) ∪ (3..7.4) # \cup<TAB>; can also use `union()`
71+
isclosedset(0.5..2.0)
72+
isopenset(OpenInterval(0.5..2.5))
73+
isleftopen(2..3)
74+
(0.25..5) ∪ (6..7.4) # union of interval must be an interval
75+
```
76+
77+
### Importing the `..` operator
78+
79+
To import the [`..`](@ref) operator, use `import IntervalSets: (..)`.
80+
The parantheses are necessary to avoid parsing issues.

src/IntervalSets.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ clamp(t, i::TypedEndpointsInterval{:closed,:closed}) =
241241
"""
242242
mod(x, i::AbstractInterval)
243243
244-
Find `y` in the `i` interval such that ``x ≡ y (mod w)``, where `w = width(i)`.
244+
Find `y` in the `i` interval such that ``x ≡ y \\pmod w``, where `w = width(i)`.
245245
246246
# Examples
247247

0 commit comments

Comments
 (0)