Skip to content

Commit

Permalink
now using phidl's new hash_geometry function.
Browse files Browse the repository at this point in the history
  • Loading branch information
atait committed Mar 13, 2019
1 parent 61c88e4 commit 63ece97
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 8 additions & 7 deletions lytest/kdb_xor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,17 @@ def run_xor(file1, file2, tolerance=1, verbose=False):
raise GeometryDifference("Differences found between layouts {} and {}".format(*fn_abgd))


def xor_polygons_phidl(A, B, geom_hash=True):
def xor_polygons_phidl(A, B, hash_geom=True):
""" Given two devices A and B, performs a layer-by-layer XOR diff between
A and B, and returns polygons representing the differences between A and B.
"""
import phidl
import phidl.geometry as pg
from phidl import Device
import gdspy
# first do
# first do a geometry hash to vastly speed up if they are equal
if hash_geom and (A.hash_geometry() == B.hash_geometry()):
return Device()

D = phidl.Device()
D = Device()
A_polys = A.get_polygons(by_spec = True)
B_polys = B.get_polygons(by_spec = True)
A_layers = A_polys.keys()
Expand All @@ -106,14 +107,14 @@ def xor_polygons_phidl(A, B, geom_hash=True):
return D


def run_xor_phidl(file1, file2, tolerance=1, verbose=False):
def run_xor_phidl(file1, file2, tolerance=1, verbose=False, hash_geom=True):
import phidl.geometry as pg
from lytest.phidl_oas import import_oas
TOPS = []
for fn in [file1, file2]:
TOPS.append(import_oas(fn))
TOP1, TOP2 = TOPS
XOR = xor_polygons_phidl(TOP1, TOP2)
XOR = xor_polygons_phidl(TOP1, TOP2, hash_geom=True)
if len(XOR.elements) > 0:
raise GeometryDifference("Differences found between layouts {} and {}".format(file1, file2))

Expand Down
6 changes: 3 additions & 3 deletions tests/phidl/test_phidl/test_1_phidldevices.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ def test_phidlXOR():
TOP1 = phidlib.box()
TOP2 = pg.import_gds(ref_file)
TOP_different = phidlib.box(width=100)
for geom_hash in [True, False]:
XOR = xor_polygons_phidl(TOP1, TOP2, geom_hash=geom_hash)
for hash_geom in [True, False]:
XOR = xor_polygons_phidl(TOP1, TOP2, hash_geom=hash_geom)
if len(XOR.elements) > 0:
raise GeometryDifference("Differences found between phidl Devices.")
XOR_different = xor_polygons_phidl(TOP_different, TOP2, geom_hash=geom_hash)
XOR_different = xor_polygons_phidl(TOP_different, TOP2, hash_geom=hash_geom)
assert len(XOR_different.elements) > 0


Expand Down

0 comments on commit 63ece97

Please sign in to comment.