Skip to content

Commit 2547e29

Browse files
committed
Export the interval macro from the LSHFunctions module.
1 parent 2d0a87a commit 2547e29

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

docs/src/full_api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ Private = false
3434
Pages = ["similarities.jl"]
3535
```
3636

37+
## Miscellaneous
38+
39+
```@docs
40+
@interval
41+
```
42+
3743
## Private interface
3844

3945
```@autodocs

src/LSHFunctions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ export SimHash, L1Hash, L2Hash, MIPSHash, SignALSH, MinHash,
4848

4949
# Helper / utility functions for LSHFunctions
5050
export index_hash, query_hash, n_hashes, hashtype, similarity, lsh_family,
51-
embedded_similarity, collision_probability
51+
embedded_similarity, collision_probability, @interval
5252

5353
end # module

src/function_hashing/chebhash.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ChebHash(similarity, args...; kws...) =
2727

2828
function ChebHash(::SimilarityFunction{S},
2929
args...;
30-
interval::RealInterval = LSHFunctions.@interval(-1 x 1),
30+
interval::RealInterval = @interval(-1 x 1),
3131
kws...) where S
3232

3333
discrete_hashfn = LSHFunction(S, args...; kws...)

src/intervals.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,25 +153,25 @@ The returned expression constructs an `LSHFunctions.RealInterval` encoding the l
153153
You can construct an interval using the following syntax:
154154
155155
```jldoctest; setup = :(using LSHFunctions)
156-
julia> interval = LSHFunctions.@interval(0 ≤ x < 1);
156+
julia> interval = @interval(0 ≤ x < 1);
157157
```
158158
159159
There are usually multiple ways of constructing the same interval. For instance, each of the expressions below are equivalent ways of constructing the interval `[-1,1]`.
160160
161161
```jldoctest; setup = :(using LSHFunctions)
162-
julia> LSHFunctions.@interval(-1 ≤ x ≤ 1) ==
163-
LSHFunctions.@interval(-1 <= x <= 1) ==
164-
LSHFunctions.@interval(-1 ≤ y ≤ 1) ==
165-
LSHFunctions.@interval( 1 ≥ x ≥ -1)
162+
julia> @interval(-1 ≤ x ≤ 1) ==
163+
@interval(-1 <= x <= 1) ==
164+
@interval(-1 ≤ y ≤ 1) ==
165+
@interval( 1 ≥ x ≥ -1)
166166
true
167167
```
168168
169-
You can even create intervals with `Inf` or `-Inf` at the endpoints, e.g. `LSHFunctions.@interval(-Inf < x < Inf)`.
169+
You can even create intervals with `Inf` or `-Inf` at the endpoints, e.g. `@interval(-Inf < x < Inf)`.
170170
171171
There are two primary operations you can run on an interval: testing for membership and intersection. You can test whether or not `x` is in an interval using `x ∈ interval`, as shown below.
172172
173173
```jldoctest; setup = :(using LSHFunctions)
174-
julia> interval = LSHFunctions.@interval(0 ≤ x < 1);
174+
julia> interval = @interval(0 ≤ x < 1);
175175
176176
julia> 0 ∈ interval && 1 ∉ interval
177177
true
@@ -183,20 +183,20 @@ true
183183
You can also intersect two intervals using the `∩` operator (or by using `intersect(interval_1, interval_2)`).
184184
185185
```
186-
julia> LSHFunctions.@interval(0 ≤ x < 1) ∩ LSHFunctions.@interval(1/2 < x ≤ 1) == LSHFunctions.@interval(1/2 < x < 1)
186+
julia> @interval(0 ≤ x < 1) ∩ @interval(1/2 < x ≤ 1) == @interval(1/2 < x < 1)
187187
true
188188
```
189189
190190
See also: [`RealInterval`](@ref)
191191
"""
192192
macro interval(expr)
193193
invalid_expr_msg = """
194-
Expression is invalid. The expression passed to LSHFunctions.@interval must take the form
194+
Expression is invalid. The expression passed to @interval must take the form
195195
196196
a {<,≤,>,≥} x {<,≤,>,≥} b
197197
198198
where a and b evaluate to real numbers, and x is a valid variable identifier.
199-
See the documentation for LSHFunctions.@interval for more information.
199+
See the documentation for @interval for more information.
200200
"""
201201

202202
if !isa(expr, Expr)

src/similarities.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ for ``p = 1``, ``p = 2``, and ``p = 3``.
177177
```jldoctest; setup = :(using LSHFunctions)
178178
julia> f(x) = x^2 + 1; g(x) = 2x;
179179
180-
julia> interval = LSHFunctions.@interval(0 ≤ x ≤ 1);
180+
julia> interval = @interval(0 ≤ x ≤ 1);
181181
182182
julia> Lp(f, g, interval, 1) ≈ L1(f, g, interval) ≈ 3^(-1)
183183
true
@@ -279,7 +279,7 @@ where the interval we're integrating over is specified by the `interval` argumen
279279
```jldoctest; setup = :(using LSHFunctions)
280280
julia> f(x) = cos(x); g(x) = sin(x);
281281
282-
julia> inner_prod(f, g, LSHFunctions.@interval(0 ≤ x ≤ π/2)) ≈ 1/2
282+
julia> inner_prod(f, g, @interval(0 ≤ x ≤ π/2)) ≈ 1/2
283283
true
284284
```
285285
"""
@@ -356,7 +356,7 @@ Computes the ``L^p`` function-space norm of a function ``f``, which is given by
356356
```jldoctest; setup = :(using LSHFunctions)
357357
julia> f(x) = x;
358358
359-
julia> interval = LSHFunctions.@interval(0 ≤ x ≤ 1);
359+
julia> interval = @interval(0 ≤ x ≤ 1);
360360
361361
julia> Lp_norm(f, interval, 1) ≈ L1_norm(f, interval) ≈ 2^(-1/1)
362362
true

0 commit comments

Comments
 (0)