Skip to content

Commit de274f2

Browse files
committed
Reduce possibility of integer overflow
1 parent 9fc9829 commit de274f2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/mdio/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
INT32_MIN = -0x80000000
2222
INT32_MAX = 0x7FFFFFFF
2323

24+
INT64_MIN = -0x8000000000000000
25+
INT64_MAX = 0x7FFFFFFFFFFFFFFF
26+
2427
UINT8_MIN = 0x0
2528
UINT8_MAX = 0xFF
2629

@@ -29,3 +32,6 @@
2932

3033
UINT32_MIN = 0x0
3134
UINT32_MAX = 0xFFFFFFFF
35+
36+
UINT64_MIN = 0x0
37+
UINT64_MAX = 0xFFFFFFFFFFFFFFFF

src/mdio/core/grid.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy as np
99
import zarr
1010

11-
from mdio.constants import UINT32_MAX
11+
from mdio.constants import UINT64_MAX
1212
from mdio.core import Dimension
1313
from mdio.core.serialization import Serializer
1414

@@ -88,8 +88,8 @@ def build_map(self, index_headers):
8888
dim_hdr = index_headers[dim.name]
8989
live_dim_indices += (np.searchsorted(dim, dim_hdr),)
9090

91-
# We set dead traces to uint32 max. Should be far away from actual trace counts.
92-
self.map = zarr.full(self.shape[:-1], dtype="uint32", fill_value=UINT32_MAX)
91+
# We set dead traces to uint64 max. Should be far away from actual trace counts.
92+
self.map = zarr.full(self.shape[:-1], dtype="uint64", fill_value=UINT64_MAX)
9393
self.map.vindex[live_dim_indices] = range(len(live_dim_indices[0]))
9494

9595
self.live_mask = zarr.zeros(self.shape[:-1], dtype="bool")

0 commit comments

Comments
 (0)