Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions odc/geo/overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ def _can_paste(

(sx, _, tx, _, sy, ty, *_) = A_ # tx, ty are in dst pixel space

if any(s < 0 for s in (sx, sy)):
return False, "flipped axis"

# Expect identity for scale change
if any(abs(abs(s) - 1) > stol for s in (sx, sy)): # not equal scaling across axis?

Choose a reason for hiding this comment

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

One question on this line - not particularly important as this fixes my original issue but.

Is there a need for the two calls to abs?

I found that changing this line to if any(abs(s - 1) > stol for s in (sx, sy)): made more sense in my head and also meant that can_paste is set to false if any axes are flipped.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, especially since "reason" messages aren't used, most likely, probably an early debugging tool

return False, "sx!=sy, probably"
Expand Down
11 changes: 7 additions & 4 deletions tests/test_overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,20 +427,23 @@ def test_axis_overlap() -> None:
def test_can_paste() -> None:
assert _can_paste(mkA(translation=(10, -20))) == (True, None)
assert _can_paste(mkA(scale=(10, 10))) == (True, None)
assert _can_paste(mkA(scale=(-10, 10), translation=(0, -4 * 10))) == (True, None)
assert _can_paste(mkA(scale=(-10, 10), translation=(0, -4 * 10))) == (
False,
"flipped axis",
)

assert _can_paste(mkA(shear=0.3)) == (False, "has rotation or shear")
assert _can_paste(mkA(rot=30)) == (False, "has rotation or shear")

assert _can_paste(mkA(scale=(-11.1, 11.1))) == (False, "non-integer scale")
assert _can_paste(mkA(scale=(11.1, 11.1))) == (False, "non-integer scale")
assert _can_paste(mkA(scale=(0.5, 0.5))) == (False, "non-integer scale")
assert _can_paste(mkA(scale=(2, 3))) == (False, "sx!=sy, probably")

assert _can_paste(mkA(scale=(-10, 10), translation=(0, -4))) == (
assert _can_paste(mkA(scale=(10, 10), translation=(0, -4))) == (
False,
"sub-pixel translation",
)
assert _can_paste(mkA(scale=(-10, 10), translation=(-4, 10))) == (
assert _can_paste(mkA(scale=(10, 10), translation=(-4, 10))) == (
False,
"sub-pixel translation",
)
Expand Down
Loading