Skip to content

Commit

Permalink
Ruff --fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasc-ubc committed Jul 29, 2024
1 parent 9d444bc commit 8b637c3
Show file tree
Hide file tree
Showing 73 changed files with 157 additions and 223 deletions.
12 changes: 7 additions & 5 deletions klayout/EBeam/CDC_SM/MATLAB/matlabenginestart.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
@author: Mustafa Hammood
"""

import os,time, math
import os
import time
import math
import numpy as np
#import matplotlib.pyplot as plt

Expand Down Expand Up @@ -43,10 +45,10 @@

_lambda = np.linspace(1500,1600,10001)*1e-9

n_eff1 = n_eff1_fit[0] + n_eff1_fit[1]*_lambda;
n_eff2 = n_eff2_fit[0] + n_eff2_fit[1]*_lambda;
n_g1 = n_g1_fit[0] + n_g1_fit[1]*_lambda;
n_g2 = n_g2_fit[0] + n_g2_fit[1]*_lambda;
n_eff1 = n_eff1_fit[0] + n_eff1_fit[1]*_lambda
n_eff2 = n_eff2_fit[0] + n_eff2_fit[1]*_lambda
n_g1 = n_g1_fit[0] + n_g1_fit[1]*_lambda
n_g2 = n_g2_fit[0] + n_g2_fit[1]*_lambda

def find_nearest(a, a0):
"Element in nd array `a` closest to the scalar value `a0`"
Expand Down
4 changes: 2 additions & 2 deletions klayout/EBeam/CML/EBeam/source_data/CDC/contraDC_CMT_TMM.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"""
#%% import dependencies
import cmath, math
import sys, os, time
import cmath
import math
import numpy as np
import scipy.linalg

Expand Down
6 changes: 4 additions & 2 deletions klayout/EBeam/CML/EBeam/source_data/CDC/lumerical_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@


#%% find lumapi
import sys, os, platform
import sys
import os
import platform

mode = None # variable for the Lumerical Python API

Expand Down Expand Up @@ -41,7 +43,7 @@
matches.append(root)
if matches:
lumapi_path = matches[0]
if not lumapi_path in sys.path:
if lumapi_path not in sys.path:
sys.path.append(lumapi_path)
# os.chdir(lumapi_path)

Expand Down
4 changes: 3 additions & 1 deletion klayout/EBeam/CML/EBeam/source_data/CDC/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
# conda install numpy scipy matplotlib xmltodict


import xmltodict, sys, os
import xmltodict
import sys
import os
from collections import OrderedDict
from xml.etree import cElementTree as ET

Expand Down
3 changes: 2 additions & 1 deletion klayout/EBeam/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
print('SiEPIC-EBeam-PDK Python module: siepic_ebeam_pdk, KLayout technology: EBeam')

