Skip to content

Commit 3a19c28

Browse files
committed
Read the session, epoch and software blocks of either schema; tests for the merged shape
- ndi.dataset.dir, the bodies navigator and ndi.vintage.objectClass read through ndi.v2.blockOf, so an entity of type session/epoch/software is read - TestHaleyWrite: value.data_type (was datum_type); fits found by leaf name - TestDatasetMetadataHaley: a web resource's host is reported unrepresented when the schema has no hosted_by Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf
1 parent 07ac828 commit 3a19c28

5 files changed

Lines changed: 25 additions & 11 deletions

File tree

‎src/ndi/+ndi/+dataset/dir.m‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@
8686
% a query-shaped grep does not find it -- the daqsystem
8787
% lesson. A dataset can hold a session document of either
8888
% vintage, so both spellings are accepted.
89-
session_blk = candidate_session_doc{1}.document_properties.session;
90-
if isfield(session_blk,'local_identifier')
91-
ref = session_blk.local_identifier;
92-
else
93-
ref = session_blk.reference;
89+
% and from 2026-10-08 the session may be an `entity` of
90+
% type session (ndi.v2.blockOf reads either block)
91+
p_session = candidate_session_doc{1}.document_properties;
92+
ref = ndi.v2.blockOf(p_session, 'session', 'local_identifier');
93+
if isempty(ref)
94+
ref = ndi.v2.blockOf(p_session, 'session', 'reference');
9495
end
9596
session_id = candidate_session_doc{1}.document_properties.base.session_id;
9697
ndi_dataset_dir_obj.session = ndi.session.dir(ref,ndi_dataset_dir_obj.session.path,session_id);

‎src/ndi/+ndi/+file/+navigator/bodies.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
e = S.database_search(ndi.query('base.id', 'exact_string', referent, '') & ...
198198
ndi.v2.isaQuery('epoch'));
199199
if numel(e) == 1
200-
id = e{1}.document_properties.epoch.local_identifier;
200+
id = ndi.v2.blockOf(e{1}.document_properties, 'epoch', 'local_identifier');
201201
return;
202202
end
203203
end

‎src/ndi/+ndi/+vintage/objectClass.m‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,14 @@
101101
end
102102

103103
swProps = swDocs{1}.document_properties;
104-
if ~isfield(swProps, 'software') || ~isstruct(swProps.software) ...
105-
|| ~isfield(swProps.software, 'name') || isempty(swProps.software.name)
104+
% the `software` block, or from 2026-10-08 an `entity` of type software
105+
objClass = ndi.v2.blockOf(swProps, 'software', 'name');
106+
if isempty(objClass)
106107
error('NDI:vintage:softwareHasNoName', ...
107108
['software document %s carries no `name`, and `name` is where ' ...
108109
'jSoftware puts the implementation class string'], swId);
109110
end
110-
objClass = swProps.software.name;
111+
objClass = char(objClass);
111112
end
112113

113114
function v = assertionValue(ndi_document_obj, ndi_session_obj, label)

‎tests/+ndi/+unittest/+setup/+V2/TestDatasetMetadataHaley.m‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,17 @@ function testUnrepresentedContentIsReportedNotDropped(testCase)
211211
testCase.verifyEqual(nnz(isType), numel(testCase.Spec.formulations));
212212
end
213213
u = u(~isType);
214+
% with one entity class a web resource's host has no relation
215+
% (hosted_by retired, 2026-10-08): one row per resource naming one
216+
isHost = strcmp({u.field}, 'host');
217+
if ndi.setup.V2.mergedEntities()
218+
wr = testCase.Spec.web_resources;
219+
if isstruct(wr), wr = num2cell(wr); end
220+
testCase.verifyEqual(nnz(isHost), sum(cellfun(@(x) isfield(x, 'host'), wr)));
221+
else
222+
testCase.verifyFalse(any(isHost));
223+
end
224+
u = u(~isHost);
214225
testCase.verifyEqual(unique({u.field}), {'vendor'});
215226
% one row per software entry that names a vendor (the analysis
216227
% package and macOS name none)

‎tests/+ndi/+unittest/+setup/+V2/TestHaleyWrite.m‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ function testGeometry(testCase)
489489
testCase.verifyEqual(edge(a, 'software_id'), ids('haley_analysis'));
490490
testCase.verifyEqual(edge(a, 'interpreter_id'), ids('matlab'));
491491
testCase.verifyEqual(edge(a, 'operating_system_id'), ids('macos'));
492-
testCase.verifyEqual(a.value.datum_type, 'bool');
492+
% `datum_type` was renamed `data_type` on 2026-10-08
493+
testCase.verifyEqual(ndi.v2.blockOf(a, 'value', 'data_type', ndi.v2.blockOf(a, 'value', 'datum_type')), 'bool');
493494
mp = entries(a.interaction.method_parameters);
494495
testCase.verifyEqual(mp{1}.variable.name, 'arena diameter');
495496

@@ -755,7 +756,7 @@ function testDensity(testCase)
755756
testCase.verifyEmpty(de.checks.encounterDisagrees, 'encounter.mat reproduces from the fits');
756757

757758
dd = de.datasetDocuments;
758-
dc = cellfun(@(d) d.document_class.class_name, dd, 'UniformOutput', false);
759+
dc = cellfun(@ndi.v2.leafName, dd, 'UniformOutput', false);
759760
fits = dd(strcmp(dc, 'model_fit_calculation'));
760761
groups = dd(strcmp(dc, 'subject'));
761762
testCase.verifyNumElements(groups, 2);

0 commit comments

Comments
 (0)