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

New particle access syntax #4402

Merged
merged 3 commits into from
Dec 13, 2021

Conversation

christophlohrmann
Copy link
Contributor

@christophlohrmann christophlohrmann commented Dec 7, 2021

Fixes #4389

Description of changes:

  • The []-operator on system.part was removed
  • An individual particle can be accessed by id using system.part.by_id(id), where id is the numerical particle id. This returns a ParticleHandle
  • A slice of particles can be accessed via an iterable of ids with system.part.by_ids(id_list), which returns a ParticleSlice
  • system.part.all() returns a slice containing all particles
  • The order in which particles will be provided when iterating over a slice will stay fixed, once the slice has been instanced. I.e, for pos, vel in zip(system.part.all().pos, system.part.all().v) will produce the expected result.
  • Selection by criterion (either using key=value or a lambda) can be done with the existing system.part.select()

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Member

@jngrad jngrad left a comment

Choose a reason for hiding this comment

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

Thanks for the hard work!

@jngrad jngrad added this to the Espresso 4.2 milestone Dec 13, 2021
@jngrad jngrad changed the title rework particle access New particle access syntax Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-work Python particle access
2 participants