Skip to content

Commit 6fa659a

Browse files
UndefVarError Random not defined in data_generation.jl (#28)
* Use Random in data_generation; added tests * Bumped version in Project.toml to 0.2.4 * Address CR feedback * Removed Test from extras and target section * Updated testing for well conditioned matrices * Update test/data_generation.jl Co-authored-by: Nick Robinson <[email protected]> * Update test/data_generation.jl Co-authored-by: Nick Robinson <[email protected]> * Matrix condition < 100 Co-authored-by: Nick Robinson <[email protected]>
1 parent 552932d commit 6fa659a

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

Project.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
name = "ChainRulesTestUtils"
22
uuid = "cdddcdb0-9152-4a09-a978-84456f9df70a"
3-
version = "0.2.3"
3+
version = "0.2.4"
44

55
[deps]
66
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
77
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
88
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
99
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
10+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1011
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1112

1213
[compat]
1314
ChainRulesCore = "0.7.1"
1415
Compat = "3"
1516
FiniteDifferences = "0.9"
1617
julia = "1"
17-
18-
[extras]
19-
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
20-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
21-
22-
[targets]
23-
test = ["Random", "Test"]

src/ChainRulesTestUtils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ using Compat: only
66
using FiniteDifferences
77
using FiniteDifferences: to_vec
88
using LinearAlgebra
9+
using Random
910
using Test
1011

1112
const _fdm = central_fdm(5, 1)

test/data_generation.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@testset "Data Generation" begin
2+
function _is_well_conditioned(matrix)
3+
@test !isempty(matrix)
4+
@test isposdef(matrix)
5+
@assert length(matrix) 25
6+
@test cond(matrix) < 100
7+
end
8+
9+
10+
@testset "Generate Well Conditioned Matrix" begin
11+
@testset "Pass in RNG" begin
12+
rng = MersenneTwister(1)
13+
matrix = generate_well_conditioned_matrix(rng, 5)
14+
15+
_is_well_conditioned(matrix)
16+
end
17+
18+
@testset "Global RNG" begin
19+
matrix = generate_well_conditioned_matrix(5)
20+
21+
_is_well_conditioned(matrix)
22+
end
23+
end
24+
end

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using ChainRulesCore
22
using ChainRulesTestUtils
3+
using LinearAlgebra
34
using Random
45
using Test
56

67
@testset "ChainRulesTestUtils.jl" begin
78
include("to_vec.jl")
89
include("isapprox.jl")
910
include("testers.jl")
11+
include("data_generation.jl")
1012
end

0 commit comments

Comments
 (0)