File: tutils.py

package info (click to toggle)
gdspy 1.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,020 kB
  • sloc: python: 9,180; cpp: 4,716; sh: 39; makefile: 20
file content (56 lines) | stat: -rw-r--r-- 1,943 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
######################################################################
#                                                                    #
#  Copyright 2009-2019 Lucas Heitzmann Gabrielli.                    #
#  This file is part of gdspy, distributed under the terms of the    #
#  Boost Software License - Version 1.0.  See the accompanying       #
#  LICENSE file or <http://www.boost.org/LICENSE_1_0.txt>            #
#                                                                    #
######################################################################

import os
import pytest
import gdspy


@pytest.fixture
def target():
    return gdspy.GdsLibrary(infile="tests" + os.sep + "test.gds").cell_dict


def assertsame(c1, c2, tolerance=1e-6):
    d1 = c1.get_polygons(by_spec=True)
    d2 = c2.get_polygons(by_spec=True)
    for key in d1:
        assert key in d2
        result = gdspy.boolean(
            d1[key], d2[key], "xor", precision=1e-7, layer=key[0], datatype=100
        )
        if result is not None:
            r1 = gdspy.boolean(
                d1[key],
                gdspy.offset(d2[key], tolerance, precision=1e-7),
                "not",
                precision=1e-7,
                layer=key[0],
                datatype=99,
            )
            r2 = gdspy.boolean(
                d2[key],
                gdspy.offset(d1[key], tolerance, precision=1e-7),
                "not",
                precision=1e-7,
                layer=key[0],
                datatype=99,
            )
            # if not (r1 is None and r2 is None):
            #    c1.add(result)
            #    c2.add(result)
            #    if r1 is not None:
            #        c1.add(r1)
            #    if r2 is not None:
            #        c2.add(r2)
            #    gdspy.LayoutViewer(cells=[c1, c2])
            assert r1 is None
            assert r2 is None
        else:
            assert result is None