def to_aig(circ, *, allow_lazy=False) -> AIG: if isinstance(circ, pathlib.Path) and circ.is_file(): circ = parser.load(circ) elif isinstance(circ, str): if circ.startswith('aag '): circ = parser.parse(circ) # Assume it is an AIGER string. else: circ = parser.load(circ) # Assume it is a file path. if allow_lazy and hasattr(circ, '.lazy_aig'): return circ.lazy_aig return circ.aig # Extract AIG from potential wrapper.
def test_load(circ, data): with NamedTemporaryFile() as f: circ.write(f.name) circ2 = aigp.load(f.name) assert circ.inputs == circ2.inputs assert circ.outputs == circ2.outputs test_input = {f'{i}': data.draw(st.booleans()) for i in circ.inputs} assert circ(test_input) == circ2(test_input)
def main(): args = parse_cmdline() file_names = glob.glob(args.directory) print(f'Detected {len(file_names)} files to transform.') for file_name in file_names: print(f'Transforming {file_name}') circuit = parser.load(file_name, to_aig=False) aag2qdimacs(circuit, file_name + '.qdimacs')
def parse_and_count(path): print(count(parser.load(path)))