Skip to content

Commit e604f6f

Browse files
Update parcels/spatialhash.py
Co-authored-by: Erik van Sebille <[email protected]>
1 parent f53003a commit e604f6f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

parcels/spatialhash.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,10 @@ def _encode_morton3d(x, y, z, xmin, xmax, ymin, ymax, zmin, zmax):
385385
dz = zmax - zmin
386386

387387
# Normalize to [0,1]; if a range is degenerate, map to 0 to avoid NaN/inf.
388-
xn = np.where(dx != 0, (x - xmin) / dx, 0.0)
389-
yn = np.where(dy != 0, (y - ymin) / dy, 0.0)
390-
zn = np.where(dz != 0, (z - zmin) / dz, 0.0)
388+
with np.errstate(invalid="ignore"):
389+
xn = np.where(dx != 0, (x - xmin) / dx, 0.0)
390+
yn = np.where(dy != 0, (y - ymin) / dy, 0.0)
391+
zn = np.where(dz != 0, (z - zmin) / dz, 0.0)
391392

392393
# --- 2) Quantize to 10 bits (0..1023). ---
393394
# Multiply by 1023, round down, and clip to be safe against slight overshoot.

0 commit comments

Comments
 (0)