Skip to content

Commit

Permalink
Merge pull request #160 from amccaugh/dev
Browse files Browse the repository at this point in the history
1.6.2
  • Loading branch information
amccaugh authored Jul 26, 2022
2 parents 6bb30ef + a3385d7 commit a2e6215
Show file tree
Hide file tree
Showing 14 changed files with 485 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
pytest:
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
fail-fast: false
runs-on: ubuntu-latest
steps:
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 1.6.2 (July 25, 2022)

### New features
- Addition of `pg.snspd_candelabra()` which creates an optimally-rounded SNSPD with low current crowding and arbtitrarily-high fill factor (thanks Dileep Reddy @dileepvr)
- Lazy loading of `matplotlib`, allowing loading the base phidl libraries much faster (thanks Joaquin Matres @joamatab)


### Changes
- Modification to `pg.boolean()` s othat `OR`/union will merge all shapes within one Device, even if the second Device is `None` (thanks
Stijn Balk @sbalk)

### Bugfixes
- Modifying the `parent` of a `DeviceReference` now correctly updates the reference cell (thanks Joaquin Matres @joamatab)
- Fix bug in `pg.outline()` when `distance < 0` (thanks @yoshi74ls181)
- GDS path objects now copy over when using `pg.import_gds()` (thanks Bas Nijholt @basnijholt)
- Preserve Polygon.properties and DeviceReference.properties when saving and loading (thanks Bas Nijholt @basnijholt)
- `D.remove_layers()` works also with GDS path objects (thanks Joaquin Matres @joamatab)


## 1.6.1 (April 7, 2022)

