Skip to content

Commit 74756f5

Browse files
authored
Merge pull request #62 from amccaugh/dev
1.2.1
2 parents 52f4745 + 5e97981 commit 74756f5

File tree

8 files changed

+177
-93
lines changed

8 files changed

+177
-93
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PHotonic and Integrated Device Layout - GDS CAD layout and geometry creation for
77
- [**Tutorial + examples**](https://github.com/amccaugh/phidl/blob/master/phidl/phidl_tutorial_example.py#L35) (or [Try now in an interactive notebook](https://mybinder.org/v2/gh/amccaugh/phidl/master?filepath=phidl_tutorial_example.ipynb))
88
- [**Geometry + function documentation**](https://phidl.readthedocs.io/)
99
- [About PHIDL](#about-phidl)
10-
- [Changelog](#changelog) (latest update 1.2.0 (December 1, 2019))
10+
- [Changelog](#changelog) (latest update 1.2.1 (January 13, 2020))
1111

1212
# Installation / requirements
1313
- Install or upgrade with `pip install -U phidl`
@@ -79,6 +79,22 @@ You can also do things like create a backing fill to make sure the resist develo
7979

8080
# Changelog
8181

82+
## 1.2.1 (January 13, 2020)
83+
84+
- Maintenance update to work with `gdspy` 1.5
85+
86+
### New features
87+
- References, arrays and polygons can all be assigned to a Device using `D['myname'] = `
88+
89+
### Changes
90+
- Default precision changed to `1e-4` on boolean functions (for 1 unit = 1 micron, this corresponds to 0.1 nanometer precision)
91+
- Added `join`, `miter` and `max_points` arguments to `pg.offset` to match the arguments with gdspy
92+
- The `Device.label()` function is going to be move to `Device.add_label()` - both will still work for now, but when using `label()` a warning will pop up suggesting you switch to `add_label()` since it will be removed in future versions.
93+
94+
### Bugfixes
95+
- Maintenance update to work with `gdspy` 1.5 (specifically `pg.import_gds()` fixes)
96+
- Allow DeviceReferences to be used with `pg.port_to_geometry()` (thanks Alex Tait @atait )
97+
8298
## 1.2.0 (December 1, 2019)
8399

84100
### New features

phidl/device_layout.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
#==============================================================================
77
# Minor TODO
88
#==============================================================================
9+
# Replace write_gds() with GdsLibrary.write_gds()
910
# geometry: Add packer(), make option to limit die size
10-
# fix remove -- allow removal of labels and cellarrays
11-
# Let both References/Arrays/Polygons to be assigned as D['waveguide'] = D << WG
1211
# add wire_basic to phidl.routing. also add endcap parameter
1312
# make “elements to polygons” general function
1413
# fix boolean with empty device
14+
# make gdspy2phidl command (allow add_polygon to take gdspy things like flexpath)
1515

1616
#==============================================================================
1717
# Imports
@@ -30,8 +30,11 @@
3030
import warnings
3131
import hashlib
3232

33+
# Remove this once gdspy fully deprecates current_library
34+
import gdspy.library
35+
gdspy.library.use_current_library = False
3336

34-
__version__ = '1.2.0'
37+
__version__ = '1.2.1'
3538

3639

3740

@@ -487,7 +490,7 @@ def __lshift__(self, element):
487490

488491
def __setitem__(self, key, element):
489492
""" Allow adding polygons and cell references like D['arc3'] = pg.arc() """
490-
if isinstance(element, DeviceReference):
493+
if isinstance(element, (DeviceReference,Polygon,CellArray)):
491494
self.aliases[key] = element
492495
else:
493496
raise ValueError('[PHIDL] Tried to assign alias "%s" in Device "%s", '
@@ -522,6 +525,7 @@ def add_ref(self, device, alias = None):
522525
raise TypeError("""[PHIDL] add_ref() was passed something that
523526
was not a Device object. """)
524527
d = DeviceReference(device) # Create a DeviceReference (CellReference)
528+
d.owner = self
525529
self.add(d) # Add DeviceReference (CellReference) to Device (Cell)
526530

527531
if alias is not None:
@@ -573,6 +577,7 @@ def add_array(self, device, columns = 2, rows = 2, spacing = (100,100), alias =
573577
raise TypeError("""[PHIDL] add_array() was passed something that
574578
was not a Device object. """)
575579
a = CellArray(device = device, columns = columns, rows = rows, spacing = spacing)
580+
a.owner = self
576581
self.add(a) # Add DeviceReference (CellReference) to Device (Cell)
577582
if alias is not None:
578583
self.aliases[alias] = a
@@ -602,20 +607,21 @@ def add_port(self, name = None, midpoint = (0,0), width = 1, orientation = 45, p
602607
return p
603608

604609

605-
def label(self, text = 'hello', position = (0,0), magnification = None, rotation = None, layer = 255):
610+
def add_label(self, text = 'hello', position = (0,0), magnification = None, rotation = None, anchor = 'o', layer = 255):
606611
if len(text) >= 1023:
607612
raise ValueError('[DEVICE] label() error: Text too long (limit 1024 chars)')
608613
gds_layer, gds_datatype = _parse_layer(layer)
609614

610615
if type(text) is not str: text = str(text)
611-
l = Label(text = text, position = position, anchor = 'o', magnification = magnification, rotation = rotation,
616+
l = Label(text = text, position = position, anchor = anchor, magnification = magnification, rotation = rotation,
612617
layer = gds_layer, texttype = gds_datatype)
613618
self.add(l)
614619
return l
615620

616-
def annotate(self, *args, **kwargs):
617-
warnings.warn('[PHIDL] WARNING: annotate() has been deprecated, please replace with label()')
618-
return self.label(*args, **kwargs)
621+
622+
def label(self, *args, **kwargs):
623+
warnings.warn('[PHIDL] WARNING: label() will be deprecated, please replace with add_label()')
624+
return self.add_label(*args, **kwargs)
619625

620626

621627
def write_gds(self, filename, unit = 1e-6, precision = 1e-9,
@@ -929,6 +935,7 @@ def __init__(self, device, origin=(0, 0), rotation=0, magnification=None, x_refl
929935
x_reflection=x_reflection,
930936
ignore_missing=False)
931937
self.parent = device
938+
self.owner = None
932939
# The ports of a DeviceReference have their own unique id (uid),
933940
# since two DeviceReferences of the same parent Device can be
934941
# in different locations and thus do not represent the same port
@@ -1040,6 +1047,9 @@ def move(self, origin = (0,0), destination = None, axis = None):
10401047
# This needs to be done in two steps otherwise floating point errors can accrue
10411048
dxdy = np.array(d) - np.array(o)
10421049
self.origin = np.array(self.origin) + dxdy
1050+
1051+
if self.owner is not None:
1052+
self.owner._bb_valid = False
10431053
return self
10441054

10451055

@@ -1048,6 +1058,9 @@ def rotate(self, angle = 45, center = (0,0)):
10481058
if type(center) is Port: center = center.midpoint
10491059
self.rotation += angle
10501060
self.origin = _rotate_points(self.origin, angle, center)
1061+
1062+
if self.owner is not None:
1063+
self.owner._bb_valid = False
10511064
return self
10521065

10531066

@@ -1073,6 +1086,8 @@ def reflect(self, p1 = (0,1), p2 = (0,0)):
10731086
self.rotation += angle
10741087
self.origin = self.origin + p1
10751088

1089+
if self.owner is not None:
1090+
self.owner._bb_valid = False
10761091
return self
10771092

10781093

@@ -1108,6 +1123,7 @@ def __init__(self, device, columns, rows, spacing, origin=(0, 0),
11081123
x_reflection=x_reflection,
11091124
ignore_missing=False)
11101125
self.parent = device
1126+
self.owner = None
11111127

11121128
@property
11131129
def bbox(self):
@@ -1143,6 +1159,9 @@ def move(self, origin = (0,0), destination = None, axis = None):
11431159
# This needs to be done in two steps otherwise floating point errors can accrue
11441160
dxdy = np.array(d) - np.array(o)
11451161
self.origin = np.array(self.origin) + dxdy
1162+
1163+
if self.owner is not None:
1164+
self.owner._bb_valid = False
11461165
return self
11471166

11481167

@@ -1151,6 +1170,8 @@ def rotate(self, angle = 45, center = (0,0)):
11511170
if type(center) is Port: center = center.midpoint
11521171
self.rotation += angle
11531172
self.origin = _rotate_points(self.origin, angle, center)
1173+
if self.owner is not None:
1174+
self.owner._bb_valid = False
11541175
return self
11551176

11561177

@@ -1176,6 +1197,8 @@ def reflect(self, p1 = (0,1), p2 = (0,0)):
11761197
self.rotation += angle
11771198
self.origin = self.origin + p1
11781199

1200+
if self.owner is not None:
1201+
self.owner._bb_valid = False
11791202
return self
11801203

11811204

0 commit comments

Comments
 (0)