Skip to content

Commit b5d0f9f

Browse files
committed
Relaxed condition getindex(X, i)
1 parent 2999cfe commit b5d0f9f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ end
1111

1212

1313
"""
14-
ColVecs{T, TX<:AbstractMatrix}
14+
ColVecs(X::AbstractMatrix)
1515
1616
A lightweight box for an `AbstractMatrix` to make it behave like a vector of vectors.
1717
"""
@@ -25,7 +25,7 @@ end
2525

2626
Base.size(D::ColVecs) = (size(D.X, 2),)
2727
Base.getindex(D::ColVecs, i::Int) = view(D.X, :, i)
28-
Base.getindex(D::ColVecs, i::AbstractVector{Int}) = ColVecs(view(D.X, :, i))
28+
Base.getindex(D::ColVecs, i) = ColVecs(view(D.X, :, i))
2929

3030
# Take highest Float among possibilities
3131
# function promote_float(Tₖ::DataType...)

test/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
@test getindex(DX, 5) == X[:, 5]
1414
@test getindex(DX, 1:2:6) isa ColVecs
1515
@test getindex(DX, 1:2:6) == ColVecs(X[:, 1:2:6])
16+
@test getindex(DX, :) == ColVecs(X)
1617
@test eachindex(DX) == 1:N
1718
@test first(DX) == X[:, 1]
1819

19-
2020
let
2121
@test Zygote.pullback(ColVecs, X)[1] == DX
2222
DX, back = Zygote.pullback(ColVecs, X)

0 commit comments

Comments
 (0)