Commit Graph

410 Commits

Author SHA1 Message Date
1bb4bd6bb7 add py.typed to enable type checking for downstream 2020-05-19 00:15:51 -07:00
8082743e17 move dose2dtype() into masque.file.utils, add dtype2dose(), and add a note that use_dtype_as_dose 2020-05-19 00:13:50 -07:00
1b0b056bf9 break out build() which returns the gdsii.library.Library object 2020-05-19 00:03:29 -07:00
d7a8bd7e0d Allow b_count=None 2020-05-17 23:00:25 -07:00
22b2834d55 Documentation improvements 2020-05-17 22:59:54 -07:00
f9fb7ccad3 move gdsii import below standard packages 2020-05-17 17:22:50 -07:00
5bd1e85d89 add experimental support for dxf 2020-05-17 14:13:01 -07:00
f260fe1374 comment fixup 2020-05-17 14:12:38 -07:00
8a404a2602 Allow setting subpattern identifier in constructors 2020-05-17 14:12:27 -07:00
8302286a7a allow using a string for the layer
Can't use it in gdsii, but no reason to forbit it in masque...
2020-05-17 14:11:47 -07:00
247b31a9d6 Don't include None in referenced_patterns_by_id() by default 2020-05-17 14:05:19 -07:00
5c6c10d2be fix repetition __repr__ 2020-05-12 14:17:50 -07:00
f312f50751 some typing clarifications 2020-05-12 14:17:35 -07:00
ee8f015172 add subpattern_t type (generalizattion of SubPattern and GridRepetition) 2020-05-12 14:17:17 -07:00
6b09fc0c20 make section comments more prominent 2020-05-11 20:31:35 -07:00
a440f2e256 add Shape.set_layer() 2020-05-11 20:31:21 -07:00
c236fdb81b Add __repr__ methods to most objects`
These are closer to what __str__ should be and will likely change in the
future.
2020-05-11 20:31:07 -07:00
c79eee2a8c Stricter locking (lock contained ndarrays and turn lists into tuples) 2020-05-11 19:29:00 -07:00
79990e3806 cosmetic changes 2020-05-11 19:10:00 -07:00
157df47884 Improve type annotations based on mypy errors 2020-05-11 19:09:35 -07:00
bd4085365f Path should create a Path, not a Polygon 2020-05-11 19:04:25 -07:00
9bfb3bef9f avoid unnecessarily nested classes
Still provide a class variable for convenience
2020-05-11 19:03:55 -07:00
d33afc2bfd disambiguate some variable names 2020-05-11 19:01:02 -07:00
f8e347c997 fix scale -> scale_by 2020-05-11 19:00:25 -07:00
8493364e9c Use a tuple for .identifier 2020-05-11 18:59:47 -07:00
00394a62f0 Formally allow instances to point to None (i.e. an 'empty' pattern) 2020-05-11 18:58:57 -07:00
f8c49cdb5e Add setter/getter for .pattern to catch wrong types 2020-05-11 18:52:17 -07:00
fa8fc52dd6 Improve consistency of ndarray members 2020-05-11 18:49:30 -07:00
9fa527ea11 improve handling of patterns with no bounding box 2020-05-11 18:42:31 -07:00
334633662e Remove extra __author__ declarations 2020-05-11 18:41:13 -07:00
df179c9233 Improve type annotations for layer 2020-05-11 18:39:02 -07:00
95ab0934b7 bump version to v1.3 2020-03-14 15:54:20 -07:00
e9244055c6 Add type check for SubPattern's pattern arg 2020-03-14 15:53:35 -07:00
a4f556c3b3 clarify docs for referenced_patterns_by_id() 2020-03-14 15:53:05 -07:00
e684bd0e40 add Pattern.find_toplevel()
Topological sort for lists of Pattern objects, useful for finding top
cell of gds
2020-03-14 15:52:49 -07:00
9f27a5093a add Pattern.referenced_patterns_by_name() 2020-03-14 15:52:10 -07:00
jan
5adabfd25a Docstring format change
(new param and return format)
Also some minor code formatting fixes in utils
2020-02-17 21:02:53 -08:00
jan
20981f10b9 Fix error name
InvalidDataError -> PatternError
2020-02-16 18:17:28 -08:00
jan
a930c65d42 fix gridrepetition mirror 2020-02-10 10:09:07 -08:00
2a53d8ef4d bump version to 1.2 2020-02-07 23:49:53 -08:00
0db70d2c50 Change GridRepetition rotation/mirrored/scale properties so that they consistently apply only to the individual instances; the rotate()/mirror()/scale_by() functions apply to the full array. Add *_elements() versions of the functions 2020-02-07 23:01:14 -08:00
64b8e4dec8 Fix duplicates in gds with multiple top-level cells
Since the different patterns we are handed might reference the same
Patterns, we have to deepcopy the entire list at once so that we
don't make multiple copies of them.
2020-01-07 22:17:00 -08:00
jan
5ba67af816 bump version to 1.1 2019-12-31 13:56:18 -08:00
25c9e591cb shapes: unlock before modifying during deepcopy 2019-12-13 21:18:31 -08:00
f2e6548d21 fix locking issue in __deepcopy__ 2019-12-13 21:18:31 -08:00
e0db621595 allow locking of all objects 2019-12-13 21:18:31 -08:00
09711116a7 allow more freedom in pattern names (e.g. names which violate spec, longer suffixes, filter warning, etc) 2019-12-12 01:48:36 -08:00
df9c4b52f4 add some todos 2019-12-12 01:48:24 -08:00
fcc4770534 Mirroring fix for gdsii import 2019-12-11 21:16:31 -08:00
97b7eda21a Force repetition counts to be integers 2019-12-06 22:28:11 -08:00
f3669f2dfd fixup mirroring for subpatterns 2019-12-06 22:19:16 -08:00
4bc51f765f custom __copy__ for SubPattern and GridRepetition
the difference between copy/deepcopy should be whether a copy is made of
the contained pattern
2019-12-06 22:19:11 -08:00
7b0a567625 .mirrored should be an ndarray 2019-12-04 23:30:46 -08:00
bece3136be Bump version number to 1.0
Note MAJOR incompatibilities with previous version, including
- order of Pattern() args
- save format
- i/o functions
2019-09-30 23:54:21 -07:00
f471374b68 Use separate VERSION file 2019-09-27 21:03:52 -07:00
2259e7987b don't rename shape.to_polygons() args 2019-06-09 23:59:55 -07:00
e5f28a7a92 Fix Pattern.get_bounds() 2019-06-09 23:57:54 -07:00
6801ee7fc0 Account for rotation/mirror in Pattern.dfs() 2019-05-25 12:41:51 -07:00
b5bd7cd9c8 Pattern.get_bounds() should return None if it's empty
s
2019-05-25 12:41:30 -07:00
49982f1207 Add newlines to long log messages 2019-05-25 12:40:17 -07:00
jan
dcd8324eb4 Use to_polygons() for bounds calculation for simple path shapes 2019-05-20 21:06:28 -07:00
jan
2c9af3f63f Simplify normalize_mirror 2019-05-20 21:04:31 -07:00
jan
0ab5674fb9 strans needs starting value (0) 2019-05-20 21:04:07 -07:00
02c3d300e0 Wrap long lines (cosmetic) 2019-05-18 15:05:38 -07:00
75b42f6b63 Use normalize_mirror for all 2d-to-1d mirroring 2019-05-18 15:05:30 -07:00
194a90fe7a Add Pattern.dfs()
Depth-first traversal with hierarchy and transform tracking
2019-05-18 15:05:05 -07:00
76f213a7ce use .identifier instead of the dynamically-created .ref_name 2019-05-17 20:51:53 -07:00
ca80b14ee4 Fix text get_bounds
was addressing list using numpy slices
2019-05-17 01:20:10 -07:00
67c9b510cb Rename svg functions to reflect their gds counterparts
Backwards incompatible!
2019-05-17 01:16:18 -07:00
503a77925e Move away from __dict__ style save/load
Incompatible with previous versions, but necessary given the move to
__slots__.

Also use pickle.HIGHEST_PROTOCOL
2019-05-17 00:44:10 -07:00
28084dfe45 Make name the first argument to Pattern() init
Major incompatibility with previous versions!!
2019-05-17 00:42:55 -07:00
a154555902 Add TODO noting that polygon mirroring could be normalized 2019-05-17 00:42:14 -07:00
f00d283c56 Add missing imports 2019-05-17 00:41:43 -07:00
032c410b43 Add mirror_x to extrinsic properties
It's not implemented for Polygon shapes, since I haven't thought about
how to normalize those for reflection yet
2019-05-17 00:41:26 -07:00
2e54cf1080 initialize identifier for text shapes 2019-05-17 00:39:56 -07:00
16c6bfc70a Cosmetic changes to argument lists 2019-05-17 00:39:46 -07:00
58353b7884 Remove orphaned comment 2019-05-17 00:38:20 -07:00
38f64f7c62 Use __slots__ for class members
Also use the other sort of type hints for instance variables
2019-05-17 00:37:56 -07:00
0b962999b2 Add arbitrary identifier for labels and subpattern/repetition 2019-05-17 00:34:01 -07:00
703c1aa6d8 Custom deepcopy for labels 2019-05-17 00:32:51 -07:00
17451cd995 Force dose2dtype to accept only a list of patterns
Backwards incompatible, just like the rest of the gdsii rework
2019-05-17 00:30:32 -07:00
1ef8518c60 Fix dose2dtype
Was broken during gdsii refactor
2019-05-17 00:28:46 -07:00
a6a3ae797c Fix Pattern.scale_by() for labels
Label offsets weren't being scaled.
2019-05-15 23:51:51 -07:00
4bd5542ce9 Clarify warning when adding suffix 2019-05-15 23:51:17 -07:00
3ff9a8a506 Shorten long names when writing
Maybe turn this into an option later?
2019-05-15 23:51:00 -07:00
376cbcce26 Use buffered IO
free ~10% speedup on read, probably similar on write
2019-05-15 23:50:31 -07:00
a461446059 Custom deepcopy() implementations to help speed things up 2019-05-15 00:19:37 -07:00
94410dffc9 Fix clockwise (to-perp) path bends 2019-05-15 00:18:43 -07:00
2909b25fd7 Missing args for commit bc43be48bc (cap_extensions) 2019-05-15 00:17:40 -07:00
a44a7c176e Add type hints 2019-05-15 00:14:35 -07:00
bc43be48bc Implement SquareCustom end-caps and gds output 2019-05-15 00:14:17 -07:00
d5665f54a7 Comment and type hint updates 2019-05-15 00:12:34 -07:00
b8b848c28f add Pattern.is_empty() 2019-05-15 00:11:44 -07:00
0bbcf3823a Fix .gz suffix detection 2019-05-15 00:11:28 -07:00
347716ec6e Give shapes unique path-like identifiers when flattening 2019-05-13 23:55:42 -07:00
9ab1372c7b Allow shapes to carry an arbitrary identifier (Tuple) 2019-05-13 23:55:14 -07:00
380393dbc3 Fix mirror axis for arrays 2019-05-07 00:58:39 -07:00
5741b38ca6 fixup remove_colinear_vertices 2019-05-06 21:07:53 -07:00
ee6699a7de fix alternate polygon constructors 2019-04-20 15:44:45 -07:00
0018891200 handle defaults for path params 2019-04-20 15:42:42 -07:00
485a7bc29d General overhaul of gdsii read/write functions
- read() and write() now take streams instead of filenames
- readfile() and writefile() were added to handle filenames and can
detect and handle '.gz' suffixed/compressed files.
- write_dose2dtype() and and read_dtype2dose() were removed in favor of
read(use_dtype_as_dose=True) and dose2dtype()
2019-04-20 15:29:56 -07:00
d6d26b4e46 Add modify_originals param and don't modify the pattern by default 2019-04-20 15:26:27 -07:00
783c0c0844 Add support for gds paths 2019-04-20 15:25:19 -07:00
d53c9487ff Comment and error-checking fixes 2019-04-20 14:19:18 -07:00
8fe8bbd655 Normalization-related fixes 2019-04-20 14:18:52 -07:00
c6fac19fe0 Set standard constructor arg order and add rotation and mirrored args where reasonable 2019-04-20 14:18:25 -07:00
8dfb6d4440 Move vertex-cleanup functions to utils and generalize for non-closed paths 2019-04-20 00:35:53 -07:00
79c89b2a4b Rename empty-named patterns on gdsii save 2019-04-18 01:14:08 -07:00
9ecd34b2f7 Cast offsets to float 2019-04-18 01:12:51 -07:00
8987cf8c44 mirror_signs are per-coordinate, not per-vector 2019-04-18 01:12:33 -07:00
e3586a4574 fix variable names (manhattanize_fast fixes) 2019-04-16 22:24:43 -07:00
c6830abe22 Fix corners in manhattanize_fast 2019-04-16 00:42:48 -07:00
11bbf6aa0b Fix auto-renaming for structures 2019-04-16 00:41:18 -07:00
5e6485f410 allow setting library name 2019-04-15 22:43:03 -07:00
3094aa4043 Automatically disambiguate repeated pattern names.
Also check for >32 char names
2019-04-13 21:10:08 -07:00
3815069136 Fix out-of-range angles 2019-04-13 17:34:28 -07:00
f7ce17c293 Fix mirroring 2019-04-13 17:34:01 -07:00
bc723d96f3 Counts should be ints 2019-04-13 17:33:15 -07:00
90a068da80 tabs-to-spaces 2019-04-13 17:33:04 -07:00
628845ca4b Bump version to 0.5 2019-04-07 17:53:32 -07:00
jan
bc557a54b7 fix typo in comment 2019-03-31 20:57:18 -07:00
jan
c50bd8e148 Add GridRepetition: a SubPattern-like object which implements regular spatial arrays.
Also rework masque.file.gdsii to consolidate write() and
write_dose2dtype()
2019-03-31 20:57:10 -07:00
jan
539198435c Add .copy() and .deepcopy() convenience methods 2019-03-31 14:13:12 -07:00
jan
eb6a5d8e8c Add shapes.Polygon.rect() for simpler construction of various axis-aligned rectangles 2018-11-23 18:31:56 -08:00
jan
ef305cbac9 Fix syntax 2018-11-23 18:09:14 -08:00
3ebb87bfc7 fix location of svgwrite dependency 2018-11-13 23:33:16 -08:00
5bce2005b6 Add docstring for manhattanize_fast 2018-11-13 23:32:44 -08:00
ab483fc9d4 Remove pyclipper dependency; remove shape.cut() 2018-11-13 23:32:26 -08:00
8dfd856e18 Subtattern .as_pattern() should deepcopy 2018-10-28 13:34:37 -07:00
df5c61f1d4 Clarify that rectangle/square is centered on the origin
Eventually, should allow arbitrary limit combination (rather than center
+ width)
2018-10-28 13:34:09 -07:00
b295c318a9 Fix arc bounding box calculation 2018-10-28 13:32:04 -07:00
64cb1ced34 fix spacing (cosmetic) 2018-10-28 13:31:23 -07:00
jan
a064e74fc1 Merge branch 'master' of mpxd.net:jan/masque 2018-09-16 20:37:44 -07:00
jan
d17cf5b6be label should have a list of 1 point 2018-09-16 20:35:14 -07:00
jan
f3115baabe Add get_cap_edges() 2018-09-16 20:33:55 -07:00
jan
832e3b46fa Add general angle-to-parameter helper function
and improve accuracy of to_polygons
2018-09-16 20:32:19 -07:00
48b8087d0c Make read output consistent with write args 2018-09-16 20:19:28 -07:00
4323d81abd Change default written library name 2018-09-16 20:18:21 -07:00
7eda7ea873 Clarify docs -- read returns a dict 2018-09-16 20:18:04 -07:00
jan
f3aa27a7c4 add missing import 2018-09-02 20:01:25 -07:00
jan
4498990545 Move version string into __init__ 2018-08-30 23:12:01 -07:00
jan
4fea49edef Add missing file (support for labels) 2018-08-30 23:07:14 -07:00
jan
86068102d9 Clarify that layer can be a tuple 2018-08-30 23:06:56 -07:00
jan
6bafaaf4fc Fix typo in arc docs 2018-08-30 23:06:45 -07:00
jan
108694551b add support for labels (e.g. GDS TEXT) 2018-08-30 23:06:31 -07:00
jan
8623dbbeac Put masque-layer to gds-layer conversion into a private function, and only call once per shape 2018-08-30 23:05:30 -07:00
jan
4840c321c5 rename param for do_subset 2018-04-18 07:48:08 -07:00
jan
6fda991700 Rewrite/fix apply() implementation 2018-04-18 07:47:50 -07:00
jan
082236b6fd add missing arg 2018-04-16 15:34:14 -07:00
jan
cc35ff802e clean up comments 2018-04-16 15:33:04 -07:00
jan
4c3250a2a1 add recursive option to subset 2018-04-16 15:32:15 -07:00
jan
f875ae89d7 make sure apply() only hits each pattern one 2018-04-16 15:31:18 -07:00
jan
52adb582dc copy name when using Pattern.subset() 2018-04-16 15:06:16 -07:00
jan
e38a530dee close paren in docstring 2018-04-16 14:55:19 -07:00
jan
1f17c07bef remove errant print 2018-04-16 14:55:01 -07:00
jan
79ac6a59e4 Fix mirror axis in Pattern.mirror() 2018-04-16 13:59:44 -07:00
jan
70f3ea9304 Handle mirrored gds shapes 2018-04-14 15:29:44 -07:00
jan
f580e784f7 Add mirroring functions to patterns/subpatterns 2018-04-14 15:29:19 -07:00
jan
d5a255a9d7 Add mirror() to shapes
Might need to fix ordering on Text.to_polygons()
2018-04-14 15:27:56 -07:00
jan
358f45c5fd Error out when we see absolute positioning in GDS
We don't support it (yet?)
2018-04-14 15:23:01 -07:00
jan
c14daf2e5e Fix GDS AREF handling 2018-04-14 15:20:39 -07:00
jan
0170f45f75 GDS stores rotation in degrees 2018-04-14 15:19:48 -07:00
jan
04ff11d3cb check for zero-length names 2018-04-14 15:06:12 -07:00
jan
37a55e0d9b Add deepcopy() convenience method to Pattern 2018-04-14 15:02:35 -07:00
jan
e4545bfa30 use is_scalar for checking if layer is a tuple 2018-04-14 15:02:13 -07:00
jan
3e06214b7e Add recursive "apply()" helper to pattern 2018-04-14 14:53:53 -07:00
jan
4c535e6564 return self from Text's scale_by and rotate 2018-04-14 14:38:42 -07:00
jan
eae57f7158 add set_bit 2018-04-14 14:34:34 -07:00
jan
3d7df45c2b fix get_bit docs 2018-04-14 14:34:26 -07:00
jan
e2b05d7c86 add fast approximate manhattanization function 2018-01-15 23:55:28 -08:00
jan
2ca27b0792 fix typo 2017-11-14 10:17:11 -08:00
jan
0fd0e259aa Merge branch 'master' of mpxd.net:jan/masque 2017-11-04 12:19:08 -07:00
jan
b7b0da7432 Allow writing a list of patterns to gds (multiple topcells) 2017-11-04 12:18:42 -07:00
jan
c451e93df0 Add option to check for invalid polygons when reading gds 2017-11-04 12:15:35 -07:00
jan
6aa1787ba0 add comment specifying what gdsii lib is used 2017-11-04 12:12:05 -07:00
9308454ad4 allow cutting any shape, always require pyclipper 2017-10-17 12:35:56 -07:00
87c2ef5948 use pyclipper for polygon cutting 2017-10-17 11:09:53 -07:00
b3f99ee123 abs when thresholding raster for manhattanization 2017-10-17 11:09:53 -07:00
jan
83d163a102 fix typo 2017-09-08 14:26:27 -07:00
jan
f4b8f513d4 fix typos 2017-09-08 10:30:56 -07:00
jan
01395134ee Also clean vertices before cutting 2017-09-07 21:59:44 -07:00
jan
a817bf6642 Remove debug code 2017-09-06 21:04:57 -07:00
jan
10cd0778b8 Add copy() method to Shape 2017-09-06 21:04:44 -07:00
jan
723944018e add documentation to Polygon.cut() 2017-09-06 21:03:39 -07:00
jan
cea172e7f2 Make cut generate clean polygons 2017-09-06 21:03:23 -07:00
jan
4466198924 Add cut() function for polygon 2017-09-06 01:16:44 -07:00
jan
ffbaf8f4c4 Add manhattanization functionality 2017-09-06 01:16:24 -07:00
jan
3d52566016 Improve error handling 2017-09-06 01:14:46 -07:00
jan
934bfcd74e Clean up type info 2017-09-06 01:14:27 -07:00
jan
ccfd0f7f4f remove whitespace 2017-09-05 11:00:50 -07:00
jan
583dd7b018 allow caller to specify gdsii logical unit 2017-09-05 11:00:36 -07:00
jan
3b3ee216c2 add missing import 2017-08-29 16:55:58 -07:00
jan
3d89cd42a0 further fixes to ellipse bounding box 2017-08-29 16:55:06 -07:00
jan
85e2c662cc fix incomplete commit 2017-08-29 15:57:37 -07:00
jan
8256a540dc Use polar angle for ellipse bounds 2017-08-29 15:51:00 -07:00
jan
fdd18ca7d8 add functions for reading/writing tuple-valued layers to gds 2017-08-29 15:45:00 -07:00
jan
1127242aa0 fix typo 2017-08-24 15:35:10 -07:00
jan
dcf34536ad Improve docs for gdsii output 2017-08-12 19:32:15 -07:00
jan
bf1cabe0b0 Let gdsii output handle list-specified errors 2017-08-12 19:31:49 -07:00
jan
b99509289a Let layer be a tuple of ints (or just a single int like before) 2017-08-12 19:31:02 -07:00
jan
0a7c26bb08 No need to subclass 'object' in python3 2017-08-12 19:30:31 -07:00
jan
6cc6556e8a typo fix 2017-04-20 13:05:58 -07:00
jan
434178c853 correctly preserve total arc angle during normalize 2017-04-20 13:01:31 -07:00
jan
2c159f2798 remove extra polygonize 2017-04-20 13:00:40 -07:00
ff76626e21 fix multiple bugs in arc and ellipse 2017-04-19 18:54:58 -07:00
jan
d355d84f6d fix gds name mangling in cases with fractional dose 2016-10-19 16:59:20 -07:00
jan
103e72628c Remove extra spaces 2016-10-19 16:52:40 -07:00
jan
3a460a9296 Add Text shape
Rendered using freetype-py and matplotlib

Can eliminate the matplotlib dependency if I write my own bezier code,
but that's work (and I already use matplotlib...).
2016-10-19 16:52:28 -07:00
jan
2a20a540b9 remove extra spaces 2016-03-16 15:16:01 -07:00
jan
5bf486ac81 Add all files to repository 2016-03-15 19:12:39 -07:00