Skip to content

Commit fb7fb25

Browse files
committed
rearrange test code to make it more concise
1 parent 5991853 commit fb7fb25

File tree

1 file changed

+24
-35
lines changed

1 file changed

+24
-35
lines changed

stdlib/LinearAlgebra/test/uniformscaling.jl

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,30 @@ end
4343
end
4444

4545
# on real axis
46-
# functions defined for x ∈ ℝ
47-
J = UniformScaling(randn(Float64))
48-
for f in ( exp,
49-
sin, cos, tan,
50-
csc, sec, cot,
51-
atan, acot,
52-
sinh, cosh, tanh,
53-
csch, sech, coth,
54-
asinh, acsch )
55-
@test f(J) f(M(J))
56-
end
57-
# functions defined for x ≥ 0
58-
J = UniformScaling(abs(randn(Float64)))
59-
for f in ( log, sqrt )
60-
@test f(J) f(M(J))
61-
end
62-
# functions defined for -1 ≤ x ≤ 1
63-
J = UniformScaling(2 * rand(Float64) - 1)
64-
for f in ( asin, acos, atanh )
65-
@test f(J) f(M(J))
66-
end
67-
# functions defined for x ≤ -1 or x ≥ 1
68-
J = UniformScaling(1 ./ (2 * rand(Float64) - 1))
69-
for f in ( acsc, asec, acoth )
70-
@test f(J) f(M(J))
71-
end
72-
# functions defined for 0 ≤ x ≤ 1
73-
J = UniformScaling(rand(Float64))
74-
for f in ( asech, )
75-
@test f(J) f(M(J))
76-
end
77-
# functions defined for x ≥ 1
78-
J = UniformScaling(1 ./ rand(Float64))
79-
for f in ( acosh, )
80-
@test f(J) f(M(J))
46+
for (λ, fs) in (
47+
# functions defined for x ∈ ℝ
48+
(()->randn(), (exp,
49+
sin, cos, tan,
50+
csc, sec, cot,
51+
atan, acot,
52+
sinh, cosh, tanh,
53+
csch, sech, coth,
54+
asinh, acsch)),
55+
# functions defined for x ≥ 0
56+
(()->abs(randn()), (log, sqrt)),
57+
# functions defined for -1 ≤ x ≤ 1
58+
(()->2rand()-1, (asin, acos, atanh)),
59+
# functions defined for x ≤ -1 or x ≥ 1
60+
(()->1/(2rand()-1), (acsc, asec, acoth)),
61+
# functions defined for 0 ≤ x ≤ 1
62+
(()->rand(), (asech,)),
63+
# functions defined for x ≥ 1
64+
(()->1/rand(), (acosh,))
65+
)
66+
for f in fs
67+
J = UniformScaling(λ())
68+
@test f(J) f(M(J))
69+
end
8170
end
8271
end
8372

0 commit comments

Comments
 (0)