Skip to content

rpdmb.save: L2norm_fractional_tolerance#165

Open
markscheel wants to merge 1 commit into
sxs-collaboration:mainfrom
markscheel:rpdmb_params
Open

rpdmb.save: L2norm_fractional_tolerance#165
markscheel wants to merge 1 commit into
sxs-collaboration:mainfrom
markscheel:rpdmb_params

Conversation

@markscheel

@markscheel markscheel commented Jun 11, 2025

Copy link
Copy Markdown
Contributor

Fixes #162

  1. L2norm_fractional_tolerance is now used for w.truncate and nothing
    else. Using None or values <=0 for this parameter means no
    truncation.
  2. There is a new parameter corotating_frame_tolerance that
    is the tolerance passed into w.to_corotating_frame.
    It defaults to L2norm_fractional_tolerance for backward
    compatibility.
  3. The code paths that formerly were taken when
    L2norm_fractional_tolerance==None are now gone.
    These code paths were apparently used by Mike for testing.
    There were two code paths: 1) Don't do any of the RPDMB operations
    and 2) bypass shuffle_widths, use the standard shuffling, and
    write different attributes into the h5 file.
    It appears to me that 2) would result in files that could not
    be read by rpdmb.load (since the attributes looked for by
    rpdmb.load would be missing).

📚 Documentation preview 📚: https://sxs--165.org.readthedocs.build/en/165/

@markscheel markscheel marked this pull request as draft June 11, 2025 22:54
Fixes sxs-collaboration#162

1) L2norm_fractional_tolerance is now used for w.truncate and nothing
   else.  Using None or values <=0 for this parameter means no
   truncation.
2) There is a new parameter corotating_frame_tolerance that
   is the tolerance passed into w.to_corotating_frame.
   It defaults to L2norm_fractional_tolerance for backward
   compatibility.
3) The code paths that formerly were taken when
   L2norm_fractional_tolerance==None are now gone.
   These code paths were apparently used by Mike for testing.
   There were two code paths: 1) Don't do any of the RPDMB operations
   and 2) bypass shuffle_widths, use the standard shuffling, and
   write different attributes into the h5 file.
   It appears to me that 2) would result in files that could not
   be read by rpdmb.load (since the attributes looked for by
   rpdmb.load would be missing).
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 58.13953% with 18 lines in your changes missing coverage. Please review.

Project coverage is 44.15%. Comparing base (3f7e0eb) to head (d341fbe).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...andlers/rotating_paired_diff_multishuffle_bzip2.py 58.13% 10 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #165      +/-   ##
==========================================
- Coverage   44.24%   44.15%   -0.10%     
==========================================
  Files          83       83              
  Lines        6208     6201       -7     
  Branches     1009     1008       -1     
==========================================
- Hits         2747     2738       -9     
- Misses       3209     3211       +2     
  Partials      252      252              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@markscheel markscheel marked this pull request as ready for review June 12, 2025 13:10
Comment on lines +65 to +66
If L2norm_fractional_tolerance is <=0.0 or None, then no
truncation is done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just skip the None possibility. The old code that would have used that is gone anyway, so it won't break anything more. If anything, letting it succeed but take a different path would be a bad thing.

Suggested change
If L2norm_fractional_tolerance is <=0.0 or None, then no
truncation is done.
If L2norm_fractional_tolerance is <=0.0, then no
truncation is done.

Comment on lines +141 to +147
if corotating_frame_tolerance is None:
corotating_frame_tolerance = L2norm_fractional_tolerance
if L2norm_fractional_tolerance is None or L2norm_fractional_tolerance <=0.0:
warning = f"corotating_frame_tolerance has not been specified, so it is defaulting to L2norm_fractional_tolerance. However, L2norm_fractional_tolerance is {L2norm_fractional_tolerance} which does not make sense as a corotating_frame_tolerance. You probably want to explicitly set corotating_frame_tolerance."
warnings.warn(warning)


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minimum sensible tolerance is 100*epsilon, so let's just fall back to that.

Suggested change
if corotating_frame_tolerance is None:
corotating_frame_tolerance = L2norm_fractional_tolerance
if L2norm_fractional_tolerance is None or L2norm_fractional_tolerance <=0.0:
warning = f"corotating_frame_tolerance has not been specified, so it is defaulting to L2norm_fractional_tolerance. However, L2norm_fractional_tolerance is {L2norm_fractional_tolerance} which does not make sense as a corotating_frame_tolerance. You probably want to explicitly set corotating_frame_tolerance."
warnings.warn(warning)
if corotating_frame_tolerance is None:
corotating_frame_tolerance = max(L2norm_fractional_tolerance, 100*np.finfo(float).eps)

if L2norm_fractional_tolerance > 0.0:
w.truncate(tol=L2norm_fractional_tolerance)
# Set bits below the desired significance level to 0
if L2norm_fractional_tolerance is not None and L2norm_fractional_tolerance > 0.0:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if L2norm_fractional_tolerance is not None and L2norm_fractional_tolerance > 0.0:
if L2norm_fractional_tolerance > 0.0:

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.

bugs with sxs.rpdmb.save's L2norm_fractional_tolerance parameter

3 participants