Skip to content

Commit c5e1e02

Browse files
committed
more general similar
1 parent 4cbd4f3 commit c5e1e02

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/abstractblocksparsearray/arraylayouts.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ function Base.similar(
6767
elt::Type,
6868
axes::Tuple{<:AbstractUnitRange},
6969
)
70-
return Vector{elt}(undef, length(only(axes)))
70+
# Convert blocked axes to plain axes to avoid creating BlockedVector
71+
plain_axes = map(ax -> Base.OneTo(length(ax)), axes)
72+
return similar(mul.B, elt, plain_axes)
7173
end
7274

7375
# Materialize a SubArray view.

test/test_basics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ arrayts = (Array, JLArray)
434434

435435
c = a * v
436436
@test Array(c) Array(a) * Array(v)
437-
@test c isa Vector{elt} # Result should be a plain Vector
437+
@test c isa typeof(v) # Result should match input vector type
438438
@test length(c) == size(a, 1)
439439

440440
# Test with adjoint/transpose

0 commit comments

Comments
 (0)