Skip to content

Commit

Permalink
Merge pull request #14 from JuliaArrays/pass
Browse files Browse the repository at this point in the history
tests pass
  • Loading branch information
ChrisRackauckas authored Feb 18, 2023
2 parents 7635d02 + 2be601d commit 7f04776
Show file tree
Hide file tree
Showing 20 changed files with 1,096 additions and 958 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Documentation

on:
push:
branches:
Expand All @@ -14,10 +15,14 @@ jobs:
- uses: julia-actions/setup-julia@latest
with:
version: '1'
- run: julia --project -e 'using Pkg; Pkg.develop([PackageSpec(path=joinpath(pwd(), "lib", "ArrayInterfaceCore"))])'
- uses: julia-actions/julia-buildpkg@latest
- run: julia --project=docs/ -e 'using Pkg; Pkg.develop([PackageSpec(path=joinpath(pwd(), "lib", "ArrayInterfaceCore"))]); Pkg.instantiate()'
- uses: julia-actions/julia-docdeploy@releases/v1
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
run: julia --project=docs/ --code-coverage=user docs/make.jl
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
26 changes: 7 additions & 19 deletions .github/workflows/Downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,9 @@ jobs:
julia-version: [1,1.6]
os: [ubuntu-latest]
package:
- {user: JuliaDiff, repo: SparseDiffTools.jl, group: Core}
- {user: SciML, repo: SciMLBase.jl, group: Core}
- {user: SciML, repo: DiffEqBase.jl, group: Core}
- {user: SciML, repo: DiffEqBase.jl, group: Downstream}
- {user: SciML, repo: DiffEqBase.jl, group: Downstream2}
- {user: SciML, repo: SciMLSensitivity.jl, group: Core1}
- {user: SciML, repo: SciMLSensitivity.jl, group: Core2}
- {user: SciML, repo: SciMLSensitivity.jl, group: Core3}
- {user: SciML, repo: SciMLSensitivity.jl, group: Core4}
- {user: SciML, repo: SciMLSensitivity.jl, group: Core5}
- {user: SciML, repo: OrdinaryDiffEq.jl, group: Core}
- {user: SciML, repo: OrdinaryDiffEq.jl, group: Interface}
- {user: SciML, repo: DelayDiffEq.jl, group: Interface}
- {user: JuliaSIMD, repo: VectorizationBase.jl, group: Interface}
- {user: JuliaSIMD, repo: LoopVectorization.jl, group: Downstream3}

steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
Expand All @@ -45,18 +33,14 @@ jobs:
repository: ${{ matrix.package.user }}/${{ matrix.package.repo }}
path: downstream
- name: Load this and run the downstream tests
shell: julia --color=yes {0}
shell: julia --color=yes --project=downstream {0}
run: |
using Pkg
try
# force it to use this PR's version of the package
Pkg.develop(PackageSpec(path=".")) # resolver may fail with main deps
Pkg.develop(Pkg.PackageSpec(path=joinpath(pwd(), "lib", "ArrayInterfaceCore")))
Pkg.develop(Pkg.PackageSpec(path=joinpath(pwd(), "lib", "ArrayInterfaceOffsetArrays")))
Pkg.develop(Pkg.PackageSpec(path=joinpath(pwd(), "lib", "ArrayInterfaceStaticArrays")))
Pkg.activate("downstream")
Pkg.update()
Pkg.test() # resolver may fail with test time deps
Pkg.test(coverage=true) # resolver may fail with test time deps
catch err
err isa Pkg.Resolve.ResolverError || rethrow()
# If we can't resolve that means this is incompatible by SemVer and this is fine
Expand All @@ -65,3 +49,7 @@ jobs:
@info "Not compatible with this release. No problem." exception=err
exit(0) # Exit immediately, as a success
end
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
7 changes: 5 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "StaticArrayInterface"
uuid = "8e56abe8-95dc-4044-b214-a7de3332c128"
uuid = "0d7ed370-da01-4f52-bd93-41d350b8b718"
version = "1.0.0"

