Skip to content

Commit 73b4033

Browse files
format
1 parent 88e3d64 commit 73b4033

File tree

5 files changed

+81
-71
lines changed

5 files changed

+81
-71
lines changed

docs/make.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ using Static
22
using Documenter
33

44
makedocs(;
5-
modules = [Static],
6-
authors = "chriselrod, ChrisRackauckas, Tokazama",
7-
repo = "https://github.com/SciML/Static.jl/blob/{commit}{path}#L{line}",
8-
sitename = "Static.jl",
9-
format = Documenter.HTML(;
10-
prettyurls = get(ENV, "CI", "false") == "true",
11-
canonical = "https://SciML.github.io/Static.jl",
12-
assets = String[]),
13-
pages = [
14-
"Home" => "index.md",
15-
])
5+
modules = [Static],
6+
authors = "chriselrod, ChrisRackauckas, Tokazama",
7+
repo = "https://github.com/SciML/Static.jl/blob/{commit}{path}#L{line}",
8+
sitename = "Static.jl",
9+
format = Documenter.HTML(;
10+
prettyurls = get(ENV, "CI", "false") == "true",
11+
canonical = "https://SciML.github.io/Static.jl",
12+
assets = String[]),
13+
pages = [
14+
"Home" => "index.md"
15+
])
1616

1717
deploydocs(;
18-
repo = "github.com/SciML/Static.jl")
18+
repo = "github.com/SciML/Static.jl")

