Skip to content

Commit

Permalink
Fix behavior of copy and similar (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer authored Mar 27, 2024
1 parent cf3928d commit 9136dca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ReadOnlyArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Base.iterate(x::ReadOnlyArray, args...) = iterate(x.parent, args...)

Base.length(x::ReadOnlyArray) = length(x.parent)

Base.similar(x::ReadOnlyArray) = similar(x.parent) |> ReadOnlyArray
Base.similar(x::ReadOnlyArray) = similar(x.parent)

Base.axes(x::ReadOnlyArray) = axes(x.parent)

Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ end
fa = f()
@test fa isa ReadOnlyArray{Float64,2}
@test fa == x

a = ReadOnly([1, 2])
@test typeof(similar(a)) === Vector{Int64}

@test copy(a) == [1, 2]
@test typeof(copy(a)) === Vector{Int64}
end
end

Expand Down

0 comments on commit 9136dca

Please sign in to comment.