Skip to content

Commit 8defd8c

Browse files
authored
Merge pull request #8 from ChrisRackauckas/arrayinterface
update to StaticArrayInterface
2 parents 2a21c47 + 84825f0 commit 8defd8c

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

.github/workflows/CI.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
version:
13-
- '1.2'
13+
- '1.6'
1414
- '1'
1515
- 'nightly'
1616
os:

Project.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ authors = ["chriselrod <[email protected]> and contributors"]
44
version = "0.1.12"
55

66
[deps]
7-
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
87
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
8+
StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718"
99

1010
[compat]
11-
ArrayInterface = "3.1.33, 4, 5, 6"
1211
Static = "0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8"
13-
julia = "1.2"
12+
StaticArrayInterface = "1"
13+
julia = "1.6"
1414

1515
[extras]
1616
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

src/CloseOpenIntervals.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ SafeCloseOpen
7777
@inline Base.iterate(r::SafeCloseOpen) = (i = Int(first(r)); i getfield(r, :upper) ? nothing : (i, i))
7878
@inline Base.iterate(r::AbstractCloseOpen, i::IntegerType) = (i += one(i)) getfield(r, :upper) ? nothing : (i, i)
7979

80-
import ArrayInterface
81-
ArrayInterface.known_first(::Type{<:AbstractCloseOpen{StaticInt{F}}}) where {F} = F
82-
ArrayInterface.known_step(::Type{<:AbstractCloseOpen}) = 1
83-
ArrayInterface.known_last(::Type{<:AbstractCloseOpen{<:Any,StaticInt{L}}}) where {L} = L - 1
84-
ArrayInterface.known_length(::Type{<:AbstractCloseOpen{StaticInt{F},StaticInt{L}}}) where {F,L} = L - F
80+
import StaticArrayInterface
81+
StaticArrayInterface.known_first(::Type{<:AbstractCloseOpen{StaticInt{F}}}) where {F} = F
82+
StaticArrayInterface.known_step(::Type{<:AbstractCloseOpen}) = 1
83+
StaticArrayInterface.known_last(::Type{<:AbstractCloseOpen{<:Any,StaticInt{L}}}) where {L} = L - 1
84+
StaticArrayInterface.known_length(::Type{<:AbstractCloseOpen{StaticInt{F},StaticInt{L}}}) where {F,L} = L - F
8585

8686
Base.IteratorSize(::Type{<:AbstractCloseOpen}) = Base.HasShape{1}()
8787
Base.IteratorEltype(::Type{<:AbstractCloseOpen}) = Base.HasEltype()
8888
@inline Base.size(r::AbstractCloseOpen) = (length(r),)
8989
@inline Base.eltype(r::AbstractCloseOpen) = Int
90-
@inline Base.eachindex(r::AbstractCloseOpen) = StaticInt(1):ArrayInterface.static_length(r)
90+
@inline Base.eachindex(r::AbstractCloseOpen) = StaticInt(1):StaticArrayInterface.static_length(r)
9191

9292
@static if isdefined(Base.IteratorsMD, :OrdinalRangeInt)
9393
@inline function Base.IteratorsMD.__inc(state::Tuple{Int,Int,Vararg{Int}}, indices::Tuple{AbstractCloseOpen,Vararg{Base.IteratorsMD.OrdinalRangeInt}})

test/runtests.jl

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
using CloseOpenIntervals
22
using Test
33

4-
function mysum2(X = CartesianIndices((SafeCloseOpen(10),SafeCloseOpen(10))))
4+
function mysum2(X = CartesianIndices((SafeCloseOpen(10), SafeCloseOpen(10))))
55
s = 0
66
for I in X
77
s += sum(Tuple(I))
88
end
99
s
1010
end
1111
mysum2_allocated() = @allocated(mysum2())
12-
const ArrayInterface = CloseOpenIntervals.ArrayInterface
12+
const ArrayInterface = CloseOpenIntervals.StaticArrayInterface
1313
@testset "CloseOpenIntervals.jl" begin
1414
function mysum(x, N)
1515
s = zero(eltype(x))
@@ -25,17 +25,19 @@ const ArrayInterface = CloseOpenIntervals.ArrayInterface
2525
end
2626
s
2727
end
28-
x = rand(128);
28+
x = rand(128)
2929
for n 1:128
30-
@test mysum(x,n) mysafesum(x,n) sum(view(x,1:n))
30+
@test mysum(x, n) mysafesum(x, n) sum(view(x, 1:n))
3131
@test length(CloseOpen(n)) == n
3232
end
33-
@test @inferred(mysum(x,0)) == first(x)
34-
@test @inferred(mysafesum(x,0)) == 0.0
33+
@test @inferred(mysum(x, 0)) == first(x)
34+
@test @inferred(mysafesum(x, 0)) == 0.0
3535
@test @inferred(mysum(x, CloseOpenIntervals.StaticInt(128))) sum(x)
36-
@test @inferred(ArrayInterface.static_length(CloseOpen(CloseOpenIntervals.StaticInt(128)))) === CloseOpenIntervals.StaticInt(128)
36+
@test @inferred(
37+
ArrayInterface.static_length(CloseOpen(CloseOpenIntervals.StaticInt(128)))
38+
) === CloseOpenIntervals.StaticInt(128)
3739
@test @inferred(eltype(CloseOpen(7))) === Int
3840
@test ArrayInterface.known_length(CloseOpen(CloseOpenIntervals.StaticInt(128))) == 128
39-
@test @inferred(mysum2()) == sum(0:9)*2*length(0:9)
41+
@test @inferred(mysum2()) == sum(0:9) * 2 * length(0:9)
4042
@test mysum2_allocated() == 0
4143
end

0 commit comments

Comments
 (0)