Skip to content

Commit b8ca93e

Browse files
authored
Fix similar with eltype change (#44)
1 parent 4943431 commit b8ca93e

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BlockSparseArrays"
22
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.2.16"
4+
version = "0.2.17"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

ext/BlockSparseArraysGradedUnitRangesExt/BlockSparseArraysGradedUnitRangesExt.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module BlockSparseArraysGradedUnitRangesExt
22

33
using BlockSparseArrays: AnyAbstractBlockSparseArray, BlockSparseArray, blocktype
44
using GradedUnitRanges: AbstractGradedUnitRange
5-
using TypeParameterAccessors: set_ndims, unwrap_array_type
5+
using TypeParameterAccessors: set_eltype, set_ndims, unwrap_array_type
66

77
# A block spare array similar to the input (dense) array.
88
# TODO: Make `BlockSparseArrays.blocksparse_similar` more general and use that,
@@ -15,7 +15,9 @@ function similar_blocksparse(
1515
# TODO: Probably need to unwrap the type of `a` in certain cases
1616
# to make a proper block type.
1717
return BlockSparseArray{
18-
elt,length(axes),set_ndims(unwrap_array_type(blocktype(a)), length(axes))
18+
elt,
19+
length(axes),
20+
set_eltype(set_ndims(unwrap_array_type(blocktype(a)), length(axes)), elt),
1921
}(
2022
axes
2123
)

test/test_gradedunitrangesext.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64})
5353
@test 2 * Array(a) == b
5454
end
5555

56+
b = similar(a, ComplexF64)
57+
@test eltype(b) === ComplexF64
58+
5659
# Test mixing graded axes and dense axes
5760
# in addition/broadcasting.
5861
for b in (a + Array(a), Array(a) + a)

0 commit comments

Comments
 (0)