From 691ce03150f80933f9a3063540a1f04e4dc1180c Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Mon, 29 Jul 2024 18:08:16 -0700 Subject: [PATCH] use strict zip --- fatamorgana/basic.py | 4 ++-- fatamorgana/records.py | 16 ++++++++-------- fatamorgana/test/test_files_ctrapezoids.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fatamorgana/basic.py b/fatamorgana/basic.py index 66ba118..f72000d 100644 --- a/fatamorgana/basic.py +++ b/fatamorgana/basic.py @@ -1485,13 +1485,13 @@ class ArbitraryRepetition: size = write_uint(stream, 10) size += write_uint(stream, len(self.x_displacements) - 1) size += sum(Delta(x, y).write(stream) - for x, y in zip(self.x_displacements, self.y_displacements)) + for x, y in zip(self.x_displacements, self.y_displacements, strict=True)) else: size = write_uint(stream, 11) size += write_uint(stream, len(self.x_displacements) - 1) size += write_uint(stream, gcd) size += sum(Delta(x // gcd, y // gcd).write(stream) - for x, y in zip(self.x_displacements, self.y_displacements)) + for x, y in zip(self.x_displacements, self.y_displacements, strict=True)) return size def __eq__(self, other: Any) -> bool: diff --git a/fatamorgana/records.py b/fatamorgana/records.py index 0de9739..1e16cbf 100644 --- a/fatamorgana/records.py +++ b/fatamorgana/records.py @@ -2632,22 +2632,22 @@ def dedup_field(record, r_field: str, modals: Modals, m_field: str) -> None: Args: InvalidDataError: if both fields are `None` """ - r = getattr(record, r_field) - m = getattr(modals, m_field) - if r is not None: + rr = getattr(record, r_field) + mm = getattr(modals, m_field) + if rr is not None: if m_field in ('polygon_point_list', 'path_point_list'): if _USE_NUMPY: - equal = numpy.array_equal(m, r) + equal = numpy.array_equal(mm, rr) else: - equal = (m is not None) and all(tuple(mm) == tuple(rr) for mm, rr in zip(m, r)) + equal = (mm is not None) and all(tuple(mmm) == tuple(rrr) for mmm, rrr in zip(mm, rr, strict=True)) else: - equal = (m is not None) and m == r + equal = (mm is not None) and mm == rr if equal: setattr(record, r_field, None) else: - setattr(modals, m_field, r) - elif m is None: + setattr(modals, m_field, rr) + elif mm is None: raise InvalidDataError('Unfillable field') diff --git a/fatamorgana/test/test_files_ctrapezoids.py b/fatamorgana/test/test_files_ctrapezoids.py index d0429bf..37fc80f 100644 --- a/fatamorgana/test/test_files_ctrapezoids.py +++ b/fatamorgana/test/test_files_ctrapezoids.py @@ -61,7 +61,7 @@ def write_file_1(buf: IO[bytes]) -> IO[bytes]: + [0b11, 0b10] ) - for t, (x, x_en) in enumerate(zip(wh, wh_en)): + for t, (x, x_en) in enumerate(zip(wh, wh_en, strict=True)): write_uint(buf, 26) # CTRAPEZOID record write_byte(buf, 0b1000_1011 | (x_en << 5)) # TWHX_YRDL write_uint(buf, 1) # layer