# Load the KLayout technology, when running in Script mode
import pya, os
import pya
import os
if not pya.Technology().has_technology('EBeam'):
tech = pya.Technology().create_technology('EBeam')
tech.load(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'EBeam.lyt'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
# $menu-path: siepic_menu.exlayout.end
# Unit testing for all library layout fixed cells and PCells

import pya # klayout
import os, sys
import os
import sys

path_GitHub = os.path.expanduser('~/Documents/GitHub/')
if 0:
if 'SiEPIC' not in sys.modules:
path_siepic = os.path.join(path_GitHub, 'SiEPIC-Tools/klayout_dot_config/python')
if not path_siepic in sys.path:
if path_siepic not in sys.path:
sys.path.insert(0,path_siepic)
import SiEPIC
from SiEPIC._globals import Python_Env
print('KLayout running in mode: %s' % Python_Env)
from SiEPIC.utils.layout import new_layout, floorplan
from SiEPIC.utils.layout import new_layout
from SiEPIC.utils import load_klayout_technology
from SiEPIC.scripts import instantiate_all_library_cells, zoom_out, export_layout
from SiEPIC.scripts import instantiate_all_library_cells, export_layout

path_module = os.path.join(path_GitHub, 'SiEPIC_EBeam_PDK/klayout')
path_lyt_file = os.path.join(path_GitHub, 'SiEPIC_EBeam_PDK/klayout/EBeam/EBeam.lyt')
Expand Down
3 changes: 1 addition & 2 deletions klayout/EBeam/pymacros/PCMSpiral_PCells.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import math
import cmath
from pya import *
from SiEPIC.utils import get_technology, get_technology_by_name
from SiEPIC.scripts import path_to_waveguide
from SiEPIC.utils import get_technology_by_name

MODULE_NUMPY = True

Expand Down
6 changes: 3 additions & 3 deletions klayout/EBeam/pymacros/SiEPIC_EBeam_Library.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,12 @@

import pya
from pya import *
from SiEPIC.utils import get_technology_by_name
import os
import pathlib
import sys


from SiEPIC._globals import KLAYOUT_VERSION, KLAYOUT_VERSION_3
from SiEPIC._globals import KLAYOUT_VERSION
if KLAYOUT_VERSION < 28:
question = pya.QMessageBox()
question.setStandardButtons(pya.QMessageBox.Ok)
Expand Down Expand Up @@ -164,7 +163,8 @@ def __init__(self):
self.path = os.path.dirname(os.path.realpath(__file__))

# Import all the GDS files from the tech folder
import os, fnmatch
import os
import fnmatch
dir_path = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../gds/EBeam"))
if verbose:
print(' library path: %s' % dir_path)
Expand Down
6 changes: 2 additions & 4 deletions klayout/EBeam/pymacros/SiEPIC_EBeam_Library_ANT.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
if verbose:
print('SiEPIC_EBeam_Library_ANT')

import pya
from pya import *
from SiEPIC.utils import get_technology_by_name
import os
import pathlib
import sys

dir_path = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -56,7 +53,8 @@ def __init__(self):
self.path = os.path.dirname(os.path.realpath(__file__))

# Import all the GDS files from the tech folder
import os, fnmatch
import os
import fnmatch
dir_path = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../gds/ANT"))
if verbose:
print(' library path: %s' % dir_path)
Expand Down
5 changes: 2 additions & 3 deletions klayout/EBeam/pymacros/SiEPIC_EBeam_Library_Beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ def PCell_get_parameters ( pcell ):
if verbose:
print('SiEPIC_EBeam_Library_Beta, version %s' % version)

import pya
from pya import *
from SiEPIC.utils import get_technology_by_name
import os
import pathlib
import sys
Expand Down Expand Up @@ -180,7 +178,8 @@ def __init__(self):
self.path = os.path.dirname(os.path.realpath(__file__))

# Import all the GDS files from the tech folder
import os, fnmatch
import os
import fnmatch
dir_path = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../gds/EBeam_Beta"))
if verbose:
print(' library path: %s' % dir_path)
Expand Down
2 changes: 0 additions & 2 deletions klayout/EBeam/pymacros/SiEPIC_EBeam_Library_Dream.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
if verbose:
print('EBeam-Dream')

import pya
from pya import *
from SiEPIC.utils import get_technology_by_name
import os
import pathlib
import sys
Expand Down
6 changes: 2 additions & 4 deletions klayout/EBeam/pymacros/SiEPIC_EBeam_Library_SiN.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
if verbose:
print('siepic_ebeam_library_SiN')

import pya
from pya import *
from SiEPIC.utils import get_technology_by_name
from SiEPIC.utils.layout import make_pin
import os
import pathlib
import sys
Expand Down Expand Up @@ -77,7 +74,8 @@ def __init__(self):
self.path = os.path.dirname(os.path.realpath(__file__))

# Import all the GDS files from the tech folder
import os, fnmatch
import os
import fnmatch
dir_path = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../gds/EBeam_SiN"))
if verbose:
print(' library path: %s' % dir_path)
Expand Down
2 changes: 1 addition & 1 deletion klayout/EBeam/pymacros/broken/TestStruct_DoubleBus_Ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def produce_impl(self):
if lib == None:
raise Exception("Unknown lib 'EBeam_Beta'")

pcell_decl = lib.layout().pcell_declaration("DoubleBus_Ring");
pcell_decl = lib.layout().pcell_declaration("DoubleBus_Ring")
if pcell_decl == None:
raise Exception("Unknown PCell 'DoubleBus_Ring'")
param = {
Expand Down
3 changes: 1 addition & 2 deletions klayout/EBeam/pymacros/broken/phc_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pya
from pya import *
from SiEPIC.utils import get_technology, get_technology_by_name
from SiEPIC.utils import arc, arc_wg, arc_to_waveguide, points_per_circle#,layout
from SiEPIC.utils import get_technology_by_name
import math

class phc_test(pya.PCellDeclarationHelper):
Expand Down
2 changes: 1 addition & 1 deletion klayout/EBeam/pymacros/pcells_EBeam/Waveguide.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self):
# Important: initialize the super class
super(Waveguide, self).__init__()

from SiEPIC.utils import get_technology_by_name, load_Waveguides_by_Tech
from SiEPIC.utils import load_Waveguides_by_Tech

'''
# https://github.com/KLayout/klayout/issues/879
Expand Down
2 changes: 1 addition & 1 deletion klayout/EBeam/pymacros/pcells_EBeam/Waveguide_SBend.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def produce_impl(self):
ly = self.layout
shapes = self.cell.shapes

from SiEPIC.utils.layout import layout_waveguide_sbend, layout_waveguide_sbend_bezier
from SiEPIC.utils.layout import layout_waveguide_sbend_bezier
from SiEPIC.extend import to_itype

LayerSi = self.layer
Expand Down
7 changes: 3 additions & 4 deletions klayout/EBeam/pymacros/pcells_EBeam/Waveguide_bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def coerce_parameters_impl(self):
else:
mult = 1
self.radius = float(params[0]['radius']) * mult
from SiEPIC.extend import to_itype
self.wg_width = float(params[0]['width'])


Expand All @@ -73,7 +72,7 @@ def produce_impl(self):
ly = self.layout
shapes = self.cell.shapes

from SiEPIC.utils import get_technology_by_name, load_Waveguides_by_Tech
from SiEPIC.utils import get_technology_by_name
TECHNOLOGY = get_technology_by_name('EBeam')
params = [t for t in self.waveguide_types if t['name'] == self.waveguide_type]
layer = [wg['layer'] for wg in params[0]['component']]
Expand All @@ -88,8 +87,8 @@ def produce_impl(self):
LayerDevRecN = ly.layer(self.devrec)
LayerTextN = ly.layer(self.text)

from math import pi, cos, sin, log, sqrt
from SiEPIC.utils import arc, arc_to_waveguide, points_per_circle, arc_wg
from math import pi, cos, sin
from SiEPIC.utils import arc_wg

x = 0
y = 0
Expand Down
3 changes: 1 addition & 2 deletions klayout/EBeam/pymacros/pcells_EBeam/Wireguide.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def parameters_from_shape_impl(self):

def produce_impl(self):

from SiEPIC.utils import arc_xy, arc_bezier, angle_vector, angle_b_vectors, inner_angle_b_vectors, translate_from_normal
from math import cos, sin, pi, sqrt
from SiEPIC.utils import arc_xy, arc_bezier, angle_vector, angle_b_vectors, inner_angle_b_vectors
import pya
from SiEPIC.extend import to_itype

Expand Down
3 changes: 2 additions & 1 deletion klayout/EBeam/pymacros/pcells_EBeam/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os, sys
import os
import sys
import SiEPIC

from SiEPIC.utils import get_technology_by_name
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ def produce_impl(self):
shapes_wg += box3

# Create the pins on the waveguides, as short paths:
from SiEPIC._globals import PIN_LENGTH as pin_length

w1 = to_itype(self.wg1_width, dbu)
w2 = to_itype(self.wg2_width, dbu)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def can_create_from_shape_impl(self):
def produce_impl(self):
# This is the main part of the implementation: create the layout

from math import pi, cos, sin
from SiEPIC.utils import arc_wg, arc_wg_xy
from SiEPIC.utils import arc_wg_xy
from SiEPIC._globals import PIN_LENGTH

# fetch the parameters
Expand Down
3 changes: 1 addition & 2 deletions klayout/EBeam/pymacros/pcells_EBeam/wg_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def coerce_parameters_impl(self):
params = [t for t in self.waveguide_types if t['name'] == self.waveguide_type]
if not params:
raise Exception ('Waveguides.XML not correctly configured')
from SiEPIC.extend import to_itype
self.wg_width = float(params[0]['width'])

def can_create_from_shape_impl(self):
Expand Down Expand Up @@ -93,7 +92,7 @@ def produce_impl(self):
ly = self.layout
shapes = self.cell.shapes

from SiEPIC.utils import get_technology_by_name, load_Waveguides_by_Tech
from SiEPIC.utils import get_technology_by_name
TECHNOLOGY = get_technology_by_name('EBeam')
params = [t for t in self.waveguide_types if t['name'] == self.waveguide_type]
layer = [wg['layer'] for wg in params[0]['component']]
Expand Down
1 change: 0 additions & 1 deletion klayout/EBeam/pymacros/pcells_EBeam_Beta/Bezier_Bend.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def produce_impl(self):

from SiEPIC.utils import arc_bezier
from SiEPIC._globals import PIN_LENGTH as pin_length
from SiEPIC.extend import to_itype
wg_width = self.wg_width
w = self.wg_width/dbu

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pya
from pya import *
import math
from SiEPIC.utils import get_technology_by_name

class BraggWaveguide_holes(pya.PCellDeclarationHelper):
Expand Down
2 changes: 1 addition & 1 deletion klayout/EBeam/pymacros/pcells_EBeam_Beta/Bragg_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def produce_impl(self):
LayerDevRecN = ly.layer(self.devrec)

from SiEPIC.extend import to_itype
from math import pi, cos, sin, acos
from math import pi, sin

N = int(self.N)
#draw the encoded bragg grating:
Expand Down
13 changes: 6 additions & 7 deletions klayout/EBeam/pymacros/pcells_EBeam_Beta/Contra_DC_Bent.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def produce(self, layout, layers, parameters, cell):
# length units in dbu

from math import pi, cos, sin
from SiEPIC.utils import arc_wg, arc_wg_xy
from SiEPIC._globals import PIN_LENGTH
from SiEPIC.utils import arc_wg_xy

# fetch the parameters
dbu = self.layout.dbu
Expand Down Expand Up @@ -98,9 +97,9 @@ def produce(self, layout, layers, parameters, cell):
# Bend radius of bus
rBus = r + gap + w_bus/2 +w_ring/2

N_input = N;
N_input = N
# Normalized number of corrugations to periodAngle
N = N*periodAngle*2;
N = N*periodAngle*2

# Convention: Set A is the CDC portion that is not offsetted, set B is offsetted by corrugation width

Expand Down Expand Up @@ -141,8 +140,8 @@ def produce(self, layout, layers, parameters, cell):

bendAngleRad = (pi/180) * bendAngle
# Draw Bus non-CDC Waveguide
y_center = rBus * cos(bendAngleRad) + busBendR * cos(bendAngleRad);
x_center = rBus * sin(bendAngleRad) + busBendR * sin(bendAngleRad);
y_center = rBus * cos(bendAngleRad) + busBendR * cos(bendAngleRad)
x_center = rBus * sin(bendAngleRad) + busBendR * sin(bendAngleRad)

self.cell.shapes(LayerSiN).insert(arc_wg_xy(x_center,y_center, busBendR, w_bus, 270-bendAngle,270))
self.cell.shapes(LayerSiN).insert(arc_wg_xy(-x_center,y_center, busBendR, w_bus, 270, 270-bendAngle))
Expand All @@ -151,7 +150,7 @@ def produce(self, layout, layers, parameters, cell):
from SiEPIC._globals import PIN_LENGTH as pin_length

# Pin on the right side:
y_center = rBus * cos(bendAngleRad) + busBendR * cos(bendAngleRad) - busBendR;
y_center = rBus * cos(bendAngleRad) + busBendR * cos(bendAngleRad) - busBendR
p2 = [Point(-pin_length/2 +x_center, y_center), Point(pin_length/2 +x_center, y_center)]
p2c = Point(x_center, y_center)
self.set_p2 = p2c
Expand Down
Loading

0 comments on commit 8b637c3

Please sign in to comment.