Skip to content

BUG: clip_evals uses wrong indicator #3227

Closed

Description

@josef-pkt
def clip_evals(x, value=0): #threshold=0, value=0):
    evals, evecs = np.linalg.eigh(x)
    clipped = np.any(evals < 0)
    x_new = np.dot(evecs * np.maximum(evals, value), evecs.T)
    return x_new, clipped

we are clipping based on value and not necessarily at 0
clipped = np.any(evals < value)

this is used as indicator in the functions to see whether clipping was necessary. So, that's incorrect if threshold (value) != 0.
(in examples, value was still tiny like 1e-15, IIRC, just to get positive definiteness. So there is a small imprecision in the results because of this bug)

Activity

  1. bashtage commented on Jul 30, 2026

    @bashtage
    Member

    Fixed by PR #6105 (merge commit 02388b3): clip_evals now correctly computes clipped = np.any(evals < value) using the value threshold argument instead of a hardcoded comparison to zero. Closing as fixed.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions