Skip to content

Commit a68a15e

Browse files
committed
CLN: added asserts to make debugging easier
1 parent 1876f69 commit a68a15e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

larray_editor/arrayadapter.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,17 @@ def get_data_values_and_attributes(self, h_start, v_start, h_stop, v_stop):
404404
f"{self.__class__.__name__}.get_data_values_and_attributes("
405405
f"{h_start=}, {v_start=}, {h_stop=}, {v_stop=})"
406406
)
407+
height, width = self.shape2d()
408+
assert v_start >= 0, f"v_start ({v_start}) is out of bounds (should be >= 0)"
409+
assert h_start >= 0, f"h_start ({h_start}) is out of bounds (should be >= 0)"
410+
assert v_stop >= 0, f"v_stop ({v_stop}) is out of bounds (should be >= 0)"
411+
assert h_stop >= 0, f"h_stop ({h_stop}) is out of bounds (should be >= 0)"
412+
if height > 0:
413+
assert v_start < height, f"v_start ({v_start}) is out of bounds (should be < {height})"
414+
if width > 0:
415+
assert h_start < width, f"h_start ({h_start}) is out of bounds (should be < {width})"
416+
assert v_stop <= height, f"v_stop ({v_stop}) is out of bounds (should be <= {height})"
417+
assert h_stop <= width, f"h_stop ({h_stop}) is out of bounds (should be <= {width})"
407418
chunk_values = self.get_values(h_start, v_start, h_stop, v_stop)
408419
if isinstance(chunk_values, np.ndarray):
409420
assert chunk_values.ndim == 2
@@ -1976,6 +1987,7 @@ def __init__(self, data, attributes):
19761987
num_rows_per_group = np.array([meta.row_group(i).num_rows
19771988
for i in range(data.num_row_groups)])
19781989
self._group_ends = num_rows_per_group.cumsum()
1990+
assert self._group_ends[-1] == meta.num_rows
19791991
self._cached_table = None
19801992
self._cached_table_h_start = None
19811993
self._cached_table_v_start = None

0 commit comments

Comments
 (0)