mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-13 19:33:46 +08:00
done sorting dependencies logic; verified with temp testing
This commit is contained in:
1 parent
50b3bbd740
commit
57c0c9830c
2 files changed
+49
-5
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from mattport.nerf.graph import Graph
|
||||
|
||||
|
||||
@@ -135,7 +135,6 @@ def test_construct_graph_repeat():
|
||||
|
||||
test_graph.modules_config["mlp_0"]["inputs"][1] = "encoder_1"
|
||||
test_graph.modules_config["encoder_1"] = {"class_name": "Encoding", "inputs": ["x"], "meta_data": {"out_dim": 8}}
|
||||
print(test_graph.modules_config["mlp_0"]["inputs"][1])
|
||||
roots = test_graph.construct_graph()
|
||||
assert len(roots) == 2
|
||||
|
||||
@@ -157,3 +156,30 @@ def test_construct_graph_complex():
|
||||
|
||||
targets_p3 = [("encoder_0", 3), ("mlp_2", 0)]
|
||||
check_consistency(roots[0], targets_p3)
|
||||
|
||||
|
||||
def test_ordering():
|
||||
"""test dependency ordering of constructed graph"""
|
||||
test_basic_graph = Graph(create_basic_graph())
|
||||
_ = test_basic_graph.construct_graph()
|
||||
order = test_basic_graph.get_module_order()
|
||||
target = ["encoder_0", "mlp_0", "mlp_1"]
|
||||
assert np.array_equal(target, order)
|
||||
|
||||
test_repeated_graph = Graph(create_repeat_graph())
|
||||
_ = test_repeated_graph.construct_graph()
|
||||
order = test_repeated_graph.get_module_order()
|
||||
target = ["encoder_0", "mlp_0", "mlp_1"]
|
||||
assert np.array_equal(target, order)
|
||||
|
||||
test_repeated_graph.modules_config["mlp_0"]["inputs"][1] = "encoder_1"
|
||||
test_repeated_graph.modules_config["encoder_1"] = {"class_name": "Encoding", "inputs": ["x"], "meta_data": {"out_dim": 8}}
|
||||
order = test_repeated_graph.get_module_order()
|
||||
assert order.index('mlp_0') > order.index('encoder_0') and order.index('mlp_0') > order.index('encoder_1')
|
||||
|
||||
test_complex_graph = Graph(create_complex_graph())
|
||||
_ = test_complex_graph.construct_graph()
|
||||
order = test_complex_graph.get_module_order()
|
||||
assert order.index('mlp_2') > order.index('mlp_0')
|
||||
assert order.index('mlp_2') > order.index('encoder_0')
|
||||
assert order.index('mlp_3') > order.index('encoder_0')
|
||||
Reference in new issue
Block a user