Skip to content

WIP: Weighting#34

Open
AlecThomson wants to merge 7 commits intomainfrom
weighting
Open

WIP: Weighting#34
AlecThomson wants to merge 7 commits intomainfrom
weighting

Conversation

@AlecThomson
Copy link
Owner

Adds Robust and other forms of weighting

@AlecThomson AlecThomson requested a review from Copilot May 1, 2025 03:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces additional weighting options for RM-synthesis, including support for natural and Briggs weighting, and updates related function signatures and configuration options. Key changes include:

  • Introducing a new WEIGHT_TYPES literal and updating the FDFOptions option to support four weighting types with a new robust parameter.
  • Adding four functions (uniform_weight, noise_weight, natural_weight, briggs_weight) to compute weights based on the selected option.
  • Updating the compute_rmsynth_params logic and the run_rmsynth signature to accommodate the new weighting options and robust parameter.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
rm_lite/utils/synthesis.py Adds new weighting functions and updates FDFOptions and weight computation logic.
rm_lite/tools_1d/rmsynth.py Updates parameter types and passes the robust parameter to the synthesis functions.

AlecThomson and others added 2 commits May 1, 2025 11:53
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@AlecThomson AlecThomson marked this pull request as ready for review May 1, 2025 03:54
@AlecThomson AlecThomson requested a review from Copilot May 1, 2025 03:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces new weighting options and related API updates for RM-synthesis. Key changes include defining a new literal type (WEIGHT_TYPES), updating default weighting from "variance" to "uniform" (with support for natural and Briggs weighting), and propagating the new strict parameter to several function calls and examples.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_nufft.py Added strict=False flag to the helper call in tests
rm_lite/utils/synthesis.py Defined new WEIGHT_TYPES and refactored weighting logic with match-case
rm_lite/utils/fitting.py Updated the call to sf.round to include strict=False
pyproject.toml Raised the minimum Python version and updated classifiers
.github/workflows/ci.yml Updated supported Python versions
Comments suppressed due to low confidence (3)

rm_lite/utils/synthesis.py:573

  • The use of match-case for selecting the weighting method greatly improves readability; ensure that tests fully cover all cases (including the error branch) for these new weighting options.
match fdf_options.weight_type:

rm_lite/utils/fitting.py:292

  • Verify that the sf.round function accepts the strict parameter and that its behavior with strict=False is as expected, ensuring consistency across the codebase.
+    fit_vals = [sf.round(p, e) for p, e in zip(popt, errors, strict=False)]

pyproject.toml:14

  • Updating the required Python version to >=3.10 is appropriate given new syntax features; ensure that this change is clearly communicated to contributors and documented in the release notes.
+requires-python = ">=3.10"

@@ -427,6 +427,7 @@ def test_rmsf():
["phi2Arr", "RMSFcube", "fwhmRMSFArr"],
[phi2Arr, RMSFcube, fwhmRMSFArr],
[phi2Arr_old, RMSFcube_old, fwhmRMSFArr_old],
Copy link

Copilot AI May 1, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a brief comment explaining the purpose of the 'strict=False' flag in this test context to aid future maintainers.

Suggested change
[phi2Arr_old, RMSFcube_old, fwhmRMSFArr_old],
[phi2Arr_old, RMSFcube_old, fwhmRMSFArr_old],
# Allow iterables of different lengths without raising an error, as this is acceptable in this test context.

Copilot uses AI. Check for mistakes.
return TheoreticalNoise(**as_dict)


WEIGHT_TYPES = Literal["variance", "uniform", "natural", "briggs"]
Copy link

Copilot AI May 1, 2025

Choose a reason for hiding this comment

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

[nitpick] It may be beneficial to update the function docstrings and related documentation to reflect the new valid weighting types and any changes in default behavior.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented May 1, 2025

Codecov Report

Attention: Patch coverage is 39.06250% with 39 lines in your changes missing coverage. Please review.

Project coverage is 80.64%. Comparing base (3ccf1c3) to head (7c1d6c2).
Report is 92 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
rm_lite/utils/synthesis.py 39.34% 37 Missing ⚠️
rm_lite/utils/multiscale.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #34      +/-   ##
==========================================
+ Coverage   71.09%   80.64%   +9.54%     
==========================================
  Files          13       13              
  Lines        1249     1121     -128     
==========================================
+ Hits          888      904      +16     
+ Misses        361      217     -144     

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

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.

2 participants