Fix performance regression in base resampler class when comparing geometries #520
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As mentioned in #517, the new comparison added to the base resampler class in #508 was significantly slowing down any cases where non-areas were involved. This was most noticeable with EWA resampling as it is based on this resampler class and only deals with swath definitions.
The primary issue is/was that if the swaths are not equal the
==
used in theif
statement was comparing the every coordinate (every pixel) of the source swath arrays to every pixel of the area definitions generated coordinates. This is usually not necessary since when we get to that point the objects are probably not equal and two swaths that aren't the same exact objects (or the underlying arrays are not the same) are probably not equal even if they have the same shape.This PR is the first step in a proper fix. This should be released in a 1.27.1 release to fix the performance issue. The second step will be a separate PR (as discussed on the pytroll slack) where a
coordinates_equal
method will be added to the geometries to compare coordinates values no matter the cost in performance. The__eq__
method will be updated to be strict about objects needing to be the same type and then take the shortcuts implemented in this PR.git diff origin/main **/*py | flake8 --diff