### New features
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GDS scripting for Python that's intuitive, fast, and powerful.
- [**Installation / requirements**](#installation--requirements)
- [**Tutorial + examples**](https://phidl.readthedocs.io/en/latest/tutorials.html) (or [try an interactive notebook](https://mybinder.org/v2/gh/amccaugh/phidl/master?filepath=phidl_tutorial_example.ipynb))
- [**Geometry library + function documentation**](https://phidl.readthedocs.io/en/latest/geometry_reference.html)
- [Changelog](https://github.com/amccaugh/phidl/blob/master/CHANGELOG.md) (latest update 1.6.1 on April 7, 2022)
- [Changelog](https://github.com/amccaugh/phidl/blob/master/CHANGELOG.md) (latest update 1.6.2 on July 25, 2022)
- Huge new routing rewrite for `phidl.routing`, including automatic manhattan routing with custom cross-sections! See [the routing documentation](https://phidl.readthedocs.io/en/latest/tutorials/routing.html) for details. Big thanks to Jeffrey Holzgrafe @jolzgrafe for this contribution
- `Path`s can now be used to produce sharp angles, in addition to smooth bends. See [the Path documentation](https://phidl.readthedocs.io/en/latest/tutorials/waveguides.html#Sharp/angular-paths)

Expand All @@ -30,7 +30,7 @@ If you found PHIDL useful, please consider citing it in (just one!) of your publ

# Installation / requirements
- Install or upgrade with `pip install -U phidl`
- Python version >=3.5
- Python version >=3.6
- If you are on Windows or Mac and don't already have `gdspy` installed, you will need a C++ compiler
- For Windows + Python 3, install ["Build Tools for Visual Studio"](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) (make sure to check the "C++ build tools" checkbox when installing)
- For Mac, install "Xcode" from the App Store, then run the command `xcode-select --install` in the terminal
Expand Down
6 changes: 6 additions & 0 deletions docs/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ snspd_expanded
.. autofunction:: phidl.geometry.snspd_expanded


snspd_candelabra
==============

.. autofunction:: phidl.geometry.snspd_candelabra


straight
========

Expand Down
8 changes: 4 additions & 4 deletions docs/gen_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class B(*):
if os.stat(fwrite).st_size == 0:
fw.write(
"#" * len(main_header)
+ "\n{}\n".format(main_header)
+ f"\n{main_header}\n"
+ "#" * len(main_header)
+ "\n\n\n"
)
Expand All @@ -81,7 +81,7 @@ class B(*):
fread_header = fread_header.capitalize()
fw.write(
"*" * (len(fread_header) + len(sub_header))
+ "\n{}{}\n".format(fread_header, sub_header)
+ f"\n{fread_header}{sub_header}\n"
+ "*" * (len(fread_header) + len(sub_header))
+ "\n\n"
)
Expand Down Expand Up @@ -116,14 +116,14 @@ class B(*):
fw.write(name[0] + "\n")
fw.write(("=" * len(name[0])) + "\n\n")
if name[1] == "C":
fw.write(".. autoclass:: phidl.{}.{}\n".format(fread_name, name[0]))
fw.write(f".. autoclass:: phidl.{fread_name}.{name[0]}\n")
fw.write(
" :members:\n"
" :inherited-members:\n"
" :show-inheritance:\n\n\n"
)
else:
fw.write(".. autofunction:: phidl.{}.{}\n\n\n".format(fread_name, name[0]))
fw.write(f".. autofunction:: phidl.{fread_name}.{name[0]}\n\n\n")
fw.close()


Expand Down
80 changes: 66 additions & 14 deletions docs/geometry_reference.ipynb

Large diffs are not rendered by default.

32 changes: 26 additions & 6 deletions phidl/device_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@


import hashlib
import numbers
import warnings
from copy import deepcopy as _deepcopy

Expand All @@ -51,7 +52,7 @@

gdspy.library.use_current_library = False

__version__ = "1.6.1"
__version__ = "1.6.2"


# ==============================================================================
Expand Down Expand Up @@ -540,7 +541,7 @@ def _parse_layer(layer):
gds_layer, gds_datatype = layer[0], 0
elif layer is None:
gds_layer, gds_datatype = 0, 0
elif isinstance(layer, (int, float)):
elif isinstance(layer, numbers.Number):
gds_layer, gds_datatype = layer, 0
else:
raise ValueError(
Expand Down Expand Up @@ -1206,9 +1207,13 @@ def add_polygon(self, points, layer=np.nan):
layers = zip(points.layers, points.datatypes)
else:
layers = [layer] * len(points.polygons)
return [
self.add_polygon(p, layer) for p, layer in zip(points.polygons, layers)
]

polygons = []
for p, layer in zip(points.polygons, layers):
new_polygon = self.add_polygon(p, layer)
new_polygon.properties = points.properties
polygons.append(new_polygon)
return polygons

if layer is np.nan:
layer = 0
Expand Down Expand Up @@ -1516,6 +1521,14 @@ def remove_layers(self, layers=(), include_labels=True, invert_selection=False):
p for p, keep in zip(polygonset.datatypes, polygons_to_keep) if keep
]

paths = []
for path in D.paths:
for layer in zip(path.layers, path.datatypes):
if layer not in layers:
paths.append(path)

D.paths = paths

if include_labels:
new_labels = []
for l in D.labels:
Expand Down Expand Up @@ -1907,7 +1920,6 @@ def __init__(
x_reflection=x_reflection,
ignore_missing=False,
)
self.parent = device
self.owner = None
# The ports of a DeviceReference have their own unique id (uid),
# since two DeviceReferences of the same parent Device can be
Expand All @@ -1916,6 +1928,14 @@ def __init__(
name: port._copy(new_uid=True) for name, port in device.ports.items()
}

@property
def parent(self):
return self.ref_cell

@parent.setter
def parent(self, value):
self.ref_cell = value

def __repr__(self):
"""Prints a description of the DeviceReference, including parent
Device, ports, origin, rotation, and x_reflection.
Expand Down
2 changes: 1 addition & 1 deletion phidl/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _get_glyph(font, letter): # noqa: C901
# If there is no postscript name, use the family name
font_name = font.family_name.replace(" ", "_")

block_name = "*char_{}_0x{:2X}".format(font_name, ord(letter))
block_name = f"*char_{font_name}_0x{ord(letter):2X}"

# Load control points from font file
font.load_char(letter, freetype.FT_LOAD_FLAGS["FT_LOAD_NO_BITMAP"])
Expand Down
Loading

0 comments on commit a2e6215

Please sign in to comment.