-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtZarrInfo.m
More file actions
92 lines (77 loc) · 3.74 KB
/
Copy pathtZarrInfo.m
File metadata and controls
92 lines (77 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
classdef tZarrInfo < SharedZarrTestSetup
% Tests for zarrinfo function to get info of the Zarr file in MATLAB.
% Copyright 2025 The MathWorks, Inc.
properties(Constant)
% SharedZarrTestSetup copies the contents of dataFiles/ into the
% working folder, so fixtures are at the working folder root.
GrpPathV2 = "grp_v2"
ArrPathV2 = "grp_v2/arr_v2"
GrpPathV3 = "grp_v3"
ArrPathV3 = "grp_v3/arr_v3"
% Loaded at class-load time, while pwd is still the test folder.
ExpInfo = load(fullfile(pwd,"dataFiles","expZarrArrInfo.mat"))
end
methods(Test)
function verifyArrayInfoV2(testcase)
% Verify array info created with Zarr v2 format.
actInfo = zarrinfo(testcase.ArrPathV2);
expInfo = testcase.ExpInfo.zarrV2ArrInfo;
testcase.verifyEqual(actInfo,expInfo,'Failed to verify array info.');
end
function verifyGroupInfoV2(testcase)
% Verify group info created with Zarr v2 format.
actInfo = zarrinfo(testcase.GrpPathV2);
expInfo = testcase.ExpInfo.zarrV2GrpInfo;
testcase.verifyEqual(actInfo,expInfo,'Failed to verify group info.');
end
function getArrayInfoRelativePath(testcase)
% Verify array info if the input is using a relative path to the
% array. Read from a subfolder using a "../" prefixed path.
import matlab.unittest.fixtures.CurrentFolderFixture
testcase.applyFixture(CurrentFolderFixture("grp_v2"));
inpPath = fullfile('..', testcase.ArrPathV2);
actInfo = zarrinfo(inpPath);
expInfo = testcase.ExpInfo.zarrV2ArrInfo;
testcase.verifyEqual(actInfo, expInfo, ['Failed to verify array info ' ...
'with relative path.']);
end
function verifyArrayInfoV3(testcase)
% Verify array info created with Zarr v3 format.
actInfo = zarrinfo(testcase.ArrPathV3);
expInfo = testcase.ExpInfo.zarrV3ArrInfo;
testcase.verifyEqual(actInfo,expInfo,'Failed to verify array info.');
end
function verifyGroupInfoV3(testcase)
% Verify group info created with Zarr v3 format.
actInfo = zarrinfo(testcase.GrpPathV3);
expInfo = testcase.ExpInfo.zarrV3GrpInfo;
testcase.verifyEqual(actInfo,expInfo,'Failed to verify group info.');
end
function missingZgroupFile(testcase)
% Verify error when using zarrinfo function on a directory not
% containing .zgroup file.
import matlab.unittest.fixtures.WorkingFolderFixture;
testcase.applyFixture(WorkingFolderFixture);
mkdir('prt_grp_write/arr1');
grpPath = 'prt_grp_write/';
errID = 'MATLAB:zarrinfo:invalidZarrObject';
testcase.verifyError(@()zarrinfo(grpPath),errID);
end
function nonExistentArr(testcase)
% Verify zarrinfo error when a user tries to read a non-existent
% array.
errID = 'MATLAB:zarrinfo:invalidZarrObject';
testcase.verifyError(@()zarrinfo('nonexistentArr/'),errID);
end
function invalidInput(testcase)
% Verify error when using invalid input with zarrinfo function.
import matlab.unittest.fixtures.WorkingFolderFixture;
testcase.applyFixture(WorkingFolderFixture);
errID = 'MATLAB:TooManyInputs';
testcase.verifyError(@()zarrinfo('testFiles/arr1','arr1'),errID);
errID = 'MATLAB:validators:mustBeTextScalar';
zarrcreate('prt_grp/arr_1',[10 10]);
testcase.verifyError(@()zarrinfo({'prt_grp/arr_1'}),errID);
end
end
end