Skip to content

Conversation

@astrofrog
Copy link
Member

Work in progress, but can already be tested out.

…fer to speed up identical pixel transformations across layers (e.g. when subsets are present)
@astrofrog
Copy link
Member Author

@dhomeier - do you understand the ruff issue here?

@Carifio24
Copy link
Member

Carifio24 commented Mar 19, 2025

@dhomeier can correct me if I'm wrong, but I think what it wants is

# `value` is a bad variable name but I don't know what this thing is
for chid, value in PIXEL_CACHE.items():
   if value['hash'] == current_pixel_hash:
       for ipix, pix in enumerate(data.pixel_component_ids):
           if (
                   ipix not in matching_pixel_cache and
                   ipix in value and
                   value[ipix]['bounds'] == bounds
           ):
               matching_pixel_cache[ipix] = value[ipix]

rather than (what is currently is):

for chid in PIXEL_CACHE:
   if PIXEL_CACHE[chid]['hash'] == current_pixel_hash:
         for ipix, pix in enumerate(data.pixel_component_ids):
             if (
                     ipix not in matching_pixel_cache and
                     ipix in PIXEL_CACHE[chid] and
                     PIXEL_CACHE[chid][ipix]['bounds'] == bounds
             ):
                 matching_pixel_cache[ipix] = PIXEL_CACHE[chid][ipix]

@dhomeier
Copy link
Collaborator

dhomeier commented Mar 19, 2025

@dhomeier can correct me if I'm wrong, but I think what it wants is

I can only agree ;-)

Co-authored-by: Derek Homeier <dhomeie@gwdg.de>
# still use cache_id because we still want to make sure we save results from different layers
# to the cache in case any layers get removed or changed.
matching_pixel_cache = {}
for chid, i_cache in PIXEL_CACHE.items():
Copy link
Collaborator

Choose a reason for hiding this comment

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

actually I am surprised Ruff does not complain now that chid is never used – or suggested to use PIXEL_CACHE.values() in the first place... 😂

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah, we should fix that, we should just use .values()...

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