networks: Make it possible to skip expensive test cases.
At the moment, this is particularly for skipping the tests constructing the interaction graphs.
This commit is contained in:
parent
097c5a7f09
commit
f1a1123cc4
1 changed files with 48 additions and 35 deletions
83
networks.rkt
83
networks.rkt
|
@ -150,7 +150,12 @@
|
||||||
[sbn? contract?]))
|
[sbn? contract?]))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(require rackunit))
|
(require rackunit)
|
||||||
|
;; When this variable is set to #t, some particularly expensive test
|
||||||
|
;; cases are omitted.
|
||||||
|
(define skip-expensive-tests? #t)
|
||||||
|
(unless skip-expensive-tests?
|
||||||
|
(displayln "Running the complete test suite...")))
|
||||||
|
|
||||||
|
|
||||||
;;; =================
|
;;; =================
|
||||||
|
@ -526,23 +531,27 @@
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(test-case "build-interaction-graph"
|
(test-case "build-interaction-graph"
|
||||||
(define n-bool
|
(cond
|
||||||
(hash 'x '(not y)
|
[skip-expensive-tests?
|
||||||
'y 'x
|
(displayln "Skipping test case build-interaction-graph.")]
|
||||||
'z '(and y z)
|
[else
|
||||||
't '(or (and (not x) y)
|
(define n-bool
|
||||||
(and x (not y)))))
|
(hash 'x '(not y)
|
||||||
(define bool-doms (make-boolean-domains '(x y z t)))
|
'y 'x
|
||||||
(check-equal? (graphviz (build-interaction-graph/form n-bool bool-doms))
|
'z '(and y z)
|
||||||
"digraph G {\n\tnode0 [label=\"y\"];\n\tnode1 [label=\"z\"];\n\tnode2 [label=\"x\"];\n\tnode3 [label=\"t\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t\tnode0 -> node2;\n\t\tnode1 -> node1;\n\t}\n\tsubgraph D {\n\t\tnode0 -> node3;\n\t\tnode0 -> node1;\n\t\tnode2 -> node3;\n\t}\n}\n")
|
't '(or (and (not x) y)
|
||||||
(define n-multi
|
(and x (not y)))))
|
||||||
(hash 'x '(min (+ y 1) 2)
|
(define bool-doms (make-boolean-domains '(x y z t)))
|
||||||
'y '(max (- y 1) 0)
|
(check-equal? (graphviz (build-interaction-graph/form n-bool bool-doms))
|
||||||
'z '(- 2 y)
|
"digraph G {\n\tnode0 [label=\"y\"];\n\tnode1 [label=\"z\"];\n\tnode2 [label=\"x\"];\n\tnode3 [label=\"t\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t\tnode0 -> node2;\n\t\tnode1 -> node1;\n\t}\n\tsubgraph D {\n\t\tnode0 -> node3;\n\t\tnode0 -> node1;\n\t\tnode2 -> node3;\n\t}\n}\n")
|
||||||
't '(abs (- y 1))))
|
(define n-multi
|
||||||
(define 123-doms (make-same-domains '(x y z t) '(0 1 2)))
|
(hash 'x '(min (+ y 1) 2)
|
||||||
(check-equal? (graphviz (build-interaction-graph/form n-multi 123-doms))
|
'y '(max (- y 1) 0)
|
||||||
"digraph G {\n\tnode0 [label=\"y\"];\n\tnode1 [label=\"z\"];\n\tnode2 [label=\"x\"];\n\tnode3 [label=\"t\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t\tnode0 -> node0;\n\t}\n\tsubgraph D {\n\t\tnode0 -> node2;\n\t\tnode0 -> node3;\n\t\tnode0 -> node1;\n\t}\n}\n")))
|
'z '(- 2 y)
|
||||||
|
't '(abs (- y 1))))
|
||||||
|
(define 123-doms (make-same-domains '(x y z t) '(0 1 2)))
|
||||||
|
(check-equal? (graphviz (build-interaction-graph/form n-multi 123-doms))
|
||||||
|
"digraph G {\n\tnode0 [label=\"y\"];\n\tnode1 [label=\"z\"];\n\tnode2 [label=\"x\"];\n\tnode3 [label=\"t\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t\tnode0 -> node0;\n\t}\n\tsubgraph D {\n\t\tnode0 -> node2;\n\t\tnode0 -> node3;\n\t\tnode0 -> node1;\n\t}\n}\n")])))
|
||||||
|
|
||||||
;;; Given a network, builds its signed interaction graph. The graph
|
;;; Given a network, builds its signed interaction graph. The graph
|
||||||
;;; has variables as nodes and has a directed edge from x to
|
;;; has variables as nodes and has a directed edge from x to
|
||||||
|
@ -564,23 +573,27 @@
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(test-case "build-signed-interaction-graph"
|
(test-case "build-signed-interaction-graph"
|
||||||
(define n-bool
|
(cond
|
||||||
(hash 'x '(not y)
|
[skip-expensive-tests?
|
||||||
'y 'x
|
(displayln "Skipping test case build-signed-interaction-graph.")]
|
||||||
'z '(and y z)
|
[else
|
||||||
't '(or (and (not x) y)
|
(define n-bool
|
||||||
(and x (not y)))))
|
(hash 'x '(not y)
|
||||||
(define bool-doms (make-boolean-domains '(x y z t)))
|
'y 'x
|
||||||
(check-equal? (graphviz (build-signed-interaction-graph/form n-bool bool-doms))
|
'z '(and y z)
|
||||||
"digraph G {\n\tnode0 [label=\"y\"];\n\tnode1 [label=\"z\"];\n\tnode2 [label=\"x\"];\n\tnode3 [label=\"t\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t\tnode1 -> node1 [label=\"1\"];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node2 [label=\"-1\"];\n\t\tnode0 -> node3 [label=\"0\"];\n\t\tnode0 -> node1 [label=\"1\"];\n\t\tnode2 -> node3 [label=\"0\"];\n\t\tnode2 -> node0 [label=\"1\"];\n\t}\n}\n")
|
't '(or (and (not x) y)
|
||||||
(define n-multi
|
(and x (not y)))))
|
||||||
(hash 'x '(min (+ y 1) 2)
|
(define bool-doms (make-boolean-domains '(x y z t)))
|
||||||
'y '(max (- y 1) 0)
|
(check-equal? (graphviz (build-signed-interaction-graph/form n-bool bool-doms))
|
||||||
'z '(- 2 y)
|
"digraph G {\n\tnode0 [label=\"y\"];\n\tnode1 [label=\"z\"];\n\tnode2 [label=\"x\"];\n\tnode3 [label=\"t\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t\tnode1 -> node1 [label=\"1\"];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node2 [label=\"-1\"];\n\t\tnode0 -> node3 [label=\"0\"];\n\t\tnode0 -> node1 [label=\"1\"];\n\t\tnode2 -> node3 [label=\"0\"];\n\t\tnode2 -> node0 [label=\"1\"];\n\t}\n}\n")
|
||||||
't '(abs (- y 1))))
|
(define n-multi
|
||||||
(define 123-doms (make-same-domains '(x y z t) '(0 1 2)))
|
(hash 'x '(min (+ y 1) 2)
|
||||||
(check-equal? (graphviz (build-signed-interaction-graph/form n-multi 123-doms))
|
'y '(max (- y 1) 0)
|
||||||
"digraph G {\n\tnode0 [label=\"y\"];\n\tnode1 [label=\"z\"];\n\tnode2 [label=\"x\"];\n\tnode3 [label=\"t\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t\tnode0 -> node0 [label=\"1\"];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node2 [label=\"1\"];\n\t\tnode0 -> node3 [label=\"0\"];\n\t\tnode0 -> node1 [label=\"-1\"];\n\t}\n}\n")))
|
'z '(- 2 y)
|
||||||
|
't '(abs (- y 1))))
|
||||||
|
(define 123-doms (make-same-domains '(x y z t) '(0 1 2)))
|
||||||
|
(check-equal? (graphviz (build-signed-interaction-graph/form n-multi 123-doms))
|
||||||
|
"digraph G {\n\tnode0 [label=\"y\"];\n\tnode1 [label=\"z\"];\n\tnode2 [label=\"x\"];\n\tnode3 [label=\"t\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t\tnode0 -> node0 [label=\"1\"];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node2 [label=\"1\"];\n\t\tnode0 -> node3 [label=\"0\"];\n\t\tnode0 -> node1 [label=\"-1\"];\n\t}\n}\n")])))
|
||||||
|
|
||||||
;;; ====================
|
;;; ====================
|
||||||
;;; Dynamics of networks
|
;;; Dynamics of networks
|
||||||
|
|
Loading…
Reference in a new issue