Skip to content

Fix slice selection bug in ChunkCachedArray - #2898

Closed
erikvansebille wants to merge 1 commit into
Parcels-code:mainfrom
erikvansebille:fix-2897
Closed

Fix slice selection bug in ChunkCachedArray#2898
erikvansebille wants to merge 1 commit into
Parcels-code:mainfrom
erikvansebille:fix-2897

Conversation

@erikvansebille

@erikvansebille erikvansebille commented Sep 11, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes #2897 by supporting slice selection

Perhaps we should add some tests too?

Checklist

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.
    • Describe how you used it (e.g., by pasting your prompt):

I asked CoPilot how to fix the error shown in #2897; Claude then came with this solution that indeed fixed the error I encountered. However, I'm not entirely sure it's a full/valid solution, so I'd be keen to hear @VeckoTheGecko's feedback.

Comment on lines +143 to +147
# The chunk-cache fast path requires a fancy integer array per dimension.
# Some dims (e.g. unindexed extra dims) may come through as a bare slice
# instead, so fall back to dask's own vectorized indexing in that case.
if any(isinstance(k, slice) for k in key):
return self.array.vindex[key].compute()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This completely bypasses the chunk caching mechanism and will degrade performance

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

OK thanks; that's clear then. I'll close this PR

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.

TypeError in ChunkCachedArray: '<' not supported between instances of 'slice' and 'int'

2 participants