Skip to content
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

Refactored stats_refitting.py for better robustness and readability #2424

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rrawatt
Copy link

@rrawatt rrawatt commented Feb 13, 2025

Description

Refactored the code

  1. core logic is kept same.
  2. extracted scale conversion into a helper function (_get_scale_value) to keep the main function cleaner
  3. replaced np.argwhere with np.flatnonzero for simpler, 1D indexing of problematic observations
  4. np.sqrt instead of raising to the power of 0.5 for computing the standard error.

Checklist

  • Follows official PR format
  • Includes a sample plot to visually illustrate the changes (only for plot-related functions)
  • New features are properly documented (with an example if appropriate)?
  • Includes new or updated tests to cover the new feature
  • Code style correct (follows pylint and black guidelines)
  • Changes are listed in changelog

Refactored the code
1) core logic is kept same.
2) replaced np.argwhere with np.flatnonzero
3) _get_scale_value encapsulates the logic for converting the scale string
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