Skip to content

Support partial reading of Zarr datasets #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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: 4 additions & 4 deletions PythonModule/ZarrPy.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def readZarr (kvstore_schema, starts, ends, strides):

Parameters:
- kvstore_schema (dictionary): Schema for the file store (local or remote)
- starts (list): Array of start indices for each dimension (0-based)
- ends (list): Array of end indices for each dimension (elements
- starts (numpy.ndarray): Array of start indices for each dimension (0-based)
- ends (numpy.ndarray): Array of end indices for each dimension (elements
at the end index will not be read)
- strides (list): Array of strides for each dimensions
- strides (numpy.ndarray): Array of strides for each dimensions

Returns:
- numpy.ndarray: The subset of the data read from the Zarr file.
Expand All @@ -105,5 +105,5 @@ def readZarr (kvstore_schema, starts, ends, strides):

# Read a subset of the data
data = zarr_file[slices].read().result()
#data = zarr_file[...].read().result()

return data
12 changes: 0 additions & 12 deletions test/tZarrRead.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,6 @@ function invalidPartialReadParams(testcase)
@()zarrread(zpath,Count=wrongNumberOfDimensions),...
errID);

errID = 'MATLAB:validators:mustBeRow';
wrongSize = [1; 1];
testcase.verifyError(...
@()zarrread(zpath,Start=wrongSize),...
errID);
testcase.verifyError(...
@()zarrread(zpath,Stride=wrongSize),...
errID);
testcase.verifyError(...
@()zarrread(zpath,Count=wrongSize),...
errID);

%TODO: negative values, wrong datatypes, out of bounds

end
Expand Down
6 changes: 3 additions & 3 deletions zarrread.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

arguments
filepath {mustBeTextScalar, mustBeNonzeroLengthText}
options.Start {mustBeInteger, mustBePositive, mustBeRow} = double.empty(1,0);
options.Count {mustBeInteger, mustBePositive, mustBeRow} = double.empty(1,0);
options.Stride {mustBeInteger, mustBePositive, mustBeRow} = double.empty(1,0);
options.Start (1,:) {mustBeInteger, mustBePositive} = [];
options.Count (1,:) {mustBeInteger, mustBePositive} = [];
options.Stride (1,:) {mustBeInteger, mustBePositive} = [];
end

zarrObj = Zarr(filepath);
Expand Down
Loading