From 8c32f4c63ae6a3a32f2d737cd410547e79afe033 Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Fri, 21 Jul 2023 12:26:01 +0200 Subject: [PATCH] Fix #65 (#66) * Fix #65 * test 1.10 --- .github/workflows/ci.yml | 4 ++-- Project.toml | 2 +- src/abstractarray.jl | 8 ++++++++ test/abstractarray.jl | 8 ++++++++ test/linalg.jl | 6 +++++- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5899ed3..3751dad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - julia-version: ['1.6', '1.8', '~1.9.0-0'] + julia-version: ['1.6', '1.9', '~1.10.0-0'] os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v3 @@ -22,6 +22,6 @@ jobs: - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-runtest@latest - uses: julia-actions/julia-uploadcodecov@latest - if: ${{ matrix.julia-version == '1.6' && matrix.os =='ubuntu-latest' }} + if: ${{ matrix.os =='ubuntu-latest' }} env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/Project.toml b/Project.toml index 0ed05bd..f765abd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "HybridArrays" uuid = "1baab800-613f-4b0a-84e4-9cd3431bfbb9" authors = ["Mateusz Baran "] -version = "0.4.15" +version = "0.4.16" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/abstractarray.jl b/src/abstractarray.jl index bb20833..ad8871e 100644 --- a/src/abstractarray.jl +++ b/src/abstractarray.jl @@ -69,6 +69,14 @@ similar(::Type{<:HybridArray{S,T,N,M}},::Type{T2}) where {S,T,N,M,T2} = HybridAr similar(::Type{SA},::Type{T},s::Size{S}) where {SA<:HybridArray,T,S} = hybridarray_similar_type(T,s,StaticArrays.length_val(s))(undef) hybridarray_similar_type(::Type{T},s::Size{S},::Type{Val{D}}) where {T,S,D} = HybridArray{Tuple{S...},T,D,length(s)} +#disambiguation +function similar(a::HybridArray, t::Type{T2}, i::Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}}) where T2 + return invoke(similar, Tuple{AbstractArray, Type, Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}}}, a, t, i) +end +function similar(a::HybridArray, t::Type{T2}, i::Tuple{Int64, Vararg{Int64}}) where T2 + return invoke(similar, Tuple{AbstractArray, Type, Tuple{Int64, Vararg{Int64}}}, a, t, i) +end + # for internal use only (used in vcat and hcat) # TODO: try to make this less hacky # adding method to similar_type ends up being used in broadcasting for some reason? diff --git a/test/abstractarray.jl b/test/abstractarray.jl index e20f091..984bca5 100644 --- a/test/abstractarray.jl +++ b/test/abstractarray.jl @@ -138,4 +138,12 @@ using StaticArrays: Dynamic @test isa(M3, HybridArray{Tuple{Dynamic(),3,4},Int,3,3,Array{Int,3}}) @test size(M3) === (5, 3, 4) end + + @testset "getindex" begin + A = HybridArray{Tuple{2,2,StaticArrays.Dynamic()}}(randn(2,2,100)) + B = A[1:2] + @test B isa Vector + @test A[1] == B[1] + @test A[2] == B[2] + end end diff --git a/test/linalg.jl b/test/linalg.jl index d377bd6..d81fe72 100644 --- a/test/linalg.jl +++ b/test/linalg.jl @@ -42,6 +42,10 @@ using Test @test isa(vcat(HybridVector{2}([1, 2]), HybridVector{3}([1, 2, 3])), HybridVector{5, Int}) @test_throws DimensionMismatch hcat(HybridVector{2}([1, 2]), HybridVector{3}([1, 2, 3])) - @test_throws ArgumentError vcat(m1, hcat(m1, m2)) + if VERSION < v"1.10" + @test_throws ArgumentError vcat(m1, hcat(m1, m2)) + else + @test_throws DimensionMismatch vcat(m1, hcat(m1, m2)) + end end end