Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

rxchitrx
Copy link

Add Scale Parameter to PowerNorm init with default value 1.0 Apply scaling in call method before normalization Handle inverse scaling in inverse method
Add comprehensive text for scale parameter functionality Maintains backward Compatibility

PR summary

This PR adds a scale parameter to the PowerNorm class to allow pre-scaling of input data before applying power normalization.

Why is this change necessary?
Users sometimes need to scale their data before applying power normalization, which currently requires manual preprocessing. Adding a built-in scale parameter makes this workflow more convenient and consistent.

What problem does it solve?
Provides a clean way to scale input data before normalization without requiring users to manually transform their data or create wrapper functions.

Implementation details:

  • Added scale parameter to PowerNorm.__init__ with default value 1.0 (maintains backward compatibility)
  • Modified __call__ method to apply scaling before normalization: scaled_data = data * self.scale
  • Updated inverse method to handle reverse scaling: return result / self.scale
  • Added comprehensive test test_PowerNorm_scale to verify functionality

Example usage:

import matplotlib.colors as mcolors
norm = mcolors.PowerNorm(gamma=2.0, scale=2.0)  # Scale data by 2x before normalization```

```markdown
## PR checklist
- [ ] "closes #0000" is in the body of the PR description (if there's no specific issue, leave unchecked)
- [x] new and changed code is tested
- [ ] Plotting related features are demonstrated in an example (you could add this if needed)
- [ ] New Features and API Changes are noted with a directive and release note (may be needed)
- [x] Documentation complies with general and docstring guidelines```

Add Scale Parameter to PowerNorm __init__ with default value 1.0
Apply scaling in __call__ method before normalization
Handle inverse scaling in inverse method
Add comprehensive text for scale parameter functionality
Maintains backward Compatibility
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Sorry, but the task is to create PowerScale class (and possibly define PowerNorm via PowerScale), not a to add a scale parameter to PowerNorm. Please reread all comments in the issue #20355 carefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants