From 35bc535fd47d1f1625fe5e88e828472c7b2019c1 Mon Sep 17 00:00:00 2001 From: Charles Horn Date: Thu, 4 Mar 2021 12:11:51 +1300 Subject: [PATCH 01/12] rm stray swp file --- .gitignore | 3 +++ src/.file.qasm.swp | Bin 1024 -> 0 bytes 2 files changed, 3 insertions(+) delete mode 100644 src/.file.qasm.swp diff --git a/.gitignore b/.gitignore index 894a44c..7a1046b 100644 --- a/.gitignore +++ b/.gitignore @@ -94,6 +94,9 @@ venv.bak/ .spyderproject .spyproject +# Swap files +*.swp + # Rope project settings .ropeproject diff --git a/src/.file.qasm.swp b/src/.file.qasm.swp deleted file mode 100644 index 36b957d4122ba043ddffb25988ef0f7071efee1b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{7E)H7y40{o#240-v98Aw7nnILt#&Z#-6#W Date: Thu, 4 Mar 2021 12:29:04 +1300 Subject: [PATCH 02/12] mainly whitespace changes in tests --- src/tests/gate_maker_tests.py | 83 +++++++++++++++++------------------ src/tests/lexer_tests.py | 11 +++-- src/tests/parser_tests.py | 3 +- src/tests/qast_tests.py | 11 ++--- 4 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/tests/gate_maker_tests.py b/src/tests/gate_maker_tests.py index ed27146..76749e7 100644 --- a/src/tests/gate_maker_tests.py +++ b/src/tests/gate_maker_tests.py @@ -1,7 +1,8 @@ import unittest from math import pi from random import randint -#from context import GateMaker +# from context import GateMaker + class GateMakerTest(unittest.TestCase): def setUp(self): @@ -12,108 +13,106 @@ def test_test(self): pass def test_idle_gate(self): - i = self.gm.u3(0,0,0) - self.assertEqual(i.simulate(0,0,0), (0,0,0)) + i = self.gm.u3(0, 0, 0) + self.assertEqual(i.simulate(0, 0, 0), (0, 0, 0)) def test_pauli_x(self): x = self.gm.u3(pi, 0, pi) - self.assertEqual(x.simulate(0,0,0), (1,0,1)) + self.assertEqual(x.simulate(0, 0, 0), (1, 0, 1)) def test_pauli_y(self): - y = self.gm.u3(pi,pi/2, pi/2) - self.assertEqual(y.simulate(0,0,0), (1,0.5,0.5)) + y = self.gm.u3(pi, pi/2, pi/2) + self.assertEqual(y.simulate(0, 0, 0), (1, 0.5, 0.5)) def test_pauli_z(self): z = self.gm.u1(pi) - self.assertEqual(z.simulate(0,0,0), (0,0,1)) + self.assertEqual(z.simulate(0, 0, 0), (0, 0, 1)) def test_hadamard(self): - h = self.gm.u2(0,pi) - self.assertEqual(h.simulate(0,0,0), (0,0.5,0.5)) + h = self.gm.u2(0, pi) + self.assertEqual(h.simulate(0, 0, 0), (0, 0.5, 0.5)) def test_clifford_gate(self): s = self.gm.u1(pi/2) - self.assertEqual(s.simulate(0,0,0), (0,0,.5)) + self.assertEqual(s.simulate(0, 0, 0), (0, 0, .5)) def test_clifford_conjugate(self): sdg = self.gm.u1(-pi/2) - self.assertEqual(sdg.simulate(0,0,0), (0,0,-.5)) + self.assertEqual(sdg.simulate(0, 0, 0), (0, 0, -.5)) def test_c3_gate(self): t = self.gm.u1(pi/4) - self.assertEqual(t.simulate(0,0,0), (0,0,0.25)) + self.assertEqual(t.simulate(0, 0, 0), (0, 0, 0.25)) def test_c3_conjugate(self): tdg = self.gm.u1(pi/4) - self.assertEqual(tdg.simulate(0,0,0), (0,0,-0.25)) - + self.assertEqual(tdg.simulate(0, 0, 0), (0, 0, -0.25)) + def test_x_rotation(self): - theta = randint(0,180) + theta = randint(0, 180) rx = self.gm.u3(theta, -pi/2, pi/2) - self.assertEqual(rx.simulate(0,0,0), (theta, -pi/2, pi/2)) + self.assertEqual(rx.simulate(0, 0, 0), (theta, -pi/2, pi/2)) def test_y_rotation(self): - theta = randint(0,180) + theta = randint(0, 180) ry = self.gm.u3(theta, 0, 0) - self.assertEqual(rx.simulate(0,0,0), (theta, 0, 0)) + self.assertEqual(rx.simulate(0, 0, 0), (theta, 0, 0)) def test_z_rotation(self): - phi = randint(0,180) + phi = randint(0, 180) rz = self.gm.u1(phi) - self.assertEqual(rz.simulate(0,0,0), (0,0,phi)) + self.assertEqual(rz.simulate(0, 0, 0), (0, 0, phi)) def test_controlled_not(self): cx = self.gm.CX() - self.assertEqual(cx.simulate([[0,0,0],[0,0,0]]), ([[0,0,0],[1,1,1]])) + self.assertEqual(cx.simulate([[0, 0, 0], [0, 0, 0]]), ([[0, 0, 0], [1, 1, 1]])) def test_controlled_phase(self): # set qubit start - a = [0,0,1] - b = [1,1,1] + a = [0, 0, 1] + b = [1, 1, 1] # define gates - h = self.gm.u2(0,pi) - cx= self.gm.CX() + h = self.gm.u2(0, pi) + cx = self.gm.CX() # Simulate cphase b = h.simulate(b) - a,b = cx.simulate(a,b) + a, b = cx.simulate(a, b) b = h.simulate(b) # Check results - self.assertEqual(a, [0,0,0]) - self.assertEqual(b, [1,1,0]) + self.assertEqual(a, [0, 0, 0]) + self.assertEqual(b, [1, 1, 0]) def test_controlled_y(self): # set qubit start - a = [0,1,0] - b = [0,0,0] + a = [0, 1, 0] + b = [0, 0, 0] # define gates s = self.gm.u1(pi/2) sdg = self.gm.u1(-pi/2) - cx= self.gm.CX() + cx = self.gm.CX() # Simulate cphase b = sdg.simulate(b) - a,b = cx.simulate(a,b) + a, b = cx.simulate(a, b) b = s.simulate(b) # Check results - self.assertEqual(a, [0,1,0]) - self.assertEqual(b, [1,0,1]) + self.assertEqual(a, [0, 1, 0]) + self.assertEqual(b, [1, 0, 1]) def test_controlled_h(self): # set qubit start - control = [0,0,0] - target = [1,1,1] - h = self.gm.u2(0,pi) + control = [0, 0, 0] + target = [1, 1, 1] + h = self.gm.u2(0, pi) sdg = self.gm.u1(-pi/2) - cx= self.gm.CX() + cx = self.gm.CX() t = self.gm.u1(pi/4) s = self.gm.u1(pi/2) b = h.simulate(b) b = sdg.simulate(b) - a,b = cx.simulate(a,b) + a, b = cx.simulate(a, b) b = t.simulate(b) b = h.simulate(b) - - def test_measure(self): pass @@ -126,7 +125,7 @@ def test_arbitrary_u(self): def test_ccx(self): pass - + if __name__ == '__main__': unittest.main() diff --git a/src/tests/lexer_tests.py b/src/tests/lexer_tests.py index 7270cc3..52a4dda 100644 --- a/src/tests/lexer_tests.py +++ b/src/tests/lexer_tests.py @@ -1,6 +1,7 @@ import unittest from tests.context import Lexer + class LexerTests(unittest.TestCase): def setUp(self): @@ -18,7 +19,7 @@ def _tokens_equ(self, tokens, equals): def test_comments(self): # comments should be completely ignored - text ='//this is a comment in qasm//h1' + text = '//this is a comment in qasm//h1' tokens = self._get_tokens(text) self._tokens_equ(tokens, ['ID']) # Only the H gate should be seen in the above code @@ -38,7 +39,7 @@ def test_string(self): def test_specification(self): text = 'OPENQASM: 2.0;' tokens = self._get_tokens(text) - equals = ['OPENQASM' , 'COLON', 'REAL', 'SEMI_COLON'] + equals = ['OPENQASM', 'COLON', 'REAL', 'SEMI_COLON'] self._tokens_equ(tokens, equals) def test_include(self): @@ -106,7 +107,7 @@ def test_gate(self): equals = ['GATE', 'ID', 'PAREN_OPEN', 'ID', 'COMMA', 'ID', 'COMMA', 'ID', 'PAREN_CLOSE', - 'ID', 'OPEN_BRACE', + 'ID', 'OPEN_BRACE', 'U', 'PAREN_OPEN', 'ID', 'COMMA', 'ID', 'COMMA', 'ID', 'PAREN_CLOSE', 'ID', 'SEMI_COLON', @@ -141,11 +142,9 @@ def test_full_script(self): 'CLOSE_BRACKET', 'COMMA', 'ID', 'OPEN_BRACKET', 'INT', 'CLOSE_BRACKET', 'COMMA', 'ID', 'OPEN_BRACKET', 'INT', 'CLOSE_BRACKET', 'COMMA', 'ID', 'OPEN_BRACKET', 'INT', - 'CLOSE_BRACKET', 'SEMI_COLON', 'ID','ID', 'ASSIGN_TO', + 'CLOSE_BRACKET', 'SEMI_COLON', 'ID', 'ID', 'ASSIGN_TO', 'ID', 'SEMI_COLON'] - - if __name__ == '__main__': unittest.main() diff --git a/src/tests/parser_tests.py b/src/tests/parser_tests.py index 32deeae..a88e6ee 100644 --- a/src/tests/parser_tests.py +++ b/src/tests/parser_tests.py @@ -2,6 +2,7 @@ from tests.context import Lexer, Parser + class ParserTest(unittest.TestCase): def setUp(self): self.lexer = Lexer().get_lexer() @@ -9,9 +10,9 @@ def setUp(self): self.page.parse() self.parser = self.page.get_parser() - def test_space(self): pass + if __name__ == '__main__': unittest.main() diff --git a/src/tests/qast_tests.py b/src/tests/qast_tests.py index 78a94a0..713594f 100644 --- a/src/tests/qast_tests.py +++ b/src/tests/qast_tests.py @@ -1,6 +1,7 @@ import unittest from tests.context import qast + class QAST_Tests(unittest.TestCase): def setUp(self): self.end = qast.End @@ -57,7 +58,7 @@ def test_uq_gate(self): def test_cq_gate(self): control = 1 - targets = [2,3,4,5] + targets = [2, 3, 4, 5] self.assertEqual(self.cq_gate(control=control, targets=targets).eval(), (control, targets, None)) @@ -65,7 +66,7 @@ def test_custom_q_gate(self): self.assertEqual(self.custom_q_gate('test').eval(), (None, None, None)) control = 1 - targets = [2,3,4] + targets = [2, 3, 4] self.assertEqual(self.custom_q_gate('test', control, targets).eval(), (control, targets, None)) @@ -105,12 +106,10 @@ def test_z_gate(self): self.assertEqual(self.z(0).eval(), (qast.LIB, 'ZGate')) - def test_rx_gate(self): self.assertEqual(self.rx(0).eval(), (qast.LIB, 'RXGate')) - def test_rz_gate(self): self.assertEqual(self.rz(0).eval(), (qast.LIB, 'RZGate')) @@ -145,7 +144,7 @@ def test_ch_gate(self): def test_ccx_gate(self): control = 1 - targets = [2,3] + targets = [2, 3] self.assertEqual(self.ccx(control, targets).eval(), (control, targets, (qast.LIB, 'CCXGate'))) @@ -174,5 +173,7 @@ def test_cu3_gate(self): def test_measurement(self): self.assertEqual(self.measure(0).eval(), (qast.LIB, 'MEASURE')) + + if __name__ == '__main__': unittest.main() From 31bd4be397b61a22ed160c41672f3f7f06407ddb Mon Sep 17 00:00:00 2001 From: Charles Horn Date: Thu, 4 Mar 2021 12:38:54 +1300 Subject: [PATCH 03/12] whitespace changes in qeda --- src/qeda/lexer.py | 8 ++++---- src/qeda/pcb.py | 38 ++++++++++++++++++++------------------ src/qeda/threader.py | 2 +- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/qeda/lexer.py b/src/qeda/lexer.py index 9a50305..9d0191d 100755 --- a/src/qeda/lexer.py +++ b/src/qeda/lexer.py @@ -1,5 +1,6 @@ from rply import LexerGenerator + class Lexer(): def __init__(self): self.lexer = LexerGenerator() @@ -7,7 +8,7 @@ def __init__(self): def _add_tokens(self): # Specification self.lexer.add('OPENQASM', r'(?i)OPENQASM') - #String support + # String support self.lexer.add('STRING', r'".*"') self.lexer.add('STRING', r"'.*'") # Includes @@ -54,7 +55,7 @@ def _add_tokens(self): self.lexer.add('EXP', r'(?i)exp') self.lexer.add('LN', r'(?i)ln') self.lexer.add('SQRT', r'(?i)sqrt') - #ID support + # ID support self.lexer.add('ID', r'[a-z][A-Za-z0-9_]*|[A-Z][A-Za-z0-9_]*') # Numbers self.lexer.add('REAL', r'([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([eE][-+]?[0-9]+)?') @@ -63,9 +64,8 @@ def _add_tokens(self): #self.lexer.add('CHARS', r'[A-Za-z]*') self.lexer.add('DOT', r'\.') - # Other Chars - self.lexer.ignore('\s+') + self.lexer.ignore(r'\s+') # Ignore Comments self.lexer.ignore(r'\//.*//') self.lexer.ignore(r'\\\.*\\') diff --git a/src/qeda/pcb.py b/src/qeda/pcb.py index 71e9436..0653ccc 100755 --- a/src/qeda/pcb.py +++ b/src/qeda/pcb.py @@ -10,6 +10,7 @@ config = configparser.ConfigParser() config.read('conf/pcb.conf') + class PCB: def __init__(self, verbose=False, title='Quantum PCB Output', comment1='', s='DEFAULT'): # Setup verbosity @@ -32,7 +33,7 @@ def __init__(self, verbose=False, title='Quantum PCB Output', comment1='', s='DE self.drill_size = float(config[s]['drill_size']) self.clearance = float(config[s]['clearance']) self.num_layers = int(config[s]['layers']) - self.layers=[] + self.layers = [] self.page_type = [int(x) for x in config[s]['page_type'].split(',')] self.trace_width = config[s]['trace_width'] self.coords = [(0, 0), (10, 0), (10, 10), (0, 10)] @@ -40,14 +41,14 @@ def __init__(self, verbose=False, title='Quantum PCB Output', comment1='', s='DE V("PCB INFO:") self.title = title self.comment1 = comment1 - grid_orig = [int(x/2) for x in self.page_type] + grid_orig = [int(x / 2) for x in self.page_type] V("Title: {}\nComment1: {}\nGrid Origin: {}".format(self.title, self.comment1, grid_orig)) self.setup = Setup(grid_origin=grid_orig) def setup_verbosity(self): global V V = getattr(importlib.import_module("qeda.verbose", self.verbose), -self.verbose) + self.verbose) V("Verbosity setup on PCB prototype complete") def _connect_pad(self, comp, pad, net): @@ -62,7 +63,7 @@ def _connect_pad(self, comp, pad, net): def _place_component(self, comp, x_pos, y_pos): """Places component comp at position x,y and adds it to PCB list""" - V("Placing component at cooridinate ({},{})".format( x_pos, y_pos)) + V("Placing component at cooridinate ({},{})".format(x_pos, y_pos)) comp.at = [x_pos, y_pos] self.modules.append(comp) @@ -88,7 +89,7 @@ def _compute_positions(self, comp1, comp2, pads=[1, 0], create_vias=True): V("Computing positions of vias for components.") start = array(comp1.pads[pads[0]].at) + array(comp1.at) end = array(comp2.pads[pads[1]].at) + array(comp2.at) - pos = start + (end-start)/2 + pos = start + (end - start) / 2 V("Start: {}\nEnd: {}\nPosition: {}".format(start, end, pos)) if create_vias: @@ -137,7 +138,7 @@ def _create_zones(self): Layer('Inner2.Cu'), Layer('B.Cu'), Layer('Edge.Cuts', type='user') - ] + ] V(self.layers) for layer in ['Mask', 'Paste', 'SilkS', 'CrtYd', 'Fab']: for side in ['B', 'F']: @@ -171,17 +172,17 @@ def _create_pcb(self): pcb.zones = self.zones V("Writing to file") pcb.to_file('project') - - + + class PCBBuilder: def __init__(self, qcode={}, verbose=False): self.verbose = str(verbose).lower() self.setup_verbosity() - self.pcb=PCB(self.verbose) - self.qcode={} - self.oldq=qcode - for i in range(1,len(qcode)+1): - self.qcode[i]=[] + self.pcb = PCB(self.verbose) + self.qcode = {} + self.oldq = qcode + for i in range(1, len(qcode) + 1): + self.qcode[i] = [] self.qcode[i].append(Module.from_file(qcode[i][0][0] + 'Photon-Source.kicad_mod')) for each in qcode[i]: self.qcode[i].append(Module.from_file(each[0] + each[1] + '.kicad_mod')) @@ -202,7 +203,7 @@ def _find_max_x(self, comp): x = [each for each in geo] for each in x: if each.start == None and each.end != None: - y = abs(0-each.end[0]) + y = abs(0 - each.end[0]) elif each.end == None and each.start != None: y = abs(each.start) elif each.start == each.end == None: @@ -236,13 +237,13 @@ def _find_maxes(self, comp): x = self._find_max_x(comp) y = self._find_max_y(comp) return int(x), int(y) - + def _place_component(self, comp, x, y): """Places the component at x,y""" - V("Placing component {} at ({}, {})".format(comp.name, x,y)) + V("Placing component {} at ({}, {})".format(comp.name, x, y)) self.pcb._place_component(comp, x, y) V("Component {} is at {}".format(comp.name, comp.at)) - + def _autoplace_(self): V("Running auto-placer") pos = { @@ -264,12 +265,13 @@ def _autoplace_(self): V("Placing component.") cur_x += x pos['X'] = cur_x - if y > cur_y: + if y > cur_y: cur_y = y self._place_component(gates[i], pos['X'], pos['Y']) cur_x = 0 pos['X'] = cur_x pos['Y'] += cur_y + if __name__ == '__main__': x = PCB() diff --git a/src/qeda/threader.py b/src/qeda/threader.py index c57ab78..39ba6ba 100755 --- a/src/qeda/threader.py +++ b/src/qeda/threader.py @@ -5,4 +5,4 @@ The threader.py script enables multithreading with the QEDA software. """ -# Lines are chunked by the main script and then passed into +# Lines are chunked by the main script and then passed into From 41c87957e14c4a689d571a79e03145be869c759e Mon Sep 17 00:00:00 2001 From: Charles Horn Date: Thu, 4 Mar 2021 12:42:33 +1300 Subject: [PATCH 04/12] fix None equality checks --- src/qeda/pcb.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qeda/pcb.py b/src/qeda/pcb.py index 0653ccc..61e8431 100755 --- a/src/qeda/pcb.py +++ b/src/qeda/pcb.py @@ -202,11 +202,11 @@ def _find_max_x(self, comp): geo = comp.geometry() x = [each for each in geo] for each in x: - if each.start == None and each.end != None: + if each.start is None and each.end is not None: y = abs(0 - each.end[0]) - elif each.end == None and each.start != None: + elif each.end is None and each.start is not None: y = abs(each.start) - elif each.start == each.end == None: + elif each.start == each.end is None: pass else: y = abs(each.start[0] - each.end[0]) @@ -220,11 +220,11 @@ def _find_max_y(self, comp): geo = comp.geometry() x = [each for each in geo] for each in x: - if each.start == None and each.end != None: + if each.start is None and each.end is not None: y = abs(0 - each.end) - if each.end == None and each.start != None: + if each.end is None and each.start is not None: y = abs(each.start) - elif each.start == each.end == None: + elif each.start == each.end is None: pass else: y = abs(each.start[1] - each.end[1]) From 3ad07780d586aebdc5e46385e248c40624c789b4 Mon Sep 17 00:00:00 2001 From: Charles Horn Date: Thu, 4 Mar 2021 12:51:39 +1300 Subject: [PATCH 05/12] remove redundant lines in gates --- src/qeda/gates.py | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/qeda/gates.py b/src/qeda/gates.py index fc95d73..fd9bb58 100755 --- a/src/qeda/gates.py +++ b/src/qeda/gates.py @@ -1,62 +1,60 @@ from primitives import U1, U2, U3 -global PI + PI = 3.14159 + class X(U3): - global PI def __init__(self): self.theta = PI self.phi = 0 self.lamda = PI - pass + class Y(U3): - global PI def __init__(self): self.theta = PI - self.phi = PI/2 - self.lamda = PI/2 - pass + self.phi = PI / 2 + self.lamda = PI / 2 + class Z(U1): - global PI def __init__(self): self.lamda = PI - pass + class H(U2): - global PI def __init__(self): self.phi = 0 self.lamda = PI + class S(U1): - global PI def __init__(self): - self.lamda = PI/2 + self.lamda = PI / 2 + class SDG(U1): - global PI def __init__(self): - self.lamda = -PI/2 + self.lamda = -PI / 2 + class T(U1): - global PI def __init__(self): - self.lamda = PI/4 + self.lamda = PI / 4 + class TDG(U1): - global PI def __init__(self): - self.lamda = -PI/4 + self.lamda = -PI / 4 + class RX(U3): - global PI def __init__(self, theta): self.theta = theta - self.phi = -PI/2 - self.lamda = PI/2 + self.phi = -PI / 2 + self.lamda = PI / 2 + class RY(U3): def __init__(self, theta): @@ -64,6 +62,7 @@ def __init__(self, theta): self.phi = 0 self.lamda = 0 + class RZ(U1): def __init__(self, lamda): self.lamda = lamda From 32c157283db60852e13c27103b07ba96cec3be17 Mon Sep 17 00:00:00 2001 From: Charles Horn Date: Thu, 4 Mar 2021 13:02:30 +1300 Subject: [PATCH 06/12] more whitespace changes --- src/qeda/parser.py | 30 +++++++++++++++--------------- src/qeda/verbose.py | 4 +++- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/qeda/parser.py b/src/qeda/parser.py index 95c8e9b..fbc49ae 100755 --- a/src/qeda/parser.py +++ b/src/qeda/parser.py @@ -13,15 +13,16 @@ def __init__(self, verbose=False): 'RESET', 'QREG', 'CREG', 'GATE', 'PAREN_OPEN', 'PAREN_CLOSE', 'STRING', 'OPEN_BRACKET', 'CLOSE_BRACKET', 'OPEN_BRACE', 'CLOSE_BRACE', 'SEMI_COLON', 'COLON', 'DASH', 'UNDER_SCORE', 'COMMA', 'QUOTE', - 'U', 'CX', 'PLUS', 'MINUS', 'MUL', 'DIV', 'POW', 'PI', 'SIN', + 'U', 'CX', 'PLUS', 'MINUS', 'MUL', 'DIV', 'POW', 'PI', 'SIN', 'COS', 'TAN', 'EXP', 'LN', 'SQRT', 'ASSIGN_TO', 'EQU', 'ID', 'INT', 'REAL'] ) + def setup_verbosity(self): global V V = getattr(importlib.import_module("qeda.verbose", self.verbose), self.verbose) V("Verbosity setup complete") - + def parse(self): @self.parser_generator.production('main : OPENQASM real SEMI_COLON program') @@ -89,15 +90,15 @@ def goplist(p): @self.parser_generator.production('qop : MEASURE argument ASSIGN_TO argument SEMI_COLON') @self.parser_generator.production('qop : RESET argument SEMI_COLON') def qop(p): - if "Token" in str(type(p[0])): + if "Token" in str(type(p[0])): V("Token") if p[0].name == 'MEASURE': - V("MEASURE: {}, {}".format(p[1],p[3])) + V("MEASURE: {}, {}".format(p[1], p[3])) Measure(p[1]) V("Measure complete") elif p[0].name == 'RESET': V("RESET") - else: + else: return p[0] @self.parser_generator.production('uop : U PAREN_OPEN explist PAREN_CLOSE argument SEMI_COLON') @@ -106,10 +107,10 @@ def qop(p): @self.parser_generator.production('uop : int anylist SEMI_COLON') @self.parser_generator.production('uop : int PAREN_OPEN PAREN_CLOSE anylist SEMI_COLON') @self.parser_generator.production('uop : int PAREN_OPEN explist PAREN_CLOSE anylist SEMI_COLON') - @self.parser_generator.production('uop : id anylist SEMI_COLON') # Adds support for custom gates: ccx a,b,c; - @self.parser_generator.production('uop : id id SEMI_COLON') # supports: y b; - @self.parser_generator.production('uop : id id OPEN_BRACKET int CLOSE_BRACKET SEMI_COLON') # supports X a[1]; - @self.parser_generator.production('uop : id PAREN_OPEN int PAREN_CLOSE SEMI_COLON') # Supports X(0); + @self.parser_generator.production('uop : id anylist SEMI_COLON') # Adds support for custom gates: ccx a,b,c; + @self.parser_generator.production('uop : id id SEMI_COLON') # Supports: y b; + @self.parser_generator.production('uop : id id OPEN_BRACKET int CLOSE_BRACKET SEMI_COLON') # Supports X a[1]; + @self.parser_generator.production('uop : id PAREN_OPEN int PAREN_CLOSE SEMI_COLON') # Supports X(0); def uop(p): V('uop', p) if p[0].name in ('U', 'u'): @@ -118,11 +119,11 @@ def uop(p): elif p[0].name in ('cx', 'CX'): V("CX Gate") if len(p) == 5: - return CX(p[1],p[3]) + return CX(p[1], p[3]) else: - return CX(p[0][0],p[0][1]) + return CX(p[0][0], p[0][1]) elif p[0].name == 'ID': - V('a',p) + V('a', p) if p[0].value.lower() == 'h': V("Hadamard!") return H(p[2]) @@ -191,14 +192,14 @@ def idlist(p): x = [p[0], p[2]] V('idlist token res', x) return x - + @self.parser_generator.production('mixedlist : id OPEN_BRACKET int CLOSE_BRACKET') @self.parser_generator.production('mixedlist : mixedlist COMMA id') @self.parser_generator.production('mixedlist : mixedlist COMMA id OPEN_BRACKET int CLOSE_BRACKET') @self.parser_generator.production('mixedlist : idlist COMMA id OPEN_BRACKET int CLOSE_BRACKET') def mixedlist(p): if 'token' in str(type(p[0])): - x = [{ 'name': p[0], 'val': p[2]}] + x = [{'name': p[0], 'val': p[2]}] elif type(p[0]) == list: if len(p) == 3: x = [x for x in p[0]] @@ -280,4 +281,3 @@ def error_handle(token): def get_parser(self): '''Returns a parser generator object''' return self.parser_generator.build() - diff --git a/src/qeda/verbose.py b/src/qeda/verbose.py index b914962..0df0151 100644 --- a/src/qeda/verbose.py +++ b/src/qeda/verbose.py @@ -4,11 +4,13 @@ x = getattr(importlib.import_module("qeda.verbose", "true/false"), "true/false") x('string') """ + + def true(*args, **kwargs): for arg in args: print(arg,) for kwarg in kwargs: print(kwarg,) -false = lambda *a: None +false = lambda *a: None From a0dfa4d81223ff534da37b6ef741ca82e20d5f7c Mon Sep 17 00:00:00 2001 From: Charles Horn Date: Thu, 4 Mar 2021 13:08:46 +1300 Subject: [PATCH 07/12] fix typo and whitespace changes --- src/qeda/qast_primitives.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/qeda/qast_primitives.py b/src/qeda/qast_primitives.py index ec8790d..bba8654 100755 --- a/src/qeda/qast_primitives.py +++ b/src/qeda/qast_primitives.py @@ -1,32 +1,38 @@ import configparser + + CONFIG = configparser.ConfigParser() CONFIG.read('conf/components.conf') -SEL = CONFIG['PROJECT']['SELECTION'] # Current Configs -LIB = CONFIG[SEL]['QLib'] # Component Library +SEL = CONFIG['PROJECT']['SELECTION'] # Current Configs +LIB = CONFIG[SEL]['QLib'] # Component Library QCODE = {} + class End(): def __init__(self): global QCODE def eval(self): - return QCODE, 0 + return QCODE, 0 + class Int(): def __init__(self, value): - self.value=value + self.value = value def eval(self): return int(self.value) + class Real(): - def __init__(self, vaue): + def __init__(self, value): self.value = value def eval(self): return float(self.value) + class Char(): def __init__(self, value): self.value = value @@ -34,6 +40,7 @@ def __init__(self, value): def eval(self): return self.value + class String(): def __init__(self, string): self.string = string @@ -41,11 +48,13 @@ def __init__(self, string): def eval(self): return self.string + class BinaryOp(): def __init__(self, left, right): self.left = left self.right = right + class Component: """The Component Primitive @@ -60,9 +69,10 @@ def __init__(self): self.qid = None def _set_footprint(self, fp): - #self.footprint = Module.from_library(LIB, fp) # Final code - self.footprint = (LIB, fp) # Testing code + #self.footprint = Module.from_library(LIB, fp) # Final code + self.footprint = (LIB, fp) # Testing code self._add_qcomponent(self.qid) + def _add_qcomponent(self, qid): """Adds the components to master dictionary""" try: @@ -89,9 +99,11 @@ def _add_qcomponent(self, qid): except Exception as e: print("exception", e) pass + def eval(self): return self.footprint, QCODE - + + class UQGate(Component): """The Unitary Quantum Gates. qid: Integer representing the qubit (starting from 0 to +N) @@ -104,6 +116,7 @@ def __init__(self, qid): def eval(self): return self.footprint + class CQGate(Component): """The Controlled Quantum Gates. contol: Control qubit @@ -133,6 +146,7 @@ def set_targets(self): # def eval(self): # return self.qid, self.targets, self.footprint + class CustomQGate(Component): """Class for Custom Quantum Gates.""" def __init__(self, gate_name, control=None, targets=None): @@ -144,4 +158,3 @@ def __init__(self, gate_name, control=None, targets=None): def eval(self): print(self.qid) return self.qid, self.targets, self.footprint - From bcc8435608d3660f668b25d8aaede49341593351 Mon Sep 17 00:00:00 2001 From: Charles Horn Date: Thu, 4 Mar 2021 13:12:54 +1300 Subject: [PATCH 08/12] whitespace changes in cli --- src/cli.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cli.py b/src/cli.py index 965ce7d..a67c36e 100755 --- a/src/cli.py +++ b/src/cli.py @@ -3,11 +3,13 @@ import sys from qeda.qeda import QEDAManager + def test(): """Runs the test suite""" print(test) sys.exit(0) + def help(): """Prints the help information to terminal""" print("\t\tQEDA") @@ -21,12 +23,14 @@ def help(): print("\n\nCopyright 2020 Spooky Manufacturing, LLC") sys.exit(0) + def run(inf, outf, proc, verbose, pcb, schema): """Runs QEDA""" print("Starting QEDA Manager") x = QEDAManager(inf, outf, proc, verbose, pcb, schema) sys.exit(0) + def main(args=None): """The main routine""" inf = "" @@ -82,5 +86,6 @@ def main(args=None): print(str(err)) sys.exit(2) + if __name__ == '__main__': main() From f466d8564eb5c550e79739f8784eb9b03f2014d1 Mon Sep 17 00:00:00 2001 From: Charles Horn Date: Thu, 4 Mar 2021 13:38:17 +1300 Subject: [PATCH 09/12] tidy comparisons --- src/qeda/qeda.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/qeda/qeda.py b/src/qeda/qeda.py index aa3d0be..1be3cbd 100644 --- a/src/qeda/qeda.py +++ b/src/qeda/qeda.py @@ -1,10 +1,12 @@ import importlib +import sys from qeda.lexer import Lexer from qeda.parser import Parser from qeda.schema import SchemaBuilder from qeda.pcb import PCBBuilder + class QEDAManager: """QEDA Manager Class The QEDA Manager class takes inputs from the CLI or other interfaces @@ -36,7 +38,7 @@ def __init__(self, infile, outfile=None, processors=1, self.make_schema = make_schema # Setup up verbosity self.verbose_setup() - + # Initialization verification self.init_checks() @@ -53,18 +55,17 @@ def verbose_setup(self): V("Verbosity setup complete") def init_checks(self): - if self.infile == None: + if not self.infile: raise Exception('Error: No input file specified') - if self.outfile == None: + if not self.outfile: self.outfile = self.infile + '.out' V("Outfile: {}".format(self.outfile)) - if self.make_pcb == self.make_schema == False: + if not (self.make_pcb or self.make_schema): V("No work to be done.") sys.exit(0) def mp_manager(self): """The multiprocessor manager, spawns and delegates tasks if possible""" - pass def main_block(self): @@ -76,11 +77,11 @@ def main_block(self): V("Tokens", tokens) qcode = self.call_parser(tokens) V("QCode", qcode) - if self.make_pcb == True: + if self.make_pcb: self.call_pcb_maker(qcode) - if self.make_schema == True: + if self.make_schema: self.call_schema_maker(qcode) - + except Exception as e: V("An error occurred.") V(e) From e775c3e99110d7f1d008d6691d1592a6dbec65ec Mon Sep 17 00:00:00 2001 From: Charles Horn Date: Thu, 4 Mar 2021 14:04:10 +1300 Subject: [PATCH 10/12] last of the trivial / whitespace changes --- src/qeda/automaker.py | 39 +++++++++++------------ src/qeda/placement.py | 8 +++-- src/qeda/primitives.py | 70 +++++++++++++++++++++++++----------------- src/qeda/qast.py | 32 ++++++++++++++++--- 4 files changed, 92 insertions(+), 57 deletions(-) diff --git a/src/qeda/automaker.py b/src/qeda/automaker.py index 49672d4..2032011 100755 --- a/src/qeda/automaker.py +++ b/src/qeda/automaker.py @@ -1,8 +1,9 @@ #!/usr/bin/python3 -from math import ceil as CEIL +from math import ceil from pcb import PCB, Segment from pykicad.module import Module + class Automaker(): def __init__(self): self.pcb = PCB() @@ -18,13 +19,12 @@ def __init__(self): b.set_reference('b') c = Module.from_library('Resistors_SMD', 'R_0805') c.set_reference('c') - qcode = [[a,b,c], [x,y], [z]] + qcode = [[a, b, c], [x, y], [z]] self.automake(qcode) pass def _find_max_x(self, comp): """Returns the maximal X size as an integer""" - global CEIL max_x = 0 geo = comp.geometry() x = [each for each in geo] @@ -39,11 +39,10 @@ def _find_max_x(self, comp): y = abs(each.start[0] - each.end[0]) if y > max_x: max_x = y - return CEIL(max_x) + return ceil(max_x) def _find_max_y(self, comp): """Return maximal Y size as an integer""" - global CEIL max_y = 0 geo = comp.geometry() x = [each for each in geo] @@ -58,7 +57,7 @@ def _find_max_y(self, comp): y = abs(each.start[1] - each.end[1]) if y > max_y: max_y = y - return CEIL(max_y) + return ceil(max_y) def _find_maxes(self, comp): """Returns the maximal x and y value of a component (starting at 0,0)""" @@ -72,12 +71,12 @@ def _find_x(self, pos, maxx): def _find_y(sef, pos, maxy): return pos[1] + maxy - + def _autoplace_unitary_gates(self, qcode): pos = { 'X': 0, 'Y': 0 - } + } max_y = 0 for qubit in qcode: for i in range(len(qubit)): @@ -85,16 +84,15 @@ def _autoplace_unitary_gates(self, qcode): self.pcb._place_component(qubit[i], pos['X'], pos['Y']) print('Component is at ', qubit[i].at) x, y = self._find_maxes(qubit[i]) - #update x, y values + # update x, y values pos['X'] = pos['X'] + x if y > max_y: max_y += y - #loop + # loop # Step down y by max_x pos['X'] = 0 pos['Y'] = pos['Y'] + max_y - # if i == len(qubit)-1: # start, end, np_pos = self.pcb._final_compute(qubit[i]) # else: @@ -107,23 +105,21 @@ def _autoplace_controlled_gates(self, qcode): pos = { 'X': 0, 'Y': 0 - } + } max_y = 0 - - - + def _autoplace3(self, qcode): """Automagically places components where they need to be""" pos = { 'X': 0, 'Y': 0 - } + } cur_x = 0 cur_y = 0 for qubit in qcode: for i in range(len(qubit)): # Connect pads -# self.pcb._connect_pad(qubit[i], 1, 1) + # self.pcb._connect_pad(qubit[i], 1, 1) # Find maxes x, y = self._find_maxes(qubit[i]) print(x) @@ -135,18 +131,18 @@ def _autoplace3(self, qcode): self.pcb._place_component(qubit[i], pos['X'], pos['Y']) print('Component is at ', qubit[i].at) # compute and place vias - if i == len(qubit)-1: + if i == len(qubit) - 1: start, end, pos_np = self.pcb._final_compute(qubit[i]) else: start, end, pos_np = self.pcb._compute_positions( - qubit[i], qubit[i+1]) + qubit[i], qubit[i + 1]) # Create segments self.pcb._create_segment(start, end, self.pcb.nets[1]) print('Rechecking, component is at ', qubit[i].at) cur_x = 0 pos['X'] = cur_x pos['Y'] = cur_y - + def automake(self, qcode): """Attempts to automagically make a PCB from modules @@ -160,12 +156,13 @@ def automake(self, qcode): For quantum gates, we only need to place footprints. For electrical/analog gates we will need to computer positions, vias, etc""" - #Place components + # Place components self._autoplace(qcode) # Create PCB Zones self.pcb._create_zones() # Make the PCB self.pcb._create_pcb() + if __name__ == '__main__': a = Automaker() diff --git a/src/qeda/placement.py b/src/qeda/placement.py index 91d8fd3..ef296fb 100644 --- a/src/qeda/placement.py +++ b/src/qeda/placement.py @@ -1,5 +1,7 @@ # The placement algorithm import configparser + + class Placement: def __init__(self, specs, qcode): self.spec_conf = specs @@ -28,7 +30,7 @@ def import_specs(self): def placement_algorithm(self): """Runs the placement algorithm""" - pos = { 'X':0, 'Y':0 } # First component is placed at (0,0) + pos = {'X': 0, 'Y': 0} # First component is placed at (0,0) cur_x = 0 cur_y = 0 # cur_x = Current X, init at 0 or x origin @@ -43,8 +45,8 @@ def placement_algorithm(self): # Verify within circuit specs - throw an error if component height is # greater than comp_max_y. # Calculate V and H points for the first component - V_Points = {'X':0, 'Y':0} - H_Points = {'X':0, 'Y':0} + V_Points = {'X': 0, 'Y': 0} + H_Points = {'X': 0, 'Y': 0} # To calculate the X, use the Min(X) and Max(X) of the component found # earlier. # To calculate the V(Y), take the Max(y) and subtract comp_mode_V_top_margin diff --git a/src/qeda/primitives.py b/src/qeda/primitives.py index dddaff5..7363872 100755 --- a/src/qeda/primitives.py +++ b/src/qeda/primitives.py @@ -1,5 +1,6 @@ from math import pi, sin, cos + class Rotation(): """Specifies the rotation matrix applied to the blochsphere""" def __init__(self): @@ -7,18 +8,18 @@ def __init__(self): def _deg_to_rad(self, deg): """Converts degrees to radians""" - rpd = pi/180 #Radians per degree + rpd = pi / 180 # Radians per degree return deg * rpd def _rad_to_deg(self, rad): """Converts radians to degrees""" - rpd = pi/180 + rpd = pi / 180 return rad / rpd def isDeg(self, n): """Determines if value n is an angle""" if type(n) == type(1): - if n in range(-360,360): + if n in range(-360, 360): return True else: return False @@ -38,7 +39,7 @@ def rotate(self, axis, angle): class Mirror(Rotation): def __init__(self, angle=45): - self.angle = angle # angle of incidence in degrees, default 45 + self.angle = angle # Angle of incidence in degrees, default 45 pass def set_angle(self, n): @@ -75,6 +76,7 @@ def full_rotation(self, m): # cos(theta), -sin(theta) # sin(theta), cos(theta) + class BeamSplitter(Mirror): def __init__(self): super().__init__() @@ -90,6 +92,7 @@ def build(self): """Builds the component""" pass + class PhaseShift(): def __init__(self, n1=1.00029, n2=1.5, t=500, lamda=650): """Phase shifting material. @@ -103,7 +106,7 @@ def __init__(self, n1=1.00029, n2=1.5, t=500, lamda=650): self.n2 = n2 self.t = t self.lamda = lamda - + def _t_calc(self, phase, accuracy): # first we need to get within integer range while True: @@ -114,7 +117,7 @@ def _t_calc(self, phase, accuracy): if x > iphase % 2: self.t = self.t / 2 else: - self.t -=1 + self.t -= 1 elif x < iphase: if x < iphase % 2: self.t = self.t * 2 @@ -134,15 +137,16 @@ def _t_calc(self, phase, accuracy): else '0' for i in range(accuracy)])) else: break - + def t_calc(self, phase, accuracy=3): """Calculates the thickness of material needed to create a given phase shift""" self._t_calc(phase, accuracy) return round(self.t, accuracy) - + def _phase_shift(self): - return (2 * pi * (self.n2 - self.n1) *self.t ) / self.lamda + return (2 * pi * (self.n2 - self.n1) * self.t) / self.lamda + class Polarizer(): """polarization calculations""" @@ -155,6 +159,7 @@ def __init__(self, start, rotation, axis): def eval(self): pass + class Bloch(): """Represents the bloch sphere of a photon to be used for simulation and testing purposes @@ -181,6 +186,7 @@ def rotation(self, axis, angle): pass pass + class U(): """Defines a basic quantum gate""" def __init__(self, theta, phi, lamda): @@ -224,6 +230,7 @@ def _rotate(self, axis, angle): Rz(phi + 3pi), Rx(pi/2), Rz(theta + pi), Rx(pi/2), Rz(lamda) """ + class U1(U): """Performs lamda transformations Equivalent to a Z transformation changing the PHASE of the qubit @@ -239,15 +246,17 @@ def eval(self): t = z.t_calc(self.lamda) return t + class U2(U): """Performs phi and lamda transformations Equivalent to an X, Z, transformation changing the PHASE of the quit and applying an x rotation. """ def __init(self, phi, lamda): - super().__init__(pi/2, phi, lamda) + super().__init__(pi / 2, phi, lamda) pass + class U3(U): """Performs theta , phi, and lambda transformations Changes phase, x and y rotations. @@ -256,11 +265,13 @@ def __init__(self, theta, phi, lamda): super().__init__(theta, phi, lamda) pass + class CX(): """Controlled X Gate""" def __init__(self): pass + class CU1(): """Controlled phase rotation""" def __init__(self, lamda): @@ -273,6 +284,7 @@ def __init__(self, lamda): ''' pass + class CU3(): """Controlled-U(theta, phi, lambda) with target t and control c""" def __init__(self, theta, phi, lamda, t, c): @@ -294,17 +306,18 @@ def __init__(self): # 1 laser off # 1 phase shifter # 3 beam splitters - # 1 + # 1 pass + class INSGate(): """The inverted non-linear sign-shift gate""" def __init__(self): self.inputs = { - 1: { 'type': 'quantum', 'state': 'any' }, - 2: { 'type': 'laser', 'state': 1 }, - 3: { 'type': 'laser', 'state': 0 }, - } + 1: {'type': 'quantum', 'state': 'any'}, + 2: {'type': 'laser', 'state': 1}, + 3: {'type': 'laser', 'state': 0}, + } self.theta = { 1: 22.5, 2: 65.5302, @@ -317,9 +330,9 @@ def __init__(self): 4: pi, } self.outputs = { - '1': { 'type': 'quantum', 'state': 'any' }, - '2': { 'type': 'electric', 'state': 1 }, - '3': { 'type': 'electric', 'state': 0 }, + '1': {'type': 'quantum', 'state': 'any'}, + '2': {'type': 'electric', 'state': 1}, + '3': {'type': 'electric', 'state': 0}, } def describe_gate(self): @@ -329,20 +342,23 @@ def describe_gate(self): def _internals(self): """Defines the internal circuitry of the gate""" - #1 passes through phase shifter and into beam splitter 2. - #2 passes into beam splitter 1 - #3 passes into beam splitter 1 - #bs1 passes into bs2 & bs3 - #bs2 passes into out1 & bs2 - #bs3 passes into out2 & 3 + # 1 passes through phase shifter and into beam splitter 2. + # 2 passes into beam splitter 1 + # 3 passes into beam splitter 1 + # bs1 passes into bs2 & bs3 + # bs2 passes into out1 & bs2 + # bs3 passes into out2 & 3 pass + def _build_circuit(self): pass -''' self.circuit = { + ''' + self.circuit = { 1: { 1: phase pass''' + class GateDesigner(): def __init__(self): @@ -354,8 +370,6 @@ def __init__(self): "Start": "0", "End": "1", "Out": "Q2" - }, + }, 'Q2': []} pass - - diff --git a/src/qeda/qast.py b/src/qeda/qast.py index 328897a..b234346 100755 --- a/src/qeda/qast.py +++ b/src/qeda/qast.py @@ -8,6 +8,7 @@ # Import gate primitives from qeda.qast_primitives import Int, Char, Real, String, BinaryOp, Component, UQGate, CQGate, CustomQGate + class OpenQASM(): def __init__(self, value): self.version = value @@ -31,17 +32,19 @@ def _add_controls(self, controls): def _add_targets(self, targets): self.targets = [x.value for x in targets] - + def gate_definition(self): pass + class CREG(Component): """The classical register. n: Integer representing the number of bits to store """ def __init__(self, n): self.qid = -1 - self._add_register(n,'CREG') + self._add_register(n, 'CREG') + class QREG(Component): """The quantum register. @@ -49,9 +52,10 @@ class QREG(Component): """ def __init__(self, n): self.n = n - self.qid = range(1,len(n)) + self.qid = range(1, len(n)) self._set_footprint('QREG') + class H(UQGate): def __init__(self, qid): UQGate.__init__(self, qid) @@ -63,98 +67,116 @@ def __init__(self, qid): UQGate.__init__(self, qid) self._set_footprint('IGate') + class S(UQGate): def __init__(self, qid): UQGate.__init__(self, qid) self._set_footprint('SGate') + class SDG(UQGate): def __init__(self, qid): UQGate.__init__(self, qid) self._set_footprint('SDGGate') + class T(UQGate): def __init__(self, qid): UQGate.__init__(self, qid) self._set_footprint('TGate') + class TDG(UQGate): def __init__(self, qid): UQGate.__init__(self, qid) self._set_footprint('TDGGate') + class X(UQGate): def __init__(self, qid): UQGate.__init__(self, qid) self._set_footprint('XGate') + class Y(UQGate): def __init__(self, qid): UQGate.__init__(self, qid) self._set_footprint('YGate') + class Z(UQGate): def __init__(self, qid): UQGate.__init__(self, qid) self._set_footprint('ZGate') + class RX(UQGate): def __init__(self, qid): UQGate.__init__(self, qid) self._set_footprint('RXGate') + class RY(UQGate): def __init__(self, qid): UQGate.__init__(self, qid) self._set_footprint('RYGate') + class RZ(UQGate): def __init__(self, qid): UQGate.__init__(self, qid) self._set_footprint('RZGate') + class Measure(UQGate): def __init__(self, qid): UQGate.__init__(self, qid) self._set_footprint('Measure') + class CX(CQGate): def __init__(self, control, targets): CQGate.__init__(self, control, targets) self._set_footprint('CXGate') + class CYGate(CQGate): def __init__(self, control, targets): CQGate.__init__(self, control, targets) self._set_footprint('CYGate') - + + class CZGate(CQGate): def __init__(self, control, targets): CQGate.__init__(self, control, targets) self._set_footprint('CZGate') + class CHGate(CQGate): def __init__(self, control, targets): CQGate.__init__(self, control, targets) self._set_footprint('CHGate') + class CCXGate(CQGate): def __init__(self, control, targets): CQGate.__init__(self, control, targets) self._set_footprint('CCXGate') + class CRZGate(CQGate): def __init__(self, control, targets): CQGate.__init__(self, control, targets) self._set_footprint('CRZGate') + class CU1Gate(CQGate): def __init__(self, control, targets): CQGate.__init__(self, control, targets) self._set_footprint('CU1Gate') + class CU3Gate(CQGate): def __init__(self, control, targets): CQGate.__init__(self, control, targets) self._set_footprint('CU3Gate') - From 1c0aa2236e3a86ca855256e190cb6f15be7e5d0c Mon Sep 17 00:00:00 2001 From: Charles Horn Date: Thu, 4 Mar 2021 17:01:19 +1300 Subject: [PATCH 11/12] change wildcard import to specific --- src/qeda/pcb.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/qeda/pcb.py b/src/qeda/pcb.py index 61e8431..e319ed5 100755 --- a/src/qeda/pcb.py +++ b/src/qeda/pcb.py @@ -1,11 +1,12 @@ #!/usr/bin/python3 import configparser import importlib +from math import ceil from numpy import array -from math import ceil as CEIL + from pykicad.pcb import Net, Via, Segment, Setup, Layer, NetClass, Pcb -from pykicad.module import * +from pykicad.module import Module config = configparser.ConfigParser() config.read('conf/pcb.conf') @@ -127,9 +128,9 @@ def _create_segment(self, start, end, net): def _create_zones(self): """Creates the zones (layers) of the PCB""" - #coords = self.coords + # coords = self.coords # Unneeded? - #gndplane_top = Zone(net_name='GND', layer='F.Cu', + # gndplane_top = Zone(net_name='GND', layer='F.Cu', # polygon=coords, clearance=self.clearance) V("Creating Zones.") self.layers = [ @@ -212,7 +213,7 @@ def _find_max_x(self, comp): y = abs(each.start[0] - each.end[0]) if y > max_x: max_x = y - return CEIL(max_x) + return ceil(max_x) def _find_max_y(self, comp): """Return the maximal X size of a component as an interger""" @@ -230,7 +231,7 @@ def _find_max_y(self, comp): y = abs(each.start[1] - each.end[1]) if y > max_y: max_y = y - return CEIL(max_y) + return ceil(max_y) def _find_maxes(self, comp): """Returns the maximal x and y value of a component (starting at 0,0)""" From 321f551da9e82f4c4e8f14e25dacaf13ec73db72 Mon Sep 17 00:00:00 2001 From: Charles Horn Date: Thu, 4 Mar 2021 17:39:31 +1300 Subject: [PATCH 12/12] remove stray kicad file --- src/fp-info-cache | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/fp-info-cache diff --git a/src/fp-info-cache b/src/fp-info-cache deleted file mode 100644 index 573541a..0000000 --- a/src/fp-info-cache +++ /dev/null @@ -1 +0,0 @@ -0