Skip to content

swt documentation mistake #838

Closed

Description

@Smogy001

Documentation for pywt.swt states:
"If start_level = m is given, then the beginning m steps are skipped:
[(cAm+n, cDm+n), ..., (cAm+1, cDm+1), (cAm, cDm)]"

It is misleading, because level = n is implied to be positive integer and not non-negative integer, i.e. starts from 1 and not 0.

I provide a counterexample level=1, start_level = 1.
According to documentation, coeffs = [(cA1+1, cD1+1), (cA1, cD1)], len(coeffs) = 2.
In reality, coeffs = [(cA1, cD1)], len(coeffs) = 1.

I suggest removing (cAm, cDm) from documentation or better yet, changing indexes to start from 0 for clarity.
Right now default start_level = 0 corresponds to [(cAn, cDn), ..., (cA2, cD2), (cA**1**, cD**1**)] which is also convoluted and misleading.

Activity

  1. rgommers commented on Feb 20, 2026

    @rgommers
    Member

    Thanks for the report @Smogy001, you are correct that that doesn't look accurate.

    This line is wrong:

    [(cAm+n, cDm+n), ..., (cAm+1, cDm+1), (cAm, cDm)]
    

    From a quick look, I think it should read:

    [(cAn, cDm), ..., (cAm+2, cDm+2), (cAm+1, cDm+1)]
    

    or better yet, changing indexes to start from 0 for clarity.

    I think the subscript 1 is used consistently throughout the docs, so this doesn't sound good to me.

  2. Smogy001 commented on Feb 23, 2026

    @Smogy001
    Author

    The line should read [(cAm+n, cDm+n), ..., (cAm+1, cDm+1)] because minimum n=1.
    I agree that changing notation midway is undue. However the fact that start_level starts from 0 and level starts from 1 which corresponds to 2**0 scale bugs me.

  3. rgommers commented on Feb 23, 2026

    @rgommers
    Member

    The line should read [(cAm+n, cDm+n), ..., (cAm+1, cDm+1)] because minimum n=1.

    Ah yes, you are correct - verified by running some code now. If you're interested in opening a PR to fix this, that'd be welcome.

    However the fact that start_level starts from 0 and level starts from 1 which corresponds to 2**0 scale bugs me.

    Yes I understand that, but we can't really change it for backwards compatibility reasons. The intent of the code reads like the argument name should have been skip_levels rather than start_level.

  4. added this to the v1.10.0 milestone on Feb 23, 2026
  5. added a commit that references this issue on Mar 30, 2026
    95ec977
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions