Skip to content

Commit c599a83

Browse files
authored
sub_materialize(::AbstractQuasiArray) (#60)
* sub_materialize(::AbstractQuasiArray) * Update test_quasisubarray.jl * increase coverage
1 parent 33f28d0 commit c599a83

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "QuasiArrays"
22
uuid = "c4ea9172-b204-11e9-377d-29865faadc5c"
33
authors = ["Sheehan Olver <solver@mac.com>"]
4-
version = "0.4.7"
4+
version = "0.4.8"
55

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

src/dense.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,7 @@
3939
else
4040
A*A^(p-1)
4141
end
42-
function (^)(A::AbstractQuasiMatrix{T}, p::Integer) where T<:Integer
43-
# make sure that e.g. [1 1;1 0]^big(3)
44-
# gets promotes in a similar way as 2^big(3)
45-
TT = promote_op(^, T, typeof(p))
46-
return convert(AbstractQuasiMatrix{TT}, A)^p
47-
end
42+
4843
# function integerpow(A::AbstractQuasiMatrix{T}, p) where T
4944
# TT = promote_op(^, T, typeof(p))
5045
# return (TT == T ? A : copyto!(similar(A, TT), A))^Integer(p)

src/subquasiarray.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ end
326326

327327
@inline sub_materialize(_, V::AbstractQuasiArray, _) = QuasiArray(V)
328328
@inline sub_materialize(V::SubQuasiArray) = sub_materialize(MemoryLayout(typeof(V)), V)
329+
@inline sub_materialize(A::AbstractQuasiArray) = A # already materialized
329330

330331

331332
###

test/test_dense.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,16 @@ import LazyArrays: ApplyStyle, MulStyle
1212
@test A^4 A*A*A*A
1313
@test A^big(2) isa QuasiArray{Float64}
1414
@test A^(-1) == inv(A) == QuasiArray(inv(A.parent), A.axes)
15+
16+
V = view(A,:,:)
17+
@test V^1 == A
18+
@test V^2 == A^2
19+
@test V^3 == A^3
20+
@test_broken V^(-1) == inv(A)
21+
22+
A = QuasiArray([1 2; 3 4], (0:0.5:0.5, 0:0.5:0.5))
23+
V = view(A,:,:)
24+
@test V^1 == A
25+
@test V^2 == A^2
1526
end
1627
end

test/test_quasisubarray.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ using QuasiArrays, Base64, Test
293293
@test V2 isa SubArray
294294
@test parent(V2) isa QuasiArray
295295
@test V2 == A[0:0.5:0.5,1:0.5:1.5]
296+
297+
@test QuasiArrays.sub_materialize(A) == A
296298
end
297299

298300
@testset "Show" begin

0 commit comments

Comments
 (0)