From c0e8c05d96eb033144897c1a35ffd28504f54682 Mon Sep 17 00:00:00 2001 From: frheault Date: Wed, 17 Jun 2026 13:49:46 -0400 Subject: [PATCH 1/4] Tested data from trx-rs --- trx/tests/test_memmap.py | 101 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/trx/tests/test_memmap.py b/trx/tests/test_memmap.py index aae8452..c9c526d 100644 --- a/trx/tests/test_memmap.py +++ b/trx/tests/test_memmap.py @@ -498,6 +498,107 @@ def test__ensure_little_endian_big_endian_input(): assert result[0] == 0x12345678 +def test_load_zip64_with_extra_fields(): + """Test loading ZIP64 files where both local and CD headers have extra fields. + + Rust and other tools always write ZIP64 extended information (extra field + ID 0x0001, 20 bytes: 4-byte tag+size + 8-byte orig + 8-byte comp) in both + local file headers and central directory entries, even for small files. + This ensures the data offset is computed correctly by reading the local + header's extra_len rather than assuming a fixed layout. + """ + positions = np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], dtype=np.float32) + offsets = np.array([0, 2], dtype=np.uint64) + header = { + "DIMENSIONS": [10, 10, 10], + "VOXEL_TO_RASMM": np.eye(4).tolist(), + "NB_VERTICES": 2, + "NB_STREAMLINES": 1, + } + + def make_zip64_extra(orig_size, comp_size): + data = struct.pack(" Date: Wed, 17 Jun 2026 13:55:14 -0400 Subject: [PATCH 2/4] ran pre-commit --- trx/tests/test_memmap.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/trx/tests/test_memmap.py b/trx/tests/test_memmap.py index c9c526d..fb6cdec 100644 --- a/trx/tests/test_memmap.py +++ b/trx/tests/test_memmap.py @@ -541,7 +541,10 @@ def make_zip64_extra(orig_size, comp_size): "<4sHHHHHIIIHH", b"PK\x03\x04", 45, # version needed: ZIP64 - 0, 0, 0, 0, + 0, + 0, + 0, + 0, crc, len(data), len(data), @@ -565,13 +568,19 @@ def make_zip64_extra(orig_size, comp_size): b"PK\x01\x02", 45, # version made by: ZIP64 45, # version needed: ZIP64 - 0, 0, 0, 0, + 0, + 0, + 0, + 0, crc, size, size, len(fname), len(extra), - 0, 0, 0, 0, + 0, + 0, + 0, + 0, offset, ) ) @@ -583,7 +592,8 @@ def make_zip64_extra(orig_size, comp_size): struct.pack( "<4sHHHHIIH", b"PK\x05\x06", - 0, 0, + 0, + 0, len(local_info), len(local_info), cd_size, From de590965e18690f8823e11010b2e34b30cf15b7c Mon Sep 17 00:00:00 2001 From: frheault Date: Mon, 22 Jun 2026 15:29:09 -0400 Subject: [PATCH 3/4] Applied automated PEP-8 formatting and removed unused imports --- docs/source/conf.py | 12 ++++++------ trx/trx_file_memmap.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 9fae80c..c520a55 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,6 +14,7 @@ # import os # import sys # sys.path.insert(0, os.path.abspath('.')) +import warnings import os from datetime import datetime as dt @@ -67,7 +68,6 @@ # Suppress known deprecation warnings from dependencies # astroid 4.x deprecation - will be fixed when sphinx-autoapi updates for astroid 5.x -import warnings warnings.filterwarnings( 'ignore', message="importing .* from 'astroid' is deprecated", @@ -180,9 +180,9 @@ def _validate_reference_urls(urls, timeout=5): # Sphinx gallery configuration sphinx_gallery_conf = { - 'examples_dirs': '../../examples', - 'gallery_dirs': 'auto_examples', - 'within_subsection_order': 'NumberOfCodeLinesSortKey', - 'reference_url': _validate_reference_urls(_reference_urls), - 'default_thumb_file': os.path.join(os.path.dirname(__file__), '..', '_static', 'trx_logo.png'), + 'examples_dirs': '../../examples', + 'gallery_dirs': 'auto_examples', + 'within_subsection_order': 'NumberOfCodeLinesSortKey', + 'reference_url': _validate_reference_urls(_reference_urls), + 'default_thumb_file': os.path.join(os.path.dirname(__file__), '..', '_static', 'trx_logo.png'), } diff --git a/trx/trx_file_memmap.py b/trx/trx_file_memmap.py index 1556f59..9a94faa 100644 --- a/trx/trx_file_memmap.py +++ b/trx/trx_file_memmap.py @@ -762,7 +762,7 @@ def _setup_groups_for_concatenation( count = 0 for curr_trx in trx_list: curr_len = len(curr_trx.groups[group_key]) - new_trx.groups[group_key][pos : pos + curr_len] = ( + new_trx.groups[group_key][pos: pos + curr_len] = ( curr_trx.groups[group_key] + count ) pos += curr_len From aebccdedfde2d09d69093fc2eddcdb469c75a7d3 Mon Sep 17 00:00:00 2001 From: frheault Date: Mon, 22 Jun 2026 15:31:37 -0400 Subject: [PATCH 4/4] Run pre-commit --- trx/trx_file_memmap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trx/trx_file_memmap.py b/trx/trx_file_memmap.py index 9a94faa..1556f59 100644 --- a/trx/trx_file_memmap.py +++ b/trx/trx_file_memmap.py @@ -762,7 +762,7 @@ def _setup_groups_for_concatenation( count = 0 for curr_trx in trx_list: curr_len = len(curr_trx.groups[group_key]) - new_trx.groups[group_key][pos: pos + curr_len] = ( + new_trx.groups[group_key][pos : pos + curr_len] = ( curr_trx.groups[group_key] + count ) pos += curr_len