def row_col_from_lin(ct, sh):
"""
Convert a 1D counter into a col and row counter
"""
assert len(sh) == 2, 'Shape must be 2D'
tot_rows = sh[0]
tot_cols = sh[1]
if isinstance(ct, _np.ndarray):
if (ct > tot_rows*tot_cols).any():
print('Count is out-of-range. Returning None.')
return None
else:
if ct > tot_rows*tot_cols:
print('Count is out-of-range. Returning None.')
return None
row = _np.mod(ct, tot_rows)
col = ct//tot_rows
return [row, col]
评论列表
文章目录