Skip to content

Fix sentinel header select - #133

Merged
arokem merged 7 commits into
tee-ar-ex:masterfrom
frheault:fix_sentinel_header_select
Aug 20, 2026
Merged

Fix sentinel header select#133
arokem merged 7 commits into
tee-ar-ex:masterfrom
frheault:fix_sentinel_header_select

Conversation

@frheault

@frheault frheault commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Fixes the offset sentinel calculation during deepcopy and serialization of sliced or subsetted TrxFile instances created via .select(), to avoid a problem with header dimensions upon reload.

I discovered a bug when running old example (updating stuff from the poster to the new API)

…ields_testing

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
@frheault
frheault requested a review from arokem August 17, 2026 17:45
Comment thread trx/trx_file_memmap.py
if not self._copy_safe:
to_dump = _append_last_offsets(
self.streamlines.copy()._offsets, self.header["NB_VERTICES"]
self.streamlines.copy()._offsets, tmp_header["NB_VERTICES"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems the key line related to the title of the PR. Is there a test in place that fails without this change?

Comment thread trx/tests/test_memmap.py
out = os.path.join(tmp_dir, "sub.trx")
tmm.save(sub, out)
loaded = tmm.load(out)
assert len(loaded.streamlines) == 5

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing this is the test I was asking about?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because of the mismatch between the actual length of the arrays vs the header this could cause problem

@arokem
arokem merged commit 6243be8 into tee-ar-ex:master Aug 20, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants