Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ jobs:
arch: x86
version: 1
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v5
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -57,8 +57,8 @@ jobs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v5
- uses: julia-actions/setup-julia@v2
with:
version: 'nightly'
- run: |
Expand Down
16 changes: 4 additions & 12 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@ version = "0.4.0"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
ArrayInterface = "5"
Static = "0.6"
julia = "1.6"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Aqua", "ArrayInterface", "Documenter"]
ArrayInterface = "7"
Static = "1.2"
julia = "1.11"
11 changes: 8 additions & 3 deletions src/MetaArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@ for f in [:axes, :size, :stride]
end

# ArrayInterface traits that just need the parent type
for f in [:can_change_size, :defines_strides, :known_size, :known_length, :axes_types,
for f in [:defines_strides]
eval(:(ArrayInterface.$(f)(@nospecialize T::Type{<:MetaArray}) = ArrayInterface.$(f)(parent_type(T))))
end

# StaticArrayInterface traits that just need the parent type
for f in [:can_change_size, :known_size, :known_length, :axes_types,
:known_offsets, :known_strides, :contiguous_axis, :contiguous_axis_indicator,
:stride_rank, :contiguous_batch_size,:known_first, :known_last, :known_step]
eval(:(ArrayInterface.$(f)(@nospecialize T::Type{<:MetaArray}) = ArrayInterface.$(f)(parent_type(T))))
eval(:(StaticArrayInterface.$(f)(@nospecialize T::Type{<:MetaArray}) = StaticArrayInterface.$(f)(parent_type(T))))
end

Base.pointer(@nospecialize(x::MetaArray), n::Integer) = pointer(parent(x), n)

for f in [:axes, :size, :strides, :offsets]
eval(:(ArrayInterface.$(f)(@nospecialize(x::MetaArray)) = ArrayInterface.$f(parent(x))))
eval(:(StaticArrayInterface.$(f)(@nospecialize(x::MetaArray)) = StaticArrayInterface.$f(parent(x))))
end

Base.copy(A::MetaArray) = copy_metadata(A, copy(parent(A)))
Expand Down
2 changes: 1 addition & 1 deletion src/MetaTuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct MetaTuple{N,P,M}
global _MetaTuple(p::P, m::M) where {P,M} = new{length(p),P,M}(p, m)
end

ArrayInterface.known_length(::Type{<:MetaTuple{N}}) where {N} = N
StaticArrayInterface.known_length(::Type{<:MetaTuple{N}}) where {N} = N

Base.eltype(T::Type{<:MetaTuple}) = eltype(parent_type(T))

Expand Down
4 changes: 2 additions & 2 deletions src/MetaUnitRange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ end

Base.@propagate_inbounds Base.getindex(r::MetaUnitRange, i::Integer) = parent(r)[i]

ArrayInterface.known_first(::Type{T}) where {T<:MetaUnitRange} = known_first(parent_type(T))
StaticArrayInterface.known_first(::Type{T}) where {T<:MetaUnitRange} = known_first(parent_type(T))

ArrayInterface.known_last(::Type{T}) where {T<:MetaUnitRange} = known_last(parent_type(T))
StaticArrayInterface.known_last(::Type{T}) where {T<:MetaUnitRange} = known_last(parent_type(T))

@propagate_inbounds Base.getindex(r::MetaUnitRange, i) = propagate_metadata(r, parent(r)[i])

Expand Down
4 changes: 3 additions & 1 deletion src/Metadata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module Metadata
end Metadata

using ArrayInterface
using ArrayInterface: parent_type, known_first, known_last, known_step, StaticInt, to_dims, axes_types
using ArrayInterface: parent_type
using StaticArrayInterface
using StaticArrayInterface: known_first, known_last, known_step, StaticInt, to_dims, axes_types
using Base: @propagate_inbounds, OneTo, tail
using LinearAlgebra
using Statistics
Expand Down
6 changes: 3 additions & 3 deletions test/MetaUnitRange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ mx = Metadata.test_wrapper(Metadata.MetaUnitRange, x)
@test @inferred(step(x)) == step(mx)
@test @inferred(last(x)) == last(mx)
@test @inferred(length(mx)) == length(x)
@test ArrayInterface.known_first(mx) === ArrayInterface.known_first(x)
@test ArrayInterface.known_last(mx) === ArrayInterface.known_last(x)
@test ArrayInterface.known_step(mx) === ArrayInterface.known_step(x)
@test StaticArrayInterface.known_first(mx) === StaticArrayInterface.known_first(x)
@test StaticArrayInterface.known_last(mx) === StaticArrayInterface.known_last(x)
@test StaticArrayInterface.known_step(mx) === StaticArrayInterface.known_step(x)
@test mx[1:2:10] == x[1:2:10]
@test mx[:] == x[:]
Metadata.test_wrapper(Metadata.MetaUnitRange, 1:10)
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

using ArrayInterface
using StaticArrayInterface
using Aqua
using Documenter
using Metadata
using Test

using ArrayInterface: parent_type, StaticInt
using ArrayInterface: parent_type
using StaticArrayInterface: StaticInt
using Metadata: MetaArray, no_data

Aqua.test_all(Metadata)
Expand Down