cleanup based on flake8 output
This commit is contained in:
parent
b2928c8b1c
commit
01b3f9ca3a
1
.flake8
1
.flake8
@ -27,3 +27,4 @@ ignore =
|
||||
per-file-ignores =
|
||||
# F401 import without use
|
||||
*/__init__.py: F401,
|
||||
__init__.py: F401,
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
"""
|
||||
|
@ -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],
|
||||
])
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) |