Skip to content

Commit aa50cdd

Browse files
committed
add code suggestions
1 parent e3ed720 commit aa50cdd

File tree

4 files changed

+39
-34
lines changed

4 files changed

+39
-34
lines changed

test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if isempty(settings[:groups])
2222
if haskey(ENV, "GROUP")
2323
groups = [ENV["GROUP"]]
2424
else
25-
groups = filter(isdir, readdir(@__DIR__))
25+
groups = filter(isdir Base.Fix1(joinpath, @__DIR__), readdir(@__DIR__))
2626
end
2727
else
2828
groups = settings[:groups]
@@ -32,6 +32,8 @@ checktestgroup(group) = isdir(joinpath(@__DIR__, group)) ||
3232
throw(ArgumentError("Invalid group ($group), no such folder"))
3333
foreach(checktestgroup, groups)
3434

35+
@info "Loaded test groups:" groups
36+
3537
# don't run all tests on GPU, only the GPU specific ones
3638
is_buildkite = get(ENV, "BUILDKITE", "false") == "true"
3739

test/setup.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@ export smallset, randsector, hasfusiontensor, force_planar
44
export sectorlist
55
export Vtr, Vℤ₂, Vfℤ₂, Vℤ₃, VU₁, VfU₁, VCU₁, VSU₂, VfSU₂, VSU₂U₁, Vfib
66

7-
using Test
8-
using TestExtras
97
using Random
108
using TensorKit
11-
using Combinatorics
12-
using TensorKit: ProductSector, fusiontensor, pentagon_equation, hexagon_equation
139
using TensorKit: ℙ, PlanarTrivial
14-
using TensorOperations
1510
using Base.Iterators: take, product
16-
using LinearAlgebra: LinearAlgebra
1711

1812
Random.seed!(1234)
1913

@@ -38,7 +32,7 @@ function randsector(::Type{I}) where {I <: Sector}
3832
end
3933
function hasfusiontensor(I::Type{<:Sector})
4034
try
41-
fusiontensor(one(I), one(I), one(I))
35+
TensorKit.fusiontensor(one(I), one(I), one(I))
4236
return true
4337
catch e
4438
if e isa MethodError

test/symmetries/spaces.jl

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@ using TensorKitSectors
88
@isdefined(TestSetup) || include("../setup.jl")
99
using .TestSetup
1010

11-
parse_show(x) = Meta.parse(sprint(show, x; context = (:module => @__MODULE__)))
11+
"""
12+
eval_show(x)
13+
14+
Use `show` to generate a string representation of `x`, then parse and evaluate the resulting expression.
15+
"""
16+
function eval_show(x)
17+
str = sprint(show, x; context = (:module => @__MODULE__))
18+
ex = Meta.parse(str)
19+
return eval(ex)
20+
end
1221

