Skip to content

BUG: infer multiresolution levels from transformed axes - #886

Open
antonsoo wants to merge 1 commit into
PyWavelets:mainfrom
antonsoo:fix/mra-default-level-axes
Open

antonsoo wants to merge 1 commit into
PyWavelets:mainfrom
antonsoo:fix/mra-default-level-axes

Conversation

@antonsoo

Copy link
Copy Markdown

Automatic SWT depth in mra2 and mran includes dimensions that are not being transformed. An RGB image transformed over its spatial axes therefore gets depth zero from its three-channel dimension and raises during reconstruction:

from scipy.datasets import face
import pywt

image = face()[300:332, 300:348]  # shape (32, 48, 3)
for forward in (pywt.mra2, pywt.mran):
    coeffs = forward(image, 'db2', axes=(0, 1))
    expected = forward(image[..., 0], 'db2')
    assert len(coeffs) == len(expected) == 5  # four levels and approximation

Before this change both calls raise a dimension-mismatch error. A two-channel input instead silently selects one level where its spatial dimensions support four.

Infer the default depth from the selected axes. mran already has their sizes; mra2 uses the existing axis-validation helper. Clarify the default-level documentation and remove the outdated restriction of mra2's axes to DWT. Explicit levels and DWT behavior stay the same.

On 72 actual face-image configurations (1/2/3 channels, channel-axis placement, both APIs, db1/db2 and float32/64), 48 errors and 24 shallow decompositions become 72 correct decompositions. Every component matches processing each real channel independently, and all 72 explicit-level controls retain identical arrays.

All 18 new regression cases fail on main and pass with the fix. The full package suite passes (1070 tests, two skips) and project hooks pass. The release 1.10.0 wheel and the actual head of #847 reproduce the same issue; that PR changes MRA annotations only.

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.

1 participant