You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sub_matrix panics on an out-of-range or negative index #26
pysnptools.util.sub_matrix (used by every SnpData/PstData subset) passes indexes straight to the Rust helper, which panics on an index out of range:
importnumpyasnp, pysnptools.utilaspstutilmatrix=np.random.rand(4, 3)
pstutil.sub_matrix(matrix, [5], [0]) # pyo3_runtime.PanicException: ndarray: index out of boundspstutil.sub_matrix(matrix, np.array([-1]), [0]) # PanicException (the -1 wraps to a huge uintp)pstutil.sub_matrix(matrix, [-1], [0]) # OverflowError: Python integer -1 out of bounds for uint64
A Rust panic also prints a thread backtrace to stderr and is a BaseException, so except Exception does not catch it.
Expected: a clear IndexError naming the bad index, for lists and arrays alike.
Found while adding CuPy support to sub_matrix (PR #25), where CuPy indexing silently wraps such indexes instead.
Activity