Add a Bottleneck engine to Patch.rolling #770
d-chambers
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Bobine currently uses
Patch.rolling(..., engine="numpy").mean()for centered smoothing of 2-D DAS patches. Bottleneck is already an optional DASCore dependency and is substantially faster for these moving reductions: on a representative 120 × 20,000 patch with a 20-sample distance window, the full operation was about 4.9× faster locally (0.057 s → 0.012 s).DASCore exposes Bottleneck through
dascore.utils.moving, butPatch.rollingcurrently accepts only the NumPy and pandas engines. Usingmoving_windowdirectly is not a drop-in replacement becausePatch.rollinghas its own step, coordinate, history, full-window NaN, and even-window centering semantics.Would it make sense to add
engine="bottleneck"directly toPatch.rolling?The compatibility contract I would expect is:
mean,median,min,max,std, andsumpreserve the existing NumPy/pandas output shape, coordinates, history, full-window NaN behavior, step/overlap handling, and centering placement, including even windows.applyeither raises a clear unsupported-operation error for the Bottleneck engine or deliberately falls back to NumPy; an explicit error seems less surprising.engine="bottleneck"without Bottleneck installed raises a focused optional-dependency error rather than silently selecting another engine.An implementation could add a
_BottleneckPatchRolleralongside the existing NumPy and pandas rollers, reusing the common coordinate/history logic while dispatching built-in reductions to Bottleneck moving functions. The important part would be matchingPatch.rollingsemantics rather than inheriting the separate centering/boundary behavior ofutils.moving.All reactions