1322
@timedtestset "Fields" begin
1423
@test isa(ℝ, Field)
1524
@test isa(ℂ, Field)
16-
@test eval(parse_show(ℝ)) ==
17-
@test eval(parse_show(ℂ)) ==
25+
@test eval_show(ℝ) ==
26+
@test eval_show(ℂ) ==
1827
@test
1928
@test
2029
@test
@@ -55,8 +64,8 @@ end
5564
@timedtestset "ElementarySpace: CartesianSpace" begin
5665
d = 2
5766
V =^d
58-
@test eval(parse_show(V)) == V
59-
@test eval(parse_show(typeof(V))) == typeof(V)
67+
@test eval_show(V) == V
68+
@test eval_show(typeof(V)) == typeof(V)
6069
@test isa(V, VectorSpace)
6170
@test isa(V, ElementarySpace)
6271
@test isa(InnerProductStyle(V), HasInnerProduct)
@@ -99,9 +108,9 @@ end
99108
@timedtestset "ElementarySpace: ComplexSpace" begin
100109
d = 2
101110
V =^d
102-
@test eval(parse_show(V)) == V
103-
@test eval(parse_show(V')) == V'
104-
@test eval(parse_show(typeof(V))) == typeof(V)
111+
@test eval_show(V) == V
112+
@test eval_show(V') == V'
113+
@test eval_show(typeof(V)) == typeof(V)
105114
@test isa(V, VectorSpace)
106115
@test isa(V, ElementarySpace)
107116
@test isa(InnerProductStyle(V), HasInnerProduct)
@@ -151,10 +160,10 @@ end
151160
@timedtestset "ElementarySpace: GeneralSpace" begin
152161
d = 2
153162
V = GeneralSpace{ℂ}(d)
154-
@test eval(parse_show(V)) == V
155-
@test eval(parse_show(dual(V))) == dual(V)
156-
@test eval(parse_show(conj(V))) == conj(V)
157-
@test eval(parse_show(typeof(V))) == typeof(V)
163+
@test eval_show(V) == V
164+
@test eval_show(dual(V)) == dual(V)
165+
@test eval_show(conj(V)) == conj(V)
166+
@test eval_show(typeof(V)) == typeof(V)
158167
@test !isdual(V)
159168
@test isdual(V')
160169
@test !isdual(conj(V))
@@ -185,8 +194,8 @@ end
185194
end
186195
V = GradedSpace(gen)
187196
@test eval(Meta.parse(type_repr(typeof(V)))) == typeof(V)
188-
@test eval(parse_show(V)) == V
189-
@test eval(parse_show(V')) == V'
197+
@test eval_show(V) == V
198+
@test eval_show(V') == V'
190199
@test V' == GradedSpace(gen; dual = true)
191200
@test V == @constinferred GradedSpace(gen...)
192201
@test V' == @constinferred GradedSpace(gen...; dual = true)
@@ -207,8 +216,8 @@ end
207216
end
208217
@test @constinferred(hash(V)) == hash(deepcopy(V)) != hash(V')
209218
@test V == GradedSpace(reverse(collect(gen))...)
210-
@test eval(parse_show(V)) == V
211-
@test eval(parse_show(typeof(V))) == typeof(V)
219+
@test eval_show(V) == V
220+
@test eval_show(typeof(V)) == typeof(V)
212221
# space with no sectors
213222
@test dim(@constinferred(zerospace(V))) == 0
214223
# space with a single sector
@@ -218,7 +227,7 @@ end
218227
@test @constinferred(zerospace(V)) == GradedSpace(unit(I) => 0)
219228
# randsector never returns trivial sector, so this cannot error
220229
@test_throws ArgumentError GradedSpace(unit(I) => 1, randsector(I) => 0, unit(I) => 3)
221-
@test eval(parse_show(W)) == W
230+
@test eval_show(W) == W
222231
@test isa(V, VectorSpace)
223232
@test isa(V, ElementarySpace)
224233
@test isa(InnerProductStyle(V), HasInnerProduct)
@@ -263,8 +272,8 @@ end
263272
@timedtestset "ProductSpace{ℂ}" begin
264273
V1, V2, V3, V4 =^1, ℂ^2, ℂ^3, ℂ^4
265274
P = @constinferred ProductSpace(V1, V2, V3, V4)
266-
@test eval(parse_show(P)) == P
267-
@test eval(parse_show(typeof(P))) == typeof(P)
275+
@test eval_show(P) == P
276+
@test eval_show(typeof(P)) == typeof(P)
268277
@test isa(P, VectorSpace)
269278
@test isa(P, CompositeSpace)
270279
@test spacetype(P) == ComplexSpace
@@ -291,11 +300,11 @@ end
291300
@test fuse(flip(V1), V2, flip(V3)) V1 V2 V3
292301
@test @constinferred((P)) == P
293302
@test @constinferred((V1)) == ProductSpace(V1)
294-
@test eval(parse_show((V1))) == (V1)
303+
@test eval_show((V1)) == (V1)
295304
@test @constinferred(one(V1)) == @constinferred(one(typeof(V1))) ==
296305
@constinferred(one(P)) == @constinferred(one(typeof(P))) ==
297306
ProductSpace{ComplexSpace}(())
298-
@test eval(parse_show(one(P))) == one(P)
307+
@test eval_show(one(P)) == one(P)
299308
@test @constinferred((one(P), P)) == P
300309
@test @constinferred((P, one(P))) == P
301310
@test @constinferred((one(P), one(P))) == one(P)
@@ -330,8 +339,8 @@ end
330339
V1, V2, V3 = SU₂Space(0 => 3, 1 // 2 => 1), SU₂Space(0 => 2, 1 => 1),
331340
SU₂Space(1 // 2 => 1, 1 => 1)'
332341
P = @constinferred ProductSpace(V1, V2, V3)
333-
@test eval(parse_show(P)) == P
334-
@test eval(parse_show(typeof(P))) == typeof(P)
342+
@test eval_show(P) == P
343+
@test eval_show(typeof(P)) == typeof(P)
335344
@test isa(P, VectorSpace)
336345
@test isa(P, CompositeSpace)
337346
@test spacetype(P) == SU₂Space
@@ -409,8 +418,8 @@ end
409418
@test W == (V3 V4 V5 V1 V2)
410419
@test W == (V1 V2 V3 V4 V5)
411420
@test W' == (V1 V2 V3 V4 V5)
412-
@test eval(parse_show(W)) == W
413-
@test eval(parse_show(typeof(W))) == typeof(W)
421+
@test eval_show(W) == W
422+
@test eval_show(typeof(W)) == typeof(W)
414423
@test spacetype(W) == typeof(V1)
415424
@test sectortype(W) == sectortype(V1)
416425
@test W[1] == V1

test/tensors/planar.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Test, TestExtras
22
using TensorKit
3-
using TensorKit: planaradd!, planartrace!, planarcontract!
43
using TensorKit: PlanarTrivial, ℙ
4+
using TensorKit: planaradd!, planartrace!, planarcontract!
55
using TensorOperations
66

77
@isdefined(TestSetup) || include("../setup.jl")

0 commit comments

Comments
 (0)