Skip to content

Commit

Permalink
Fix length(::Type{<:NDIndex}) (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokazama authored May 18, 2022
1 parent 0a5b294 commit ef95ab9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Static"
uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
authors = ["chriselrod", "ChrisRackauckas", "Tokazama"]
version = "0.6.4"
version = "0.6.5"

[deps]
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
Expand Down
2 changes: 1 addition & 1 deletion src/ndindex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ end

# length
Base.length(@nospecialize(x::NDIndex))::Int = length(Tuple(x))
Base.length(@nospecialize(T::Type{<:NDIndex}))::Int = @inbounds(T.parameters[1])
Base.length(::Type{<:NDIndex{N}}) where {N} = N

# indexing
@propagate_inbounds function Base.getindex(x::NDIndex{N,T}, i::Int)::Int where {N,T}
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ using Test
@test @inferred(Base.IteratorsMD.split(x, Val(2))) === (NDIndex(1, 2), NDIndex(3,))
@test @inferred(length(x)) === 3
@test @inferred(length(typeof(x))) === 3
NDIndex2{I<:Tuple{Vararg{Union{StaticInt,Int},2}}} = NDIndex{2, I}
@test length(NDIndex2) === 2
@test @inferred(y[2]) === 2
@test @inferred(y[static(2)]) === static(2)

Expand Down

2 comments on commit ef95ab9

@Tokazama
Copy link
Collaborator 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/60463

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 v0.6.5 -m "<description of version>" ef95ab9aeb3288764cec72f25efabc21b7fc1f4a
git push origin v0.6.5

Please sign in to comment.