Skip to content

Fix RawArray init kwargs retaining stale data#14075

Open
floze-the-genius wants to merge 2 commits into
mne-tools:mainfrom
floze-the-genius:fix-rawarray-init-kwargs-gc
Open

Fix RawArray init kwargs retaining stale data#14075
floze-the-genius wants to merge 2 commits into
mne-tools:mainfrom
floze-the-genius:fix-rawarray-init-kwargs-gc

Conversation

@floze-the-genius

Copy link
Copy Markdown

Reference issue (if any)

Fixes #14074.

What does this implement/fix?

Store the RawArray constructor metadata without a strong reference to the original data ndarray. Accessing _init_kwargs still returns a normal constructor-ready dictionary whose data value is the current _data array.

The regression test uses weakref and gc to verify collection after resampling, and covers reconstruction, copying, repr, and pickle round trips.

Additional information

Tests: pytest mne/io/array/tests/test_array.py --no-cov --tb=short -q (4 passed)

AI assistance disclosure: OpenAI Codex helped inspect the codebase, implement the property-backed constructor metadata, write the regression test, and run validation. The changes were reviewed against the issue requirements and repository contribution policy.

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.

RawArray._init_kwargs blocks garbage collection by retaining the input NumPy ndarray

1 participant