[deps]
Expand All @@ -22,6 +22,10 @@ Static = "0.8"
Requires = "1"
julia = "1.6"

[extensions]
StaticArrayInterfaceOffsetArraysExt = "OffsetArrays"
StaticArrayInterfaceStaticArraysExt = "StaticArrays"

[extras]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Expand All @@ -35,4 +39,3 @@ test = ["SafeTestsets", "Pkg", "Test", "OffsetArrays", "StaticArrays"]
[weakdeps]
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
49 changes: 24 additions & 25 deletions ext/StaticArrayInterfaceOffsetArraysExt.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module StaticArrayInterfaceOffsetArraysExt

using ArrayInterface
using StaticArrayInterface
using Static
if isdefined(Base, :get_extension)
using OffsetArrays
using Static
else
using ..OffsetArrays
using ..Static
end

relative_offsets(r::OffsetArrays.IdOffsetRange) = (getfield(r, :offset),)
Expand All @@ -25,43 +24,43 @@ function relative_offsets(A::OffsetArrays.OffsetArray, dim::Int)
return getfield(relative_offsets(A), dim)
end
end
ArrayInterface.parent_type(::Type{<:OffsetArrays.OffsetArray{T,N,A}}) where {T,N,A} = A
StaticArrayInterface.parent_type(::Type{<:OffsetArrays.OffsetArray{T,N,A}}) where {T,N,A} = A
function _offset_axis_type(::Type{T}, dim::StaticInt{D}) where {T,D}
OffsetArrays.IdOffsetRange{Int,ArrayInterface.axes_types(T, dim)}
OffsetArrays.IdOffsetRange{Int,StaticArrayInterface.axes_types(T, dim)}
end
function ArrayInterface.axes_types(::Type{T}) where {T<:OffsetArrays.OffsetArray}
function StaticArrayInterface.axes_types(::Type{T}) where {T<:OffsetArrays.OffsetArray}
Static.eachop_tuple(
_offset_axis_type,
ntuple(static, StaticInt(ndims(T))),
ArrayInterface.parent_type(T)
StaticArrayInterface.parent_type(T)
)
end
ArrayInterface.static_strides(A::OffsetArray) = ArrayInterface.static_strides(parent(A))
function ArrayInterface.known_offsets(::Type{A}) where {A<:OffsetArrays.OffsetArray}
StaticArrayInterface.static_strides(A::OffsetArray) = StaticArrayInterface.static_strides(parent(A))
function StaticArrayInterface.known_offsets(::Type{A}) where {A<:OffsetArrays.OffsetArray}
ntuple(identity -> nothing, Val(ndims(A)))
end
function ArrayInterface.offsets(A::OffsetArrays.OffsetArray)
map(+, ArrayInterface.offsets(parent(A)), relative_offsets(A))
function StaticArrayInterface.offsets(A::OffsetArrays.OffsetArray)
map(+, StaticArrayInterface.offsets(parent(A)), relative_offsets(A))
end
@inline function ArrayInterface.offsets(A::OffsetArrays.OffsetArray, dim)
d = ArrayInterface.to_dims(A, dim)
ArrayInterface.offsets(parent(A), d) + relative_offsets(A, d)
@inline function StaticArrayInterface.offsets(A::OffsetArrays.OffsetArray, dim)
d = StaticArrayInterface.to_dims(A, dim)
StaticArrayInterface.offsets(parent(A), d) + relative_offsets(A, d)
end
@inline function ArrayInterface.static_axes(A::OffsetArrays.OffsetArray)
map(OffsetArrays.IdOffsetRange, ArrayInterface.static_axes(parent(A)), relative_offsets(A))
@inline function StaticArrayInterface.static_axes(A::OffsetArrays.OffsetArray)
map(OffsetArrays.IdOffsetRange, StaticArrayInterface.static_axes(parent(A)), relative_offsets(A))
end
@inline function ArrayInterface.static_axes(A::OffsetArrays.OffsetArray, dim)
d = ArrayInterface.to_dims(A, dim)
OffsetArrays.IdOffsetRange(ArrayInterface.static_axes(parent(A), d), relative_offsets(A, d))
@inline function StaticArrayInterface.static_axes(A::OffsetArrays.OffsetArray, dim)
d = StaticArrayInterface.to_dims(A, dim)
OffsetArrays.IdOffsetRange(StaticArrayInterface.static_axes(parent(A), d), relative_offsets(A, d))
end
function ArrayInterface.stride_rank(T::Type{<:OffsetArray})
ArrayInterface.stride_rank(ArrayInterface.parent_type(T))
function StaticArrayInterface.stride_rank(T::Type{<:OffsetArray})
StaticArrayInterface.stride_rank(StaticArrayInterface.parent_type(T))
end
function ArrayInterface.dense_dims(T::Type{<:OffsetArray})
ArrayInterface.dense_dims(ArrayInterface.parent_type(T))
function StaticArrayInterface.dense_dims(T::Type{<:OffsetArray})
StaticArrayInterface.dense_dims(StaticArrayInterface.parent_type(T))
end
function ArrayInterface.contiguous_axis(T::Type{<:OffsetArray})
ArrayInterface.contiguous_axis(ArrayInterface.parent_type(T))
function StaticArrayInterface.contiguous_axis(T::Type{<:OffsetArray})
StaticArrayInterface.contiguous_axis(StaticArrayInterface.parent_type(T))
end

end # module
54 changes: 26 additions & 28 deletions ext/StaticArrayInterfaceStaticArraysExt.jl
Original file line number Diff line number Diff line change
@@ -1,57 +1,55 @@
module StaticArrayInterfaceStaticArraysExt

using Adapt
using ArrayInterface
using StaticArrayInterface
using LinearAlgebra
using Static
using Static: StaticInt

if isdefined(Base, :get_extension)
using StaticArrays
using Static
using Static: StaticInt
else
using ..StaticArrays
using ..Static
using ..Static: StaticInt
end

const CanonicalInt = Union{Int,StaticInt}

function Static.OptionallyStaticUnitRange(::StaticArrays.SOneTo{N}) where {N}
Static.OptionallyStaticUnitRange(StaticInt(1), StaticInt(N))
end
ArrayInterface.known_first(::Type{<:StaticArrays.SOneTo}) = 1
ArrayInterface.known_last(::Type{StaticArrays.SOneTo{N}}) where {N} = N
ArrayInterface.known_length(::Type{StaticArrays.SOneTo{N}}) where {N} = N
ArrayInterface.known_length(::Type{StaticArrays.Length{L}}) where {L} = L
function ArrayInterface.known_length(::Type{A}) where {A<:StaticArrays.StaticArray}
ArrayInterface.known_length(StaticArrays.Length(A))
StaticArrayInterface.known_first(::Type{<:StaticArrays.SOneTo}) = 1
StaticArrayInterface.known_last(::Type{StaticArrays.SOneTo{N}}) where {N} = N
StaticArrayInterface.known_length(::Type{StaticArrays.SOneTo{N}}) where {N} = N
StaticArrayInterface.known_length(::Type{StaticArrays.Length{L}}) where {L} = L
function StaticArrayInterface.known_length(::Type{A}) where {A<:StaticArrays.StaticArray}
StaticArrayInterface.known_length(StaticArrays.Length(A))
end

