Skip to content

Commit dc97ca8

Browse files
authored
Suppose resizedata! on transposed arrays (#392)
1 parent d47f4d5 commit dc97ca8

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "LazyArrays"
22
uuid = "5078a376-72f3-5289-bfd5-ec5146d43c02"
3-
version = "2.9.3"
3+
version = "2.9.4"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/cache.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,13 @@ resizedata!(B::CachedArray, mn...) = resizedata!(MemoryLayout(B.data), MemoryLay
228228
resizedata!(B::AbstractCachedArray, mn...) = resizedata!(MemoryLayout(B.data), UnknownLayout(), B, mn...)
229229
resizedata!(A, mn...) = A # don't do anything
230230
function resizedata!(A::AdjOrTrans, m, n)
231-
m 0 || resizedata!(parent(A), n)
231+
resizedata!(parent(A), n, m)
232232
A
233233
end
234+
function resizedata!(A::AdjOrTrans{<:Any, <:AbstractVector}, m, n)
235+
resizedata!(parent(A), n)
236+
A
237+
end
234238

235239
function cache_filldata!(B, inds...)
236240
B.data[inds...] .= view(B.array,inds...)

test/cachetests.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ using Infinities
538538
@testset "DualLayout{<:AbstractCachedLayout}" begin
539539
arg1 = view((1:100)', :, 1:10)
540540
arg2 = view(AccumulateAbstractVector(*, 1:100)', :, 1:10)
541-
bc = Base.Broadcast.Broadcasted(CachedArrayStyle{2}(), *, (arg1, arg2))
541+
bc = Base.Broadcast.Broadcasted(CachedArrayStyle{2}(), *, (arg1, arg2));
542542
rsz_bc = LazyArrays.resize_bcargs!(bc);
543543
@test rsz_bc.args[2] == view(arg2.parent.parent.data', :, 1:10)
544544
end
@@ -574,6 +574,13 @@ using Infinities
574574
@test cacheddata(F) === view(cacheddata(parent(parent(F))), 1:1)'
575575
@test cacheddata(G) === adjoint(view(cacheddata(parent(G)), 1:1, 1:1))
576576
end
577+
578+
@testset "resizedata! for AdjTrans array" begin
579+
x = LazyArrays.CachedArray(rand(1, 10))';
580+
@test parent(x).datasize == (0, 0)
581+
LazyArrays.resizedata!(x, 4, 1)
582+
@test parent(x).datasize == (1, 4)
583+
end
577584
end
578585

579586
end # module

0 commit comments

Comments
 (0)