def circuits_page(): page = Circuit(dsn = app.config['dsn']) if request.method == 'GET': return page.list_page() elif 'deletecircuitwithid' in request.form: id = request.form['id'] return page.delete_circuit_with_id(id) elif 'updatecircuit' in request.form: id = request.form['id'] name = request.form['name'] length = request.form['length'] width = request.form['width'] left_corners = request.form['left_corners'] right_corners = request.form['right_corners'] longest_straight = request.form['longest_straight'] country = request.form['country'] constructed_year = request.form['constructed_year'] return page.update_circuit(name, length, width, left_corners, right_corners, longest_straight, country, constructed_year, id) elif 'addcircuit' in request.form: name = request.form['name'] length = request.form['length'] width = request.form['width'] left_corners = request.form['left_corners'] right_corners = request.form['right_corners'] longest_straight = request.form['longest_straight'] country = request.form['country'] constructed_year = request.form['constructed_year'] return page.add_circuit(name, length, width, left_corners, right_corners, longest_straight, country, constructed_year) elif 'searchcircuit' in request.form: page.search_name = request.form['name'] return page.search_circuit(page.search_name) else: return redirect(url_for('home_page'))
help="netlist file specifying first circuit (default: %(default)s)") parser.add_argument( "netlist2", nargs='?', default="netlists/cmos_nand_2.txt", help="netlist file specifying second circuit (default: %(default)s)") parser.add_argument("--show-plot", action='store_true', help="display plot of graphs of the circuits") parser.add_argument("--save-plot", action='store_true', help="save plot of graphs of the circuits to file") args = parser.parse_args() C1 = Circuit(args.netlist1) C2 = Circuit(args.netlist2) results = find_equivalence(C1, C2) if results is None: print('No equivalence found') else: print('Circuits are equivalent:') for n1, n2 in results.items(): print(' {} -> {}'.format(n1, n2)) if args.show_plot or args.save_plot: axes = plot_graphs(C1.G, C2.G, results) axes[0].set_title(args.netlist1) axes[1].set_title(args.netlist2)
def test_not_equivalent(self): C1 = Circuit("netlists/cmos_nand_1.txt") C2 = Circuit("netlists/cmos_nand_error.txt") results = find_equivalence(C1, C2) self.assertEqual(results, None)
def test_unequal_node_count(self): C1 = Circuit("netlists/cmos_nand_1.txt") C2 = Circuit("netlists/cmos_nand_missing.txt") results = find_isomorphism(C1.G, C2.G) self.assertEqual(results, None)
def test_non_isomorph(self): C1 = Circuit("netlists/cmos_nand_1.txt") C2 = Circuit("netlists/cmos_nand_error.txt") results = find_isomorphism(C1.G, C2.G) self.assertEqual(results, None)
def test_parsing(self): C = Circuit("netlists/cmos_nand_1.txt") self.assertEqual(len(C.netlist), 4) self.assertEqual(C.G.number_of_nodes(), 10)
"""Utility code to plot graph of the CMOS NAND gate. The resulting image is used in the README""" import matplotlib.pyplot as plt import numpy as np import networkx as nx from circuits import Circuit C = Circuit("netlists/cmos_nand_1.txt") f, ax = plt.subplots(figsize=0.75 * np.array([6.4, 4.8])) pos = nx.spring_layout(C.G, seed=5) nx.draw(C.G, with_labels=True, pos=pos, node_color='orange') plt.savefig("nand_graph.png", bbox_inches='tight', dpi=200) # plt.show()