Skip to content

Commit 3c019f2

Browse files
committed
Fix index parsing in mpas_to_xdmf tool
1 parent c3d49ec commit 3c019f2

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

  • conda_package/mpas_tools/viz/mpas_to_xdmf

conda_package/mpas_tools/viz/mpas_to_xdmf/io.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,16 @@ def _parse_indices(index_string, dim_size):
300300
if not index_string:
301301
return []
302302
if ':' in index_string:
303-
parts = [int(p) if p else None for p in index_string.split(':')]
304-
return list(range(parts[0] or 0, parts[1] or dim_size, parts[2] or 1))
303+
# Support slice notation like ':', '0:10', '0:10:2', etc.
304+
parts = index_string.split(':')
305+
# Pad parts to length 3 with empty strings if needed
306+
while len(parts) < 3:
307+
parts.append('')
308+
# Convert to int or None
309+
start = int(parts[0]) if parts[0] else 0
310+
stop = int(parts[1]) if parts[1] else dim_size
311+
step = int(parts[2]) if parts[2] else 1
312+
return list(range(start, stop, step))
305313
return [int(i) for i in index_string.split(',')]
306314

307315

0 commit comments

Comments
 (0)