Skip to content

Fix: align SplitBregman docs and cost with implementation, fix tol=0 - #809

Merged
mrava87 merged 1 commit into
PyLops:devfrom
mrava87:fix-sb_doc
Oct 6, 2026
Merged

mrava87 merged 1 commit into
PyLops:devfrom
mrava87:fix-sb_doc

Conversation

@mrava87

@mrava87 mrava87 commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Closes #808.

Docs

  • The effective weight of each L1 term is epsRL1s[i]**2: epsRL1s[i] is used both as the weight of the augmented L2 term in the x-subproblem and as the threshold of the shrinkage step. The cost function in the Notes, the constrained/split formulation, and the epsRL1s parameter descriptions now reflect this.
  • Use d_i for the split variable (was y_i, clashing with the data y), and add tau to the Bregman update.
  • Describe the x-subproblem solvers precisely (scipy.sparse.linalg.lsqr for engine="scipy" with NumPy arrays, cgls for engine="pylops" or other array types) and the closed-form shrinkage of the d-subproblem, including the stopping criterion.
  • Fix other docstring errors: duplicated nregsL1 attribute (should be nregsL2), types of b/d, OMP/IRLS copy-paste in step/run, size of the initial guess returned by setup, engine/show_inner/kwargs_lsqr descriptions mentioning lsqr only, over-indented itershow/preallocate in splitbregman, "Split-Bergman" typo.

Code

  • The recorded cost now matches the documented cost function: 1/2 on the L2 terms and epsRL1s**2 on the L1 terms (previously epsRL2s without 1/2, and unit weight on L1). The solution is unchanged.
  • tol=0 no longer skips all outer iterations: the model-update norm is initialized to inf, so at least one iteration is always run.

Tests

  • test_SplitBregman_tol0: all niter_outer iterations are run with tol=0.
  • test_SplitBregman_cost: cost[0] matches the documented cost computed by hand (with both L1 and L2 terms and nonzero dataregsL2).

🤖 Generated with Claude Code

- doc: effective L1 weight is epsRL1s**2 (eps is both the weight of the
  augmented L2 term and the shrinkage threshold); use d_i for the split
  variable, add tau to the Bregman update, describe the x-subproblem
  solvers, and fix several docstring errors
- fix: recorded cost now matches the documented cost function (1/2 on
  the L2 terms and epsRL1s**2 on the L1 terms)
- fix: tol=0 no longer skips all outer iterations
- test: add tests for tol=0 and for the cost function

Closes PyLops#808

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@mrava87 mrava87 self-assigned this Oct 6, 2026
@mrava87
mrava87 merged commit 16769aa into PyLops:dev Oct 6, 2026
23 of 24 checks passed
@mrava87
mrava87 deleted the fix-sb_doc branch October 6, 2026 21:18
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.

splitbregman: documented cost function is not consistent with the implementation (epsRL1s acts as squared L1 weight)

1 participant