Skip to content

feat: Add comprehensive uncertainty analysis and fit validation to FitResult classFeat/add pcov in fit#3

Open
joanjcaceres wants to merge 46 commits intoUlysseREGLADE:mainfrom
Quantronics:feat/add-pcov-in-fit
Open

feat: Add comprehensive uncertainty analysis and fit validation to FitResult classFeat/add pcov in fit#3
joanjcaceres wants to merge 46 commits intoUlysseREGLADE:mainfrom
Quantronics:feat/add-pcov-in-fit

Conversation

@joanjcaceres
Copy link

This pull request introduces significant updates to the abcd_rf_fit package, focusing on refactoring, code cleanup, and enhanced documentation for improved usability and maintainability. The most important changes include removing the resonators-checkpoint.py file, adding type hints and docstrings to key functions, and enhancing the fit_signal function to return a FitResult object with additional fit quality metrics.

Code cleanup and removal:

  • Removed the abcd_rf_fit/.ipynb_checkpoints/resonators-checkpoint.py file, which included unused functions and classes for resonator modeling. This streamlines the codebase and eliminates redundancy.

Enhanced documentation and type hints:

  • Added comprehensive docstrings and type hints to functions in abcd_rf_fit/abcd_rf_fit.py, including get_abcd, abcd2params, get_fit_function, meta_fit_edelay, and fit_signal. These updates clarify function purposes, parameters, and return values, improving code readability and usability. [1] [2] [3] [4] [5]

Functional improvements:

  • Enhanced the fit_signal function to return a FitResult object, which includes parameter uncertainties, goodness-of-fit metrics, and validation capabilities. This provides users with more detailed insights into the fit quality and results.
  • Modified the meta_fit_edelay function to use a reduced number of test points (21 instead of 1001) for electrical delay estimation, improving computational efficiency.

Package structure updates:

  • Updated the abcd_rf_fit/__init__.py file to include FitResult and ResonatorParams in the module's exports (__all__), ensuring these components are accessible when importing the package.

These changes collectively enhance the robustness, usability, and maintainability of the abcd_rf_fit package.
[Copilot is generating a summary...]

joanjcaceres and others added 29 commits November 20, 2024 14:01
…e hints

- Updated synthetic_signal.py to import resonator functions from resonators module.
- Simplified parameter handling in get_synthetic_resonance function.
- Improved docstrings and added type hints in utils.py for better clarity and type safety.
- Introduced new utility functions for SI prefix formatting and enhanced existing functions.
- Updated pyproject.toml to include configuration for Ruff linter with specific rules and exclusions.
…es for numpy, scipy, and matplotlib; format readme.ipynb for improved readability
- Fix syntax error where @Property decorator was malformed
- Ensure all property methods are properly defined
- Maintain code quality after linting improvements
- Remove trailing whitespace
- Maintain code quality standards
- Final cleanup before PR
- Fixed circular import between plot.py and resonators.py
- Added analyze() function as new API entry point
- Fixed syntax errors from merge conflict resolution
- Corrected typo in __init__.py exports
- All functionality tested and working:
  * FitResult class with uncertainty analysis
  * Parameter error calculation from covariance matrix
  * Goodness of fit metrics (R², χ²_red, RMS)
  * Fit validation with warnings and recommendations
  * Parameter correlation analysis
This commit addresses the API redundancy issue where fit_signal() returned
(fit_func, FitResult) but FitResult.fit_func already contained the same function.

Major changes:
- Created _fit_signal_core() as internal implementation returning only FitResult
- Modified fit_signal() to be a deprecated wrapper with proper DeprecationWarning
- Enhanced analyze() as the recommended API with comprehensive documentation
- Added plot() method to FitResult class for direct visualization
- Fixed parameter naming bug in plot.py (red_Warning → red_warning)

Backward compatibility is fully maintained while providing a clear migration
path from the redundant fit_signal() API to the cleaner analyze() API.

The refactor eliminates redundancy while preserving all existing functionality
and adding enhanced plotting capabilities through FitResult.plot().
…esult export and add _get_fit_summary() for detailed fit summaries
…ground-corrected signal and remove original signal overlay
@measBF2a measBF2a deleted the feat/add-pcov-in-fit branch June 10, 2025 12:38
@joanjcaceres joanjcaceres force-pushed the feat/add-pcov-in-fit branch 2 times, most recently from 6d01d73 to 53b2e90 Compare July 5, 2025 17:14
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.

3 participants