Skip to content

Commit 94f20a5

Browse files
committed
Address review: plain-int count, loosen cross-algorithm tolerance (#3597)
1 parent fba4321 commit 94f20a5

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

xrspatial/geotiff/_symbology.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ def update(self, buf):
268268
vals = buf.ravel() if bool(mask.all()) else buf[mask]
269269
else:
270270
vals = buf.ravel()
271-
n_b = vals.size
271+
# Plain ``int`` so the running count (and the moment arithmetic
272+
# built on it) stays in unbounded Python ints, not numpy scalars.
273+
n_b = int(vals.size)
272274
if n_b == 0:
273275
return
274276
# Reductions with float64 accumulators on the original buffer:

xrspatial/geotiff/tests/write/test_color_ramp_single_pass_3597.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,14 @@ def test_streaming_stats_matches_finite_stats_uneven_slabs():
203203
for r0, r1 in [(0, 5), (5, 6), (6, 40), (40, 64)]:
204204
acc.update(_BASE[r0:r1])
205205
da = xr.DataArray(_BASE, dims=("y", "x"))
206-
assert acc.result() == pytest.approx(_finite_stats(da, None), rel=1e-12)
206+
assert acc.result() == pytest.approx(_finite_stats(da, None), rel=1e-9)
207207

208208

209209
def test_streaming_stats_nan_nodata_treated_as_unset():
210210
acc = StreamingStats(nodata=float("nan"))
211211
acc.update(_BASE)
212212
da = xr.DataArray(_BASE, dims=("y", "x"))
213-
assert acc.result() == pytest.approx(_finite_stats(da, None), rel=1e-12)
213+
assert acc.result() == pytest.approx(_finite_stats(da, None), rel=1e-9)
214214

215215

216216
def test_streaming_stats_empty_returns_none():

0 commit comments

Comments
 (0)