From 4d29030db1213dc47a0567165c668bca91ea8fc2 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Thu, 31 Jul 2025 21:03:22 +0200 Subject: [PATCH 1/4] Update ZarrPy.py --- PythonModule/ZarrPy.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/PythonModule/ZarrPy.py b/PythonModule/ZarrPy.py index 6a182b9..a78c4ff 100644 --- a/PythonModule/ZarrPy.py +++ b/PythonModule/ZarrPy.py @@ -100,6 +100,14 @@ def readZarr (kvstore_schema, starts, ends, strides): 'kvstore': kvstore_schema, }).result() + # Ensure all inputs are lists/tuples + if isinstance(starts, (int, type(None))): + starts = [starts] + if isinstance(ends, (int, type(None))): + ends = [ends] + if isinstance(strides, (int, type(None))): + strides = [strides] + # Construct the indexing slices slices = tuple(slice(start, end, stride) for start, end, stride in zip(starts, ends, strides)) From 15e922099dc83b487bfeaeef3c7ba64089ccf274 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Tue, 30 Sep 2025 10:54:25 +0200 Subject: [PATCH 2/4] Update ZarrPy.py Simplify - Expecting input to be array or int, never None --- PythonModule/ZarrPy.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PythonModule/ZarrPy.py b/PythonModule/ZarrPy.py index a78c4ff..2b7e395 100644 --- a/PythonModule/ZarrPy.py +++ b/PythonModule/ZarrPy.py @@ -100,12 +100,12 @@ def readZarr (kvstore_schema, starts, ends, strides): 'kvstore': kvstore_schema, }).result() - # Ensure all inputs are lists/tuples - if isinstance(starts, (int, type(None))): + # Convert integer inputs to single-element lists + if isinstance(starts, int): starts = [starts] - if isinstance(ends, (int, type(None))): + if isinstance(ends, int): ends = [ends] - if isinstance(strides, (int, type(None))): + if isinstance(strides, int): strides = [strides] # Construct the indexing slices From b858a1f963d55c659fdadf2013254af8ef67466e Mon Sep 17 00:00:00 2001 From: ehennestad Date: Fri, 3 Apr 2026 21:20:34 +0200 Subject: [PATCH 3/4] Add unit test --- test/dataFiles/grp_v2/scalarData/.zarray | 1 + test/dataFiles/grp_v2/scalarData/0 | Bin 0 -> 24 bytes test/tZarrRead.m | 18 +++++++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/dataFiles/grp_v2/scalarData/.zarray create mode 100644 test/dataFiles/grp_v2/scalarData/0 diff --git a/test/dataFiles/grp_v2/scalarData/.zarray b/test/dataFiles/grp_v2/scalarData/.zarray new file mode 100644 index 0000000..ed3a58b --- /dev/null +++ b/test/dataFiles/grp_v2/scalarData/.zarray @@ -0,0 +1 @@ +{"chunks":[1],"compressor":{"blocksize":0,"clevel":5,"cname":"lz4","id":"blosc","shuffle":1},"dtype":" Date: Mon, 29 Jun 2026 16:03:26 +0200 Subject: [PATCH 4/4] Simplify verifyReadScalarData test --- test/tZarrRead.m | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/test/tZarrRead.m b/test/tZarrRead.m index 98566ef..a815231 100644 --- a/test/tZarrRead.m +++ b/test/tZarrRead.m @@ -82,16 +82,9 @@ function verifyPartialVectorData(testcase) function verifyReadScalarData(testcase) zpath = testcase.ArrPathReadScalar; % data is 0 expectedData = 0; - try - actualData = zarrread(zpath); - testcase.verifyEqual(actualData, expectedData) - catch exception - diagnostic = sprintf([... - 'Failed to read scalar dataset. '... - 'Caused by: %s'... - ], exception.message); - testcase.verifyFail(diagnostic) - end + + actualData = testcase.verifyWarningFree(@()zarrread(zpath)); + testcase.verifyEqual(actualData, expectedData) end function verifyArrayDataRelativePath(testcase)