Skip to content

Commit

Permalink
Fix: OverflowError error when casting approx sum to integer
Browse files Browse the repository at this point in the history
  • Loading branch information
rantolin committed Jan 8, 2025
1 parent f9f5ff5 commit ec74108
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions raster_loader/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,14 @@ def raster_band_approx_stats(
_sum = 0
sum_squares = 0
if count > 0:
_sum = int(np.sum(samples_band))
sum_squares = int(np.sum(np.array(samples_band) ** 2))
try:
_sum = int(np.sum(samples_band))
except OverflowError:
_sum = float("inf")
try:
sum_squares = int(np.sum(np.array(samples_band) ** 2))
except OverflowError:
sum_squares = float("inf")

if basic_stats:
quantiles = None
Expand Down

0 comments on commit ec74108

Please sign in to comment.