Skip to content

Commit cd5452a

Browse files
authored
Add colsupport for OneElelement (#164)
* Add colsupport for OneElelement * Bump version to v1.2.0
1 parent 8c250b4 commit cd5452a

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ArrayLayouts"
22
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
33
authors = ["Sheehan Olver <solver@mac.com>"]
4-
version = "1.1.1"
4+
version = "1.2.0"
55

66
[deps]
77
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"

src/memorylayout.jl

+3
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,9 @@ end
666666
rowsupport(::ZerosLayout, A, _) = 1:0
667667
colsupport(::ZerosLayout, A, _) = 1:0
668668

669+
colsupport(::UnknownLayout, A::OneElement{<:Any,1}, _) =
670+
intersect(axes(A,1), A.ind[1]:A.ind[1])
671+
669672
rowsupport(::DiagonalLayout, _, k) = k
670673
colsupport(::DiagonalLayout, _, j) = j
671674

test/test_layouts.jl

+7
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,13 @@ struct FooNumber <: Number end
313313
@test isempty(colsupport(Zeros(5,10), 2))
314314
@test isempty(rowsupport(Zeros(5,10), 2))
315315

316+
@testset "OneElement" begin
317+
for ind in (4, 20)
318+
o = OneElement(2, ind, 10)
319+
@test sum(o) == sum(o[colsupport(o)])
320+
end
321+
end
322+
316323
# views of Fill no longer create Sub Arrays, but are supported
317324
# as there was no strong need to delete their support
318325
v = SubArray(Fill(1,10),(1:3,))

0 commit comments

Comments
 (0)