8000 Refactored stats_refitting.py for better robustness and readability by rrawatt · Pull Request #2424 · arviz-devs/arviz · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Refactored stats_refitting.py for better robustness and readability #2424

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 2 commits 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
Made minor improvements in the docstrings for clarity while preserving the original information.
Streamlined the exception handling in _check_method_is_implemented for conciseness without changing the behavior.
Replaced conditional assignments with the more concise pattern
Copy link
Member
@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. It looks like it needs to pass formatting and linter checks. We have a requirements-dev.txt file and a scripts/lint.sh that you can use to check all formatters and linters are happy

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
0