From d29e6fab2317a1d42167e0e978d35fadb416fd72 Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Wed, 17 Dec 2025 15:10:20 +0100 Subject: [PATCH 1/2] Fix various invalidations - '>' and '>=' are already defined by Base in terms of '<' and '<=' - Base already defines a `convert(::T, ::Number)` method using type constructors. Replacing our `convert` method with the relevant constructors doesn't completely fix all the invalidations `convert` caused, but it does help. - `any()`, `all()`, and `Broadcast.broadcasted()` all have default implementations in Base that do the same thing. --- src/chainedvector.jl | 22 +++++----------------- test/chainedvector.jl | 2 ++ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/chainedvector.jl b/src/chainedvector.jl index 2ce72da..dbc246f 100644 --- a/src/chainedvector.jl +++ b/src/chainedvector.jl @@ -248,13 +248,12 @@ struct ChainedVectorIndex{A} <: Integer i::Int end -import Base: +, -, *, <, >, <=, >=, == -for f in (:+, :-, :*, :<, :>, :<=, :>=, :(==)) - @eval $f(a::ChainedVectorIndex, b::Integer) = $f(a.i, b) - @eval $f(a::Integer, b::ChainedVectorIndex) = $f(a, b.i) - @eval $f(a::ChainedVectorIndex, b::ChainedVectorIndex) = $f(a.i, b.i) +for f in (:+, :-, :*, :<, :<=, :(==)) + @eval Base.$f(a::ChainedVectorIndex, b::Integer) = $f(a.i, b) + @eval Base.$f(a::Integer, b::ChainedVectorIndex) = $f(a, b.i) + @eval Base.$f(a::ChainedVectorIndex, b::ChainedVectorIndex) = $f(a.i, b.i) end -Base.convert(::Type{T}, x::ChainedVectorIndex) where {T <: Union{Signed, Unsigned}} = convert(T, x.i) +(::Type{T})(x::ChainedVectorIndex) where {T <: Union{Signed, Unsigned}} = T(x.i) Base.hash(x::ChainedVectorIndex, h::UInt) = hash(x.i, h) @inline Base.getindex(x::ChainedVectorIndex) = @inbounds x.array[x.array_i] @@ -372,10 +371,6 @@ end return ci[], (idx, st) end -# other AbstractArray functions -Base.similar(x::ChainedVector) = similar(x, length(x)) -Base.similar(x::ChainedVector{T}, len::Base.DimOrInd) where {T} = similar(x, T, len) - function Base.similar(x::ChainedVector{T}, ::Type{S}, _len::Base.DimOrInd=length(x)) where {T, S} len = _len isa Integer ? _len : length(_len) if len == length(x) @@ -819,11 +814,6 @@ function Base.map!(f::F, x::ChainedVector, y::ChainedVector{T}) where {F, T} return x end -Base.any(f::Function, x::ChainedVector) = any(y -> any(f, y), x.arrays) -Base.any(x::ChainedVector) = any(y -> any(y), x.arrays) -Base.all(f::Function, x::ChainedVector) = all(y -> all(f, y), x.arrays) -Base.all(x::ChainedVector) = all(y -> all(y), x.arrays) - Base.reduce(op::OP, x::ChainedVector) where {OP} = reduce(op, (reduce(op, y) for y in x.arrays)) Base.foldl(op::OP, x::ChainedVector) where {OP} = foldl(op, (foldl(op, y) for y in x.arrays)) Base.foldr(op::OP, x::ChainedVector) where {OP} = foldr(op, (foldr(op, y) for y in x.arrays)) @@ -978,5 +968,3 @@ Base.replace(f::Base.Callable, a::ChainedVector) = ChainedVector([replace(f, A) Base.replace!(f::Base.Callable, a::ChainedVector) = (foreach(A -> replace!(f, A), a.arrays); return a) Base.replace(a::ChainedVector, old_new::Pair...; count::Union{Integer,Nothing}=nothing) = ChainedVector([replace(A, old_new...; count=count) for A in a.arrays]) Base.replace!(a::ChainedVector, old_new::Pair...; count::Integer=typemax(Int)) = (foreach(A -> replace!(A, old_new...; count=count), a.arrays); return a) - -Base.Broadcast.broadcasted(f::F, A::ChainedVector) where {F} = map(f, A) diff --git a/test/chainedvector.jl b/test/chainedvector.jl index faf3d93..92f9596 100644 --- a/test/chainedvector.jl +++ b/test/chainedvector.jl @@ -230,8 +230,10 @@ x = ChainedVector([[1,2,3], [4,5,6], [7,8,9,10]]) @test any(x -> iseven(x), x) @test any(map(x -> iseven(x), x)) + @test any(iseven.(x)) @test !all(x -> iseven(x), x) @test !all(map(x -> iseven(x), x)) + @test !all(iseven.(x)) @test reduce(+, x) == 55 @test foldl(+, x) == 55 @test foldr(+, x) == 55 From 8aa783c866157f1ec4060ed26033cdfe53ba7bba Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Wed, 17 Dec 2025 15:41:15 +0100 Subject: [PATCH 2/2] Update github actions --- .github/workflows/ci.yml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8984708..a086aba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,25 +27,15 @@ jobs: version: '1' arch: x86 steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: actions/checkout@v6 + - uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: actions/cache@v1 - env: - cache-name: cache-artifacts - with: - path: ~/.julia/artifacts - key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} - restore-keys: | - ${{ runner.os }}-test-${{ env.cache-name }}- - ${{ runner.os }}-test- - ${{ runner.os }}- - - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/cache@v2 - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v5 with: file: lcov.info # docs: