Skip to content
Merged
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
18 changes: 4 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 5 additions & 17 deletions src/chainedvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
2 changes: 2 additions & 0 deletions test/chainedvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading