Skip to content

Commit c6d523b

Browse files
committed
Hardcode exceptions for warnIfMissingRequiredProperties
+ fix syntax errror (missing end) in nwbExportTest
1 parent f88f947 commit c6d523b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

+tests/+unit/nwbExportTest.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ function testExportTimeseriesWithMissingTimestampsAndStartingTime(testCase)
4949
nwbFilePath = fullfile(testCase.OutputFolder, 'testfile.nwb');
5050
testCase.verifyError(@(f, fn) nwbExport(testCase.NwbObject, nwbFilePath), ...
5151
'NWB:CustomConstraintUnfulfilled')
52-
52+
end
53+
5354
function testExportDependentAttributeWithMissingParentA(testCase)
5455
testCase.NwbObject.general_source_script_file_name = 'my_test_script.m';
5556
nwbFilePath = fullfile(testCase.OutputFolder, 'test_part1.nwb');

+types/+untyped/MetaClass.m

+13
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ function warnIfPropertyAttributeNotExported(obj, propName, depPropName, fullpath
139139

140140
function displayWarningIfMissingRequiredProps(obj)
141141
missingRequiredProps = obj.checkRequiredProps();
142+
143+
% Exception: 'file_create_date' is automatically added by the
144+
% matnwb API on export, so no need to warn if it is missing.
145+
if isa(obj, 'types.core.NWBFile')
146+
missingRequiredProps = setdiff(missingRequiredProps, 'file_create_date', 'stable');
147+
end
148+
149+
% Exception: 'id' of DynamicTable is automatically assigned if not
150+
% specified, so no need to warn if it is missing.
151+
if isa(obj, 'types.hdmf_common.DynamicTable')
152+
missingRequiredProps = setdiff(missingRequiredProps, 'id', 'stable');
153+
end
154+
142155
if ~isempty( missingRequiredProps )
143156
warnState = warning('backtrace', 'off');
144157
cleanerObj = onCleanup(@(s) warning(warnState));

0 commit comments

Comments
 (0)