diff --git a/gds_helpers.py b/gds_helpers.py index 14c7f35..44fc4cd 100644 --- a/gds_helpers.py +++ b/gds_helpers.py @@ -15,15 +15,15 @@ def gds_cross_section(gds_file, cut_segment, layer_map=None): layer_map: optional filename for GDS map file. If present, the returned dictionary's keys will be layer names instead of numbers.''' cut_segment = geometry.LineString(cut_segment) - cell = gdsCAD.core.GdsImport(gds_file).values()[0] + cell = list(gdsCAD.core.GdsImport(gds_file).values())[0] layers = {layer: polygons_to_cross_section(polygons, cut_segment) - for layer, polygons in cell_to_MultiPolygon(cell).items()} + for layer, polygons in list(cell_to_MultiPolygon(cell).items())} if layer_map is None: self.layers = layers else: layer_map = load_gds_map(layer_map) layers = {layer_map[layer]: geometry - for layer, geometry in layers.items()} + for layer, geometry in list(layers.items())} return layers def load_gds_map(filename): diff --git a/geometry_helpers.py b/geometry_helpers.py index a650deb..b05bbe5 100644 --- a/geometry_helpers.py +++ b/geometry_helpers.py @@ -28,10 +28,10 @@ def plot_geometry(geometry, axes=None, **kwargs): if axes is None: axes = pyplot.gca() polygons = ensure_multipolygon(geometry) - for polygon in polygons: + for polygon in polygons.geoms: xy = numpy.column_stack( polygon.exterior.xy) axes.add_patch(matplotlib.patches.Polygon(xy, **kwargs)) - axes.update_datalim(zip(polygon.bounds[::2], polygon.bounds[1::2])) + axes.update_datalim(list(zip(polygon.bounds[::2], polygon.bounds[1::2]))) # Only first polygon needs a legend entry kwargs.pop('label', None) axes.autoscale() @@ -49,7 +49,7 @@ def plot_geometryref(geometryref, axes=None, **kwargs): def multilinestring_to_segments(multilinestring): return [[point[0] for point in segment.coords] - for segment in ensure_multilinestring(multilinestring)] + for segment in ensure_multilinestring(multilinestring).geoms] class GeometryReference(object): '''Pointer to shapely geometry''' @@ -71,8 +71,8 @@ def polygons_to_cross_section(polygons, cut_segment): cut_segment.intersection(side)) if intersection > cuts[0] and intersection < cuts[-1] \ and intersection not in cuts: - index = (ii for ii, element in enumerate(cuts) - if element > intersection).next() + index = next((ii for ii, element in enumerate(cuts) + if element > intersection)) cuts.insert(index, intersection) present = [False] * (len(cuts) - 1) for polygon in polygons: diff --git a/hole.py b/hole.py index 4800ab4..08bfd2a 100644 --- a/hole.py +++ b/hole.py @@ -6,8 +6,8 @@ original_coords = [ (0,0), (3,0), (3, 1.5-gap), (2,1.5-gap), (2,1), (1,1), (1,2), (2.2,2), (2.2,1.5+gap), (2.8,1.5+gap), (2.8,3), (0,3)] -original_segments = map(shapely.geometry.LineString, zip(original_coords[:-1], - original_coords[1:])) +original_segments = list(map(shapely.geometry.LineString, list(zip(original_coords[:-1], + original_coords[1:])))) # Split segments at every intersection all_coords = [] for ii, segmentA in enumerate(original_segments): @@ -20,7 +20,7 @@ segmentA = shapely.geometry.LineString([coordB, segmentA.coords[1]]) all_coords.append(segmentA.coords[1]) -print all_coords +print(all_coords) # Separate interior from exterior processed = [] @@ -41,11 +41,11 @@ ii += 1 processed.append(current) -print processed +print(processed) #plot_geometryref(GeometryReference(holey)) from itertools import cycle colors = cycle('rgbcmyk') for p in processed: - plt.plot(*zip(*p), linestyle='solid', marker='x', color=next(colors)) + plt.plot(*list(zip(*p)), linestyle='solid', marker='x', color=next(colors)) #plt.plot(*zip(*exterior), linestyle='solid', marker='o', color='b') plt.show() diff --git a/mypmos-x.png b/mypmos-x.png index 319111c..439accc 100644 Binary files a/mypmos-x.png and b/mypmos-x.png differ diff --git a/planarprocess.py b/planarprocess.py index e2d66d9..02ede42 100644 --- a/planarprocess.py +++ b/planarprocess.py @@ -48,8 +48,8 @@ def grow(self, height, mask, base=None, consuming=None, outdiffusion=0., ret = GeometryReference(top.geometry.union(bottom.geometry)) self.solids.append(ret) return ret - base_union = shapely.ops.cascaded_union([b.geometry for b in base]) - consuming_union = shapely.ops.cascaded_union( + base_union = shapely.ops.unary_union([b.geometry for b in base]) + consuming_union = shapely.ops.unary_union( [c.geometry for c in consuming]) whole_interface = base_union.intersection(consuming_union) buried = numpy.sign(height) != numpy.sign(y_offset) @@ -62,6 +62,8 @@ def grow(self, height, mask, base=None, consuming=None, outdiffusion=0., self.air.geometry.bounds[3]))) if isinstance(interface, shapely.geometry.Point): continue + if isinstance(interface, shapely.geometry.MultiLineString): + interface = interface.geoms; for linestring in interface: if not isinstance(linestring, shapely.geometry.LineString): # Don't want Points and other strange bits of the @@ -96,7 +98,7 @@ def grow(self, height, mask, base=None, consuming=None, outdiffusion=0., 0, 2 * numpy.pi, outdiffusion_vertices))) # Only consume from specified geometry - ret = shapely.ops.cascaded_union(polygons).intersection( + ret = shapely.ops.unary_union(polygons).intersection( consuming_union) for c in consuming: c.geometry = c.geometry.difference(ret) @@ -141,7 +143,7 @@ def implant(self, depth, mask, target=None, source=None, buried=0., def planarize(self): '''Etch down to the lowest point of the wafer surface''' - base_union = shapely.ops.cascaded_union([s.geometry + base_union = shapely.ops.unary_union([s.geometry for s in self.solids]) whole_interface = base_union.intersection(self.air.geometry) min_y = whole_interface.bounds[1] diff --git a/test.py b/test.py index c12f606..3f8883f 100644 --- a/test.py +++ b/test.py @@ -55,10 +55,10 @@ # Presentation custom_style = {s: {} for s in wafer.solids} -for solid, color in { +for solid, color in list({ fox: '.4', gox: 'r', poly: 'g', mld: 'k', ild1: '.3', contact: '.5', via1: '.5', - metal1: '.7', metal2: '.8'}.items(): + metal1: '.7', metal2: '.8'}.items()): custom_style[solid].update(dict(facecolor=color, edgecolor='k')) for solid in wafer.solids: diff --git a/test_nwell.py b/test_nwell.py index 1eb7ed6..c965d59 100644 --- a/test_nwell.py +++ b/test_nwell.py @@ -11,7 +11,7 @@ # N-Well nw = layers['N-Well'] -print nw +print(nw) wafer.implant(.7, nw, outdiffusion=0., label='N-Well') present(wafer) pyplot.legend()