def test_var_fac_nolink(self): f1 = relation_from_str('f1', '0.5', []) cv1 = VariableComputationNode(v1, []) cf1 = FactorComputationNode(f1) cg = ComputationsFactorGraph([cv1], [cf1]) self.assertEqual( _computation_memory_in_cg('v1', cg, computation_memory), 0) self.assertEqual( _computation_memory_in_cg('f1', cg, computation_memory), 0)
def test_var_fac_link(self): f1 = relation_from_str('f1', 'v1 * 0.5', [v1]) cv1 = VariableComputationNode(v1, ['f1']) cf1 = FactorComputationNode(f1) cg = ComputationsFactorGraph([cv1], [cf1]) # size of the domain of v1 self.assertEqual( _computation_memory_in_cg('v1', cg, computation_memory), 4 * VARIABLE_UNIT_SIZE) self.assertEqual( _computation_memory_in_cg('f1', cg, computation_memory), 4)
def test_fac_2var(self): f1 = relation_from_str('f1', 'v1 * 0.5+v2', [v1, v2]) cv1 = VariableComputationNode(v1, ['f1']) cv2 = VariableComputationNode(v2, ['f1']) cf1 = FactorComputationNode(f1) cg = ComputationsFactorGraph([cv1, cv2], [cf1]) # size of the domain of v1 + size domain v2 self.assertEqual( _computation_memory_in_cg('f1', cg, computation_memory), 8)