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

Slicing support #67

Merged
merged 6 commits into from
Mar 25, 2023
Merged

Slicing support #67

merged 6 commits into from
Mar 25, 2023

Conversation

rashidrafeek
Copy link
Contributor

Now with the key-based property interface we can do system[:, :property] to get the corresponding :property for all atoms. Wouldn't it also make sense to support system[rng, :property] for a subset, rng of atom indices. Also, from the discussion in #29, I think returning a list of particle objects for slicing is more intuitive and useful. In this PR, I have implemented both of these, i.e., returning vector of particles objects on slicing AbstractSystems and the corresponding extension to the key-based property interface.

For example, with this, we can do system[atomic_symbol(system) .== :H] to get all H atoms.

I am just putting this here as a working version to show the usefulness of this feature. Feel free to close this in case we think slicing need not be supported.

@rkurchin
Copy link
Collaborator

rkurchin commented Feb 7, 2023

Cool! I'd like to see others' thoughts and perhaps discuss a bit, but I'm certainly preliminarily in favor of merging this (or something like it) in!

Copy link
Member

@mfherbst mfherbst left a comment

Choose a reason for hiding this comment

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

Nice idea. Certainly in favour of having something like this.

src/flexible_system.jl Outdated Show resolved Hide resolved
src/fast_system.jl Outdated Show resolved Hide resolved
@jgreener64
Copy link
Collaborator

Looks good, definitely in favour of some version of this.

- Now only getindex for Integer need to be defined for concrete types
  and all other slicing automatically work.
- Remove the specific implentations from concrete types,
- Add tests for getindex with 2D arrays.
Copy link
Member

@mfherbst mfherbst left a comment

Choose a reason for hiding this comment

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

LGTM, just found a few nits.

src/flexible_system.jl Outdated Show resolved Hide resolved
src/interface.jl Outdated Show resolved Hide resolved
test/atom.jl Outdated Show resolved Hide resolved
@mfherbst mfherbst enabled auto-merge (squash) March 25, 2023 20:44
@mfherbst mfherbst merged commit bab6c92 into JuliaMolSim:master Mar 25, 2023
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.

4 participants