Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a5c3e91
Optimize optimize() traversal and add tests
Erotemic Jan 23, 2026
fb46891
Refine optimize fixed-point loops and py38 annotations
Erotemic Jan 24, 2026
3f14bd2
Align warp optimize split flow with legacy behavior
Erotemic Feb 1, 2026
be19300
Restore optimize rewrite semantics with memoization
Erotemic Feb 1, 2026
4579e9e
Guard concat rewrites and auto dsize
Erotemic Feb 1, 2026
3481342
Restore auto dsize and guard concat optimize
Erotemic Feb 2, 2026
4e4ecbd
Fix optimize memoization keying
Erotemic Feb 2, 2026
d515913
Fix warp finalize transform direction and antialias
Erotemic Feb 18, 2026
7528b8c
Fix warp finalize mapping and keep crop-after-warp order
Erotemic Feb 18, 2026
95c10ab
Improve warp antialias compatibility across numpy versions
Erotemic Feb 18, 2026
5a6b55a
Document antialiasing issue and force inverse warp mapping
Erotemic Feb 19, 2026
31c29e1
Simplify warp mapping to fixed inverse convention
Erotemic Feb 19, 2026
6c2e036
Handle kwimage warp matrix convention per dtype/backend
Erotemic Feb 19, 2026
36a3ab3
Prefer inverse affine mapping for float64 warps
Erotemic Feb 19, 2026
0a002ae
Use probed matrix mode for float64 warp paths
Erotemic Feb 19, 2026
6ee9b3e
Add nearest-warp fallback for matrix convention mismatches
Erotemic Feb 19, 2026
a8b31e1
Evaluate both nearest warp matrix conventions and add debug hook
Erotemic Feb 19, 2026
310f089
Improve nearest warp scoring and add debug journal
Erotemic Feb 19, 2026
23fc289
Add richer off-by-one diagnostics and NaN border compatibility tweak
Erotemic Feb 19, 2026
c91912c
Deepen nearest-warp diagnostics and add pure-scale rescue path
Erotemic Feb 19, 2026
f834ac0
Add nearest pure-scale fastpath and fix off-by-one diagnostics
Erotemic Feb 19, 2026
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## Version 0.4.6 - Unreleased

### Performance
* Improve optimize() performance via per-call memoization, reduced allocations, and fixed-point rewrite loops; no behavior change intended.

### Fix
* Handle case when input sensorchan strings are string subclasses.
* Fix issue where lazy warps did not respect explicitly given dsize arguments
Expand Down
15 changes: 14 additions & 1 deletion delayed_image/delayed_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Abstract nodes
"""
from __future__ import annotations
import numpy as np
import ubelt as ub

Expand All @@ -13,6 +14,18 @@
USE_SLOTS = True


# Per-call optimization context
class OptimizeContext:
"""
Holds per-call optimization state to avoid repeated work.
"""
if USE_SLOTS:
__slots__ = ('memo',)

def __init__(self):
self.memo = {}


# from kwcoco.util.util_monkey import Reloadable # NOQA
# @Reloadable.developing # NOQA
class DelayedOperation:
Expand Down Expand Up @@ -385,7 +398,7 @@ def finalize(self, prepare=True, optimize=True, **kwargs):
# final = np.asanyarray(final) # does not work with xarray
return final

def optimize(self):
def optimize(self, ctx=None):
"""
Returns:
DelayedOperation
Expand Down
9 changes: 8 additions & 1 deletion delayed_image/delayed_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ from _typeshed import Incomplete
from collections.abc import Generator


class OptimizeContext:
memo: Dict[int, 'DelayedOperation']

def __init__(self) -> None:
...


class DelayedOperation(ub.NiceRepr):
meta: Incomplete

Expand Down Expand Up @@ -57,7 +64,7 @@ class DelayedOperation(ub.NiceRepr):
**kwargs) -> ArrayLike:
...

def optimize(self) -> DelayedOperation:
def optimize(self, ctx: OptimizeContext | None = None) -> DelayedOperation:
...


Expand Down
9 changes: 8 additions & 1 deletion delayed_image/delayed_leafs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Terminal nodes
"""
from __future__ import annotations

import kwarray
import kwimage
Expand Down Expand Up @@ -30,9 +31,15 @@ def get_transform_from_leaf(self):
"""
return kwimage.Affine.eye()

def optimize(self):
def optimize(self, ctx=None):
if ctx is None:
ctx = delayed_base.OptimizeContext()
memo = ctx.memo
if self in memo:
return memo[self]
if TRACE_OPTIMIZE:
self._opt_logs.append('optimize DelayedImageLeaf')
memo[self] = self
return self


Expand Down
3 changes: 2 additions & 1 deletion delayed_image/delayed_leafs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ from os import PathLike
from typing import Tuple
from _typeshed import Incomplete
from delayed_image.delayed_nodes import DelayedImage
from delayed_image.delayed_base import OptimizeContext

from delayed_image.channel_spec import FusedChannelSpec

Expand All @@ -14,7 +15,7 @@ class DelayedImageLeaf(DelayedImage):
def get_transform_from_leaf(self) -> kwimage.Affine:
...

def optimize(self):
def optimize(self, ctx: OptimizeContext | None = None):
...


Expand Down
Loading