Skip to content

Keep the given order of Matsubara sampling points - #87

Merged
shinaoka merged 2 commits into
mainlinefrom
fix/matsubara-point-order
Sep 25, 2026
Merged

shinaoka merged 2 commits into
mainlinefrom
fix/matsubara-point-order

Conversation

@shinaoka

Copy link
Copy Markdown
Member

Summary

MatsubaraSampling with custom points given in any order but ascending returned evaluate results and expected fit data in a different order from sampling_points. Results were silently wrong for the caller's data order.

The C library orders Matsubara points ascending internally, while the wrapper kept sampling_points in the caller's order.

This follows up #86, found while fixing the tutorial notebooks.

Changes

  • Order. The wrapper hands the C library sorted points and permutes the data between the two orders in evaluate and fit, on any axis. TauSampling already follows the given order since Enrich the tests, fix the wrapper defects they expose, and document the conventions #86.
    • Default points are sorted already and take no extra work.
    • cond is unchanged, since a row permutation does not change it.
  • Docstrings.
    • MatsubaraSampling states that points may be given in any order.
    • The unfolded default τ points were said to be symmetric about 0. They come in pairs ±τ, plus β/2 when their number is odd. So reversing them maps τ to −τ only for an even number, while reversing the folded default points maps τ to β − τ in every case.

Tests

tests/test_boundary.py checks that shuffled default points give evaluate equal to gl @ basis.uhat(points) and a fit round trip, along axis 0 and axis 1. It covers:

  • fermions and bosons, with and without positive_only;
  • an augmented basis;
  • a DLR.

All five cases failed before the fix. The full suite gives 350 passed, 5 xfailed (was 345 passed, 5 xfailed).

🤖 Generated with Claude Code

shinaoka and others added 2 commits September 25, 2026 21:42
The C library orders Matsubara sampling points ascending. MatsubaraSampling
kept `sampling_points` in the caller's order but returned evaluate() and
expected fit() data in the sorted order, so custom points given in any
other order silently mismatched the data (plain, positive-only, augmented
and DLR bases alike).

The wrapper now hands the C library sorted points and permutes the data
between the two orders, as TauSampling already follows the given order.
Default points are sorted already and take no extra work.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The docstrings said the unfolded default τ points are symmetric about 0.
For an odd number of points one of them is β/2, which has no partner, so
reversing the unfolded points maps τ to -τ only for an even number;
reversing the folded default points maps τ to β - τ in every case.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@shinaoka
shinaoka enabled auto-merge September 25, 2026 12:42
@shinaoka
shinaoka merged commit a7dbeca into mainline Sep 25, 2026
9 checks passed
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