Skip to content

README getting-started GF(2) example crashes because rho0w is not scalar-safe #74

Description

@terasakisatoshi

Summary

The README's main getting-started example crashes as written.

At README.rst:78-79, the example defines:

def rho0w(w):
    return np.sqrt(1-w.clip(-1,1)**2) * 2/np.pi

During the documented flow, basis.v.overlap(rho0w) calls rho0w with a scalar float, so w.clip(...) raises an exception before the solver loop starts.

Reproduction

On commit 75b9f8fbb7991f09867e64d19424868a1c598f63:

uv sync
uv run python - <<'PY'
import sparse_ir, numpy as np
basis = sparse_ir.FiniteTempBasis('F', beta=10, wmax=8, eps=1e-6)
def rho0w(w):
    return np.sqrt(1-w.clip(-1,1)**2) * 2/np.pi
basis.v.overlap(rho0w)
PY

Actual

AttributeError: 'float' object has no attribute 'clip'

Expected

The README example should run verbatim.

Notes

Using np.clip(w, -1, 1) instead of w.clip(-1, 1) makes the full README GF(2) path run successfully in my test run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions