Skip to content

Conversation

NolanBrb
Copy link
Contributor

New feature / Bug Fix

Added default behaviour when values to normalize are all equal; previously holoviews would attempt division by zero and return a runtime warning.
Proposed change : if all values are equal to zero, set all values to 0; otherwise, set all values to 1.

added default behaviour when values to normalize are all equal; if they are all 0 then all values are set to 0, otherwise all values are set to 1
@hoxbro
Copy link
Member

hoxbro commented Aug 29, 2024

Can you explain why this is needed?

@NolanBrb
Copy link
Contributor Author

NolanBrb commented Aug 29, 2024

Sure !

I ran into this error because I'm working on xarray datasets with multiple variables and procedurally creating vectorfields for each variable. I'm controlling the scale of the vectors using .opts(magnitude=hv.dim("Magnitude").norm())
Some of the variables I use have fixed magnitude, and when displaying the plot the line above returned a warning because since min==max, norm() was attempting to divide by zero.

@hoxbro
Copy link
Member

hoxbro commented Sep 13, 2024

I'm not opposed to this PR, but currently, it breaks CI.

Did you try to pass in limits to hv.dim("Magnitude").norm(limits=(0, None))? Or would you like it to be dynamically updated?

Would you happen to have a small example I could play around with?

@philippjfr philippjfr added this to the 1.21.0 milestone Jun 16, 2025
hoxbro and others added 2 commits June 16, 2025 11:58
Co-authored-by: Philipp Rudiger <prudiger@anaconda.com>
@hoxbro hoxbro changed the title Update norm function in transform.py enh: Update norm function in transform.py Jun 16, 2025
@hoxbro hoxbro enabled auto-merge (squash) June 16, 2025 11:40
@hoxbro
Copy link
Member

hoxbro commented Jun 16, 2025

Thank you for the PR, this will be part of the next release 1.21.0

Copy link

codecov bot commented Jun 16, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.84%. Comparing base (7aaeebc) to head (05c2a35).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
holoviews/util/transform.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6366      +/-   ##
==========================================
+ Coverage   88.83%   88.84%   +0.01%     
==========================================
  Files         328      328              
  Lines       69805    69829      +24     
==========================================
+ Hits        62010    62039      +29     
+ Misses       7795     7790       -5     

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

@hoxbro hoxbro merged commit e07c399 into holoviz:main Jun 16, 2025
14 checks passed
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