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: christoph.weiss@gtd-gmbh.de <christoph.weiss@gtd-gmbh.de>
Co-authored-by: Philipp Rudiger <prudiger@anaconda.com>
  • Loading branch information
3 people committed Nov 16, 2021
1 parent 0e88830 commit 403c1aa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions holoviews/core/util.py
Expand Up @@ -1969,8 +1969,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 403c1aa

Please sign in to comment.