Jutho/TensorKit.jl

Edge cases for empty `ProductSpace`s

Closed this issue · 1 comments

The following throws an error:

julia> blockdim(ComplexSpace(2), Trivial())
2

julia> blockdim(one(ComplexSpace(2)), Trivial())
ERROR: MethodError: no method matching fusiontrees(::Tuple{}, ::Trivial)

Closest candidates are:
  fusiontrees(::Tuple{Vararg{I, N}}, ::I, ::Tuple{Vararg{Bool, N}}) where {N, I<:Sector}
   @ TensorKit ~/Projects/People/Sylvain/dev/TensorKit/src/fusiontrees/iterator.jl:4
  fusiontrees(::Tuple{I, Vararg{I}}, ::I) where I<:Sector
   @ TensorKit ~/Projects/People/Sylvain/dev/TensorKit/src/fusiontrees/iterator.jl:8

Stacktrace:
 [1] blockdim(P::ProductSpace{ComplexSpace, 0}, c::Trivial)
   @ TensorKit ~/Projects/People/Sylvain/dev/TensorKit/src/spaces/productspace.jl:182

Similar results for graded spaces etc. It seems like this was introduced in 9ad2804, and is fixed by just replacing Tuple{I,Vararg{I}} with Tuple{Vararg{I}} in this line. I think this got introduced because Aqua was complaining?

Ok that's bad cause this is probably causing actual bugs. We should test against this. I made that change to make Aqua.jl happy, so I'll have to rethink this. The complaint of Aqua was that in principle the old definition allows for a function call that does not enable to infer I, namely if the first argument is an empty tuple and the second is not specified, relying on the default value (which cannot be determined anyway for an empty tuple). So we should split out specifying the default value of the second argument.