Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BlockSparseArrays"
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.2.4"
version = "0.2.5"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,52 +134,4 @@ function GradedUnitRanges.blocklabels(a::BlockSparseVector)
end
end

# This is a temporary fix for `show` being broken for BlockSparseArrays
# with mixed dual and non-dual axes. This shouldn't be needed once
# GradedUnitRanges is rewritten using BlockArrays v1.
# TODO: Delete this once GradedUnitRanges is rewritten.
@interface ::AbstractBlockSparseArrayInterface function Base.show(
io::IO, mime::MIME"text/plain", a::AbstractArray, axes_a::Tuple; kwargs...
)
println(io, "typeof(axes) = ", typeof(axes_a), "\n")
println(
io,
"Warning: To temporarily circumvent a bug in printing BlockSparseArrays with mixtures of dual and non-dual axes, the types of the dual axes printed below might not be accurate. The types printed above this message are the correct ones.\n",
)
return invoke(show, Tuple{IO,MIME"text/plain",AbstractArray}, io, mime, a; kwargs...)
end

# This is a temporary fix for `show` being broken for BlockSparseArrays
# with mixed dual and non-dual axes. This shouldn't be needed once
# GradedUnitRanges is rewritten using BlockArrays v1.
# TODO: Delete this once GradedUnitRanges is rewritten.
function Base.show(io::IO, mime::MIME"text/plain", a::BlockSparseArray; kwargs...)
axes_a = axes(a)
a_nondual = BlockSparseArray(blocks(a), nondual.(axes(a)))
return @interface BlockSparseArrayInterface() show(io, mime, a_nondual, axes_a; kwargs...)
end

# This is a temporary fix for `show` being broken for BlockSparseArrays
# with mixed dual and non-dual axes. This shouldn't be needed once
# GradedUnitRanges is rewritten using BlockArrays v1.
# TODO: Delete this once GradedUnitRanges is rewritten.
function Base.show(
io::IO, mime::MIME"text/plain", a::Adjoint{<:Any,<:BlockSparseMatrix}; kwargs...
)
axes_a = axes(a)
a_nondual = BlockSparseArray(blocks(a'), dual.(nondual.(axes(a'))))'
return @interface BlockSparseArrayInterface() show(io, mime, a_nondual, axes_a; kwargs...)
end

# This is a temporary fix for `show` being broken for BlockSparseArrays
# with mixed dual and non-dual axes. This shouldn't be needed once
# GradedUnitRanges is rewritten using BlockArrays v1.
# TODO: Delete this once GradedUnitRanges is rewritten.
function Base.show(
io::IO, mime::MIME"text/plain", a::Transpose{<:Any,<:BlockSparseMatrix}; kwargs...
)
axes_a = axes(a)
a_nondual = tranpose(BlockSparseArray(transpose(blocks(a)), nondual.(axes(a))))
return @interface BlockSparseArrayInterface() show(io, mime, a_nondual, axes_a; kwargs...)
end
end
6 changes: 2 additions & 4 deletions test/basics/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1051,10 +1051,8 @@ arrayts = (Array, JLArray)
# spacing so it isn't easy to make the test general.
a = BlockSparseArray{elt}([2, 2], [2, 2])
a[1, 2] = 12
# TODO: Reenable this once we delete the hacky `Base.show` definitions
# in `BlockSparseArraysTensorAlgebraExt`.
@test_broken sprint(show, "text/plain", a) ==
"$(summary(a)):$(zero(eltype(a))) $(eltype(a)(12)) │ ⋅ ⋅\n $(zero(eltype(a))) $(zero(eltype(a))) │ ⋅ ⋅\n ───────────┼──────\n ⋅ ⋅ │ ⋅ ⋅\n ⋅ ⋅ │ ⋅ ⋅"
@test sprint(show, "text/plain", a) ==
"$(summary(a)):\n $(zero(eltype(a))) $(eltype(a)(12)) │ . .\n $(zero(eltype(a))) $(zero(eltype(a))) │ . .\n ───────────┼──────\n . . │ . .\n . . │ . ."
end
end
end
Loading