Commit 9c801556 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib] CLUnfolder: homogenization of attributes free_clocks/inputs

parent fa7a0fce
......@@ -577,11 +577,13 @@ class CLUnfolder(object):
index = var_code - self.shift_step_init - 1
return self.__aux_list[index] + '_%s'% var_step
def get_free_clocks(self):
@property
def free_clocks(self):
"""Get the DIMACS codes of the free_clocks variables"""
return self.__free_clocks
def get_inputs(self):
@property
def inputs(self):
"""Get the DIMACS codes of the input variables"""
return self.__inputs
......
......@@ -304,22 +304,22 @@ class TestCLUnfolder(unittest.TestCase):
# model3: no free clock, no input
model = model3()
unfolder = create_unfolder(model)
lfc = unfolder.get_free_clocks()
lfc = unfolder.free_clocks
res = len(lfc) == 0
self.assert_(res,'Error in free clocks: model3')
lin = unfolder.get_inputs()
lin = unfolder.inputs
res = len(lin) == 0
self.assert_(res,'Error in inputs 1')
# model4: two free clocks and one input
model = model4()
unfolder = create_unfolder(model)
lfc = unfolder.get_free_clocks()
lfc = unfolder.free_clocks
res = len(lfc) == 2
found_names = {unfolder.get_var_name(clock) for clock in lfc}
res = found_names == {'hh2', 'hh1'}
self.assert_(res,'Error in free clocks: model4')
lin = unfolder.get_inputs()
lin = unfolder.inputs
res = len(lin) == 1
found_names = {unfolder.get_var_name(inpt) for inpt in lin}
res = found_names == {'in1'}
......@@ -419,12 +419,12 @@ def test_init_unfolder(feed_mclanalyser):
assert found == frozenset([4, 5, 6, 7, 9, 12, 14, -14, -12, -9, -7, -6, -5, -4])
# Check clocks
free_clocks = unfolder._CLUnfolder__free_clocks
free_clocks = unfolder.free_clocks
print("Free clocks/events", free_clocks)
assert free_clocks == frozenset([16, 17, 18, 19, 20, 21, 22, 23])
clocks_values_mapping = {
value: unfolder.get_var_name(value) for value in unfolder._CLUnfolder__free_clocks
value: unfolder.get_var_name(value) for value in unfolder.free_clocks
}
print("Clocks values mapping", clocks_values_mapping)
assert clocks_values_mapping == {16: '_h2', 17: '_h3', 18: '_h4', 19: '_h5', 20: '_h6', 21: '_h7', 22: '_h_0', 23: '_h_1'}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment