Skip to content

Conversation

@marcosdanieldasilva
Copy link

This PR adds a major performance optimization for finding indices on a TransformedGrid, specifically when it has a non-invertible SequentialTransform (like a Rotate followed by a Morphological transform).

Previously, this situation would fall back to the generic findall(intersects(geometry), domain) method, which is extremely slow because it must perform a costly intersection check for every single cell.

This new, specialized method implements a much faster "partial revert" strategy. It introspects the transform sequence, finds the invertible component (using isinvertible), and reverts the input geometry using only that part. This "un-transforms" the geometry back to the original grid's coordinate space, allowing it to call the existing, highly-optimized indices(grid.mesh, ...) function on the simple, non-deformed grid. A new test is included to validate this exact scenario.

Copy link
Member

@juliohm juliohm left a comment

Choose a reason for hiding this comment

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

Thank you @marcosdanieldasilva !

Added a few suggestions to generalize the code:

  1. The transform can have multiple steps, so we need to combine all the revertible ones into a new transform in reverse order.
  2. We can then just apply the created transform to the geometry.

We still need to check if any transform step needs special treatment.

@codecov
Copy link

codecov bot commented Nov 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.52%. Comparing base (7c2fbc3) to head (cfb2407).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1264      +/-   ##
==========================================
- Coverage   87.90%   87.52%   -0.38%     
==========================================
  Files         197      197              
  Lines        6240     6246       +6     
==========================================
- Hits         5485     5467      -18     
- Misses        755      779      +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

marcosdanieldasilva and others added 4 commits November 1, 2025 21:15
Co-authored-by: Júlio Hoffimann <[email protected]>
Co-authored-by: Júlio Hoffimann <[email protected]>
Co-authored-by: Júlio Hoffimann <[email protected]>
Co-authored-by: Júlio Hoffimann <[email protected]>
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.

2 participants