Skip to content

Commit ca62df2

Browse files
authored
Construct PseudoBlockVector/Matrix from arrays (#263)
* Construct PseudoBlockVector/Matrix from arrays * Add tests * PseudoBlockArray constructor with ndims
1 parent cd1fe7e commit ca62df2

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BlockArrays"
22
uuid = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
3-
version = "0.16.29"
3+
version = "0.16.30"
44

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

src/pseudo_blockarray.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ convert(::Type{AbstractArray}, A::PseudoBlockArray) = A
129129
PseudoBlockArray{T, N}(A::AbstractArray{T2, N}) where {T,T2,N} =
130130
PseudoBlockArray(Array{T, N}(A), axes(A))
131131
PseudoBlockArray{T1}(A::AbstractArray{T2, N}) where {T1,T2,N} = PseudoBlockArray{T1, N}(A)
132+
PseudoBlockArray{<:Any,N}(A::AbstractArray{T, N}) where {T,N} = PseudoBlockArray{T, N}(A)
132133
PseudoBlockArray(A::AbstractArray{T, N}) where {T,N} = PseudoBlockArray{T, N}(A)
133134

134135
convert(::Type{PseudoBlockArray{T, N}}, A::AbstractArray{T2, N}) where {T,T2,N} =

test/test_blockarrays.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ end
9494
@test A == PseudoBlockArray(A, 1:3) == PseudoBlockArray{Int}(A, 1:3) ==
9595
PseudoBlockArray(A, (blockedrange(1:3),)) == PseudoBlockArray{Int}(A, (blockedrange(1:3),)) ==
9696
PseudoBlockArray{Float64}(A, 1:3)
97+
98+
@testset "from arrays" begin
99+
v = [1,2,3]
100+
@test PseudoBlockVector(v) == v
101+
@test PseudoBlockArray(v) == v
102+
M = [1 2; 3 4]
103+
@test PseudoBlockMatrix(M) == M
104+
@test PseudoBlockArray(M) == M
105+
end
97106
end
98107

99108
@testset "similar" begin

0 commit comments

Comments
 (0)