Skip to content

Commit 794f12f

Browse files
committed
improve errors
1 parent a80ecb5 commit 794f12f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/tensors/abstracttensor.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,14 @@ end
357357
Base.@propagate_inbounds function subblock(t::AbstractTensorMap, sectors::Tuple)
358358
return subblock(t, map(Base.Fix1(convert, sectortype(t)), sectors))
359359
end
360+
# attempt to provide better error messages
361+
function subblock(t::AbstractTensorMap, (f₁, f₂)::Tuple{FusionTree, FusionTree})
362+
(sectortype(t)) == sectortype(f₁) == sectortype(f₂) ||
363+
throw(SectorMismatch("Not a valid sectortype for this tensor."))
364+
numout(t) == length(f₁) && numin(t) == length(f₂) ||
365+
throw(DimensionMismatch("Invalid number of fusiontree legs for this tensor."))
366+
throw(MethodError(subblock, (t, (f₁, f₂))))
367+
end
360368

361369
@doc """
362370
subblocktype(t)

0 commit comments

Comments
 (0)