use is_scalar for checking if layer is a tuple

This commit is contained in:
jan 2018-04-14 15:02:13 -07:00
parent 3e06214b7e
commit e4545bfa30

View File

@ -13,7 +13,7 @@ import numpy
from .utils import mangle_name, make_dose_table from .utils import mangle_name, make_dose_table
from .. import Pattern, SubPattern, PatternError from .. import Pattern, SubPattern, PatternError
from ..shapes import Polygon from ..shapes import Polygon
from ..utils import rotation_matrix_2d, get_bit, vector2 from ..utils import rotation_matrix_2d, get_bit, set_bit, vector2, is_scalar
__author__ = 'Jan Petykiewicz' __author__ = 'Jan Petykiewicz'
@ -76,15 +76,15 @@ def write(patterns: Pattern or List[Pattern],
for polygon in shape.to_polygons(): for polygon in shape.to_polygons():
xy_open = numpy.round(polygon.vertices + polygon.offset).astype(int) xy_open = numpy.round(polygon.vertices + polygon.offset).astype(int)
xy_closed = numpy.vstack((xy_open, xy_open[0, :])) xy_closed = numpy.vstack((xy_open, xy_open[0, :]))
if hasattr(polygon.layer, '__len__'): if is_scalar(polygon.layer):
layer = polygon.layer
data_type = 0
else:
layer = polygon.layer[0] layer = polygon.layer[0]
if len(polygon.layer) > 1: if len(polygon.layer) > 1:
data_type = polygon.layer[1] data_type = polygon.layer[1]
else: else:
data_type = 0 data_type = 0
else:
layer = polygon.layer
data_type = 0
structure.append(gdsii.elements.Boundary(layer=layer, structure.append(gdsii.elements.Boundary(layer=layer,
data_type=data_type, data_type=data_type,
xy=xy_closed)) xy=xy_closed))
@ -184,10 +184,10 @@ def write_dose2dtype(patterns: Pattern or List[Pattern],
data_type = dose_vals_list.index(polygon.dose * pat_dose) data_type = dose_vals_list.index(polygon.dose * pat_dose)
xy_open = numpy.round(polygon.vertices + polygon.offset).astype(int) xy_open = numpy.round(polygon.vertices + polygon.offset).astype(int)
xy_closed = numpy.vstack((xy_open, xy_open[0, :])) xy_closed = numpy.vstack((xy_open, xy_open[0, :]))
if hasattr(polygon.layer, '__len__'): if is_scalar(polygon.layer):
layer = polygon.layer[0]
else:
layer = polygon.layer layer = polygon.layer
else:
layer = polygon.layer[0]
structure.append(gdsii.elements.Boundary(layer=layer, structure.append(gdsii.elements.Boundary(layer=layer,
data_type=data_type, data_type=data_type,
xy=xy_closed)) xy=xy_closed))