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

Fixing bug when executing a breaking pset #1630

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

erikvansebille
Copy link
Member

Previously, running a pset.execute() on an empty set returned an Error

Traceback (most recent call last):
  File "/Users/erik/Codes/ParcelsCode/parcels/particleset.py", line 907, in execute
    min_rt = np.min(self.particledata.data['time_nextloop'])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/erik/anaconda3/envs/parcels/lib/python3.12/site-packages/numpy/core/fromnumeric.py", line 2953, in min
    return _wrapreduction(a, np.minimum, 'min', axis, None, out,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/erik/anaconda3/envs/parcels/lib/python3.12/site-packages/numpy/core/fromnumeric.py", line 88, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: zero-size array to reduction operation minimum which has no identity

This PR fixes that Issue by gracefully returning from pset.execute when there are no particles to execute. This fixes #1629

@erikvansebille erikvansebille marked this pull request as ready for review July 31, 2024 07:11
@erikvansebille erikvansebille merged commit 8bfa17f into master Jul 31, 2024
10 checks passed
@erikvansebille erikvansebille deleted the fix_bug_empty_pset_execute branch July 31, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Crash on empty particleset
2 participants