Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions PythonModule/ZarrPy.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ def readZarr (kvstore_schema, starts, ends, strides):
'kvstore': kvstore_schema,
}).result()

# Convert integer inputs to single-element lists
if isinstance(starts, int):
starts = [starts]
if isinstance(ends, int):
ends = [ends]
if isinstance(strides, int):
strides = [strides]

# Construct the indexing slices
slices = tuple(slice(start, end, stride) for start, end, stride in zip(starts, ends, strides))

Expand Down
1 change: 1 addition & 0 deletions test/dataFiles/grp_v2/scalarData/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"chunks":[1],"compressor":{"blocksize":0,"clevel":5,"cname":"lz4","id":"blosc","shuffle":1},"dtype":"<f8","fill_value":0,"filters":[],"order":"C","shape":[1],"zarr_format":2}
Binary file added test/dataFiles/grp_v2/scalarData/0
Binary file not shown.
11 changes: 10 additions & 1 deletion test/tZarrRead.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
ArrPathRead = "dataFiles/grp_v2/arr_v2"
ArrPathReadSmall = "dataFiles/grp_v2/smallArr"
ArrPathReadVector = "dataFiles/grp_v2/vectorData"
ArrPathReadScalar = "dataFiles/grp_v2/scalarData"
ArrPathReadV3 = "dataFiles/grp_v3/arr_v3"

ExpData = load(fullfile(pwd,"dataFiles","expZarrArrData.mat"))
Expand Down Expand Up @@ -78,6 +79,14 @@ function verifyPartialVectorData(testcase)
'Failed to verify using scalar Start, Stride, and Count.');
end

function verifyReadScalarData(testcase)
zpath = testcase.ArrPathReadScalar; % data is 0
expectedData = 0;

actualData = testcase.verifyWarningFree(@()zarrread(zpath));
testcase.verifyEqual(actualData, expectedData)
end

function verifyArrayDataRelativePath(testcase)
% Verify array data if the input is using relative path to the
% array.
Expand Down Expand Up @@ -182,4 +191,4 @@ function invalidPartialReadParams(testcase)
@()zarrread(zpath,Start=[3 4],Count=[2 2]),errID)
end
end
end
end
Loading