Skip to content

Background estimation with a custom callable statistic #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

hpparvi
Copy link
Contributor

@hpparvi hpparvi commented Apr 7, 2025

This PR continues the work done in #255 and #253, enabling the user to provide a custom callable for background calculation. The primary changes are:

  • The statistic argument in the Background initializer now accepts "average", "median", or a custom callable. The callable should accept a numpy.ma.MaskedArray as input and must also support an axis argument.

  • The bkg_statistic keyword in Background.bkg_spectrum() is now deprecated and triggers a warning if used. Instead, the statistic argument in the Background initializer should be used.

I'd prefer to include these changes in a bugfix release (v1.5.2), which is why I've opted to deprecate rather than remove the bkg_statistic argument. However, the current implementation ignores the bkg_statistic argument, meaning that although the API itself hasn't technically changed, the code's behaviour has.

Let me know your thoughts on this approach or if you have suggestions for handling this differently.

Copy link

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.61%. Comparing base (6b1887b) to head (20ff843).

Files with missing lines Patch % Lines
specreduce/background.py 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #263      +/-   ##
==========================================
- Coverage   87.74%   87.61%   -0.13%     
==========================================
  Files          15       15              
  Lines        1289     1284       -5     
==========================================
- Hits         1131     1125       -6     
- Misses        158      159       +1     

☔ 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.

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