Skip to content

Commit

Permalink
Fix unhandled numpy.round overflow return value in core/util.py:bound…
Browse files Browse the repository at this point in the history
…_range(...) (#5095)

* Core/Util: Fix unhandled np.round overflow return

The function numpy.round return for the input
np.float64(2.6558061446181644e+295) the output
numpy.inf. This should lead to
density = full_precision_density.

* Core/Util: Supress numpy.round overflow error

The function numpy.round produces for the input
numpy.float64(2.6558061446181644e+295) an
FloatingPointError with the message
"overflow encountered in multiply". This error
should be suppressed because its an internal
computation by holoview.

* Use context manager

Co-authored-by: [email protected] <[email protected]>
Co-authored-by: Philipp Rudiger <[email protected]>
  • Loading branch information
3 people committed Nov 16, 2021
1 parent f094d4b commit 1d9f19f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2045,8 +2045,9 @@ def bound_range(vals, density, time_unit='us'):
with warnings.catch_warnings():
warnings.filterwarnings('ignore', r'invalid value encountered in double_scalars')
full_precision_density = compute_density(low, high, len(vals)-1)
density = round(full_precision_density, sys.float_info.dig)
if density == 0:
with np.errstate(over='ignore'):
density = round(full_precision_density, sys.float_info.dig)
if density == 0 or density == np.inf:
density = full_precision_density
if density == 0:
raise ValueError('Could not determine Image density, ensure it has a non-zero range.')
Expand Down

0 comments on commit 1d9f19f

Please sign in to comment.