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 ParticleSet object #1742

Open
VeckoTheGecko opened this issue Oct 25, 2024 · 0 comments
Open

Slicing ParticleSet object #1742

VeckoTheGecko opened this issue Oct 25, 2024 · 0 comments

Comments

@VeckoTheGecko
Copy link
Contributor

Currently indexing a particleset doesn't work with slice objects.

pset[0]
- > gives first particle

pset[:7]
self = <parcels.particledata.ParticleData object at 0x1620e3110>, index = slice(None, 7, None)

    def get_single_by_index(self, index):
        """Get a particle object from the ParticleData instance based on its index."""
>       assert type(index) in [
            int,
            np.int32,
            np.intp,
        ], f"Trying to get a particle by index, but index {index} is not a 32-bit integer - invalid operation."
E       AssertionError: Trying to get a particle by index, but index slice(None, 7, None) is not a 32-bit integer - invalid operation.

It would be a nice quality of life change for pset to support slicing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

1 participant