@inline ArrayInterface.static_length(x::StaticArrays.StaticArray) = Static.maybe_static(ArrayInterface.known_length, Base.length, x)
ArrayInterface.device(::Type{<:StaticArrays.MArray}) = ArrayInterface.CPUPointer()
ArrayInterface.device(::Type{<:StaticArrays.SArray}) = ArrayInterface.CPUTuple()
ArrayInterface.contiguous_axis(::Type{<:StaticArrays.StaticArray}) = StaticInt{1}()
ArrayInterface.contiguous_batch_size(::Type{<:StaticArrays.StaticArray}) = StaticInt{0}()
function ArrayInterface.stride_rank(::Type{T}) where {N,T<:StaticArray{<:Any,<:Any,N}}
@inline StaticArrayInterface.static_length(x::StaticArrays.StaticArray) = Static.maybe_static(StaticArrayInterface.known_length, Base.length, x)
StaticArrayInterface.device(::Type{<:StaticArrays.MArray}) = StaticArrayInterface.CPUPointer()
StaticArrayInterface.device(::Type{<:StaticArrays.SArray}) = StaticArrayInterface.CPUTuple()
StaticArrayInterface.contiguous_axis(::Type{<:StaticArrays.StaticArray}) = StaticInt{1}()
StaticArrayInterface.contiguous_batch_size(::Type{<:StaticArrays.StaticArray}) = StaticInt{0}()
function StaticArrayInterface.stride_rank(::Type{T}) where {N,T<:StaticArray{<:Any,<:Any,N}}
ntuple(static, StaticInt(N))
end
function ArrayInterface.dense_dims(::Type{<:StaticArray{S,T,N}}) where {S,T,N}
ArrayInterface._all_dense(Val(N))
function StaticArrayInterface.dense_dims(::Type{<:StaticArray{S,T,N}}) where {S,T,N}
StaticArrayInterface._all_dense(Val(N))
end
ArrayInterface.defines_strides(::Type{<:StaticArrays.SArray}) = true
ArrayInterface.defines_strides(::Type{<:StaticArrays.MArray}) = true
StaticArrayInterface.defines_strides(::Type{<:StaticArrays.SArray}) = true
StaticArrayInterface.defines_strides(::Type{<:StaticArrays.MArray}) = true

@generated function ArrayInterface.axes_types(::Type{<:StaticArrays.StaticArray{S}}) where {S}
@generated function StaticArrayInterface.axes_types(::Type{<:StaticArrays.StaticArray{S}}) where {S}
Tuple{[StaticArrays.SOneTo{s} for s in S.parameters]...}
end
@generated function ArrayInterface.static_size(A::StaticArrays.StaticArray{S}) where {S}
@generated function StaticArrayInterface.static_size(A::StaticArrays.StaticArray{S}) where {S}
t = Expr(:tuple)
Sp = S.parameters
for n = 1:length(Sp)
push!(t.args, Expr(:call, Expr(:curly, :StaticInt, Sp[n])))
end
return t
end
@generated function ArrayInterface.static_strides(A::StaticArrays.StaticArray{S}) where {S}
@generated function StaticArrayInterface.static_strides(A::StaticArrays.StaticArray{S}) where {S}
t = Expr(:tuple, Expr(:call, Expr(:curly, :StaticInt, 1)))
Sp = S.parameters
x = 1
Expand All @@ -61,10 +59,10 @@ end
return t
end
if StaticArrays.SizedArray{Tuple{8,8},Float64,2,2} isa UnionAll
@inline ArrayInterface.static_strides(B::StaticArrays.SizedArray{S,T,M,N,A}) where {S,T,M,N,A<:SubArray} = ArrayInterface.static_strides(B.data)
ArrayInterface.parent_type(::Type{<:StaticArrays.SizedArray{S,T,M,N,A}}) where {S,T,M,N,A} = A
@inline StaticArrayInterface.static_strides(B::StaticArrays.SizedArray{S,T,M,N,A}) where {S,T,M,N,A<:SubArray} = StaticArrayInterface.static_strides(B.data)
StaticArrayInterface.parent_type(::Type{<:StaticArrays.SizedArray{S,T,M,N,A}}) where {S,T,M,N,A} = A
else
ArrayInterface.parent_type(::Type{<:StaticArrays.SizedArray{S,T,M,N}}) where {S,T,M,N} = Array{T,N}
StaticArrayInterface.parent_type(::Type{<:StaticArrays.SizedArray{S,T,M,N}}) where {S,T,M,N} = Array{T,N}
end

end # module
Loading

0 comments on commit 7f04776

Please sign in to comment.