示例#1
0
    def test_nested_parameter_node_snapshot_with_parent(self):
        parameter_node = ParameterNode(use_as_attributes=True)
        nested_parameter_node = ParameterNode(use_as_attributes=True)
        parameter_node.nested = nested_parameter_node

        nested_parameter_node.parent = parameter_node
        nested_parameter_node.snapshot()
示例#2
0
    def test_subnode_snapshot(self):
        node = ParameterNode()
        node.subnode = ParameterNode()

        self.assertDictEqual(node.snapshot()['parameter_nodes']['subnode'],
                             node.subnode.snapshot())

        node.subnode.param = Parameter()
        self.assertDictEqual(node.snapshot()['parameter_nodes']['subnode'],
                             node.subnode.snapshot())
示例#3
0
    def test_empty_node_snapshot(self):
        node = ParameterNode()
        snapshot = node.snapshot()
        self.assertCountEqual(snapshot.keys(), [
            '__class__', 'functions', 'parameters', 'submodules',
            'parameter_nodes'
        ])

        node.name = 'node_name'
        self.assertEqual(node.snapshot()['name'], 'node_name')
示例#4
0
 def test_parameter_in_node_simplified_snapshot(self):
     node = ParameterNode(simplify_snapshot=True)
     node.p = Parameter(initial_value=42)
     self.assertEqual(node.snapshot()['p'], 42)
示例#5
0
 def test_parameter_in_node_snapshot(self):
     node = ParameterNode()
     node.p = Parameter()
     self.assertEqual(node.snapshot()['parameters']['p'], node.p.snapshot())