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
2 changes: 1 addition & 1 deletion test/mooncake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using RecursiveArrayTools, Mooncake, Test

@testset "ArrayPartition increment_and_get_rdata!" begin
@test Base.get_extension(RecursiveArrayTools, :RecursiveArrayToolsMooncakeExt) !==
nothing
nothing

# Tangent produced by an upstream ChainRule.
t = ArrayPartition([1.0, 2.0], [3.0, 4.0])
Expand Down
14 changes: 7 additions & 7 deletions test/named_array_partition_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ end
@test x[[1, 2]] == [1.0, 1.0]
@test x[[1, 4]] == [1.0, 2.0]

@test x[1:2] isa Vector{Float64}
@test x[1:end] isa Vector{Float64}
@test x[1:2] isa Vector{Float64}
@test x[1:end] isa Vector{Float64}
@test x[[1, 4]] isa Vector{Float64}

# Inferred return types: Vector, not Union
@test (@inferred x[1:2]) isa Vector{Float64}
@test (@inferred x[1:length(x)]) isa Vector{Float64}
@test (@inferred x[[1, 4]]) isa Vector{Float64}
@test (@inferred x[1:2]) isa Vector{Float64}
@test (@inferred x[1:length(x)]) isa Vector{Float64}
@test (@inferred x[[1, 4]]) isa Vector{Float64}

# `similar` with a non-matching dims falls back to the backing array;
# with matching dims keeps the NamedArrayPartition wrapper.
@test similar(x, Float64, (2,)) isa Vector{Float64}
@test similar(x, (2,)) isa Vector{Float64}
@test similar(x, (2,)) isa Vector{Float64}
@test similar(x, Float64, size(x)) isa NamedArrayPartition
@test similar(x, size(x)) isa NamedArrayPartition
@test similar(x, size(x)) isa NamedArrayPartition

# Scalar indexing untouched and type-stable
@test x[1] == 1.0
Expand Down
Loading