Skip to content

Commit ec74108

Browse files
committed
Fix: OverflowError error when casting approx sum to integer
1 parent f9f5ff5 commit ec74108

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

raster_loader/io/common.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,14 @@ def raster_band_approx_stats(
507507
_sum = 0
508508
sum_squares = 0
509509
if count > 0:
510-
_sum = int(np.sum(samples_band))
511-
sum_squares = int(np.sum(np.array(samples_band) ** 2))
510+
try:
511+
_sum = int(np.sum(samples_band))
512+
except OverflowError:
513+
_sum = float("inf")
514+
try:
515+
sum_squares = int(np.sum(np.array(samples_band) ** 2))
516+
except OverflowError:
517+
sum_squares = float("inf")
512518

513519
if basic_stats:
514520
quantiles = None

0 commit comments

Comments
 (0)