From 01b3f9ca3a29849eca36cfc84a309f55d51654dd Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Thu, 26 Jan 2023 13:36:22 -0800 Subject: [PATCH] cleanup based on flake8 output --- .flake8 | 1 + fatamorgana/basic.py | 5 +- fatamorgana/records.py | 2 +- fatamorgana/test/test_files_cblocks.py | 179 +++--- fatamorgana/test/test_files_cells.py | 7 +- fatamorgana/test/test_files_circles.py | 86 ++- fatamorgana/test/test_files_ctrapezoids.py | 143 ++--- fatamorgana/test/test_files_empty.py | 7 +- fatamorgana/test/test_files_layernames.py | 118 ++-- fatamorgana/test/test_files_modals.py | 208 +++--- fatamorgana/test/test_files_paths.py | 176 +++--- fatamorgana/test/test_files_placements.py | 564 ++++++++--------- fatamorgana/test/test_files_polygons.py | 305 ++++----- fatamorgana/test/test_files_properties.py | 698 ++++++++++----------- fatamorgana/test/test_files_rectangles.py | 160 +++-- fatamorgana/test/test_files_texts.py | 21 +- fatamorgana/test/test_files_trapezoids.py | 230 ++++--- fatamorgana/test/test_int.py | 3 - fatamorgana/test/utils.py | 10 +- 19 files changed, 1429 insertions(+), 1494 deletions(-) diff --git a/.flake8 b/.flake8 index 0042015..fb07707 100644 --- a/.flake8 +++ b/.flake8 @@ -27,3 +27,4 @@ ignore = per-file-ignores = # F401 import without use */__init__.py: F401, + __init__.py: F401, diff --git a/fatamorgana/basic.py b/fatamorgana/basic.py index 2e41b6c..476e5f6 100644 --- a/fatamorgana/basic.py +++ b/fatamorgana/basic.py @@ -7,7 +7,6 @@ from fractions import Fraction from enum import Enum import math import struct -import io import warnings try: @@ -1663,13 +1662,13 @@ def write_point_list( if implicit_closed: ManhattanDelta(points[-1][0] - points[0][0], points[-1][1] - points[0][1]) list_type = 2 - except: + except InvalidDataError: try: deltas = [OctangularDelta(x, y) for x, y in points] if implicit_closed: OctangularDelta(points[-1][0] - points[0][0], points[-1][1] - points[0][1]) list_type = 3 - except: + except InvalidDataError: pass if list_type is not None: size = write_uint(stream, list_type) diff --git a/fatamorgana/records.py b/fatamorgana/records.py index 20e9819..46beb48 100644 --- a/fatamorgana/records.py +++ b/fatamorgana/records.py @@ -383,7 +383,7 @@ class Start(Record): def __init__( self, unit: real_t, - version: Union[AString, str] = "1.0", + version: Union[AString, str] = "1.0", offset_table: Optional[OffsetTable] = None, ) -> None: """ diff --git a/fatamorgana/test/test_files_cblocks.py b/fatamorgana/test/test_files_cblocks.py index 93ff0ac..cf3f2ec 100644 --- a/fatamorgana/test/test_files_cblocks.py +++ b/fatamorgana/test/test_files_cblocks.py @@ -1,17 +1,11 @@ # type: ignore -from typing import List, Tuple, Iterable -from itertools import chain from io import BytesIO, BufferedIOBase -import struct -import pytest # type: ignore -import numpy from numpy.testing import assert_equal from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte, PathExtensionScheme -from ..basic import InvalidRecordError, InvalidDataError +from ..basic import write_uint, write_bstring, write_byte from ..main import OasisLayout @@ -98,86 +92,105 @@ def test_file_1() -> None: assert geometry[1].height == 610 assert geometry[1].width == 680 - assert_equal(geometry[2].point_list, - [[-30, -360], [480, -50], [180, 430], [-630, -20]]) + assert_equal(geometry[2].point_list, [ + [-30, -360], + [480, -50], + [180, 430], + [-630, -20], + ]) - assert_equal(geometry[3].point_list, - [[-30, -400], - [450, 40], - [70, -220], - [10, 210], - [740, -20], - [0, 660], - [570, 10], - [50, 500], - [630, 20], - [10, 100], - [-810, 10], - [20, -470], - [-660, 0], - [20, -470], - [-620, 10], - [0, 610], - [610, -10], - [0, -100], - [210, 10], - [40, 820], - [-1340, 60], - [30, -1370]]) + assert_equal(geometry[3].point_list, [ + [-30, -400], + [450, 40], + [70, -220], + [10, 210], + [740, -20], + [0, 660], + [570, 10], + [50, 500], + [630, 20], + [10, 100], + [-810, 10], + [20, -470], + [-660, 0], + [20, -470], + [-620, 10], + [0, 610], + [610, -10], + [0, -100], + [210, 10], + [40, 820], + [-1340, 60], + [30, -1370], + ]) - assert_equal(geometry[4].point_list, - [[40, -760], [490, -50], [110, 800], [-640, 10]]) + assert_equal(geometry[4].point_list, [ + [40, -760], + [490, -50], + [110, 800], + [-640, 10], + ]) - assert_equal(geometry[5].point_list, - [[140, -380], - [340, -10], - [30, -100], - [-320, 20], - [130, -460], - [-480, -20], - [-210, 910], - [370, 40]]) + assert_equal(geometry[5].point_list, [ + [140, -380], + [340, -10], + [30, -100], + [-320, 20], + [130, -460], + [-480, -20], + [-210, 910], + [370, 40], + ]) - assert_equal(geometry[6].point_list, - [[720, -20], - [20, 20], - [690, 0], - [-10, 650], - [-20, 30], - [-90, -10], - [10, 70], - [470, -30], - [20, -120], - [-320, 0], - [40, -790], - [-90, -20], - [-60, 140], - [-1390, 50], - [10, 30]]) + assert_equal(geometry[6].point_list, [ + [720, -20], + [20, 20], + [690, 0], + [-10, 650], + [-20, 30], + [-90, -10], + [10, 70], + [470, -30], + [20, -120], + [-320, 0], + [40, -790], + [-90, -20], + [-60, 140], + [-1390, 50], + [10, 30], + ]) - assert_equal(geometry[7].point_list, - [[150, -830], - [-1320, 40], - [-70, 370], - [310, -30], - [10, 220], - [250, -40], - [40, -220], - [340, 10], - [-20, 290], - [-1070, 20], - [0, 230], - [1380, -60]]) + assert_equal(geometry[7].point_list, [ + [150, -830], + [-1320, 40], + [-70, 370], + [310, -30], + [10, 220], + [250, -40], + [40, -220], + [340, 10], + [-20, 290], + [-1070, 20], + [0, 230], + [1380, -60], + ]) - assert_equal(geometry[8].point_list, - [[330, 0], [-10, 480], [620, -20], [-10, 330], [-930, 60], [0, -850]]) + assert_equal(geometry[8].point_list, [ + [330, 0], + [-10, 480], + [620, -20], + [-10, 330], + [-930, 60], + [0, -850], + ]) - assert_equal(geometry[9].point_list, - [[-140, -410], - [10, -140], - [270, 0], - [130, 1030], - [-500, 50], - [10, -330], - [210, -10], - [10, -190]]) + assert_equal(geometry[9].point_list, [ + [-140, -410], + [10, -140], + [270, 0], + [130, 1030], + [-500, 50], + [10, -330], + [210, -10], + [10, -190], + ]) diff --git a/fatamorgana/test/test_files_cells.py b/fatamorgana/test/test_files_cells.py index 9239994..9fae7b8 100644 --- a/fatamorgana/test/test_files_cells.py +++ b/fatamorgana/test/test_files_cells.py @@ -1,14 +1,11 @@ # type: ignore -from typing import List, Tuple, Iterable -from itertools import chain from io import BytesIO, BufferedIOBase -import struct -import pytest # type: ignore +import pytest from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring +from ..basic import write_uint, write_bstring from ..basic import InvalidRecordError, InvalidDataError from ..main import OasisLayout diff --git a/fatamorgana/test/test_files_circles.py b/fatamorgana/test/test_files_circles.py index 35c7a14..794c18f 100644 --- a/fatamorgana/test/test_files_circles.py +++ b/fatamorgana/test/test_files_circles.py @@ -1,17 +1,9 @@ # type: ignore -from typing import List, Tuple, Iterable -from itertools import chain from io import BytesIO, BufferedIOBase -import struct - -import pytest # type: ignore -import numpy -from numpy.testing import assert_equal from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte, PathExtensionScheme -from ..basic import InvalidRecordError, InvalidDataError +from ..basic import write_uint, write_sint, write_bstring, write_byte from ..main import OasisLayout @@ -37,52 +29,52 @@ def write_file_1(buf: BufferedIOBase) -> BufferedIOBase: ''' buf.write(HEADER) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'A') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'A') # Cell name - write_uint(buf, 27) # CIRCLE record - write_byte(buf, 0b0011_1011) # 00rX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 150) # radius - write_sint(buf, -100) # geometry-x (absolute) - write_sint(buf, 200) # geometry-y (absolute) + write_uint(buf, 27) # CIRCLE record + write_byte(buf, 0b0011_1011) # 00rX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 150) # radius + write_sint(buf, -100) # geometry-x (absolute) + write_sint(buf, 200) # geometry-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record - write_uint(buf, 27) # CIRCLE record - write_byte(buf, 0b0000_1000) # 00rX_YRDL - write_sint(buf, 400) # geometry-y (relative) + write_uint(buf, 27) # CIRCLE record + write_byte(buf, 0b0000_1000) # 00rX_YRDL + write_sint(buf, 400) # geometry-y (relative) - write_uint(buf, 27) # CIRCLE record - write_byte(buf, 0b0010_1000) # 00rX_YRDL - write_uint(buf, 0) # radius - write_sint(buf, 400) # geometry-y (relative) + write_uint(buf, 27) # CIRCLE record + write_byte(buf, 0b0010_1000) # 00rX_YRDL + write_uint(buf, 0) # radius + write_sint(buf, 400) # geometry-y (relative) - write_uint(buf, 27) # CIRCLE record - write_byte(buf, 0b0010_1000) # 00rX_YRDL - write_uint(buf, 1) # radius - write_sint(buf, 400) # geometry-y (relative) + write_uint(buf, 27) # CIRCLE record + write_byte(buf, 0b0010_1000) # 00rX_YRDL + write_uint(buf, 1) # radius + write_sint(buf, 400) # geometry-y (relative) - write_uint(buf, 27) # CIRCLE record - write_byte(buf, 0b0010_1000) # 00rX_YRDL - write_uint(buf, 6) # radius - write_sint(buf, 400) # geometry-y (relative) + write_uint(buf, 27) # CIRCLE record + write_byte(buf, 0b0010_1000) # 00rX_YRDL + write_uint(buf, 6) # radius + write_sint(buf, 400) # geometry-y (relative) - write_uint(buf, 27) # CIRCLE record - write_byte(buf, 0b0010_1000) # 00rX_YRDL - write_uint(buf, 20) # radius - write_sint(buf, 400) # geometry-y (relative) + write_uint(buf, 27) # CIRCLE record + write_byte(buf, 0b0010_1000) # 00rX_YRDL + write_uint(buf, 20) # radius + write_sint(buf, 400) # geometry-y (relative) - write_uint(buf, 27) # CIRCLE record - write_byte(buf, 0b0010_1100) # 00rX_YRDL - write_uint(buf, 100) # radius - write_sint(buf, 400) # geometry-y (relative) - write_uint(buf, 1) # repetition (3x4 matrix) - write_uint(buf, 1) # (repetition) x-dimension - write_uint(buf, 2) # (repetition) y-dimension - write_uint(buf, 400) # (repetition) x-spacing - write_uint(buf, 300) # (repetition) y-spacing + write_uint(buf, 27) # CIRCLE record + write_byte(buf, 0b0010_1100) # 00rX_YRDL + write_uint(buf, 100) # radius + write_sint(buf, 400) # geometry-y (relative) + write_uint(buf, 1) # repetition (3x4 matrix) + write_uint(buf, 1) # (repetition) x-dimension + write_uint(buf, 2) # (repetition) y-dimension + write_uint(buf, 400) # (repetition) x-spacing + write_uint(buf, 300) # (repetition) y-spacing buf.write(FOOTER) return buf diff --git a/fatamorgana/test/test_files_ctrapezoids.py b/fatamorgana/test/test_files_ctrapezoids.py index b98794a..fdcc6cf 100644 --- a/fatamorgana/test/test_files_ctrapezoids.py +++ b/fatamorgana/test/test_files_ctrapezoids.py @@ -1,17 +1,9 @@ # type: ignore -from typing import List, Tuple, Iterable -from itertools import chain from io import BytesIO, BufferedIOBase -import struct - -import pytest # type: ignore -import numpy -from numpy.testing import assert_equal from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte, PathExtensionScheme -from ..basic import InvalidRecordError, InvalidDataError +from ..basic import write_uint, write_sint, write_bstring, write_byte from ..main import OasisLayout @@ -33,29 +25,29 @@ def write_file_1(buf: BufferedIOBase) -> BufferedIOBase: ''' buf.write(HEADER) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'A') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'A') # Cell name - write_uint(buf, 26) # CTRAPEZOID record - write_byte(buf, 0b1111_1011) # TWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 24) # ctrapezoid type - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, -100) # geometry-x (absolute) - write_sint(buf, 200) # geometry-y (absolute) + write_uint(buf, 26) # CTRAPEZOID record + write_byte(buf, 0b1111_1011) # TWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 24) # ctrapezoid type + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, -100) # geometry-x (absolute) + write_sint(buf, 200) # geometry-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record - write_uint(buf, 26) # CTRAPEZOID record - write_byte(buf, 0b0000_1000) # TWHX_YRDL - write_sint(buf, 400) # geometry-y (relative) + write_uint(buf, 26) # CTRAPEZOID record + write_byte(buf, 0b0000_1000) # TWHX_YRDL + write_sint(buf, 400) # geometry-y (relative) - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0000_0011) # SWHX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0000_0011) # SWHX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype h = [250, 100] v = [100, 250] @@ -66,33 +58,34 @@ def write_file_1(buf: BufferedIOBase) -> BufferedIOBase: + [0b10] * 4 + [0b01] * 2 + [0b10] * 2 - + [0b11, 0b10]) + + [0b11, 0b10] + ) for t, (x, x_en) in enumerate(zip(wh, wh_en)): - write_uint(buf, 26) # CTRAPEZOID record + write_uint(buf, 26) # CTRAPEZOID record write_byte(buf, 0b1000_1011 | (x_en << 5)) # TWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, t) # ctrapezoid type + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, t) # ctrapezoid type if x_en & 0b10: - write_uint(buf, x[0]) # width + write_uint(buf, x[0]) # width if x_en & 0b01: - write_uint(buf, x[1]) # height - write_sint(buf, 400) # geometry-y (relative) + write_uint(buf, x[1]) # height + write_sint(buf, 400) # geometry-y (relative) - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0000_0011) # SWHX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0000_0011) # SWHX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype - write_uint(buf, 26) # CTRAPEZOID record - write_byte(buf, 0b0000_1100) # TWHX_YRDL - write_sint(buf, 400) # geometry-y (relative) - write_uint(buf, 1) # repetition (3x4 matrix) - write_uint(buf, 1) # (repetition) x-dimension - write_uint(buf, 2) # (repetition) y-dimension - write_uint(buf, 400) # (repetition) x-spacing - write_uint(buf, 300) # (repetition) y-spacing + write_uint(buf, 26) # CTRAPEZOID record + write_byte(buf, 0b0000_1100) # TWHX_YRDL + write_sint(buf, 400) # geometry-y (relative) + write_uint(buf, 1) # repetition (3x4 matrix) + write_uint(buf, 1) # (repetition) x-dimension + write_uint(buf, 2) # (repetition) y-dimension + write_uint(buf, 400) # (repetition) x-spacing + write_uint(buf, 300) # (repetition) y-spacing buf.write(FOOTER) return buf @@ -143,7 +136,7 @@ def test_file_1() -> None: elif ct_type in range(22, 24) or ct_type == 25: assert gg.height == [100, None][is_ctrapz], msg else: - if ct_type < 8 or 16 <= ct_type < 25 or 26 <= ct_type : + if ct_type < 8 or 16 <= ct_type < 25 or 26 <= ct_type: assert gg.width == 250, msg assert gg.height == 100, msg else: @@ -169,39 +162,39 @@ def write_file_2(buf: BufferedIOBase) -> BufferedIOBase: write_bstring(buf, b'A') # Cell name # Shouldn't access (undefined) height modal, despite not having a height. - write_uint(buf, 26) # CTRAPEZOID record - write_byte(buf, 0b1101_1011) # TWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 16) # ctrapezoid type - write_uint(buf, 200) # width - write_sint(buf, -100) # geometry-x (absolute) - write_sint(buf, 200) # geometry-y (absolute) + write_uint(buf, 26) # CTRAPEZOID record + write_byte(buf, 0b1101_1011) # TWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 16) # ctrapezoid type + write_uint(buf, 200) # width + write_sint(buf, -100) # geometry-x (absolute) + write_sint(buf, 200) # geometry-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record - write_uint(buf, 26) # CTRAPEZOID record - write_byte(buf, 0b0000_1000) # TWHX_YRDL - write_sint(buf, 400) # geometry-y (relative) + write_uint(buf, 26) # CTRAPEZOID record + write_byte(buf, 0b0000_1000) # TWHX_YRDL + write_sint(buf, 400) # geometry-y (relative) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'B') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'B') # Cell name # Shouldn't access (undefined) width modal, despite not having a width. - write_uint(buf, 26) # CTRAPEZOID record - write_byte(buf, 0b1011_1011) # TWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 20) # ctrapezoid type - write_uint(buf, 200) # height - write_sint(buf, -100) # geometry-x (absolute) - write_sint(buf, 200) # geometry-y (absolute) + write_uint(buf, 26) # CTRAPEZOID record + write_byte(buf, 0b1011_1011) # TWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 20) # ctrapezoid type + write_uint(buf, 200) # height + write_sint(buf, -100) # geometry-x (absolute) + write_sint(buf, 200) # geometry-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record - write_uint(buf, 26) # CTRAPEZOID record - write_byte(buf, 0b0000_1000) # TWHX_YRDL - write_sint(buf, 400) # geometry-y (relative) + write_uint(buf, 26) # CTRAPEZOID record + write_byte(buf, 0b0000_1000) # TWHX_YRDL + write_sint(buf, 400) # geometry-y (relative) buf.write(FOOTER) return buf diff --git a/fatamorgana/test/test_files_empty.py b/fatamorgana/test/test_files_empty.py index 1fbb63c..acf651d 100644 --- a/fatamorgana/test/test_files_empty.py +++ b/fatamorgana/test/test_files_empty.py @@ -1,14 +1,10 @@ # type: ignore -from typing import List, Tuple, Iterable -from itertools import chain from io import BytesIO, BufferedIOBase import struct -import pytest # type: ignore - from .utils import MAGIC_BYTES, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring +from ..basic import write_uint, write_bstring from ..main import OasisLayout @@ -59,7 +55,6 @@ def test_file_1() -> None: assert layout.unit == 1000 - def write_file_2(buf: BufferedIOBase) -> BufferedIOBase: ''' File contains no records. diff --git a/fatamorgana/test/test_files_layernames.py b/fatamorgana/test/test_files_layernames.py index 56ddc23..94a2cc8 100644 --- a/fatamorgana/test/test_files_layernames.py +++ b/fatamorgana/test/test_files_layernames.py @@ -1,16 +1,10 @@ # type: ignore +from typing import Sequence -from typing import List, Tuple, Iterable, Sequence -from itertools import chain from io import BytesIO, BufferedIOBase -import pytest # type: ignore -import numpy -from numpy.testing import assert_equal - from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte, PathExtensionScheme -from ..basic import InvalidRecordError, InvalidDataError +from ..basic import write_uint, write_sint, write_bstring, write_byte from ..main import OasisLayout @@ -37,67 +31,67 @@ def base_tests(layout: OasisLayout) -> None: def write_names_geom(buf: BufferedIOBase, short: bool = False) -> BufferedIOBase: - write_uint(buf, 11) # LAYERNAME record (geometry) - write_bstring(buf, b'AA') # name - write_uint(buf, 0) # all layers - write_uint(buf, 0) # all datatypes + write_uint(buf, 11) # LAYERNAME record (geometry) + write_bstring(buf, b'AA') # name + write_uint(buf, 0) # all layers + write_uint(buf, 0) # all datatypes - write_uint(buf, 11) # LAYERNAME record (geometry) - write_bstring(buf, b'L5A') # name - write_uint(buf, 1) # layer <=5 - write_uint(buf, 5) # (...) - write_uint(buf, 0) # all datatypes + write_uint(buf, 11) # LAYERNAME record (geometry) + write_bstring(buf, b'L5A') # name + write_uint(buf, 1) # layer <=5 + write_uint(buf, 5) # (...) + write_uint(buf, 0) # all datatypes - write_uint(buf, 11) # LAYERNAME record (geometry) - write_bstring(buf, b'H5A') # name - write_uint(buf, 2) # layer >=5 - write_uint(buf, 5) # (...) - write_uint(buf, 0) # all datatypes + write_uint(buf, 11) # LAYERNAME record (geometry) + write_bstring(buf, b'H5A') # name + write_uint(buf, 2) # layer >=5 + write_uint(buf, 5) # (...) + write_uint(buf, 0) # all datatypes - write_uint(buf, 11) # LAYERNAME record (geometry) - write_bstring(buf, b'E5A') # name - write_uint(buf, 3) # layer ==5 - write_uint(buf, 5) # (...) - write_uint(buf, 0) # all datatypes + write_uint(buf, 11) # LAYERNAME record (geometry) + write_bstring(buf, b'E5A') # name + write_uint(buf, 3) # layer ==5 + write_uint(buf, 5) # (...) + write_uint(buf, 0) # all datatypes - write_uint(buf, 11) # LAYERNAME record (geometry) - write_bstring(buf, b'I56A') # name - write_uint(buf, 4) # layer 5 to 6 - write_uint(buf, 5) # (...) - write_uint(buf, 6) # (...) - write_uint(buf, 0) # all datatypes + write_uint(buf, 11) # LAYERNAME record (geometry) + write_bstring(buf, b'I56A') # name + write_uint(buf, 4) # layer 5 to 6 + write_uint(buf, 5) # (...) + write_uint(buf, 6) # (...) + write_uint(buf, 0) # all datatypes if short: return buf - write_uint(buf, 11) # LAYERNAME record (geometry) - write_bstring(buf, b'E5L4') # name - write_uint(buf, 3) # layer ==5 - write_uint(buf, 5) # (...) - write_uint(buf, 1) # datatype <=4 - write_uint(buf, 4) # (...) + write_uint(buf, 11) # LAYERNAME record (geometry) + write_bstring(buf, b'E5L4') # name + write_uint(buf, 3) # layer ==5 + write_uint(buf, 5) # (...) + write_uint(buf, 1) # datatype <=4 + write_uint(buf, 4) # (...) - write_uint(buf, 11) # LAYERNAME record (geometry) - write_bstring(buf, b'E5H4') # name - write_uint(buf, 3) # layer ==5 - write_uint(buf, 5) # (...) - write_uint(buf, 2) # datatype >=4 - write_uint(buf, 4) # (...) + write_uint(buf, 11) # LAYERNAME record (geometry) + write_bstring(buf, b'E5H4') # name + write_uint(buf, 3) # layer ==5 + write_uint(buf, 5) # (...) + write_uint(buf, 2) # datatype >=4 + write_uint(buf, 4) # (...) - write_uint(buf, 11) # LAYERNAME record (geometry) - write_bstring(buf, b'E5E4') # name - write_uint(buf, 3) # layer ==5 - write_uint(buf, 5) # (...) - write_uint(buf, 3) # datatype ==4 - write_uint(buf, 4) # (...) + write_uint(buf, 11) # LAYERNAME record (geometry) + write_bstring(buf, b'E5E4') # name + write_uint(buf, 3) # layer ==5 + write_uint(buf, 5) # (...) + write_uint(buf, 3) # datatype ==4 + write_uint(buf, 4) # (...) - write_uint(buf, 11) # LAYERNAME record (geometry) - write_bstring(buf, b'E5I47') # name - write_uint(buf, 3) # layer ==5 - write_uint(buf, 5) # (...) - write_uint(buf, 4) # datatype 4 to 7 - write_uint(buf, 4) # (...) - write_uint(buf, 7) # (...) + write_uint(buf, 11) # LAYERNAME record (geometry) + write_bstring(buf, b'E5I47') # name + write_uint(buf, 3) # layer ==5 + write_uint(buf, 5) # (...) + write_uint(buf, 4) # datatype 4 to 7 + write_uint(buf, 4) # (...) + write_uint(buf, 7) # (...) return buf @@ -127,7 +121,7 @@ def write_names_text(buf: BufferedIOBase, prefix: bytes = b'') -> BufferedIOBase write_uint(buf, 0) # all datatypes write_uint(buf, 12) # LAYERNAME record (geometry) - write_bstring(buf, prefix + b'I56A') # name + write_bstring(buf, prefix + b'I56A') # name write_uint(buf, 4) # layer 5 to 6 write_uint(buf, 5) # (...) write_uint(buf, 6) # (...) @@ -160,7 +154,8 @@ def write_text(buf: BufferedIOBase) -> BufferedIOBase: def name_test(layers: Sequence, is_textlayer: bool) -> None: for ii, nn in enumerate(layers): - assert is_textlayer == nn.is_textlayer, f'Fail on layername {ii}' + msg = f'Fail on layername {ii}' + assert is_textlayer == nn.is_textlayer, msg assert nn.nstring.string == ['AA', 'L5A', 'H5A', 'E5A', 'I56A', 'E5L4', 'E5H4', 'E5E4', 'E5I47'][ii], msg @@ -172,7 +167,8 @@ def name_test(layers: Sequence, is_textlayer: bool) -> None: def name_test_text(layers: Sequence) -> None: for ii, nn in enumerate(layers): - assert nn.is_textlayer, f'Fail on layername {ii}' + msg = f'Fail on layername {ii}' + assert nn.is_textlayer, msg assert nn.nstring.string == ['TAA', 'TL5A', 'TH5A', 'TE5A', 'TI56A'][ii], msg assert nn.layer_interval[0] == [None, None, 5, 5, 5][ii], msg diff --git a/fatamorgana/test/test_files_modals.py b/fatamorgana/test/test_files_modals.py index 0021bf1..d2417f2 100644 --- a/fatamorgana/test/test_files_modals.py +++ b/fatamorgana/test/test_files_modals.py @@ -1,17 +1,9 @@ # type: ignore -from typing import List, Tuple, Iterable -from itertools import chain from io import BytesIO, BufferedIOBase -import struct - -import pytest # type: ignore -import numpy -from numpy.testing import assert_equal from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte, PathExtensionScheme -from ..basic import InvalidRecordError, InvalidDataError +from ..basic import write_uint, write_sint, write_bstring, write_byte from ..main import OasisLayout @@ -33,151 +25,151 @@ def write_file_1(buf: BufferedIOBase) -> BufferedIOBase: ''' buf.write(HEADER) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'A') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'A') # Cell name # RECTANGLE 0 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0110_0011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 10) # width - write_uint(buf, 20) # height + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0110_0011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 10) # width + write_uint(buf, 20) # height # TEXT 1 - write_uint(buf, 19) # TEXT record - write_byte(buf, 0b0100_0011) # 0CNX_YRTL - write_bstring(buf, b'A') # text string - write_uint(buf, 2) # layer - write_uint(buf, 1) # datatype + write_uint(buf, 19) # TEXT record + write_byte(buf, 0b0100_0011) # 0CNX_YRTL + write_bstring(buf, b'A') # text string + write_uint(buf, 2) # layer + write_uint(buf, 1) # datatype # RECTANGLE 2 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0001_1000) # SWHX_YRDL - write_sint(buf, 100) # geometry-x (absolute) - write_sint(buf, -100) # geometry-y (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0001_1000) # SWHX_YRDL + write_sint(buf, 100) # geometry-x (absolute) + write_sint(buf, -100) # geometry-y (absolute) # TEXT 3 - write_uint(buf, 19) # TEXT record - write_byte(buf, 0b0001_1000) # 0CNX_YRTL - write_sint(buf, 100) # text-x (absolute) - write_sint(buf, -100) # text-y (absolute) + write_uint(buf, 19) # TEXT record + write_byte(buf, 0b0001_1000) # 0CNX_YRTL + write_sint(buf, 100) # text-x (absolute) + write_sint(buf, -100) # text-y (absolute) # RECTANGLE 4 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0001_1000) # SWHX_YRDL - write_sint(buf, 200) # geometry-x (absolute) - write_sint(buf, -200) # geometry-y (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0001_1000) # SWHX_YRDL + write_sint(buf, 200) # geometry-x (absolute) + write_sint(buf, -200) # geometry-y (absolute) # TEXT 5 - write_uint(buf, 19) # TEXT record - write_byte(buf, 0b0001_1000) # 0CNX_YRTL - write_sint(buf, 200) # text-x (absolute) - write_sint(buf, -200) # text-y (absolute) + write_uint(buf, 19) # TEXT record + write_byte(buf, 0b0001_1000) # 0CNX_YRTL + write_sint(buf, 200) # text-x (absolute) + write_sint(buf, -200) # text-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # RECTANGLE 6 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0001_1000) # SWHX_YRDL - write_sint(buf, 100) # geometry-x (relative) - write_sint(buf, -100) # geometry-y (relative) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0001_1000) # SWHX_YRDL + write_sint(buf, 100) # geometry-x (relative) + write_sint(buf, -100) # geometry-y (relative) # TEXT 7 - write_uint(buf, 19) # TEXT record - write_byte(buf, 0b0001_1000) # 0CNX_YRTL - write_sint(buf, 100) # text-x (relative) - write_sint(buf, -100) # text-y (relative) + write_uint(buf, 19) # TEXT record + write_byte(buf, 0b0001_1000) # 0CNX_YRTL + write_sint(buf, 100) # text-x (relative) + write_sint(buf, -100) # text-y (relative) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'B') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'B') # Cell name # RECTANGLE 0 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0110_0011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 20) # width - write_uint(buf, 10) # height + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0110_0011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 20) # width + write_uint(buf, 10) # height # TEXT 1 - write_uint(buf, 19) # TEXT record - write_byte(buf, 0b0100_0011) # 0CNX_YRTL - write_bstring(buf, b'B') # text string - write_uint(buf, 2) # layer - write_uint(buf, 1) # datatype + write_uint(buf, 19) # TEXT record + write_byte(buf, 0b0100_0011) # 0CNX_YRTL + write_bstring(buf, b'B') # text string + write_uint(buf, 2) # layer + write_uint(buf, 1) # datatype # RECTANGLE 2 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0001_1000) # SWHX_YRDL - write_sint(buf, 100) # geometry-x (absolute) - write_sint(buf, 100) # geometry-y (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0001_1000) # SWHX_YRDL + write_sint(buf, 100) # geometry-x (absolute) + write_sint(buf, 100) # geometry-y (absolute) # TEXT 3 - write_uint(buf, 19) # TEXT record - write_byte(buf, 0b0001_1000) # 0CNX_YRTL - write_sint(buf, 100) # text-x (absolute) - write_sint(buf, 100) # text-y (absolute) + write_uint(buf, 19) # TEXT record + write_byte(buf, 0b0001_1000) # 0CNX_YRTL + write_sint(buf, 100) # text-x (absolute) + write_sint(buf, 100) # text-y (absolute) # RECTANGLE 4 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0001_1000) # SWHX_YRDL - write_sint(buf, 200) # geometry-x (absolute) - write_sint(buf, 200) # geometry-y (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0001_1000) # SWHX_YRDL + write_sint(buf, 200) # geometry-x (absolute) + write_sint(buf, 200) # geometry-y (absolute) # TEXT 5 - write_uint(buf, 19) # TEXT record - write_byte(buf, 0b0001_1000) # 0CNX_YRTL - write_sint(buf, 200) # text-x (absolute) - write_sint(buf, 200) # text-y (absolute) + write_uint(buf, 19) # TEXT record + write_byte(buf, 0b0001_1000) # 0CNX_YRTL + write_sint(buf, 200) # text-x (absolute) + write_sint(buf, 200) # text-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # RECTANGLE 6 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0001_1000) # SWHX_YRDL - write_sint(buf, 100) # geometry-x (relative) - write_sint(buf, 100) # geometry-y (relative) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0001_1000) # SWHX_YRDL + write_sint(buf, 100) # geometry-x (relative) + write_sint(buf, 100) # geometry-y (relative) # TEXT 7 - write_uint(buf, 19) # TEXT record - write_byte(buf, 0b0001_1000) # 0CNX_YRTL - write_sint(buf, 100) # text-x (relative) - write_sint(buf, 100) # text-y (relative) + write_uint(buf, 19) # TEXT record + write_byte(buf, 0b0001_1000) # 0CNX_YRTL + write_sint(buf, 100) # text-x (relative) + write_sint(buf, 100) # text-y (relative) # PLACEMENT 0 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b1000_0000) # CNXY_RAAF - write_bstring(buf, b'A') # Cell reference + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b1000_0000) # CNXY_RAAF + write_bstring(buf, b'A') # Cell reference # PLACEMENT 1 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_0000) # CNXY_RAAF - write_sint(buf, 50) # placement-x (relative) - write_sint(buf, 50) # placement-y (relative) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_0000) # CNXY_RAAF + write_sint(buf, 50) # placement-x (relative) + write_sint(buf, 50) # placement-y (relative) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'TOP') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'TOP') # Cell name # PLACEMENT 0 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b1000_0000) # CNXY_RAAF - write_bstring(buf, b'B') # Cell reference + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b1000_0000) # CNXY_RAAF + write_bstring(buf, b'B') # Cell reference # RECTANGLE 0 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0110_0011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 50) # width - write_uint(buf, 5) # height + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0110_0011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 50) # width + write_uint(buf, 5) # height # TEXT 1 - write_uint(buf, 19) # TEXT record - write_byte(buf, 0b0100_0011) # 0CNX_YRTL - write_bstring(buf, b'TOP') # text string - write_uint(buf, 2) # layer - write_uint(buf, 1) # datatype + write_uint(buf, 19) # TEXT record + write_byte(buf, 0b0100_0011) # 0CNX_YRTL + write_bstring(buf, b'TOP') # text string + write_uint(buf, 2) # layer + write_uint(buf, 1) # datatype buf.write(FOOTER) return buf diff --git a/fatamorgana/test/test_files_paths.py b/fatamorgana/test/test_files_paths.py index a359817..8fb2cc0 100644 --- a/fatamorgana/test/test_files_paths.py +++ b/fatamorgana/test/test_files_paths.py @@ -1,17 +1,11 @@ # type: ignore -from typing import List, Tuple, Iterable -from itertools import chain from io import BytesIO, BufferedIOBase -import struct -import pytest # type: ignore -import numpy from numpy.testing import assert_equal from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte, PathExtensionScheme -from ..basic import InvalidRecordError, InvalidDataError +from ..basic import write_uint, write_sint, write_bstring, write_byte, PathExtensionScheme from ..main import OasisLayout @@ -37,108 +31,108 @@ def write_file_1(buf: BufferedIOBase) -> BufferedIOBase: ''' buf.write(HEADER) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'ABC') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'ABC') # Cell name # PATH 0 - write_uint(buf, 22) # PATH record - write_byte(buf, 0b1111_1011) # EWPX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 10) # half-width - write_byte(buf, 0b0000_1111) # extension-scheme 0000_SSEE - write_sint(buf, 5) # (extension-scheme) start - write_sint(buf, -5) # (extension-scheme) end - write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt - write_uint(buf, 3) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 0) # geometry-x (absolute) - write_sint(buf, 100) # geometry-y (absolute) + write_uint(buf, 22) # PATH record + write_byte(buf, 0b1111_1011) # EWPX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 10) # half-width + write_byte(buf, 0b0000_1111) # extension-scheme 0000_SSEE + write_sint(buf, 5) # (extension-scheme) start + write_sint(buf, -5) # (extension-scheme) end + write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt + write_uint(buf, 3) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 0) # geometry-x (absolute) + write_sint(buf, 100) # geometry-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # PATH 1 - write_uint(buf, 22) # PATH record - write_byte(buf, 0b1110_1011) # EWPX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 10) # half-width - write_byte(buf, 0b0000_0000) # extension-scheme 0000_SSEE - write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt - write_uint(buf, 3) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 200) # geometry-y (relative) + write_uint(buf, 22) # PATH record + write_byte(buf, 0b1110_1011) # EWPX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 10) # half-width + write_byte(buf, 0b0000_0000) # extension-scheme 0000_SSEE + write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt + write_uint(buf, 3) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 200) # geometry-y (relative) # PATH 2 - write_uint(buf, 22) # PATH record - write_byte(buf, 0b1110_1001) # EWPX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 10) # half-width - write_byte(buf, 0b0000_0100) # extension-scheme 0000_SSEE - write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt - write_uint(buf, 3) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 200) # geometry-y (relative) + write_uint(buf, 22) # PATH record + write_byte(buf, 0b1110_1001) # EWPX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 10) # half-width + write_byte(buf, 0b0000_0100) # extension-scheme 0000_SSEE + write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt + write_uint(buf, 3) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 200) # geometry-y (relative) # PATH 3 - write_uint(buf, 22) # PATH record - write_byte(buf, 0b1110_1010) # EWPX_YRDL - write_uint(buf, 2) # datatype - write_uint(buf, 12) # half-width - write_byte(buf, 0b0000_0101) # extension-scheme 0000_SSEE - write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt - write_uint(buf, 3) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 200) # geometry-y (relative) + write_uint(buf, 22) # PATH record + write_byte(buf, 0b1110_1010) # EWPX_YRDL + write_uint(buf, 2) # datatype + write_uint(buf, 12) # half-width + write_byte(buf, 0b0000_0101) # extension-scheme 0000_SSEE + write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt + write_uint(buf, 3) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 200) # geometry-y (relative) # PATH 4 - write_uint(buf, 22) # PATH record - write_byte(buf, 0b1010_1011) # EWPX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_byte(buf, 0b0000_1010) # extension-scheme 0000_SSEE - write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt - write_uint(buf, 3) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 200) # geometry-y (relative) + write_uint(buf, 22) # PATH record + write_byte(buf, 0b1010_1011) # EWPX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_byte(buf, 0b0000_1010) # extension-scheme 0000_SSEE + write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt + write_uint(buf, 3) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 200) # geometry-y (relative) # PATH 5 - write_uint(buf, 22) # PATH record - write_byte(buf, 0b0000_1011) # EWPX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype - write_sint(buf, 200) # geometry-y (relative) + write_uint(buf, 22) # PATH record + write_byte(buf, 0b0000_1011) # EWPX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype + write_sint(buf, 200) # geometry-y (relative) # PATH 6 - write_uint(buf, 22) # PATH record - write_byte(buf, 0b0000_1111) # EWPX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype - write_sint(buf, 200) # geometry-y (relative) - write_uint(buf, 1) # repetition (3x4 matrix) - write_uint(buf, 1) # (repetition) x-dimension - write_uint(buf, 2) # (repetition) y-dimension - write_uint(buf, 200) # (repetition) x-spacing - write_uint(buf, 300) # (repetition) y-spacing + write_uint(buf, 22) # PATH record + write_byte(buf, 0b0000_1111) # EWPX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype + write_sint(buf, 200) # geometry-y (relative) + write_uint(buf, 1) # repetition (3x4 matrix) + write_uint(buf, 1) # (repetition) x-dimension + write_uint(buf, 2) # (repetition) y-dimension + write_uint(buf, 200) # (repetition) x-spacing + write_uint(buf, 300) # (repetition) y-spacing - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # PATH 7 - write_uint(buf, 22) # PATH record - write_byte(buf, 0b0001_0101) # EWPX_YRDL - write_uint(buf, 1) # layer - write_sint(buf, 1000) # geometry-x (relative) - write_uint(buf, 0) # repetition (reuse) + write_uint(buf, 22) # PATH record + write_byte(buf, 0b0001_0101) # EWPX_YRDL + write_uint(buf, 1) # layer + write_sint(buf, 1000) # geometry-x (relative) + write_uint(buf, 0) # repetition (reuse) buf.write(FOOTER) return buf diff --git a/fatamorgana/test/test_files_placements.py b/fatamorgana/test/test_files_placements.py index 5059be9..390876e 100644 --- a/fatamorgana/test/test_files_placements.py +++ b/fatamorgana/test/test_files_placements.py @@ -1,17 +1,11 @@ # type: ignore - -from typing import List, Tuple, Iterable -from itertools import chain +from typing import Tuple from io import BytesIO, BufferedIOBase -import struct -import pytest # type: ignore -import numpy from numpy.testing import assert_equal from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte, PathExtensionScheme -from ..basic import InvalidRecordError, InvalidDataError, write_float32, write_float64 +from ..basic import write_uint, write_sint, write_bstring, write_byte, write_float32, write_float64 from ..main import OasisLayout @@ -28,14 +22,14 @@ def base_tests(layout: OasisLayout) -> None: def write_rectangle(buf: BufferedIOBase, pos: Tuple[int, int] = (300, -400)) -> None: - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, pos[0]) # geometry-x (absolute) - write_sint(buf, pos[1]) # geometry-y (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0111_1011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, pos[0]) # geometry-x (absolute) + write_sint(buf, pos[1]) # geometry-y (absolute) def write_file_1(buf: BufferedIOBase) -> BufferedIOBase: @@ -43,120 +37,120 @@ def write_file_1(buf: BufferedIOBase) -> BufferedIOBase: ''' buf.write(HEADER) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'A') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'A') # Cell name write_rectangle(buf) - write_uint(buf, 14) # CELL record (explicit) + write_uint(buf, 14) # CELL record (explicit) write_bstring(buf, b'TOP') # Cell name - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # PLACEMENT 0 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b1011_0000) # CNXY_RAAF - write_bstring(buf, b'A') # cell reference - write_sint(buf, -300) # placement-x (relative) - write_sint(buf, 400) # placement-y (relative) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b1011_0000) # CNXY_RAAF + write_bstring(buf, b'A') # cell reference + write_sint(buf, -300) # placement-x (relative) + write_sint(buf, 400) # placement-y (relative) # PLACEMENT 1 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_0000) # CNXY_RAAF - write_sint(buf, 0) # placement-x (relative) - write_sint(buf, 400) # placement-y (relative) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_0000) # CNXY_RAAF + write_sint(buf, 0) # placement-x (relative) + write_sint(buf, 400) # placement-y (relative) # PLACEMENT 2 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0001_0000) # CNXY_RAAF - write_sint(buf, 400) # placement-y (relative) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0001_0000) # CNXY_RAAF + write_sint(buf, 400) # placement-y (relative) # PLACEMENT 3 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0010_0000) # CNXY_RAAF - write_sint(buf, 300) # placement-x (relative) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0010_0000) # CNXY_RAAF + write_sint(buf, 300) # placement-x (relative) - write_uint(buf, 15) # XYABSOLUTE record + write_uint(buf, 15) # XYABSOLUTE record # PLACEMENT 4 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_0001) # CNXY_RAAF - write_sint(buf, 700) # placement-x (absolute) - write_sint(buf, 400) # placement-y (absolute) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_0001) # CNXY_RAAF + write_sint(buf, 700) # placement-x (absolute) + write_sint(buf, 400) # placement-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # PLACEMENT 5 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0001_0010) # CNXY_RAAF - write_sint(buf, 1000) # placement-y (relative) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0001_0010) # CNXY_RAAF + write_sint(buf, 1000) # placement-y (relative) # PLACEMENT 6 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0001_0011) # CNXY_RAAF - write_sint(buf, 1000) # placement-y (relative) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0001_0011) # CNXY_RAAF + write_sint(buf, 1000) # placement-y (relative) - write_uint(buf, 15) # XYABSOLUTE record + write_uint(buf, 15) # XYABSOLUTE record # PLACEMENT 7 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_1111) # CNXY_RAAF - write_sint(buf, 2000) # placement-x (absolute) - write_sint(buf, 0) # placement-y (absolute) - write_uint(buf, 1) # repetition (3x4 matrix) - write_uint(buf, 1) # (repetition) x-dimension - write_uint(buf, 2) # (repetition) y-dimension - write_uint(buf, 300) # (repetition) x-spacing - write_uint(buf, 300) # (repetition) y-spacing + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_1111) # CNXY_RAAF + write_sint(buf, 2000) # placement-x (absolute) + write_sint(buf, 0) # placement-y (absolute) + write_uint(buf, 1) # repetition (3x4 matrix) + write_uint(buf, 1) # (repetition) x-dimension + write_uint(buf, 2) # (repetition) y-dimension + write_uint(buf, 300) # (repetition) x-spacing + write_uint(buf, 300) # (repetition) y-spacing - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # PLACEMENT 8 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_1111) # CNXY_RAAF - write_sint(buf, 2000) # placement-x (relative) - write_sint(buf, 0) # placement-y (relative) - write_uint(buf, 0) # repetition (reuse) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_1111) # CNXY_RAAF + write_sint(buf, 2000) # placement-x (relative) + write_sint(buf, 0) # placement-y (relative) + write_uint(buf, 0) # repetition (reuse) # PLACEMENT 9 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_1111) # CNXY_RAAF - write_sint(buf, 2000) # placement-x (relative) - write_sint(buf, 0) # placement-y (relative) - write_uint(buf, 2) # repetition (3 cols.) - write_uint(buf, 1) # (repetition) count - write_uint(buf, 320) # (repetition) spacing + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_1111) # CNXY_RAAF + write_sint(buf, 2000) # placement-x (relative) + write_sint(buf, 0) # placement-y (relative) + write_uint(buf, 2) # repetition (3 cols.) + write_uint(buf, 1) # (repetition) count + write_uint(buf, 320) # (repetition) spacing # PLACEMENT 10 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_1111) # CNXY_RAAF - write_sint(buf, 2000) # placement-x (relative) - write_sint(buf, 0) # placement-y (relative) - write_uint(buf, 3) # repetition (4 rows) - write_uint(buf, 2) # (repetition) count - write_uint(buf, 310) # (repetition) spacing + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_1111) # CNXY_RAAF + write_sint(buf, 2000) # placement-x (relative) + write_sint(buf, 0) # placement-y (relative) + write_uint(buf, 3) # repetition (4 rows) + write_uint(buf, 2) # (repetition) count + write_uint(buf, 310) # (repetition) spacing # PLACEMENT 11 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_1111) # CNXY_RAAF - write_sint(buf, 2000) # placement-x (relative) - write_sint(buf, 0) # placement-y (relative) - write_uint(buf, 4) # repetition (4 arbitrary cols.) - write_uint(buf, 2) # (repetition) dimension - write_uint(buf, 320) # (repetition) spacing - write_uint(buf, 330) # (repetition) spacing - write_uint(buf, 340) # (repetition) spacing + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_1111) # CNXY_RAAF + write_sint(buf, 2000) # placement-x (relative) + write_sint(buf, 0) # placement-y (relative) + write_uint(buf, 4) # repetition (4 arbitrary cols.) + write_uint(buf, 2) # (repetition) dimension + write_uint(buf, 320) # (repetition) spacing + write_uint(buf, 330) # (repetition) spacing + write_uint(buf, 340) # (repetition) spacing # PLACEMENT 12 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_1111) # CNXY_RAAF - write_sint(buf, 2000) # placement-x (relative) - write_sint(buf, 0) # placement-y (relative) - write_uint(buf, 8) # repetition (3x4 matrix, arbitrary vectors) - write_uint(buf, 1) # (repetition) n-dimension - write_uint(buf, 2) # (repetition) m-dimension - write_uint(buf, 310 << 2 | 0b01) # (repetition) n-displacement g-delta: (310, 320) - write_sint(buf, 320) # (repetition g-delta) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_1111) # CNXY_RAAF + write_sint(buf, 2000) # placement-x (relative) + write_sint(buf, 0) # placement-y (relative) + write_uint(buf, 8) # repetition (3x4 matrix, arbitrary vectors) + write_uint(buf, 1) # (repetition) n-dimension + write_uint(buf, 2) # (repetition) m-dimension + write_uint(buf, 310 << 2 | 0b01) # (repetition) n-displacement g-delta: (310, 320) + write_sint(buf, 320) # (repetition g-delta) write_uint(buf, 330 << 4 | 0b1010) # (repetition) m-displacement g-delta: 330-northwest (-330, 330) buf.write(FOOTER) @@ -211,9 +205,9 @@ def test_file_1() -> None: assert pp.y == 0, msg if ii < 4 or ii == 5: - assert pp.flip == False, msg + assert not bool(pp.flip), msg else: - assert pp.flip == True, msg + assert bool(pp.flip), msg if ii < 5: assert pp.angle == 0, msg @@ -286,49 +280,49 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: # PLACEMENT 0 write_uint(buf, 17) # PLACEMENT (simple) if variant == 2: - write_byte(buf, 0b1011_0000) # CNXY_RAAF - write_bstring(buf, b'A') # cell reference + write_byte(buf, 0b1011_0000) # CNXY_RAAF + write_bstring(buf, b'A') # cell reference else: - write_byte(buf, 0b1111_0000) # CNXY_RAAF - write_uint(buf, 0) # cell reference - write_sint(buf, -300) # placement-x (relative) - write_sint(buf, 400) # placement-y (relative) + write_byte(buf, 0b1111_0000) # CNXY_RAAF + write_uint(buf, 0) # cell reference + write_sint(buf, -300) # placement-x (relative) + write_sint(buf, 400) # placement-y (relative) # PLACEMENT 1 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_0000) # CNXY_RAAF - write_sint(buf, 0) # placement-x (relative) - write_sint(buf, 400) # placement-y (relative) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_0000) # CNXY_RAAF + write_sint(buf, 0) # placement-x (relative) + write_sint(buf, 400) # placement-y (relative) # PLACEMENT 2 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0001_0000) # CNXY_RAAF - write_sint(buf, 400) # placement-y (relative) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0001_0000) # CNXY_RAAF + write_sint(buf, 400) # placement-y (relative) # PLACEMENT 3 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0010_0000) # CNXY_RAAF - write_sint(buf, 300) # placement-x (relative) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0010_0000) # CNXY_RAAF + write_sint(buf, 300) # placement-x (relative) - write_uint(buf, 15) # XYABSOLUTE record + write_uint(buf, 15) # XYABSOLUTE record # PLACEMENT 4 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_0001) # CNXY_RAAF - write_sint(buf, 700) # placement-x (absolute) - write_sint(buf, 400) # placement-y (absolute) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_0001) # CNXY_RAAF + write_sint(buf, 700) # placement-x (absolute) + write_sint(buf, 400) # placement-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # PLACEMENT 5 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0001_0010) # CNXY_RAAF - write_sint(buf, 1000) # placement-y (relative) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0001_0010) # CNXY_RAAF + write_sint(buf, 1000) # placement-y (relative) # PLACEMENT 6 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0001_0011) # CNXY_RAAF - write_sint(buf, 1000) # placement-y (relative) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0001_0011) # CNXY_RAAF + write_sint(buf, 1000) # placement-y (relative) if variant == 2: write_uint(buf, 14) # CELL record (explicit) @@ -502,9 +496,9 @@ def common_tests(layout: OasisLayout, variant: int) -> None: assert pp.y == 400 * (ii + 1), msg if ii in (4, 6): - assert pp.flip == True, msg + assert bool(pp.flip), msg else: - assert pp.flip == False, msg + assert not bool(pp.flip), msg if ii in (5, 6): assert pp.angle == 90, msg @@ -525,73 +519,73 @@ def write_file_4(buf: BufferedIOBase) -> BufferedIOBase: ''' buf.write(HEADER) - write_uint(buf, 3) # CELLNAME record (implicit id 0) + write_uint(buf, 3) # CELLNAME record (implicit id 0) write_bstring(buf, b'A') - write_uint(buf, 3) # CELLNAME record (implicit id 1) + write_uint(buf, 3) # CELLNAME record (implicit id 1) write_bstring(buf, b'TOP') - write_uint(buf, 13) # CELL record (name ref.) - write_uint(buf, 1) # Cell name 1 (TOP) + write_uint(buf, 13) # CELL record (name ref.) + write_uint(buf, 1) # Cell name 1 (TOP) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # PLACEMENT 0 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b1111_1000) # CNXY_RAAF - write_uint(buf, 0) # cell reference - write_sint(buf, -300) # placement-x (relative) - write_sint(buf, 400) # placement-y (relative) - write_uint(buf, 1) # repetition (3x4 matrix) - write_uint(buf, 1) # (repetition) x-dimension - write_uint(buf, 2) # (repetition) y-dimension - write_uint(buf, 20) # (repetition) x-spacing - write_uint(buf, 30) # (repetition) y-spacing + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b1111_1000) # CNXY_RAAF + write_uint(buf, 0) # cell reference + write_sint(buf, -300) # placement-x (relative) + write_sint(buf, 400) # placement-y (relative) + write_uint(buf, 1) # repetition (3x4 matrix) + write_uint(buf, 1) # (repetition) x-dimension + write_uint(buf, 2) # (repetition) y-dimension + write_uint(buf, 20) # (repetition) x-spacing + write_uint(buf, 30) # (repetition) y-spacing # PLACEMENT 1 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_1000) # CNXY_RAAF - write_sint(buf, 0) # placement-x (relative) - write_sint(buf, 400) # placement-y (relative) - write_uint(buf, 0) # repetition (reuse) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_1000) # CNXY_RAAF + write_sint(buf, 0) # placement-x (relative) + write_sint(buf, 400) # placement-y (relative) + write_uint(buf, 0) # repetition (reuse) # PLACEMENT 2 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0001_1000) # CNXY_RAAF - write_sint(buf, 400) # placement-y (relative) - write_uint(buf, 0) # repetition (reuse) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0001_1000) # CNXY_RAAF + write_sint(buf, 400) # placement-y (relative) + write_uint(buf, 0) # repetition (reuse) # PLACEMENT 3 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0010_1000) # CNXY_RAAF - write_sint(buf, 300) # placement-x (relative) - write_uint(buf, 0) # repetition (reuse) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0010_1000) # CNXY_RAAF + write_sint(buf, 300) # placement-x (relative) + write_uint(buf, 0) # repetition (reuse) - write_uint(buf, 15) # XYABSOLUTE record + write_uint(buf, 15) # XYABSOLUTE record # PLACEMENT 4 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0011_1001) # CNXY_RAAF - write_sint(buf, 700) # placement-x (absolute) - write_sint(buf, 400) # placement-y (absolute) - write_uint(buf, 0) # repetition (reuse) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0011_1001) # CNXY_RAAF + write_sint(buf, 700) # placement-x (absolute) + write_sint(buf, 400) # placement-y (absolute) + write_uint(buf, 0) # repetition (reuse) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # PLACEMENT 5 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0001_1010) # CNXY_RAAF - write_sint(buf, 1000) # placement-y (relative) - write_uint(buf, 0) # repetition (reuse) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0001_1010) # CNXY_RAAF + write_sint(buf, 1000) # placement-y (relative) + write_uint(buf, 0) # repetition (reuse) # PLACEMENT 6 - write_uint(buf, 17) # PLACEMENT (simple) - write_byte(buf, 0b0001_1011) # CNXY_RAAF - write_sint(buf, 1000) # placement-y (relative) - write_uint(buf, 0) # repetition (reuse) + write_uint(buf, 17) # PLACEMENT (simple) + write_byte(buf, 0b0001_1011) # CNXY_RAAF + write_sint(buf, 1000) # placement-y (relative) + write_uint(buf, 0) # repetition (reuse) - write_uint(buf, 13) # CELL record (name ref.) - write_uint(buf, 0) # Cell name 0 (A) + write_uint(buf, 13) # CELL record (name ref.) + write_uint(buf, 0) # Cell name 0 (A) write_rectangle(buf) @@ -604,84 +598,84 @@ def write_file_6(buf: BufferedIOBase) -> BufferedIOBase: ''' buf.write(HEADER) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'TOPTOP') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'TOPTOP') # Cell name - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record - write_uint(buf, 18) # PLACEMENT (mag 0.5, manhattan) - write_byte(buf, 0b1011_0110) # CNXY_RMAF - write_bstring(buf, b'TOP') # Cell reference - write_uint(buf, 6) # magnitude, float32 - write_float32(buf, 0.5) # (magnitude) - write_uint(buf, 7) # angle, float64 - write_float64(buf, 90.0) # (angle) - write_sint(buf, 100) # placement-x (relative) - write_sint(buf, 0) # placement-y (relative) + write_uint(buf, 18) # PLACEMENT (mag 0.5, manhattan) + write_byte(buf, 0b1011_0110) # CNXY_RMAF + write_bstring(buf, b'TOP') # Cell reference + write_uint(buf, 6) # magnitude, float32 + write_float32(buf, 0.5) # (magnitude) + write_uint(buf, 7) # angle, float64 + write_float64(buf, 90.0) # (angle) + write_sint(buf, 100) # placement-x (relative) + write_sint(buf, 0) # placement-y (relative) - write_uint(buf, 18) # PLACEMENT (no mag, manhattan) - write_byte(buf, 0b0011_0000) # CNXY_RMAF - write_sint(buf, 100) # placement-x (relative) - write_sint(buf, 1000) # placement-y (relative) + write_uint(buf, 18) # PLACEMENT (no mag, manhattan) + write_byte(buf, 0b0011_0000) # CNXY_RMAF + write_sint(buf, 100) # placement-x (relative) + write_sint(buf, 1000) # placement-y (relative) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'TOP') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'TOP') # Cell name - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # PLACEMENT 0 - write_uint(buf, 18) # PLACEMENT (mag 0.5, manhattan) - write_byte(buf, 0b1011_0110) # CNXY_RMAF - write_bstring(buf, b'A') # Cell reference - write_uint(buf, 6) # magnitude, float32 - write_float32(buf, 0.5) # (magnitude) - write_uint(buf, 7) # angle, float64 - write_float64(buf, 0.0) # (angle) - write_sint(buf, -150) # placement-x (relative) - write_sint(buf, 200) # placement-y (relative) + write_uint(buf, 18) # PLACEMENT (mag 0.5, manhattan) + write_byte(buf, 0b1011_0110) # CNXY_RMAF + write_bstring(buf, b'A') # Cell reference + write_uint(buf, 6) # magnitude, float32 + write_float32(buf, 0.5) # (magnitude) + write_uint(buf, 7) # angle, float64 + write_float64(buf, 0.0) # (angle) + write_sint(buf, -150) # placement-x (relative) + write_sint(buf, 200) # placement-y (relative) # PLACEMENT 1 - write_uint(buf, 18) # PLACEMENT (no mag, manhattan) - write_byte(buf, 0b0011_0000) # CNXY_RMAF - write_sint(buf, -150) # placement-x (relative) - write_sint(buf, 600) # placement-y (relative) + write_uint(buf, 18) # PLACEMENT (no mag, manhattan) + write_byte(buf, 0b0011_0000) # CNXY_RMAF + write_sint(buf, -150) # placement-x (relative) + write_sint(buf, 600) # placement-y (relative) # PLACEMENT 2 - write_uint(buf, 18) # PLACEMENT (no mag, manhattan) - write_byte(buf, 0b0001_0000) # CNXY_RMAF - write_sint(buf, 400) # placement-y (relative) + write_uint(buf, 18) # PLACEMENT (no mag, manhattan) + write_byte(buf, 0b0001_0000) # CNXY_RMAF + write_sint(buf, 400) # placement-y (relative) # PLACEMENT 3 - write_uint(buf, 18) # PLACEMENT (no mag, manhattan) - write_byte(buf, 0b0010_0000) # CNXY_RMAF - write_sint(buf, 300) # placement-x (relative) + write_uint(buf, 18) # PLACEMENT (no mag, manhattan) + write_byte(buf, 0b0010_0000) # CNXY_RMAF + write_sint(buf, 300) # placement-x (relative) - write_uint(buf, 15) # XYABSOLUTE record + write_uint(buf, 15) # XYABSOLUTE record # PLACEMENT 4 - write_uint(buf, 18) # PLACEMENT (no mag, manhattan) - write_byte(buf, 0b0011_0001) # CNXY_RMAF - write_sint(buf, 700) # placement-x (absolute) - write_sint(buf, 400) # placement-y (absolute) + write_uint(buf, 18) # PLACEMENT (no mag, manhattan) + write_byte(buf, 0b0011_0001) # CNXY_RMAF + write_sint(buf, 700) # placement-x (absolute) + write_sint(buf, 400) # placement-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # PLACEMENT 5 - write_uint(buf, 18) # PLACEMENT (no mag, manhattan) - write_byte(buf, 0b0001_0010) # CNXY_RMAF - write_uint(buf, 0) # angle (uint, positive) - write_uint(buf, 90) # (angle) - write_sint(buf, 1000) # placement-y (relative) + write_uint(buf, 18) # PLACEMENT (no mag, manhattan) + write_byte(buf, 0b0001_0010) # CNXY_RMAF + write_uint(buf, 0) # angle (uint, positive) + write_uint(buf, 90) # (angle) + write_sint(buf, 1000) # placement-y (relative) # PLACEMENT 6 - write_uint(buf, 18) # PLACEMENT (no mag, manhattan) - write_byte(buf, 0b0001_0011) # CNXY_RMAF - write_uint(buf, 1) # angle (uint, negative) - write_uint(buf, 90) # (angle) - write_sint(buf, 1000) # placement-y (relative) + write_uint(buf, 18) # PLACEMENT (no mag, manhattan) + write_byte(buf, 0b0001_0011) # CNXY_RMAF + write_uint(buf, 1) # angle (uint, negative) + write_uint(buf, 90) # (angle) + write_sint(buf, 1000) # placement-y (relative) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'A') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'A') # Cell name write_rectangle(buf) @@ -757,71 +751,71 @@ def write_file_8(buf: BufferedIOBase) -> BufferedIOBase: ''' buf.write(HEADER) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'TOPTOP') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'TOPTOP') # Cell name - write_uint(buf, 15) # XYABSOLUTE record + write_uint(buf, 15) # XYABSOLUTE record - write_uint(buf, 18) # PLACEMENT (mag 0.5, arbitrary angle) - write_byte(buf, 0b1011_0110) # CNXY_RMAF - write_bstring(buf, b'TOP') # Cell reference - write_uint(buf, 6) # magnitude, float32 - write_float32(buf, 0.5) # (magnitude) - write_uint(buf, 7) # angle, float64 - write_float64(buf, 22.5) # (angle) - write_sint(buf, 100) # placement-x (absolute) - write_sint(buf, 0) # placement-y (absolute) + write_uint(buf, 18) # PLACEMENT (mag 0.5, arbitrary angle) + write_byte(buf, 0b1011_0110) # CNXY_RMAF + write_bstring(buf, b'TOP') # Cell reference + write_uint(buf, 6) # magnitude, float32 + write_float32(buf, 0.5) # (magnitude) + write_uint(buf, 7) # angle, float64 + write_float64(buf, 22.5) # (angle) + write_sint(buf, 100) # placement-x (absolute) + write_sint(buf, 0) # placement-y (absolute) - write_uint(buf, 18) # PLACEMENT (mag 1.0, manhattan) - write_byte(buf, 0b1011_0110) # CNXY_RMAF - write_bstring(buf, b'TOP') # Cell reference - write_uint(buf, 6) # magnitude, float32 - write_float32(buf, 1.0) # (magnitude) - write_uint(buf, 7) # angle, float64 - write_float64(buf, 0.0) # (angle) - write_sint(buf, 1100) # placement-x (absolute) - write_sint(buf, 0) # placement-y (absolute) + write_uint(buf, 18) # PLACEMENT (mag 1.0, manhattan) + write_byte(buf, 0b1011_0110) # CNXY_RMAF + write_bstring(buf, b'TOP') # Cell reference + write_uint(buf, 6) # magnitude, float32 + write_float32(buf, 1.0) # (magnitude) + write_uint(buf, 7) # angle, float64 + write_float64(buf, 0.0) # (angle) + write_sint(buf, 1100) # placement-x (absolute) + write_sint(buf, 0) # placement-y (absolute) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'TOP') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'TOP') # Cell name - write_uint(buf, 18) # PLACEMENT (mag 2.0, manhattan) - write_byte(buf, 0b1011_0110) # CNXY_RMAF - write_bstring(buf, b'A') # Cell reference - write_uint(buf, 6) # magnitude, float32 - write_float32(buf, 2.0) # (magnitude) - write_uint(buf, 7) # angle, float64 - write_float64(buf, 0.0) # (angle) - write_sint(buf, -100) # placement-x (absolute) - write_sint(buf, 100) # placement-y (absolute) + write_uint(buf, 18) # PLACEMENT (mag 2.0, manhattan) + write_byte(buf, 0b1011_0110) # CNXY_RMAF + write_bstring(buf, b'A') # Cell reference + write_uint(buf, 6) # magnitude, float32 + write_float32(buf, 2.0) # (magnitude) + write_uint(buf, 7) # angle, float64 + write_float64(buf, 0.0) # (angle) + write_sint(buf, -100) # placement-x (absolute) + write_sint(buf, 100) # placement-y (absolute) - write_uint(buf, 18) # PLACEMENT (mag 1.0, arbitrary angle) - write_byte(buf, 0b1011_0110) # CNXY_RMAF - write_bstring(buf, b'A') # Cell reference - write_uint(buf, 6) # magnitude, float32 - write_float32(buf, 1.0) # (magnitude) - write_uint(buf, 7) # angle, float64 - write_float64(buf, 45.0) # (angle) - write_sint(buf, -150) # placement-x (absolute) - write_sint(buf, 1100) # placement-y (absolute) + write_uint(buf, 18) # PLACEMENT (mag 1.0, arbitrary angle) + write_byte(buf, 0b1011_0110) # CNXY_RMAF + write_bstring(buf, b'A') # Cell reference + write_uint(buf, 6) # magnitude, float32 + write_float32(buf, 1.0) # (magnitude) + write_uint(buf, 7) # angle, float64 + write_float64(buf, 45.0) # (angle) + write_sint(buf, -150) # placement-x (absolute) + write_sint(buf, 1100) # placement-y (absolute) - write_uint(buf, 18) # PLACEMENT (mag 0.5, arbitrary angle) - write_byte(buf, 0b1011_1111) # CNXY_RMAF - write_bstring(buf, b'A') # Cell reference - write_uint(buf, 6) # magnitude, float32 - write_float32(buf, 0.5) # (magnitude) - write_uint(buf, 7) # angle, float64 - write_float64(buf, 135.0) # (angle) - write_sint(buf, -200) # placement-x (absolute) - write_sint(buf, 2100) # placement-y (absolute) - write_uint(buf, 1) # repetition (3x4 matrix) - write_uint(buf, 1) # (repetition) x-dimension - write_uint(buf, 2) # (repetition) y-dimension - write_uint(buf, 200) # (repetition) x-spacing - write_uint(buf, 300) # (repetition) y-spacing + write_uint(buf, 18) # PLACEMENT (mag 0.5, arbitrary angle) + write_byte(buf, 0b1011_1111) # CNXY_RMAF + write_bstring(buf, b'A') # Cell reference + write_uint(buf, 6) # magnitude, float32 + write_float32(buf, 0.5) # (magnitude) + write_uint(buf, 7) # angle, float64 + write_float64(buf, 135.0) # (angle) + write_sint(buf, -200) # placement-x (absolute) + write_sint(buf, 2100) # placement-y (absolute) + write_uint(buf, 1) # repetition (3x4 matrix) + write_uint(buf, 1) # (repetition) x-dimension + write_uint(buf, 2) # (repetition) y-dimension + write_uint(buf, 200) # (repetition) x-spacing + write_uint(buf, 300) # (repetition) y-spacing - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'A') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'A') # Cell name write_rectangle(buf, pos=(30, -40)) diff --git a/fatamorgana/test/test_files_polygons.py b/fatamorgana/test/test_files_polygons.py index fc5d0c2..2deb808 100644 --- a/fatamorgana/test/test_files_polygons.py +++ b/fatamorgana/test/test_files_polygons.py @@ -1,17 +1,12 @@ # type: ignore -from typing import List, Tuple, Iterable -from itertools import chain from io import BytesIO, BufferedIOBase -import struct -import pytest # type: ignore import numpy from numpy.testing import assert_equal from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte -from ..basic import InvalidRecordError, InvalidDataError +from ..basic import write_uint, write_sint, write_bstring, write_byte from ..main import OasisLayout @@ -85,8 +80,11 @@ def common_tests(layout: OasisLayout) -> None: for ii in range(4): msg = f'Fail on poly {ii}' assert len(geometry[0].point_list) == 6, msg - assert_equal(geometry[0].point_list, [[150, 0], [0, 50], [-50, 0], [0, 50], - [-100, 0], [0, -100]], err_msg=msg) + assert_equal( + geometry[0].point_list, + [[150, 0], [0, 50], [-50, 0], [0, 50], [-100, 0], [0, -100]], + err_msg=msg, + ) assert len(geometry[4].point_list) == 6 assert_equal(geometry[4].point_list, [[0, 150], [50, 0], [0, -50], [50, 0], [0, -100], [-100, 0]]) @@ -97,8 +95,10 @@ def common_tests(layout: OasisLayout) -> None: assert len(geometry[7].point_list) == 9 assert_equal(geometry[7].point_list, [[25, 0], [50, 50], [0, 50], [-50, 50], [-50, 0], [-50, -50], [10, -75], [25, -25], [40, 0]]) assert len(geometry[8].point_list) == 9 - assert_equal(geometry[8].point_list, - numpy.cumsum([[25, 0], [50, 50], [0, 50], [-50, 50], [-50, 0], [-50, -50], [10, -75], [25, -25], [45, -575]], axis=0)) + assert_equal( + geometry[8].point_list, + numpy.cumsum([[25, 0], [50, 50], [0, 50], [-50, 50], [-50, 0], [-50, -50], [10, -75], [25, -25], [45, -575]], axis=0), + ) for ii in range(9, 12): msg = f'Fail on poly {ii}' @@ -114,49 +114,49 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: buf.write(HEADER) if variant == 3: - write_uint(buf, 7) # PROPNAME record (implict id 0) - write_bstring(buf, b'PROP0') # property name + write_uint(buf, 7) # PROPNAME record (implict id 0) + write_bstring(buf, b'PROP0') # property name - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'ABC') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'ABC') # Cell name # POLYGON 0 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0011_1011) # 00PX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt - write_uint(buf, 4) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, 0) # geometry-x (absolute) - write_sint(buf, 100) # geometry-y (absolute) + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0011_1011) # 00PX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt + write_uint(buf, 4) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, 0) # geometry-x (absolute) + write_sint(buf, 100) # geometry-y (absolute) if variant == 3: # PROPERTY 0 - write_uint(buf, 28) # PROPERTY record (explicit) - write_byte(buf, 0b0001_0110) # UUUU_VCNS - write_uint(buf, 0) # propname id - write_uint(buf, 2) # property value (real: positive reciprocal) - write_uint(buf, 5) # (real) 1/5 + write_uint(buf, 28) # PROPERTY record (explicit) + write_byte(buf, 0b0001_0110) # UUUU_VCNS + write_uint(buf, 0) # propname id + write_uint(buf, 2) # property value (real: positive reciprocal) + write_uint(buf, 5) # (real) 1/5 write_uint(buf, 16) # XYRELATIVE record # Polygon 1 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0011_1011) # 00PX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt - write_uint(buf, 4) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -200) # geometry-x (relative) - write_sint(buf, 300) # geometry-y (relative) + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0011_1011) # 00PX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt + write_uint(buf, 4) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -200) # geometry-x (relative) + write_sint(buf, 300) # geometry-y (relative) if variant == 3: # PROPERTY 1 @@ -165,55 +165,55 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 15) # XYABSOLUTE record # Polygon 2 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0011_0011) # 00PX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype - write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt - write_uint(buf, 4) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, 0) # geometry-x (absolute) + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0011_0011) # 00PX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype + write_uint(buf, 0) # pointlist: 1-delta, horiz-fisrt + write_uint(buf, 4) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, 0) # geometry-x (absolute) if variant == 3: # PROPERTY 2 write_uint(buf, 29) # PROPERTY record (repeat) # Polygon 3 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0000_1000) # 00PX_YRDL - write_sint(buf, 1000) # geometry-y (absolute) + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0000_1000) # 00PX_YRDL + write_sint(buf, 1000) # geometry-y (absolute) if variant == 3: # PROPERTY 3 write_uint(buf, 29) # PROPERTY record (repeat) # Polygon 4 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0011_0011) # 00PX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype - write_uint(buf, 1) # pointlist: 1-delta, vert-fisrt - write_uint(buf, 4) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, 200) # geometry-x (absolute) + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0011_0011) # 00PX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype + write_uint(buf, 1) # pointlist: 1-delta, vert-fisrt + write_uint(buf, 4) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, 200) # geometry-x (absolute) if variant == 3: # PROPERTY 4 write_uint(buf, 29) # PROPERTY record (repeat) # Polygon 5 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0011_0011) # 00PX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype - write_uint(buf, 2) # pointlist: 2-delta - write_uint(buf, 7) # (pointlist) dimension + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0011_0011) # 00PX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype + write_uint(buf, 2) # pointlist: 2-delta + write_uint(buf, 7) # (pointlist) dimension write_uint(buf, 150 << 2 | 0b00) # (pointlist) write_uint(buf, 50 << 2 | 0b01) # (pointlist) write_uint(buf, 50 << 2 | 0b10) # (pointlist) @@ -228,12 +228,12 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 29) # PROPERTY record (repeat) # Polygon 6 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0011_0011) # 00PX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype - write_uint(buf, 3) # pointlist: 3-delta - write_uint(buf, 8) # (pointlist) dimension + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0011_0011) # 00PX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype + write_uint(buf, 3) # pointlist: 3-delta + write_uint(buf, 8) # (pointlist) dimension write_uint(buf, 25 << 3 | 0b000) # (pointlist) write_uint(buf, 50 << 3 | 0b100) # (pointlist) write_uint(buf, 50 << 3 | 0b001) # (pointlist) @@ -249,12 +249,12 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 29) # PROPERTY record (repeat) # Polygon 7 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0011_0011) # 00PX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype - write_uint(buf, 4) # pointlist: g-delta - write_uint(buf, 8) # (pointlist) dimension + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0011_0011) # 00PX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype + write_uint(buf, 4) # pointlist: g-delta + write_uint(buf, 8) # (pointlist) dimension write_uint(buf, 25 << 4 | 0b0000) # (pointlist) write_uint(buf, 50 << 4 | 0b1000) # (pointlist) write_uint(buf, 50 << 4 | 0b0010) # (pointlist) @@ -263,7 +263,7 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 50 << 4 | 0b0100) # (pointlist) write_uint(buf, 50 << 4 | 0b1100) # (pointlist) write_uint(buf, 10 << 2 | 0b01) # (pointlist) - write_sint(buf, -75 ) + write_sint(buf, -75) write_uint(buf, 25 << 4 | 0b1110) # (pointlist) write_sint(buf, 900) # geometry-x (absolute) @@ -272,12 +272,12 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 29) # PROPERTY record (repeat) # Polygon 8 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0011_0011) # 00PX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype - write_uint(buf, 5) # pointlist: double g-delta - write_uint(buf, 8) # (pointlist) dimension + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0011_0011) # 00PX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype + write_uint(buf, 5) # pointlist: double g-delta + write_uint(buf, 8) # (pointlist) dimension write_uint(buf, 25 << 4 | 0b0000) # (pointlist) write_uint(buf, 50 << 4 | 0b1000) # (pointlist) write_uint(buf, 50 << 4 | 0b0010) # (pointlist) @@ -286,7 +286,7 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 50 << 4 | 0b0100) # (pointlist) write_uint(buf, 50 << 4 | 0b1100) # (pointlist) write_uint(buf, 10 << 2 | 0b01) # (pointlist) - write_sint(buf, -75 ) + write_sint(buf, -75) write_uint(buf, 25 << 4 | 0b1110) # (pointlist) write_sint(buf, 1100) # geometry-x (absolute) @@ -295,62 +295,62 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 29) # PROPERTY record (repeat) # Polygon 9 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0011_1111) # 00PX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype - write_uint(buf, 1) # pointlist: 1-delta (vert. first) - write_uint(buf, 4) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, 0) # geometry-x (absolute) - write_sint(buf, 2000) # geometry-y (absolute) - write_uint(buf, 1) # repetition (3x4 matrix) - write_uint(buf, 1) # (repetition) x-dimension - write_uint(buf, 2) # (repetition) y-dimension - write_uint(buf, 200) # (repetition) x-spacing - write_uint(buf, 300) # (repetition) y-spacing + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0011_1111) # 00PX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype + write_uint(buf, 1) # pointlist: 1-delta (vert. first) + write_uint(buf, 4) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, 0) # geometry-x (absolute) + write_sint(buf, 2000) # geometry-y (absolute) + write_uint(buf, 1) # repetition (3x4 matrix) + write_uint(buf, 1) # (repetition) x-dimension + write_uint(buf, 2) # (repetition) y-dimension + write_uint(buf, 200) # (repetition) x-spacing + write_uint(buf, 300) # (repetition) y-spacing if variant == 3: # PROPERTY 9 write_uint(buf, 29) # PROPERTY record (repeat) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # Polygon 10 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0011_0110) # 00PX_YRDL - write_uint(buf, 1) # datatype - write_uint(buf, 1) # pointlist: 1-delta (vert. first) - write_uint(buf, 4) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, 1000) # geometry-x (relative) - write_uint(buf, 0) # repetition (reuse) + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0011_0110) # 00PX_YRDL + write_uint(buf, 1) # datatype + write_uint(buf, 1) # pointlist: 1-delta (vert. first) + write_uint(buf, 4) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, 1000) # geometry-x (relative) + write_uint(buf, 0) # repetition (reuse) if variant == 3: # PROPERTY 10 write_uint(buf, 29) # PROPERTY record (repeat) # Polygon 11 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0011_0110) # 00PX_YRDL - write_uint(buf, 1) # datatype - write_uint(buf, 1) # pointlist: 1-delta (vert. first) - write_uint(buf, 4) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, 1000) # geometry-x (relative) - write_uint(buf, 6) # repetition (3 rows) - write_uint(buf, 1) # (repetition) dimension - write_uint(buf, 200) # (repetition) y-delta - write_uint(buf, 300) # (repetition) y-delta + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0011_0110) # 00PX_YRDL + write_uint(buf, 1) # datatype + write_uint(buf, 1) # pointlist: 1-delta (vert. first) + write_uint(buf, 4) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, 1000) # geometry-x (relative) + write_uint(buf, 6) # repetition (3 rows) + write_uint(buf, 1) # (repetition) dimension + write_uint(buf, 200) # (repetition) y-delta + write_uint(buf, 300) # (repetition) y-delta if variant == 3: # PROPERTY 11 @@ -386,21 +386,21 @@ def write_file_2(buf: BufferedIOBase) -> BufferedIOBase: write_uint(buf, 15) # XYRELATIVE record # POLYGON 0 - write_uint(buf, 21) # POLYGON record - write_byte(buf, 0b0011_0011) # 00PX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype - write_uint(buf, 4) # pointlist: g-delta - write_uint(buf, 8002) # (pointlist) dimension - write_uint(buf, 1000 << 2 | 0b11) # (pointlist) - write_sint(buf, 0) # (pointlist) + write_uint(buf, 21) # POLYGON record + write_byte(buf, 0b0011_0011) # 00PX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype + write_uint(buf, 4) # pointlist: g-delta + write_uint(buf, 8002) # (pointlist) dimension + write_uint(buf, 1000 << 2 | 0b11) # (pointlist) + write_sint(buf, 0) # (pointlist) for _ in range(4000): - write_uint(buf, 10 << 2 | 0b01) # (pointlist) - write_sint(buf, 20) # (pointlist) - write_uint(buf, 10 << 2 | 0b11) # (pointlist) - write_sint(buf, 20) # (pointlist) - write_uint(buf, 1000 << 2 | 0b01) # (pointlist) - write_sint(buf, 0) # (pointlist) + write_uint(buf, 10 << 2 | 0b01) # (pointlist) + write_sint(buf, 20) # (pointlist) + write_uint(buf, 10 << 2 | 0b11) # (pointlist) + write_sint(buf, 20) # (pointlist) + write_uint(buf, 1000 << 2 | 0b01) # (pointlist) + write_sint(buf, 0) # (pointlist) write_sint(buf, 0) # geometry-x (absolute) buf.write(FOOTER) @@ -425,7 +425,8 @@ def test_file_2() -> None: assert_equal(poly.point_list, ([[-1000, 0]] + [[(-1) ** nn * 10, 20] for nn in range(8000)] - + [[1000, 0], [0, -20 * 8000]])) + + [[1000, 0], [0, -20 * 8000]]), + ) def test_file_3() -> None: diff --git a/fatamorgana/test/test_files_properties.py b/fatamorgana/test/test_files_properties.py index a49d7e1..107b64a 100644 --- a/fatamorgana/test/test_files_properties.py +++ b/fatamorgana/test/test_files_properties.py @@ -1,17 +1,13 @@ # type: ignore -from typing import List, Tuple, Iterable -from itertools import chain from io import BytesIO, BufferedIOBase -import struct -import pytest # type: ignore -import numpy +import pytest from numpy.testing import assert_equal from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte, PathExtensionScheme -from ..basic import InvalidRecordError, InvalidDataError +from ..basic import write_uint, write_sint, write_bstring, write_byte +from ..basic import InvalidDataError from ..main import OasisLayout @@ -54,7 +50,6 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 7) # PROPNAME record (implicit id 1) write_bstring(buf, b'PROP1') - write_uint(buf, 14) # CELL record (explicit) write_bstring(buf, b'A') # Cell name @@ -74,11 +69,29 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 300) # (repetition) x-spacing write_uint(buf, 320) # (repetition) y-spacing - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0000_0100) # UUUU_VCNS + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0000_0100) # UUUU_VCNS write_bstring(buf, b'PROPX') # RECTANGLE 1 + write_uint(buf, 20) # RECTANGLE record + var_byte(buf, 0b0111_1011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 0) # geometry-x (relative) + write_sint(buf, 1000) # geometry-y (relative) + if include_repetitions: + write_uint(buf, 0) # repetition (reuse) + + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0001_0110) # UUUU_VCNS + write_uint(buf, 0) # propname id + write_uint(buf, 1) # property value 0 (real type 1, negative int) + write_uint(buf, 5) # (real 1) + + # RECTANGLE 2 write_uint(buf, 20) # RECTANGLE record var_byte(buf, 0b0111_1011) # SWHX_YRDL write_uint(buf, 1) # layer @@ -90,60 +103,20 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: if include_repetitions: write_uint(buf, 0) # repetition (reuse) - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0001_0110) # UUUU_VCNS - write_uint(buf, 0) # propname id - write_uint(buf, 1) # property value 0 (real type 1, negative int) - write_uint(buf, 5) # (real 1) - - # RECTANGLE 2 - write_uint(buf, 20) # RECTANGLE record - var_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 0) # geometry-x (relative) - write_sint(buf, 1000) # geometry-y (relative) - if include_repetitions: - write_uint(buf, 0) # repetition (reuse) - - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0100_0110) # UUUU_VCNS - write_uint(buf, 0) # propname id - write_uint(buf, 8) # prop value 0 (unsigned int) - write_uint(buf, 25) # (prop value) - write_uint(buf, 9) # prop value 1 (signed int) - write_sint(buf, -124) # (prop value) - write_uint(buf, 10) # prop value 2 (a-string) + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0100_0110) # UUUU_VCNS + write_uint(buf, 0) # propname id + write_uint(buf, 8) # prop value 0 (unsigned int) + write_uint(buf, 25) # (prop value) + write_uint(buf, 9) # prop value 1 (signed int) + write_sint(buf, -124) # (prop value) + write_uint(buf, 10) # prop value 2 (a-string) write_bstring(buf, b'PROP_VALUE2') - write_uint(buf, 13) # prop value 3 (propstring ref.) + write_uint(buf, 13) # prop value 3 (propstring ref.) write_uint(buf, 12) # RECTANGLE 3 write_uint(buf, 20) # RECTANGLE record - var_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 0) # geometry-x (relative) - write_sint(buf, 1000) # geometry-y (relative) - if include_repetitions: - write_uint(buf, 0) # repetition (reuse) - - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b1111_0000) # UUUU_VCNS - write_uint(buf, 3) # number of values - write_uint(buf, 0) # prop value 0 (unsigned int) - write_uint(buf, 25) # (prop value) - write_uint(buf, 9) # prop value 1 (signed int) - write_sint(buf, -124) # (prop value) - write_uint(buf, 14) # prop value 2 (propstring ref.) - write_uint(buf, 13) - - # RECTANGLE 4 - write_uint(buf, 20) # RECTANGLE record var_byte(buf, 0b0111_1011) # SWHX_YRDL write_uint(buf, 1) # layer write_uint(buf, 2) # datatype @@ -154,14 +127,36 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: if include_repetitions: write_uint(buf, 0) # repetition (reuse) - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0000_1000) # UUUU_VCNS + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b1111_0000) # UUUU_VCNS + write_uint(buf, 3) # number of values + write_uint(buf, 0) # prop value 0 (unsigned int) + write_uint(buf, 25) # (prop value) + write_uint(buf, 9) # prop value 1 (signed int) + write_sint(buf, -124) # (prop value) + write_uint(buf, 14) # prop value 2 (propstring ref.) + write_uint(buf, 13) - write_uint(buf, 15) # XYABSOLUTE record + # RECTANGLE 4 + write_uint(buf, 20) # RECTANGLE record + var_byte(buf, 0b0111_1011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 0) # geometry-x (relative) + write_sint(buf, 1000) # geometry-y (relative) + if include_repetitions: + write_uint(buf, 0) # repetition (reuse) + + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0000_1000) # UUUU_VCNS + + write_uint(buf, 15) # XYABSOLUTE record # TEXT 5 write_uint(buf, 19) # TEXT record - var_byte(buf, 0b0101_1011) # 0CNX_YRTL + var_byte(buf, 0b0101_1011) # 0CNX_YRTL write_bstring(buf, b'A') # text-string write_uint(buf, 2) # text-layer write_uint(buf, 1) # text-datatype @@ -173,47 +168,47 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 29) # PROPERTY (reuse) # PATH 6 - write_uint(buf, 22) # PATH record - var_byte(buf, 0b1111_1011) # EWPX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 10) # half-width - write_byte(buf, 0b0000_1111) # extension-scheme 0000_SSEE - write_sint(buf, 5) # (extension-scheme) - write_sint(buf, -5) # (extension-scheme) - write_uint(buf, 0) # pointlist (1-delta, horiz. first) - write_uint(buf, 3) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 2000) # geometry-x (absolute) - write_sint(buf, 0) # geometry-y (absolute) + write_uint(buf, 22) # PATH record + var_byte(buf, 0b1111_1011) # EWPX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 10) # half-width + write_byte(buf, 0b0000_1111) # extension-scheme 0000_SSEE + write_sint(buf, 5) # (extension-scheme) + write_sint(buf, -5) # (extension-scheme) + write_uint(buf, 0) # pointlist (1-delta, horiz. first) + write_uint(buf, 3) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 2000) # geometry-x (absolute) + write_sint(buf, 0) # geometry-y (absolute) if include_repetitions: - write_uint(buf, 0) # repetition (reuse) + write_uint(buf, 0) # repetition (reuse) - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) # POLYGON 7 - write_uint(buf, 21) # POLYGON record - var_byte(buf, 0b0011_1011) # 00PX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 0) # pointlist (1-delta, horiz. first) - write_uint(buf, 4) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, 3000) # geometry-x (absolute) - write_sint(buf, 0) # geometry-y (absolute) + write_uint(buf, 21) # POLYGON record + var_byte(buf, 0b0011_1011) # 00PX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 0) # pointlist (1-delta, horiz. first) + write_uint(buf, 4) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, 3000) # geometry-x (absolute) + write_sint(buf, 0) # geometry-y (absolute) if include_repetitions: - write_uint(buf, 0) # repetition (reuse) + write_uint(buf, 0) # repetition (reuse) - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0000_0110) # UUUU_VCNS - write_uint(buf, 1) # propname id + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0000_0110) # UUUU_VCNS + write_uint(buf, 1) # propname id if variant == 5: write_uint(buf, 10) # PROPSTRING (explicit id) @@ -375,141 +370,141 @@ def write_file_3(buf: BufferedIOBase) -> BufferedIOBase: write_uint(buf, 7) # PROPNAME record (implicit id 0) write_bstring(buf, b'S_GDS_PROPERTY') - + # ** CELL ** write_uint(buf, 14) # CELL record (explicit) write_bstring(buf, b'A') # Cell name write_uint(buf, 16) # XYRELATIVE record # RECTANGLE 0 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 0) # geometry-x (relative) - write_sint(buf, 1000) # geometry-y (relative) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0111_1011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 0) # geometry-x (relative) + write_sint(buf, 1000) # geometry-y (relative) - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0010_0111) # UUUU_VCNS - write_uint(buf, 0) # propname id - write_uint(buf, 8) # property value 0 (unsigned int) - write_uint(buf, 25) # (...) - write_uint(buf, 10) # property value 1 (a-string) + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0010_0111) # UUUU_VCNS + write_uint(buf, 0) # propname id + write_uint(buf, 8) # property value 0 (unsigned int) + write_uint(buf, 25) # (...) + write_uint(buf, 10) # property value 1 (a-string) write_bstring(buf, b'PROP_VALUE2') # RECTANGLE 1 - write_uint(buf, 20) # RECTANGLE record + write_uint(buf, 20) # RECTANGLE record write_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 0) # geometry-x (relative) - write_sint(buf, 1000) # geometry-y (relative) + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 0) # geometry-x (relative) + write_sint(buf, 1000) # geometry-y (relative) - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b1111_0001) # UUUU_VCNS - write_uint(buf, 2) # number of values - write_uint(buf, 8) # property value 0 (unsigned int) - write_uint(buf, 10) # (...) - write_uint(buf, 14) # property value 1 (prop-string ref.) - write_uint(buf, 13) # (...) + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b1111_0001) # UUUU_VCNS + write_uint(buf, 2) # number of values + write_uint(buf, 8) # property value 0 (unsigned int) + write_uint(buf, 10) # (...) + write_uint(buf, 14) # property value 1 (prop-string ref.) + write_uint(buf, 13) # (...) # RECTANGLE 2 - write_uint(buf, 20) # RECTANGLE record + write_uint(buf, 20) # RECTANGLE record write_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 0) # geometry-x (relative) - write_sint(buf, 1000) # geometry-y (relative) + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 0) # geometry-x (relative) + write_sint(buf, 1000) # geometry-y (relative) - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0000_1001) # UUUU_VCNS + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0000_1001) # UUUU_VCNS # RECTANGLE 3 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 0) # geometry-x (relative) - write_sint(buf, 1000) # geometry-y (relative) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0111_1011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 0) # geometry-x (relative) + write_sint(buf, 1000) # geometry-y (relative) - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) # RECTANGLE 4 - write_uint(buf, 20) # RECTANGLE record + write_uint(buf, 20) # RECTANGLE record write_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 0) # geometry-x (relative) - write_sint(buf, 1000) # geometry-y (relative) + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 0) # geometry-x (relative) + write_sint(buf, 1000) # geometry-y (relative) - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0000_1001) # UUUU_VCNS + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0000_1001) # UUUU_VCNS - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0010_0111) # UUUU_VCNS - write_uint(buf, 0) # propname id - write_uint(buf, 8) # prop value 0 (unsigned int) - write_uint(buf, 25) # (...) - write_uint(buf, 10) # prop-value 1 (a-string) + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0010_0111) # UUUU_VCNS + write_uint(buf, 0) # propname id + write_uint(buf, 8) # prop value 0 (unsigned int) + write_uint(buf, 25) # (...) + write_uint(buf, 10) # prop-value 1 (a-string) write_bstring(buf, b'PROP_VALUE2') # (...) write_uint(buf, 15) # XYABSOLUTE record # TEXT 5 - write_uint(buf, 19) # TEXT record - write_byte(buf, 0b0101_1011) # 0CNX_YRTL - write_bstring(buf, b'A') # text-string - write_uint(buf, 2) # text-layer - write_uint(buf, 1) # text-datatype - write_sint(buf, 1000) # geometry-x (absolute) - write_sint(buf, 0) # geometry-y (absolute) + write_uint(buf, 19) # TEXT record + write_byte(buf, 0b0101_1011) # 0CNX_YRTL + write_bstring(buf, b'A') # text-string + write_uint(buf, 2) # text-layer + write_uint(buf, 1) # text-datatype + write_sint(buf, 1000) # geometry-x (absolute) + write_sint(buf, 0) # geometry-y (absolute) - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) # PATH 6 - write_uint(buf, 22) # PATH record + write_uint(buf, 22) # PATH record write_byte(buf, 0b1111_1011) # EWPX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 10) # half-width - write_byte(buf, 0b0000_1111) # extension-scheme 0000_SSEE - write_sint(buf, 5) # (extension-scheme) - write_sint(buf, -5) # (extension-scheme) - write_uint(buf, 0) # pointlist (1-delta, horiz. first) - write_uint(buf, 3) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 2000) # geometry-x (absolute) - write_sint(buf, 0) # geometry-y (absolute) + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 10) # half-width + write_byte(buf, 0b0000_1111) # extension-scheme 0000_SSEE + write_sint(buf, 5) # (extension-scheme) + write_sint(buf, -5) # (extension-scheme) + write_uint(buf, 0) # pointlist (1-delta, horiz. first) + write_uint(buf, 3) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 2000) # geometry-x (absolute) + write_sint(buf, 0) # geometry-y (absolute) - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) # POLYGON 7 - write_uint(buf, 21) # POLYGON record + write_uint(buf, 21) # POLYGON record write_byte(buf, 0b0011_1011) # 00PX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 0) # pointlist (1-delta, horiz. first) - write_uint(buf, 4) # (pointlist) dimension - write_sint(buf, 150) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, -50) # (pointlist) - write_sint(buf, 50) # (pointlist) - write_sint(buf, 3000) # geometry-x (absolute) - write_sint(buf, 0) # geometry-y (absolute) + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 0) # pointlist (1-delta, horiz. first) + write_uint(buf, 4) # (pointlist) dimension + write_sint(buf, 150) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, -50) # (pointlist) + write_sint(buf, 50) # (pointlist) + write_sint(buf, 3000) # geometry-x (absolute) + write_sint(buf, 0) # geometry-y (absolute) - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) buf.write(FOOTER) return buf @@ -605,180 +600,180 @@ def write_file_4_6(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_bstring(buf, b'A') # Cell name # RECTANGLE 0 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 300) # geometry-x (relative) - write_sint(buf, -400) # geometry-y (relative) - + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0111_1011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 300) # geometry-x (relative) + write_sint(buf, -400) # geometry-y (relative) + # ** CELL ** write_uint(buf, 14) # CELL record (explicit) write_bstring(buf, b'TOP') # Cell name # PLACEMENT 0 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b1011_0000) # CNXY_RAAF - write_bstring(buf, b'A') # cell name - write_sint(buf, -300) # placement-x - write_sint(buf, 400) # placement-y + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b1011_0000) # CNXY_RAAF + write_bstring(buf, b'A') # cell name + write_sint(buf, -300) # placement-x + write_sint(buf, 400) # placement-y - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0010_0111) # UUUU_VCNS - write_uint(buf, 0) # propname-id - write_uint(buf, 8) # prop-value 0 (unsigned int) - write_uint(buf, 25) # (...) - write_uint(buf, 10) # prop-value 1 (a-string) + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0010_0111) # UUUU_VCNS + write_uint(buf, 0) # propname-id + write_uint(buf, 8) # prop-value 0 (unsigned int) + write_uint(buf, 25) # (...) + write_uint(buf, 10) # prop-value 1 (a-string) write_bstring(buf, b'PROP_VALUE2') if variant == 6: - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0010_0111) # UUUU_VCNS - write_uint(buf, 0) # propname-id - write_uint(buf, 8) # prop-value 0 (unsigned int) - write_uint(buf, 26) # (...) - write_uint(buf, 10) # prop-value 1 (a-string) + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0010_0111) # UUUU_VCNS + write_uint(buf, 0) # propname-id + write_uint(buf, 8) # prop-value 0 (unsigned int) + write_uint(buf, 26) # (...) + write_uint(buf, 10) # prop-value 1 (a-string) write_bstring(buf, b'PROP_VALUE26') # PLACEMENT 1 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b0011_0000) # CNXY_RAAF - write_sint(buf, 0) # placement-x + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b0011_0000) # CNXY_RAAF + write_sint(buf, 0) # placement-x if variant == 4: write_sint(buf, 200) # placement-y else: write_sint(buf, 400) # placement-y - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b1111_0001) # UUUU_VCNS - write_uint(buf, 2) # number of values - write_uint(buf, 8) # prop-value 0 (unsigned int) - write_uint(buf, 10) # (...) - write_uint(buf, 14) # prop-value 1 (prop-string ref.) - write_uint(buf, 13) # (...) + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b1111_0001) # UUUU_VCNS + write_uint(buf, 2) # number of values + write_uint(buf, 8) # prop-value 0 (unsigned int) + write_uint(buf, 10) # (...) + write_uint(buf, 14) # prop-value 1 (prop-string ref.) + write_uint(buf, 13) # (...) # PLACEMENT 2 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b0001_0000) # CNXY_RAAF - write_sint(buf, 400) # placement-y + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b0001_0000) # CNXY_RAAF + write_sint(buf, 400) # placement-y - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0000_1001) # UUUU_VCNS + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0000_1001) # UUUU_VCNS # PLACEMENT 3 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b0010_0000) # CNXY_RAAF - write_sint(buf, 300) # placement-x + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b0010_0000) # CNXY_RAAF + write_sint(buf, 300) # placement-x - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) - write_uint(buf, 15) # XYABSOLUTE record + write_uint(buf, 15) # XYABSOLUTE record # PLACEMENT 4 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b0011_0001) # CNXY_RAAF - write_sint(buf, 700) # placement-x (absolute) - write_sint(buf, 400) # placement-y (absolute) + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b0011_0001) # CNXY_RAAF + write_sint(buf, 700) # placement-x (absolute) + write_sint(buf, 400) # placement-y (absolute) - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0000_1001) # UUUU_VCNS + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0000_1001) # UUUU_VCNS - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # PLACEMENT 5 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b0001_0010) # CNXY_RAAF - write_sint(buf, 1000) # placement-y (relative) + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b0001_0010) # CNXY_RAAF + write_sint(buf, 1000) # placement-y (relative) - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0010_0111) # UUUU_VCNS - write_uint(buf, 0) # propname-id - write_uint(buf, 8) # prop-value 0 (unsigned int) - write_uint(buf, 25) # (...) - write_uint(buf, 10) # prop-value 1 (a-string) + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0010_0111) # UUUU_VCNS + write_uint(buf, 0) # propname-id + write_uint(buf, 8) # prop-value 0 (unsigned int) + write_uint(buf, 25) # (...) + write_uint(buf, 10) # prop-value 1 (a-string) write_bstring(buf, b'PROP_VALUE2') # PLACEMENT 6 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b0001_0011) # CNXY_RAAF - write_sint(buf, 1000) # placement-y (relative) + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b0001_0011) # CNXY_RAAF + write_sint(buf, 1000) # placement-y (relative) - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) - write_uint(buf, 15) # XYABSOLUTE record + write_uint(buf, 15) # XYABSOLUTE record # PLACEMENT 7 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b0011_1111) # CNXY_RAAF - write_sint(buf, 2000) # placement-x (absolute) - write_sint(buf, 0) # placement-y (absolute) - write_uint(buf, 1) # repetition (3x4 matrix) - write_uint(buf, 1) # (repetition) x-dimension - write_uint(buf, 2) # (repetition) y-dimension - write_uint(buf, 300) # (repetition) x-spacing - write_uint(buf, 300) # (repetition) y-spacing + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b0011_1111) # CNXY_RAAF + write_sint(buf, 2000) # placement-x (absolute) + write_sint(buf, 0) # placement-y (absolute) + write_uint(buf, 1) # repetition (3x4 matrix) + write_uint(buf, 1) # (repetition) x-dimension + write_uint(buf, 2) # (repetition) y-dimension + write_uint(buf, 300) # (repetition) x-spacing + write_uint(buf, 300) # (repetition) y-spacing - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # PLACEMENT 8 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b0011_1111) # CNXY_RAAF - write_sint(buf, 2000) # placement-x - write_sint(buf, 0) # placement-y - write_uint(buf, 0) # repetition (reuse) + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b0011_1111) # CNXY_RAAF + write_sint(buf, 2000) # placement-x + write_sint(buf, 0) # placement-y + write_uint(buf, 0) # repetition (reuse) - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) # PLACEMENT 9 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b0011_1111) # CNXY_RAAF - write_sint(buf, 2000) # placement-x - write_sint(buf, 0) # placement-y - write_uint(buf, 2) # repetition (3 cols.) - write_uint(buf, 1) # (repetition) dimension - write_uint(buf, 320) # (repetition) offset + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b0011_1111) # CNXY_RAAF + write_sint(buf, 2000) # placement-x + write_sint(buf, 0) # placement-y + write_uint(buf, 2) # repetition (3 cols.) + write_uint(buf, 1) # (repetition) dimension + write_uint(buf, 320) # (repetition) offset - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) # PLACEMENT 10 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b0011_1111) # CNXY_RAAF - write_sint(buf, 2000) # placement-x - write_sint(buf, 0) # placement-y - write_uint(buf, 3) # repetition (4 rows) - write_uint(buf, 2) # (repetition) dimension - write_uint(buf, 310) # (repetition) offset + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b0011_1111) # CNXY_RAAF + write_sint(buf, 2000) # placement-x + write_sint(buf, 0) # placement-y + write_uint(buf, 3) # repetition (4 rows) + write_uint(buf, 2) # (repetition) dimension + write_uint(buf, 310) # (repetition) offset - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) # PLACEMENT 11 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b0011_1111) # CNXY_RAAF - write_sint(buf, 2000) # placement-x - write_sint(buf, 0) # placement-y - write_uint(buf, 4) # repetition (4 arbitrary cols.) - write_uint(buf, 2) # (repetition) dimension - write_uint(buf, 320) # (repetition) - write_uint(buf, 330) # (repetition) - write_uint(buf, 340) # (repetition) + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b0011_1111) # CNXY_RAAF + write_sint(buf, 2000) # placement-x + write_sint(buf, 0) # placement-y + write_uint(buf, 4) # repetition (4 arbitrary cols.) + write_uint(buf, 2) # (repetition) dimension + write_uint(buf, 320) # (repetition) + write_uint(buf, 330) # (repetition) + write_uint(buf, 340) # (repetition) - write_uint(buf, 29) # PROPERTY (reuse) + write_uint(buf, 29) # PROPERTY (reuse) # PLACEMENT 12 - write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) - write_byte(buf, 0b0011_1111) # CNXY_RAAF - write_sint(buf, 2000) # placement-x - write_sint(buf, 0) # placement-y - write_uint(buf, 8) # repetition (3x4 matrix, arbitrary vectors) - write_uint(buf, 1) # (repetition) n-dimension - write_uint(buf, 2) # (repetition) m-dimension - write_uint(buf, 310 << 2 | 0b01) # (repetition) n-displacement g-delta (310, 320) + write_uint(buf, 17) # PLACEMENT record (no mag, manhattan) + write_byte(buf, 0b0011_1111) # CNXY_RAAF + write_sint(buf, 2000) # placement-x + write_sint(buf, 0) # placement-y + write_uint(buf, 8) # repetition (3x4 matrix, arbitrary vectors) + write_uint(buf, 1) # (repetition) n-dimension + write_uint(buf, 2) # (repetition) m-dimension + write_uint(buf, 310 << 2 | 0b01) # (repetition) n-displacement g-delta (310, 320) write_sint(buf, 320) - write_uint(buf, 330 << 4 | 0b1010) # (repetition) m-dispalcement g-delta 330/northwest = (-330, 330) + write_uint(buf, 330 << 4 | 0b1010) # (repetition) m-dispalcement g-delta 330/northwest = (-330, 330) write_uint(buf, 29) # PROPERTY (reuse) @@ -937,16 +932,16 @@ def write_file_7_8_9(buf: BufferedIOBase, variant: int) -> BufferedIOBase: ''' buf.write(HEADER) - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0001_0100) # UUUU_VCNS + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0001_0100) # UUUU_VCNS write_bstring(buf, b'FileProp1') # property name - write_uint(buf, 10) # prop-value 0 (a-string) + write_uint(buf, 10) # prop-value 0 (a-string) write_bstring(buf, b'FileProp1Value') - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0001_0110) # UUUU_VCNS - write_uint(buf, 13) # prop-name reference - write_uint(buf, 10) # prop-value 0 (a-string) + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0001_0110) # UUUU_VCNS + write_uint(buf, 13) # prop-name reference + write_uint(buf, 10) # prop-value 0 (a-string) write_bstring(buf, b'FileProp1Value') write_uint(buf, 8) # PROPNAME record (explicit id) @@ -957,70 +952,69 @@ def write_file_7_8_9(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 28) # PROPERTY record if variant == 8: # Will give an error since the value modal variable is reset by PROPNAME_ID - write_byte(buf, 0b0001_1110) # UUUU_VCNS + write_byte(buf, 0b0001_1110) # UUUU_VCNS else: - write_byte(buf, 0b0001_0110) # UUUU_VCNS - write_uint(buf, 13) # prop-name reference + write_byte(buf, 0b0001_0110) # UUUU_VCNS + write_uint(buf, 13) # prop-name reference if variant != 8: - write_uint(buf, 8) # prop-value 0 (unsigned int) - write_uint(buf, 17) # (...) + write_uint(buf, 8) # prop-value 0 (unsigned int) + write_uint(buf, 17) # (...) write_uint(buf, 10) # PROPSTRING (explicit id) write_bstring(buf, b'FileProp2Value') write_uint(buf, 12) # id # associated with PROPSTRING? - write_uint(buf, 28) # PROPERTY record + write_uint(buf, 28) # PROPERTY record if variant == 9: # Will give an error since the value modal variable is unset - write_byte(buf, 0b0001_1110) # UUUU_VCNS + write_byte(buf, 0b0001_1110) # UUUU_VCNS else: - write_byte(buf, 0b0001_0110) # UUUU_VCNS - write_uint(buf, 13) # prop-name reference + write_byte(buf, 0b0001_0110) # UUUU_VCNS + write_uint(buf, 13) # prop-name reference if variant != 9: - write_uint(buf, 8) # prop-value 0 (unsigned int) - write_uint(buf, 42) # (...) + write_uint(buf, 8) # prop-value 0 (unsigned int) + write_uint(buf, 42) # (...) write_uint(buf, 3) # CELLNAME record (implicit id 0) write_bstring(buf, b'A') # associated with cell A, through CELLNAME # TODO - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0001_0100) # UUUU_VCNS - write_bstring(buf, b'CellProp0') # prop name - write_uint(buf, 10) # prop-value 0 (a-string) + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0001_0100) # UUUU_VCNS + write_bstring(buf, b'CellProp0') # prop name + write_uint(buf, 10) # prop-value 0 (a-string) write_bstring(buf, b'CPValue0') - + # ** CELL ** write_uint(buf, 13) # CELL record (name ref.) write_uint(buf, 0) # Cell name 0 (XYZ) # associated with cell A - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0001_0100) # UUUU_VCNS - write_bstring(buf, b'CellProp1') # prop name - write_uint(buf, 10) # prop-value 0 (a-string) + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0001_0100) # UUUU_VCNS + write_bstring(buf, b'CellProp1') # prop name + write_uint(buf, 10) # prop-value 0 (a-string) write_bstring(buf, b'CPValue') - write_uint(buf, 28) # PROPERTY record - write_byte(buf, 0b0001_1100) # UUUU_VCNS - write_bstring(buf, b'CellProp2') # prop name + write_uint(buf, 28) # PROPERTY record + write_byte(buf, 0b0001_1100) # UUUU_VCNS + write_bstring(buf, b'CellProp2') # prop name # RECTANGLE 0 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 300) # geometry-x - write_sint(buf, -400) # geometry-y + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0111_1011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 300) # geometry-x + write_sint(buf, -400) # geometry-y buf.write(FOOTER) return buf - def test_file_7() -> None: buf = write_file_7_8_9(BytesIO(), 7) diff --git a/fatamorgana/test/test_files_rectangles.py b/fatamorgana/test/test_files_rectangles.py index f47503f..e9f0b99 100644 --- a/fatamorgana/test/test_files_rectangles.py +++ b/fatamorgana/test/test_files_rectangles.py @@ -1,15 +1,9 @@ # type: ignore -from typing import List, Tuple, Iterable -from itertools import chain from io import BytesIO, BufferedIOBase -import struct - -import pytest # type: ignore from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte -from ..basic import InvalidRecordError, InvalidDataError +from ..basic import write_uint, write_sint, write_bstring, write_byte from ..main import OasisLayout @@ -88,149 +82,149 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: buf.write(HEADER) if variant == 2: - write_uint(buf, 7) # PROPNAME record (implict id 0) - write_bstring(buf, b'PROP0') # property name + write_uint(buf, 7) # PROPNAME record (implict id 0) + write_bstring(buf, b'PROP0') # property name write_uint(buf, 14) # CELL record (explicit) write_bstring(buf, b'ABC') # Cell name # RECTANGLE 0 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 300) # geometry-x (absolute) - write_sint(buf, -400) # geometry-y (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0111_1011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 300) # geometry-x (absolute) + write_sint(buf, -400) # geometry-y (absolute) if variant == 2: # PROPERTY 0 - write_uint(buf, 28) # PROPERTY record (explicit) - write_byte(buf, 0b0001_0110) # UUUU_VCNS - write_uint(buf, 0) # propname id - write_uint(buf, 2) # property value (real: positive reciprocal) - write_uint(buf, 5) # (real) 1/5 + write_uint(buf, 28) # PROPERTY record (explicit) + write_byte(buf, 0b0001_0110) # UUUU_VCNS + write_uint(buf, 0) # propname id + write_uint(buf, 2) # property value (real: positive reciprocal) + write_uint(buf, 5) # (real) 1/5 write_uint(buf, 16) # XYRELATIVE record # RECTANGLE 1 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 100) # geometry-x (relative) - write_sint(buf, -100) # geometry-y (relative) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0111_1011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 100) # geometry-x (relative) + write_sint(buf, -100) # geometry-y (relative) if variant == 2: # PROPERTY 1 write_uint(buf, 29) # PROPERTY record (repeat) - write_uint(buf, 15) # XYABSOLUTE record + write_uint(buf, 15) # XYABSOLUTE record # RECTANGLE 2 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0111_1011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 600) # geometry-x (absolute) - write_sint(buf, -300) # geometry-y (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0111_1011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 600) # geometry-x (absolute) + write_sint(buf, -300) # geometry-y (absolute) if variant == 2: # PROPERTY 2 write_uint(buf, 29) # PROPERTY record (repeat) # RECTANGLE 3 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0111_0011) # SWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, 800) # geometry-x (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0111_0011) # SWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, 800) # geometry-x (absolute) if variant == 2: # PROPERTY 3 write_uint(buf, 29) # PROPERTY record (repeat) # RECTANGLE 4 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0110_1011) # SWHX_YRDL - write_uint(buf, 2) # layer - write_uint(buf, 3) # datatype - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, -600) # geometry-y (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0110_1011) # SWHX_YRDL + write_uint(buf, 2) # layer + write_uint(buf, 3) # datatype + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, -600) # geometry-y (absolute) if variant == 2: # PROPERTY 4 write_uint(buf, 29) # PROPERTY record (repeat) # RECTANGLE 5 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0110_1000) # SWHX_YRDL - write_uint(buf, 100) # width - write_uint(buf, 200) # height - write_sint(buf, -900) # geometry-y (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0110_1000) # SWHX_YRDL + write_uint(buf, 100) # width + write_uint(buf, 200) # height + write_sint(buf, -900) # geometry-y (absolute) if variant == 2: # PROPERTY 5 write_uint(buf, 29) # PROPERTY record (repeat) # RECTANGLE 6 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0000_1000) # SWHX_YRDL - write_sint(buf, -1200) # geometry-y (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0000_1000) # SWHX_YRDL + write_sint(buf, -1200) # geometry-y (absolute) if variant == 2: # PROPERTY 6 write_uint(buf, 29) # PROPERTY record (repeat) # RECTANGLE 7 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b1100_1000) # SWHX_YRDL - write_uint(buf, 150) # width - write_sint(buf, -1500) # geometry-y (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b1100_1000) # SWHX_YRDL + write_uint(buf, 150) # width + write_sint(buf, -1500) # geometry-y (absolute) if variant == 2: # PROPERTY 7 write_uint(buf, 29) # PROPERTY record (repeat) # RECTANGLE 8 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0000_1000) # SWHX_YRDL - write_sint(buf, -1800) # geometry-y (absolute) + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0000_1000) # SWHX_YRDL + write_sint(buf, -1800) # geometry-y (absolute) if variant == 2: # PROPERTY 8 write_uint(buf, 29) # PROPERTY record (repeat) # RECTANGLE 9 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0000_1100) # SWHX_YRDL - write_sint(buf, 500) # geometry-y (absolute) - write_uint(buf, 1) # repetition (3x4 matrix) - write_uint(buf, 1) # (repetition) x-dimension - write_uint(buf, 2) # (repetition) y-dimension - write_uint(buf, 200) # (repetition) x-spacing - write_uint(buf, 300) # (repetition) y-spacing + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0000_1100) # SWHX_YRDL + write_sint(buf, 500) # geometry-y (absolute) + write_uint(buf, 1) # repetition (3x4 matrix) + write_uint(buf, 1) # (repetition) x-dimension + write_uint(buf, 2) # (repetition) y-dimension + write_uint(buf, 200) # (repetition) x-spacing + write_uint(buf, 300) # (repetition) y-spacing if variant == 2: # PROPERTY 9 write_uint(buf, 29) # PROPERTY record (repeat) # RECTANGLE 10 - write_uint(buf, 20) # RECTANGLE record - write_byte(buf, 0b0000_1100) # SWHX_YRDL - write_sint(buf, 2000) # geometry-y (absolute) - write_uint(buf, 4) # repetition (3 arbitrary cols.) - write_uint(buf, 1) # (repetition) dimension - write_uint(buf, 200) # (repetition) x-delta - write_uint(buf, 300) # (repetition) x-delta + write_uint(buf, 20) # RECTANGLE record + write_byte(buf, 0b0000_1100) # SWHX_YRDL + write_sint(buf, 2000) # geometry-y (absolute) + write_uint(buf, 4) # repetition (3 arbitrary cols.) + write_uint(buf, 1) # (repetition) dimension + write_uint(buf, 200) # (repetition) x-delta + write_uint(buf, 300) # (repetition) x-delta if variant == 2: # PROPERTY 10 diff --git a/fatamorgana/test/test_files_texts.py b/fatamorgana/test/test_files_texts.py index c23877c..0ee22a0 100644 --- a/fatamorgana/test/test_files_texts.py +++ b/fatamorgana/test/test_files_texts.py @@ -1,14 +1,11 @@ # type: ignore -from typing import List, Tuple, Iterable -from itertools import chain from io import BytesIO, BufferedIOBase -import struct -import pytest # type: ignore +import pytest from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte +from ..basic import write_uint, write_sint, write_bstring, write_byte from ..basic import InvalidRecordError, InvalidDataError from ..basic import GridRepetition, ArbitraryRepetition from ..main import OasisLayout @@ -86,12 +83,12 @@ def common_tests(layout: OasisLayout) -> None: assert geometry[13].repetition.b_vector == [-10, 10] assert geometry[14].repetition.a_count == 3 - assert geometry[14].repetition.b_count == None + assert geometry[14].repetition.b_count is None assert geometry[14].repetition.a_vector == [11, 12] assert geometry[14].repetition.b_vector is None assert geometry[15].repetition.a_count == 4 - assert geometry[15].repetition.b_count == None + assert geometry[15].repetition.b_count is None assert geometry[15].repetition.a_vector == [-10, 10] assert geometry[15].repetition.b_vector is None @@ -256,9 +253,9 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 8) # repetition (3x4 matrix w/arb. vectors) write_uint(buf, 1) # (repetition) n-dimension write_uint(buf, 2) # (repetition) m-dimension - write_uint(buf, (10 << 4) | 0b0000) # (repetition) n-displacement g-delta: 10/east = (10, 0) - write_uint(buf, (11 << 2) | 0b11) # (repetition) m-displacement g-delta: (-11, -12) - write_sint(buf, -12) # (repetition g-delta) + write_uint(buf, (10 << 4) | 0b0000) # (repetition) n-displacement g-delta: 10/east = (10, 0) + write_uint(buf, (11 << 2) | 0b11) # (repetition) m-displacement g-delta: (-11, -12) + write_sint(buf, -12) # (repetition g-delta) # TEXT 13 write_uint(buf, 19) # TEXT record @@ -267,9 +264,9 @@ def write_file_common(buf: BufferedIOBase, variant: int) -> BufferedIOBase: write_uint(buf, 8) # repetition (3x4 matrix w/arb. vectors) write_uint(buf, 1) # (repetition) n-dimension write_uint(buf, 2) # (repetition) m-dimension - write_uint(buf, (11 << 2) | 0b01) # (repetition) n-displacement g-delta: (11, 12) + write_uint(buf, (11 << 2) | 0b01) # (repetition) n-displacement g-delta: (11, 12) write_sint(buf, 12) - write_uint(buf, (10 << 4) | 0b1010) # (repetition) n-displacement g-delta: 10/northwest = (-10, 10) + write_uint(buf, (10 << 4) | 0b1010) # (repetition) n-displacement g-delta: 10/northwest = (-10, 10) # TEXT 14 write_uint(buf, 19) # TEXT record diff --git a/fatamorgana/test/test_files_trapezoids.py b/fatamorgana/test/test_files_trapezoids.py index 1bd67e1..574054d 100644 --- a/fatamorgana/test/test_files_trapezoids.py +++ b/fatamorgana/test/test_files_trapezoids.py @@ -1,17 +1,9 @@ # type: ignore -from typing import List, Tuple, Iterable -from itertools import chain from io import BytesIO, BufferedIOBase -import struct - -import pytest # type: ignore -import numpy -from numpy.testing import assert_equal from .utils import HEADER, FOOTER -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte, PathExtensionScheme -from ..basic import InvalidRecordError, InvalidDataError +from ..basic import write_uint, write_sint, write_bstring, write_byte from ..main import OasisLayout @@ -37,145 +29,145 @@ def write_file_1(buf: BufferedIOBase) -> BufferedIOBase: ''' buf.write(HEADER) - write_uint(buf, 14) # CELL record (explicit) - write_bstring(buf, b'ABC') # Cell name + write_uint(buf, 14) # CELL record (explicit) + write_bstring(buf, b'ABC') # Cell name # Trapezoid 0 - write_uint(buf, 23) # TRAPEZOID record - write_byte(buf, 0b0111_1011) # OWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 50) # height - write_sint(buf, -20) # delta-a - write_sint(buf, 40) # delta-b - write_sint(buf, 0) # geometry-x (absolute) - write_sint(buf, 100) # geometry-y (absolute) + write_uint(buf, 23) # TRAPEZOID record + write_byte(buf, 0b0111_1011) # OWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 50) # height + write_sint(buf, -20) # delta-a + write_sint(buf, 40) # delta-b + write_sint(buf, 0) # geometry-x (absolute) + write_sint(buf, 100) # geometry-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # Trapezoid 1 - write_uint(buf, 23) # TRAPEZOID record - write_byte(buf, 0b1010_1011) # OWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 50) # height - write_sint(buf, 20) # delta-a - write_sint(buf, 40) # delta-b - write_sint(buf, 300) # geometry-y (absolute) + write_uint(buf, 23) # TRAPEZOID record + write_byte(buf, 0b1010_1011) # OWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 50) # height + write_sint(buf, 20) # delta-a + write_sint(buf, 40) # delta-b + write_sint(buf, 300) # geometry-y (absolute) # Trapezoid 2 - write_uint(buf, 23) # TRAPEZOID record - write_byte(buf, 0b1100_1001) # OWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 150) # width - write_sint(buf, 20) # delta-a - write_sint(buf, -20) # delta-b - write_sint(buf, 300) # geometry-y (relative) + write_uint(buf, 23) # TRAPEZOID record + write_byte(buf, 0b1100_1001) # OWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 150) # width + write_sint(buf, 20) # delta-a + write_sint(buf, -20) # delta-b + write_sint(buf, 300) # geometry-y (relative) # Trapezoid 3 - write_uint(buf, 23) # TRAPEZOID record - write_byte(buf, 0b0100_1101) # OWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 150) # width - write_sint(buf, 20) # delta-a - write_sint(buf, -20) # delta-b - write_sint(buf, 300) # geometry-y (relative) - write_uint(buf, 1) # repetition (3x4 matrix) - write_uint(buf, 1) # (repetition) x-dimension - write_uint(buf, 2) # (repetition) y-dimension - write_uint(buf, 200) # (repetition) x-spacing - write_uint(buf, 300) # (repetition) y-spacing + write_uint(buf, 23) # TRAPEZOID record + write_byte(buf, 0b0100_1101) # OWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 150) # width + write_sint(buf, 20) # delta-a + write_sint(buf, -20) # delta-b + write_sint(buf, 300) # geometry-y (relative) + write_uint(buf, 1) # repetition (3x4 matrix) + write_uint(buf, 1) # (repetition) x-dimension + write_uint(buf, 2) # (repetition) y-dimension + write_uint(buf, 200) # (repetition) x-spacing + write_uint(buf, 300) # (repetition) y-spacing - write_uint(buf, 15) # XYABSOLUTE record + write_uint(buf, 15) # XYABSOLUTE record # Trapezoid 4 - write_uint(buf, 24) # TRAPEZOID record - write_byte(buf, 0b0111_1011) # OWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 50) # height - write_sint(buf, -20) # delta-a - write_sint(buf, 1000) # geometry-x (absolute) - write_sint(buf, 100) # geometry-y (absolute) + write_uint(buf, 24) # TRAPEZOID record + write_byte(buf, 0b0111_1011) # OWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 50) # height + write_sint(buf, -20) # delta-a + write_sint(buf, 1000) # geometry-x (absolute) + write_sint(buf, 100) # geometry-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # Trapezoid 5 - write_uint(buf, 24) # TRAPEZOID record - write_byte(buf, 0b1010_1011) # OWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 50) # height - write_sint(buf, 20) # delta-a - write_sint(buf, 300) # geometry-y (relative) + write_uint(buf, 24) # TRAPEZOID record + write_byte(buf, 0b1010_1011) # OWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 50) # height + write_sint(buf, 20) # delta-a + write_sint(buf, 300) # geometry-y (relative) # Trapezoid 6 - write_uint(buf, 24) # TRAPEZOID record - write_byte(buf, 0b1100_1001) # OWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 150) # width - write_sint(buf, 20) # delta-a - write_sint(buf, 300) # geometry-y (relative) + write_uint(buf, 24) # TRAPEZOID record + write_byte(buf, 0b1100_1001) # OWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 150) # width + write_sint(buf, 20) # delta-a + write_sint(buf, 300) # geometry-y (relative) # Trapezoid 7 - write_uint(buf, 24) # TRAPEZOID record - write_byte(buf, 0b0100_1101) # OWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 150) # width - write_sint(buf, 20) # delta-a - write_sint(buf, 300) # geometry-y (relative) - write_uint(buf, 1) # repetition (3x4 matrix) - write_uint(buf, 1) # (repetition) x-dimension - write_uint(buf, 2) # (repetition) y-dimension - write_uint(buf, 200) # (repetition) x-spacing - write_uint(buf, 300) # (repetition) y-spacing + write_uint(buf, 24) # TRAPEZOID record + write_byte(buf, 0b0100_1101) # OWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 150) # width + write_sint(buf, 20) # delta-a + write_sint(buf, 300) # geometry-y (relative) + write_uint(buf, 1) # repetition (3x4 matrix) + write_uint(buf, 1) # (repetition) x-dimension + write_uint(buf, 2) # (repetition) y-dimension + write_uint(buf, 200) # (repetition) x-spacing + write_uint(buf, 300) # (repetition) y-spacing - write_uint(buf, 15) # XYABSOLUTE record + write_uint(buf, 15) # XYABSOLUTE record # Trapezoid 8 - write_uint(buf, 25) # TRAPEZOID record - write_byte(buf, 0b0111_1011) # OWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 100) # width - write_uint(buf, 50) # height - write_sint(buf, 40) # delta-b - write_sint(buf, 2000) # geometry-x (absolute) - write_sint(buf, 100) # geometry-y (absolute) + write_uint(buf, 25) # TRAPEZOID record + write_byte(buf, 0b0111_1011) # OWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 100) # width + write_uint(buf, 50) # height + write_sint(buf, 40) # delta-b + write_sint(buf, 2000) # geometry-x (absolute) + write_sint(buf, 100) # geometry-y (absolute) - write_uint(buf, 16) # XYRELATIVE record + write_uint(buf, 16) # XYRELATIVE record # Trapezoid 9 - write_uint(buf, 25) # TRAPEZOID record - write_byte(buf, 0b1010_1011) # OWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 2) # datatype - write_uint(buf, 50) # height - write_sint(buf, 40) # delta-b - write_sint(buf, 300) # geometry-y (relative) + write_uint(buf, 25) # TRAPEZOID record + write_byte(buf, 0b1010_1011) # OWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 2) # datatype + write_uint(buf, 50) # height + write_sint(buf, 40) # delta-b + write_sint(buf, 300) # geometry-y (relative) # Trapezoid 10 - write_uint(buf, 25) # TRAPEZOID record - write_byte(buf, 0b1100_1001) # OWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 150) # width - write_sint(buf, -20) # delta-b - write_sint(buf, 300) # geometry-y (relative) + write_uint(buf, 25) # TRAPEZOID record + write_byte(buf, 0b1100_1001) # OWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 150) # width + write_sint(buf, -20) # delta-b + write_sint(buf, 300) # geometry-y (relative) # Trapezoid 11 - write_uint(buf, 25) # TRAPEZOID record - write_byte(buf, 0b0100_1101) # OWHX_YRDL - write_uint(buf, 1) # layer - write_uint(buf, 150) # width - write_sint(buf, -20) # delta-b - write_sint(buf, 300) # geometry-y (relative) - write_uint(buf, 1) # repetition (3x4 matrix) - write_uint(buf, 1) # (repetition) x-dimension - write_uint(buf, 2) # (repetition) y-dimension - write_uint(buf, 200) # (repetition) x-spacing - write_uint(buf, 300) # (repetition) y-spacing + write_uint(buf, 25) # TRAPEZOID record + write_byte(buf, 0b0100_1101) # OWHX_YRDL + write_uint(buf, 1) # layer + write_uint(buf, 150) # width + write_sint(buf, -20) # delta-b + write_sint(buf, 300) # geometry-y (relative) + write_uint(buf, 1) # repetition (3x4 matrix) + write_uint(buf, 1) # (repetition) x-dimension + write_uint(buf, 2) # (repetition) y-dimension + write_uint(buf, 200) # (repetition) x-spacing + write_uint(buf, 300) # (repetition) y-spacing buf.write(FOOTER) return buf diff --git a/fatamorgana/test/test_int.py b/fatamorgana/test/test_int.py index 5f44053..c974535 100644 --- a/fatamorgana/test/test_int.py +++ b/fatamorgana/test/test_int.py @@ -1,9 +1,6 @@ -from typing import List, Tuple, Iterable from itertools import chain from io import BytesIO -import pytest # type: ignore - from ..basic import read_uint, read_sint, write_uint, write_sint diff --git a/fatamorgana/test/utils.py b/fatamorgana/test/utils.py index 0f60e7c..7985908 100644 --- a/fatamorgana/test/utils.py +++ b/fatamorgana/test/utils.py @@ -1,12 +1,6 @@ -from typing import List, Tuple, Iterable -from itertools import chain -from io import BytesIO, BufferedIOBase -import struct +from io import BytesIO -import pytest # type: ignore - -from ..basic import write_uint, write_sint, read_uint, read_sint, write_bstring, write_byte -from ..main import OasisLayout +from ..basic import write_uint, write_bstring, write_byte MAGIC_BYTES = b'%SEMI-OASIS\r\n'