src/Static.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ end
375375
Base.@propagate_inbounds function _promote_shape(a::Tuple{A}, ::Tuple{}) where {A}
376376
(static_promote(static(1), getfield(a, 1)),)
377377
end
378-
Base.@propagate_inbounds function Base.promote_shape(a::Tuple{
378+
Base.@propagate_inbounds function Base.promote_shape(
379+
a::Tuple{
379380
Vararg{Union{Int, StaticInt}},
380381
},
381382
b::Tuple{Vararg{Union{Int, StaticInt}}
@@ -961,8 +962,8 @@ end
961962
@inline function Base.to_indices(A, inds,
962963
I::Tuple{AbstractArray{NDIndex{N, J}}, Vararg{Any}}) where {
963964
N,
964-
J,
965-
}
965+
J
966+
}
966967
_, indstail = Base.IteratorsMD.split(inds, Val(N))
967968
return (Base.to_index(A, I[1]), to_indices(A, indstail, Base.tail(I))...)
968969
end

src/ranges.jl

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct OptionallyStaticUnitRange{F <: IntType, L <: IntType} <:
1313
stop::L
1414

1515
function OptionallyStaticUnitRange(start::IntType,
16-
stop::IntType)
16+
stop::IntType)
1717
new{typeof(start), typeof(stop)}(start, stop)
1818
end
1919
function OptionallyStaticUnitRange(start, stop)
@@ -57,39 +57,39 @@ static(2):static(2):10
5757
```
5858
"""
5959
struct OptionallyStaticStepRange{F <: IntType, S <: IntType,
60-
L <: IntType} <: OrdinalRange{Int, Int}
60+
L <: IntType} <: OrdinalRange{Int, Int}
6161
start::F
6262
step::S
6363
stop::L
6464

6565
global function _OptionallyStaticStepRange(@nospecialize(start::IntType),
66-
@nospecialize(step::IntType),
67-
@nospecialize(stop::IntType))
66+
@nospecialize(step::IntType),
67+
@nospecialize(stop::IntType))
6868
new{typeof(start), typeof(step), typeof(stop)}(start, step, stop)
6969
end
7070
end
7171
@noinline function OptionallyStaticStepRange(@nospecialize(start::IntType),
72-
::StaticInt{0},
73-
@nospecialize(stop::IntType))
72+
::StaticInt{0},
73+
@nospecialize(stop::IntType))
7474
throw(ArgumentError("step cannot be zero"))
7575
end
7676
# we don't need to check the `stop` if we know it acts like a unit range
7777
function OptionallyStaticStepRange(@nospecialize(start::IntType),
78-
step::StaticInt{1},
79-
@nospecialize(stop::IntType))
78+
step::StaticInt{1},
79+
@nospecialize(stop::IntType))
8080
_OptionallyStaticStepRange(start, step, stop)
8181
end
8282
function OptionallyStaticStepRange(@nospecialize(start::IntType),
83-
@nospecialize(step::StaticInt),
84-
@nospecialize(stop::IntType))
83+
@nospecialize(step::StaticInt),
84+
@nospecialize(stop::IntType))
8585
_OptionallyStaticStepRange(start, step, _steprange_last(start, step, stop))
8686
end
8787
function OptionallyStaticStepRange(start, step, stop)
8888
OptionallyStaticStepRange(IntType(start), IntType(step), IntType(stop))
8989
end
9090
function OptionallyStaticStepRange(@nospecialize(start::IntType),
91-
step::Int,
92-
@nospecialize(stop::IntType))
91+
step::Int,
92+
@nospecialize(stop::IntType))
9393
if step === 0
9494
throw(ArgumentError("step cannot be zero"))
9595
else
@@ -99,16 +99,16 @@ end
9999
OptionallyStaticStepRange(@nospecialize x::OptionallyStaticStepRange) = x
100100
function OptionallyStaticStepRange(x::AbstractRange)
101101
_OptionallyStaticStepRange(IntType(static_first(x)), IntType(static_step(x)),
102-
IntType(static_last(x)))
102+
IntType(static_last(x)))
103103
end
104104

105105
# to make StepRange constructor inlineable, so optimizer can see `step` value
106106
@inline function _steprange_last(start::StaticInt, step::StaticInt, stop::StaticInt)
107107
StaticInt(_steprange_last(Int(start), Int(step), Int(stop)))
108108
end
109109
@inline function _steprange_last(start::Union{StaticInt, Int},
110-
step::Union{StaticInt, Int},
111-
stop::Union{StaticInt, Int})
110+
step::Union{StaticInt, Int},
111+
stop::Union{StaticInt, Int})
112112
_steprange_last(Int(start), Int(step), Int(stop))
113113
end
114114
@inline function _steprange_last(start::Int, step::Int, stop::Int)
@@ -147,7 +147,7 @@ SOneTo(n::Int) = SOneTo{n}()
147147
Base.oneto(::StaticInt{N}) where {N} = SOneTo{N}()
148148

149149
const OptionallyStaticRange{F, L} = Union{OptionallyStaticUnitRange{F, L},
150-
OptionallyStaticStepRange{F, <:Any, L}}
150+
OptionallyStaticStepRange{F, <:Any, L}}
151151

152152
# these probide a generic method for extracting potentially static values.
153153
static_first(x::Base.OneTo) = StaticInt(1)
@@ -217,13 +217,13 @@ Base.isempty(r::OptionallyStaticUnitRange) = first(r) > last(r)
217217
end
218218

219219
function Base.checkindex(::Type{Bool},
220-
::SUnitRange{F1, L1},
221-
::SUnitRange{F2, L2}) where {F1, L1, F2, L2}
220+
::SUnitRange{F1, L1},
221+
::SUnitRange{F2, L2}) where {F1, L1, F2, L2}
222222
(F1::Int <= F2::Int) && (L1::Int >= L2::Int)
223223
end
224224

225225
function Base.getindex(r::OptionallyStaticUnitRange,
226-
s::AbstractUnitRange{<:Integer})
226+
s::AbstractUnitRange{<:Integer})
227227
@boundscheck checkbounds(r, s)
228228
f = static_first(r)
229229
fnew = f - one(f)
@@ -299,11 +299,12 @@ end
299299
function Base.axes1(x::OptionallyStaticStepRange)
300300
OptionallyStaticUnitRange(StaticInt(1), length(x))
301301
end
302-
function Base.axes1(x::OptionallyStaticStepRange{StaticInt{F}, StaticInt{S}, StaticInt{L}}) where {
303-
F,
304-
S,
305-
L
306-
}
302+
function Base.axes1(x::OptionallyStaticStepRange{
303+
StaticInt{F}, StaticInt{S}, StaticInt{L}}) where {
304+
F,
305+
S,
306+
L
307+
}
307308
OptionallyStaticUnitRange(StaticInt(1), StaticInt(_range_length(F, S, L)))
308309
end
309310
Base.axes1(x::Base.Slice{<:OptionallyStaticUnitRange{One}}) = x.indices
@@ -347,25 +348,25 @@ function Base.Broadcast.axistype(_, r::OptionallyStaticUnitRange{StaticInt{1}})
347348
Base.OneTo(last(r))
348349
end
349350
function Base.Broadcast.axistype(r::OptionallyStaticUnitRange{StaticInt{1}},
350-
::OptionallyStaticUnitRange{StaticInt{1}})
351+
::OptionallyStaticUnitRange{StaticInt{1}})
351352
Base.OneTo(last(r))
352353
end
353354
function Base.similar(::Type{<:Array{T}},
354-
axes::Tuple{OptionallyStaticUnitRange{StaticInt{1}},
355-
Vararg{
356-
Union{Base.OneTo,
357-
OptionallyStaticUnitRange{StaticInt{1}}}}}) where {
358-
T
359-
}
355+
axes::Tuple{OptionallyStaticUnitRange{StaticInt{1}},
356+
Vararg{
357+
Union{Base.OneTo,
358+
OptionallyStaticUnitRange{StaticInt{1}}}}}) where {
359+
T
360+
}
360361
Array{T}(undef, map(last, axes))
361362
end
362363
function Base.similar(::Type{<:Array{T}},
363-
axes::Tuple{Base.OneTo, OptionallyStaticUnitRange{StaticInt{1}},
364-
Vararg{
365-
Union{Base.OneTo,
366-
OptionallyStaticUnitRange{StaticInt{1}}}}}) where {
367-
T
368-
}
364+
axes::Tuple{Base.OneTo, OptionallyStaticUnitRange{StaticInt{1}},
365+
Vararg{
366+
Union{Base.OneTo,
367+
OptionallyStaticUnitRange{StaticInt{1}}}}}) where {
368+
T
369+
}
369370
Array{T}(undef, map(last, axes))
370371
end
371372

test/ranges.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@
4242
@test UnitRange{Int}(Static.OptionallyStaticUnitRange(static(1), static(10))) ===
4343
UnitRange(1, 10)
4444

45-
@test AbstractUnitRange{Int}(Static.OptionallyStaticUnitRange(static(1), static(10))) isa
45+
@test AbstractUnitRange{Int}(Static.OptionallyStaticUnitRange(
46+
static(1), static(10))) isa
4647
Static.OptionallyStaticUnitRange
47-
@test AbstractUnitRange{UInt}(Static.OptionallyStaticUnitRange(static(1), static(10))) isa
48+
@test AbstractUnitRange{UInt}(Static.OptionallyStaticUnitRange(
49+
static(1), static(10))) isa
4850
Base.OneTo
49-
@test AbstractUnitRange{UInt}(Static.OptionallyStaticUnitRange(static(2), static(10))) isa
51+
@test AbstractUnitRange{UInt}(Static.OptionallyStaticUnitRange(
52+
static(2), static(10))) isa
5053
UnitRange
5154

5255
@test @inferred((static(1):static(10))[static(2):static(3)]) === static(2):static(3)
@@ -98,11 +101,11 @@ CI = CartesianIndices((static(1):static(2), static(1):static(2)))
98101

99102
@test @inferred(length(Static.OptionallyStaticStepRange(static(1), 2, 10))) == 5
100103
@test @inferred(length(Static.OptionallyStaticStepRange(static(1), static(1),
101-
static(10)))) == 10
104+
static(10)))) == 10
102105
@test @inferred(length(Static.OptionallyStaticStepRange(static(2), static(1),
103-
static(10)))) == 9
106+
static(10)))) == 9
104107
@test @inferred(length(Static.OptionallyStaticStepRange(static(2), static(2),
105-
static(10)))) == 5
108+
static(10)))) == 5
106109
end
107110

108111
@test @inferred(getindex(static(1):10, Base.Slice(static(1):10))) === static(1):10

test/runtests.jl

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,14 @@ end
365365
# inferred is Union{Int,Nothing}
366366
@test Static.find_first_eq(1, map(Int, y)) === 3
367367

368-
@testset "reduce_tup" begin for n in 2:16
369-
x = ntuple(_ -> rand(Bool) ? rand() : (rand(Bool) ? rand(0x00:0x1f) : rand(0:31)),
370-
n)
371-
@test @inferred(Static.reduce_tup(+, x)) reduce(+, x)
372-
end end
368+
@testset "reduce_tup" begin
369+
for n in 2:16
370+
x = ntuple(
371+
_ -> rand(Bool) ? rand() : (rand(Bool) ? rand(0x00:0x1f) : rand(0:31)),
372+
n)
373+
@test @inferred(Static.reduce_tup(+, x)) reduce(+, x)
374+
end
375+
end
373376
end
374377

375378
@testset "invperm" begin
@@ -527,14 +530,16 @@ y = 1:10
527530

528531
@test @inferred(static(2.0)^2.0) === 2.0^2.0
529532

530-
@testset "trig" begin for f in [sin, cos, tan, asin, atan, acos, sinh, cosh, tanh,
531-
asinh, atanh, exp, exp2,
532-
exp10, expm1, log, log2, log10, log1p, exponent, sqrt, cbrt, sec, csc, cot, sech,
533-
secd, csch, cscd, cotd, cosd, tand, asind, acosd, atand, acotd, sech, coth, asech,
534-
acsch, deg2rad, mod2pi, sinpi, cospi]
535-
@info "Testing $f(0.5)"
536-
@test @inferred(f(static(0.5))) === static(f(0.5))
537-
end end
533+
@testset "trig" begin
534+
for f in [sin, cos, tan, asin, atan, acos, sinh, cosh, tanh,
535+
asinh, atanh, exp, exp2,
536+
exp10, expm1, log, log2, log10, log1p, exponent, sqrt, cbrt, sec, csc, cot, sech,
537+
secd, csch, cscd, cotd, cosd, tand, asind, acosd, atand, acotd, sech, coth, asech,
538+
acsch, deg2rad, mod2pi, sinpi, cospi]
539+
@info "Testing $f(0.5)"
540+
@test @inferred(f(static(0.5))) === static(f(0.5))
541+
end
542+
end
538543
@test @inferred(asec(static(2.0))) === static(asec(2.0))
539544
@test @inferred(acsc(static(2.0))) === static(acsc(2.0))
540545
@test @inferred(acot(static(2.0))) === static(acot(2.0))

0 commit comments

Comments
 (0)