There was an error while loading. Please reload this page.
1 parent 5fa5947 commit e40d1daCopy full SHA for e40d1da
7 files changed
src/auxiliary/iterators.jl
@@ -4,7 +4,7 @@ struct OneOrNoneIterator{T}
4
end
5
6
function Base.iterate(it::OneOrNoneIterator, state = true)
7
- if state && it.cond
+ if isone(state) && it.cond
8
return (it.first, false)
9
else
10
return nothing
src/fusiontrees/fusiontrees.jl
@@ -334,8 +334,7 @@ function fusiontensor((f₁, f₂)::FusionTreePair)
334
d1 = TupleTools.front(sz1)
335
d2 = TupleTools.front(sz2)
336
return reshape(
337
- reshape(F₁, TupleTools.prod(d1), sz1[end]) *
338
- reshape(F₂, TupleTools.prod(d2), sz2[end])', (d1..., d2...)
+ reshape(F₁, :, sz1[end]) * reshape(F₂, :, sz2[end])', (d1..., d2...)
339
)
340
341
fusiontensor(src::FusionTreeBlock) = sum(fusiontensor, fusiontrees(src))
src/pullbacks/tensoroperations.jl
@@ -1,5 +1,5 @@
1
function blas_contract_pullback_ΔA!(
2
- ΔA, ΔC, A, pA, B, pB, pAB, α, backend, allocator
+ ΔA, ΔC, A::AbstractTensorMap, pA, B::AbstractTensorMap, pB, pAB, α, backend, allocator
3
ipAB = invperm(linearize(pAB))
pΔC = TO.repartition(ipAB, TO.numout(pA))
@@ -23,7 +23,7 @@ function blas_contract_pullback_ΔA!(
23
24
25
function blas_contract_pullback_ΔB!(
26
- ΔB, ΔC, A, pA, B, pB, pAB, α, backend, allocator
+ ΔB, ΔC, A::AbstractTensorMap, pA, B::AbstractTensorMap, pB, pAB, α, backend, allocator
27
28
29
@@ -48,7 +48,7 @@ function blas_contract_pullback_ΔB!(
48
49
50
function trace_permute_pullback_ΔA!(
51
- ΔA, ΔC, A, p, q, α, backend
+ ΔA, ΔC, A::AbstractTensorMap, p, q, α, backend
52
53
ip = invperm((linearize(p)..., q[1]..., q[2]...))
54
pdA = TO.repartition(ip, numout(A))
src/spaces/productspace.jl
@@ -146,7 +146,7 @@ that make up the `ProductSpace` instance.
146
"""
147
function blocksectors(P::ProductSpace{S, N}) where {S, N}
148
I = sectortype(S)
149
- if I == Trivial
+ if I === Trivial
150
return OneOrNoneIterator(dim(P) != 0, Trivial())
151
152
bs = Vector{I}()
src/tensors/abstracttensor.jl
@@ -237,7 +237,11 @@ See also [`numin`](@ref) and [`numind`](@ref).
237
""" numout
238
239
numout(x) = numout(typeof(x))
240
-numout(T::Type) = throw(MethodError(numout, T)) # avoid infinite recursion
+numout(T::Type) = throw(MethodError(numout, (T,))) # avoid infinite recursion
241
+# `typeintersect(Type{<:AbstractTensorMap}, Type{<:Union{FusionTreePair, FusionTreeBlock}})` is
242
+# `Type{Union{}}`, which leaves the parametric methods mutually ambiguous. Resolve it explicitly so
243
+# the intended `MethodError` is thrown instead of an ambiguity error.
244
+numout(::Type{Union{}}) = throw(MethodError(numout, (Union{},)))
245
numout(::Type{<:AbstractTensorMap{T, S, N₁}}) where {T, S, N₁} = N₁
246
247
@doc """
@@ -251,7 +255,8 @@ See also [`numout`](@ref) and [`numind`](@ref).
251
255
""" numin
252
256
253
257
numin(x) = numin(typeof(x))
254
-numin(T::Type) = throw(MethodError(numin, T)) # avoid infinite recursion
258
+numin(T::Type) = throw(MethodError(numin, (T,))) # avoid infinite recursion
259
+numin(::Type{Union{}}) = throw(MethodError(numin, (Union{},))) # see `numout(::Type{Union{}})`
260
numin(::Type{<:AbstractTensorMap{T, S, N₁, N₂}}) where {T, S, N₁, N₂} = N₂
261
262
src/tensors/adjoint.jl
@@ -13,6 +13,7 @@ end
13
Base.parent(t::AdjointTensorMap) = t.parent
14
parenttype(t::AdjointTensorMap) = parenttype(typeof(t))
15
parenttype(::Type{AdjointTensorMap{T, S, N₁, N₂, TT}}) where {T, S, N₁, N₂, TT} = TT
16
+parenttype(::Type{Union{}}) = throw(MethodError(parenttype, (Union{},)))
17
18
# Constructor: construct from taking adjoint of a tensor
19
Base.adjoint(t::AdjointTensorMap) = parent(t)
test/other/jet.jl
@@ -2,9 +2,23 @@ using TensorKit
using Test
using JET
+# Reports that are not TensorKit's to fix. Each entry needs an upstream issue.
+const IGNORED = (
+ # `schur_full`/`schur_vals` route `Diagonal` inputs to `DiagonalAlgorithm`, which schur does
+ # not implement, so `schur_full(::DiagonalTensorMap)` throws a `MethodError`. This reproduces
+ # with a plain `LinearAlgebra.Diagonal` and no TensorKit involved:
+ # https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/issues/276
11
+ JET.LastFrameMethod(:schur_full!),
12
+ JET.LastFrameMethod(:schur_vals!),
+ # `local variable kwargs may be undefined` inside `GenericTreeTransformer`, coming entirely
+ # from Base's `@debug` expansion (`local msg, kwargs` bound in a short-circuit guard) rather
+ # than from any TensorKit code: https://github.com/aviatesk/JET.jl/issues/860
+ JET.LastFrameMethod(:GenericTreeTransformer),
+)
+
# also gated in runtests.jl; JET < 0.12 does not define `JET_AVAILABLE`
20
if isdefined(JET, :JET_AVAILABLE) && JET.JET_AVAILABLE
- JET.test_package(TensorKit; target_modules = (TensorKit,))
21
+ JET.test_package(TensorKit; target_modules = (TensorKit,), ignored_modules = IGNORED)
22
@info "Full JET functionality is unavailable on Julia $VERSION; skipping JET analysis"
0 commit comments