Skip to content
Open
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
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -48,6 +51,8 @@ jobs:
- uses: codecov/codecov-action@v5
with:
files: lcov.info
use_oidc: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
fail_ci_if_error: true
# docs:
# name: Documentation
# runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion src/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Base.length(it::MappedIterator) = length(it.parent)
Base.size(it::MappedIterator) = size(it.parent)
Base.axes(it::MappedIterator) = axes(it.parent)
Base.keys(it::MappedIterator) = keys(it.parent)
@propagate_inbounds Base.getindex(it::MappedIterator, i) = it.parent[i]
@propagate_inbounds Base.getindex(it::MappedIterator, i) = it.f(it.parent[i])

struct MappedArray{T, N, F, A <: AbstractArray{<:Any, N}} <: AbstractArray{T, N}
f::F
Expand Down
20 changes: 20 additions & 0 deletions test/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ end
iter2 = mapview(x -> x[1] + x[2], iter)
@test @inferred(first(iter2)) === 2
@test collect(iter2) == [2, 4, 6]

@testset "Indexed iterables" begin
parent = (1, 2, 3)
mapped = mapview(x -> 10x, parent)
@test collect(mapped) == [10, 20, 30]
@test @inferred(mapped[2]) == 20
@test [mapped[i] for i in keys(mapped)] == collect(mapped)
@test @inferred(mapview(string, parent)[3]) == "3"
@test @inferred(mapview(abs, (a=-1, b=-2))[:b]) == 2
@test_throws BoundsError mapped[4]
@test_throws DomainError mapview(x -> throw(DomainError(x)), parent)[1]
calls = Ref(0)
lazy = mapview(parent) do x
calls[] += 1
x + 1
end
@test calls[] == 0
@test lazy[2] == 3
@test calls[] == 1
end
end

@testset "filterview" begin
Expand Down
Loading