Skip to content

Commit

Permalink
Add 0-dim reshape tests for MyBigFill (#368)
Browse files Browse the repository at this point in the history
This should catch some missing cases in #367
  • Loading branch information
jishnub authored Dec 18, 2024
1 parent b704533 commit 5972e9e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,7 @@ struct MyBigFill{T,N} <: AbstractArray{T,N}
val :: T
axes :: NTuple{N,Base.OneTo{BigInt}}
end
MyBigFill(val, sz::Tuple{}) = MyBigFill{typeof(val),0}(val, sz)
MyBigFill(val, sz::NTuple{N,BigInt}) where {N} = MyBigFill(val, map(Base.OneTo, sz))
MyBigFill(val, sz::Tuple{Vararg{Integer}}) = MyBigFill(val, map(BigInt, sz))
Base.size(M::MyBigFill) = map(length, M.axes)
Expand All @@ -1770,6 +1771,7 @@ function Base.reshape(M::MyBigFill, ind::NTuple{N,BigInt}) where {N}
length(M) == prod(ind) || throw(ArgumentError("length mismatch in reshape"))
MyBigFill(M.val, ind)
end
Base.reshape(M::MyBigFill, ind::Tuple{}) = MyBigFill(M.val, ind)

@testset "reshape" begin
A0 = [1 3; 2 4]
Expand Down Expand Up @@ -1928,6 +1930,12 @@ end
M = MyBigFill(4, (2, 3))
O = OffsetArray(M)
@test vec(O) isa MyBigFill
@test vec(O) == vec(M)

M = MyBigFill(4, (1,1))
O = OffsetArray(M)
@test reshape(O) == reshape(M)
@test reshape(O) isa MyBigFill
end
end

Expand Down

2 comments on commit 5972e9e

@jishnub
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/121600

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.15.0 -m "<description of version>" 5972e9e7fa148e87f127cc2b0152bce1e94dfd16
git push origin v1.15.0

Please sign in to comment.