Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to modify returned frames. #324

Merged
merged 4 commits into from
Jan 22, 2024
Merged

Conversation

joaander
Copy link
Member

@joaander joaander commented Jan 22, 2024

Description

  1. Internally store a copy of the initial frame.
  2. Return copies of mutable entries from the initial frame and default values.
  3. Ensure that all non-copied numpy arrays from the initial frame are marked non-writable.

Motivation and Context

Many users expect to modify returned frames without error:

frame = trajectory[10]
frame.particles.types = ['A', 'B']

Prior to this pull request, such changes could modify the cached _initial_frame and/or default values.

How Has This Been Tested?

A new unit test verifies that the user is given copies of the

Checklist:

  • I have reviewed the Contributor Guidelines.
  • I agree with the terms of the GSD Contributor Agreement.
  • My name is on the list of contributors (doc/credits.rst) in the pull request source branch.
  • I have added a change log entry to CHANGELOG.rst.

@joaander joaander marked this pull request as ready for review January 22, 2024 18:11
@joaander joaander requested review from a team, tcmoore3, tommy-waltmann and rayasare and removed request for a team January 22, 2024 18:11
@joaander joaander merged commit 29d07bd into trunk-patch Jan 22, 2024
38 checks passed
@joaander joaander deleted the fix-initial-frame branch January 22, 2024 20:59
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