Skip to content

Commit 6c2049d

Browse files
Move validation functions to ./test (#79)
1 parent 2d756c4 commit 6c2049d

File tree

13 files changed

+47
-134
lines changed

13 files changed

+47
-134
lines changed

docs/src/lib/internals/graph.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,3 @@ Modules = [ComputableDAGs]
4141
Pages = ["graph/properties.jl"]
4242
Order = [:function]
4343
```
44-
45-
## Validate
46-
```@autodocs
47-
Modules = [ComputableDAGs]
48-
Pages = ["graph/validate.jl"]
49-
Order = [:function]
50-
```

docs/src/lib/internals/node.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,3 @@ Modules = [ComputableDAGs]
3434
Pages = ["node/print.jl"]
3535
Order = [:function]
3636
```
37-
38-
## Validate
39-
```@autodocs
40-
Modules = [ComputableDAGs]
41-
Pages = ["node/validate.jl"]
42-
Order = [:function]
43-
```

docs/src/lib/internals/operation.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,3 @@ Modules = [ComputableDAGs]
4848
Pages = ["operation/print.jl"]
4949
Order = [:function]
5050
```
51-
52-
## Validate
53-
```@autodocs
54-
Modules = [ComputableDAGs]
55-
Pages = ["operation/validate.jl"]
56-
Order = [:function]
57-
```

src/ComputableDAGs.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,11 @@ include("graph/interface.jl")
6969
include("graph/mute.jl")
7070
include("graph/print.jl")
7171
include("graph/properties.jl")
72-
include("graph/validate.jl")
7372

7473
include("node/compare.jl")
7574
include("node/create.jl")
7675
include("node/print.jl")
7776
include("node/properties.jl")
78-
include("node/validate.jl")
7977

8078
include("operation/utility.jl")
8179
include("operation/iterate.jl")
@@ -84,7 +82,6 @@ include("operation/clean.jl")
8482
include("operation/find.jl")
8583
include("operation/get.jl")
8684
include("operation/print.jl")
87-
include("operation/validate.jl")
8885

8986
include("properties/create.jl")
9087
include("properties/utility.jl")

src/node/validate.jl

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/operation/apply.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ Reduce the given nodes together into one node, return the applied difference to
116116
For details see [`NodeReduction`](@ref).
117117
"""
118118
function node_reduction!(dag::DAG, nodes::Vector{NodeType}) where {NodeType <: Node}
119-
@assert is_valid_node_reduction_input(dag, nodes)
120-
121119
# clear snapshot
122120
snapshot_diff(dag)
123121

@@ -172,8 +170,6 @@ For details see [`NodeSplit`](@ref).
172170
function node_split!(
173171
dag::DAG, n1::NodeType
174172
) where {NodeType <: Node}
175-
@assert is_valid_node_split_input(dag, n1)
176-
177173
# clear snapshot
178174
snapshot_diff(dag)
179175

src/operation/type.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ A vector of nodes can be reduced if:
3535
- All nodes have the same task type.
3636
- All nodes have the same set of children.
3737
38-
[`is_valid_node_reduction_input`](@ref) can be used to `@assert` these requirements.
39-
4038
See also: [`can_reduce`](@ref)
4139
"""
4240
struct NodeReduction <: Operation
@@ -64,8 +62,6 @@ A node can be split if:
6462
- It is in the graph.
6563
- It has at least 2 parents.
6664
67-
[`is_valid_node_split_input`](@ref) can be used to `@assert` these requirements.
68-
6965
See also: [`can_split`](@ref)
7066
"""
7167
struct NodeSplit <: Operation

test/optimization.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ RNG = Xoshiro(1)
2424
dag, instance, cpu_st(), @__MODULE__
2525
)
2626

27-
input = [rand(RNG, Float64, 3 * N) for _ in 1:100]
27+
LEN = 128
28+
input = [rand(RNG, Float64, 3 * N) for _ in 1:LEN]
2829

29-
@test isapprox(f.(input), reduced_f.(input))
30+
@test count([isapprox(orig, reduced) || isnan(orig) && isnan(reduced) for (orig, reduced) in Iterators.zip(f.(input), reduced_f.(input))]) == LEN
3031
end
3132
end

test/strassen_test.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using ComputableDAGs
22
using StaticArrays
33

4-
using ComputableDAGs: is_valid, input_expr, input_type
4+
using ComputableDAGs: input_expr, input_type
55

6+
include("validate/impl.jl")
67
include("strassen/impl.jl")
78
using .MatrixMultiplicationImpl
89

src/graph/validate.jl renamed to test/validate/graph.jl

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
"""
2-
is_connected(dag::DAG)
1+
using DataStructures
2+
using UUIDs
33

4-
Return whether the given graph is connected.
5-
"""
64
function is_connected(dag::DAG)
75
node_queue = Deque{UUID}()
86
push!(node_queue, exit_node(dag).id)
@@ -20,11 +18,6 @@ function is_connected(dag::DAG)
2018
return length(seen_nodes) == length(dag.nodes)
2119
end
2220

23-
"""
24-
is_valid(dag::DAG)
25-
26-
Validate the entire graph using asserts. Intended for testing with `@assert is_valid(dag)`.
27-
"""
2821
function is_valid(dag::DAG)
2922
for (id, node) in dag.nodes
3023
@assert is_valid(dag, node)

0 commit comments

Comments
 (0)