Skip to content

Commit 5fa5947

Browse files
committed
make JET happy
1 parent 13e108e commit 5fa5947

4 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎src/auxiliary/caches.jl‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,16 @@ macro cached(ex)
5353
error("cached macro can only be used on function definitions")
5454
fcall = ex.args[1]
5555
if Meta.isexpr(fcall, :where)
56-
hasparams = true
5756
params = fcall.args[2:end]
5857
fcall = fcall.args[1]
5958
else
60-
hasparams = false
59+
params = nothing
6160
end
6261
if Meta.isexpr(fcall, :(::))
63-
typed = true
6462
typeex = fcall.args[2]
6563
fcall = fcall.args[1]
6664
else
67-
typed = false
65+
typeex = nothing
6866
end
6967
Meta.isexpr(fcall, :call) ||
7068
error("cached macro can only be used on function definitions")
@@ -82,14 +80,14 @@ macro cached(ex)
8280
# actual implenetation, with underscore name
8381
_fname = Symbol(:_, fname)
8482
_fcall = Expr(:call, _fname, fargs...)
85-
if hasparams
83+
if !isnothing(params)
8684
_fcall = Expr(:where, _fcall, params...)
8785
end
8886
_fex = Expr(:function, _fcall, _fbody)
8987

9088
# implementation that chooses the cache style
9189
newfcall = fcall
92-
if hasparams
90+
if !isnothing(params)
9391
newfcall = Expr(:where, newfcall, params...)
9492
end
9593
cachestylevar = gensym(:cachestyle)
@@ -103,11 +101,11 @@ macro cached(ex)
103101

104102
# nocache implementation
105103
fnocachecall = Expr(:call, fname, fargs..., :(::NoCache))
106-
if hasparams
104+
if !isnothing(params)
107105
fnocachecall = Expr(:where, fnocachecall, params...)
108106
end
109107
fnocachebody = Expr(:call, _fname, fargnames...)
110-
if typed
108+
if !isnothing(typeex)
111109
T = gensym(:T)
112110
fnocachebody = Expr(:block, Expr(:(=), T, typeex), Expr(:(::), fnocachebody, T))
113111
end
@@ -116,7 +114,7 @@ macro cached(ex)
116114
# tasklocal cache implementation
117115
Dvar = gensym(:D)
118116
flocalcachecall = Expr(:call, fname, fargs..., :(::TaskLocalCache{$Dvar}))
119-
if hasparams
117+
if !isnothing(params)
120118
flocalcachecall = Expr(:where, flocalcachecall, params..., Dvar)
121119
else
122120
flocalcachecall = Expr(:where, flocalcachecall, Dvar)
@@ -139,7 +137,7 @@ macro cached(ex)
139137
return $_fname($(fargnames...))
140138
end
141139
)
142-
if typed
140+
if !isnothing(typeex)
143141
T = gensym(:T)
144142
flocalcachebody = Expr(
145143
:block,
@@ -160,12 +158,12 @@ macro cached(ex)
160158

161159
# # global cache implementation
162160
fglobalcachecall = Expr(:call, fname, fargs..., :(::GlobalLRUCache))
163-
if hasparams
161+
if !isnothing(params)
164162
fglobalcachecall = Expr(:where, fglobalcachecall, params...)
165163
end
166164
globalcachename = Symbol(:GLOBAL_, uppercase(string(fname)), :_CACHE)
167165
getglobalcachex = Expr(:(=), cachevar, globalcachename)
168-
if typed
166+
if !isnothing(typeex)
169167
T = gensym(:T)
170168
fglobalcachebody = Expr(
171169
:block,

‎src/fusiontrees/duality_manipulations.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ function planar_trace(f::FusionTree, (q₁, q₂)::Index2Tuple)
653653
# We thus handle the total trace recursively, by first looking for and
654654
# tracing away neighbouring pairs.
655655
k = 1
656-
local i, j
656+
i = j = 0
657657
while k <= length(q₁)
658658
if mod1(q₁[k] + 1, length(f)) == q₂[k]
659659
i = q₁[k]

‎src/planar/preprocessors.jl‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,18 @@ function _construct_braidingtensors!(ex, preargs, indexmap, non_braiding) # ex i
166166
i1a, i2a, = rightind
167167
end
168168

169-
foundV1, foundV2 = false, false
169+
V1 = V2 = nothing
170170
if haskey(indexmap, i1a)
171171
V1 = indexmap[i1a]
172-
foundV1 = true
173172
elseif haskey(indexmap, i1b)
174173
V1 = Expr(:call, :dual, indexmap[i1b])
175-
foundV1 = true
176174
end
177175
if haskey(indexmap, i2a)
178176
V2 = indexmap[i2a]
179-
foundV2 = true
180177
elseif haskey(indexmap, i2b)
181178
V2 = Expr(:call, :dual, indexmap[i2b])
182-
foundV2 = true
183179
end
184-
if foundV1 && foundV2
180+
if !isnothing(V1) && !isnothing(V2)
185181
s = gensym(:τ)
186182
storageex = Expr(:call, GlobalRef(TensorKit, :promote_storagetype), non_braiding...)
187183
braidingex = Expr(:call, GlobalRef(TensorKit, :braidingtensortype), V1, V2, storageex)

‎src/tensors/tensoroperations.jl‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,10 @@ function trace_permute!(
243243
return tdst
244244
end
245245

246-
function _trace_permute!(::UniqueFusion, tdst, tsrc, (p₁, p₂), (q₁, q₂), α, β, backend)
246+
function _trace_permute!(
247+
::UniqueFusion, tdst::AbstractTensorMap, tsrc::AbstractTensorMap,
248+
(p₁, p₂), (q₁, q₂), α, β, backend
249+
)
247250
scale!(tdst, β)
248251
r₁, r₂ = (p₁..., q₁...), (p₂..., q₂...)
249252
N₁, N₂ = length(p₁), length(p₂)
@@ -268,7 +271,10 @@ function _trace_permute!(::UniqueFusion, tdst, tsrc, (p₁, p₂), (q₁, q₂),
268271
return tdst
269272
end
270273

271-
function _trace_permute!(::FusionStyle, tdst, tsrc, (p₁, p₂), (q₁, q₂), α, β, backend)
274+
function _trace_permute!(
275+
::FusionStyle, tdst::AbstractTensorMap, tsrc::AbstractTensorMap,
276+
(p₁, p₂), (q₁, q₂), α, β, backend
277+
)
272278
scale!(tdst, β)
273279
r₁, r₂ = (p₁..., q₁...), (p₂..., q₂...)
274280
N₁, N₂ = length(p₁), length(p₂)

0 commit comments

Comments
 (0)