Skip to content

Commit c1817d7

Browse files
author
Abhi Baruah
committed
Add error when chunk size is bigger than data
1 parent 9ae1809 commit c1817d7

File tree

5 files changed

+3
-21
lines changed

5 files changed

+3
-21
lines changed

Zarr.m

+3
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ function write(obj, data)
149149
if ~isequal(info.shape, datasize(:))
150150
error("Size of the data to be written does not match.");
151151
end
152+
if any(info.chunks > datasize(:))
153+
error("Chunk size cannot be greater than size of the data to be written.");
154+
end
152155
py.ZarrPy.writeZarr(obj.KVStoreSchema, data);
153156
end
154157

zarrinfo.m

-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
filepath {mustBeTextScalar, mustBeNonzeroLengthText, mustBeFolder}
1313
end
1414

15-
% If the location does not exist, throw an error.
16-
if ~isfolder(filepath)
17-
error("Invalid location.")
18-
end
19-
2015
% If the location is a Zarr array
2116
if isfile(fullfile(filepath, '.zarray'))
2217
infoStr = fileread(fullfile(filepath, '.zarray'));

zarrread.m

-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
filepath {mustBeTextScalar, mustBeNonzeroLengthText, mustBeFolder}
1010
end
1111

12-
% If the location does not exist, throw an error.
13-
if ~isfolder(filepath)
14-
error("Invalid location.")
15-
end
16-
1712
zarrObj = Zarr(filepath);
1813
data = zarrObj.read;
1914
end

zarrwrite.m

-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ function zarrwrite(filepath, data)
1010
data
1111
end
1212

13-
% If the Zarr array has not been created yet, throw an error.
14-
if ~isfile(fullfile(filepath, '.zarray'))
15-
error("Invalid location.")
16-
end
17-
18-
1913
zarrObj = Zarr(filepath);
2014
zarrObj.write(data)
2115

zarrwriteatt.m

-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ function zarrwriteatt(filepath, attname, attvalue)
1313
attvalue
1414
end
1515

16-
% If the location does not exist, throw an error.
17-
if ~isfolder(filepath)
18-
error("Invalid location.")
19-
end
20-
2116
info = zarrinfo(filepath);
2217
info.(attname) = attvalue;
2318

0 commit comments

Comments
 (0)