-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve coverage for nwbRead/nwbExport * Remove tutorialTest (function-based) * Create TutorialTest (class-based unit test) * Add test classes (issue #583 ) * Update description for PynwbTutorialTest * Add specific tests for io.timestamp2datetime * Update unit tests * Create getTutorialNwbFilePath.m Add function to create a filepath for saving tutorial nwb files in a fixed folder * Fix: Add starting_time when creating TimeSeries objects (#584) Also, use misc.getTutorialNwbFilePath to create a filepath for saving tutorial nwb file * Update several tutorials: Specify timezone or NWBFile's session_start_time property * Fix bug in io.timestamp2datetime (Issue #585) Some dates are assigned wrongly when Day, Month and Year are set individually, as the datetime object internally/silently adjusts month if day is not valid * Update timestamp2datetime.m Fix: Should not preallocate datetimeArray as it is not known beforehand whether the timestamp has a timezone or not (datetime.empty contrains to datetime w/o timezone) * Update GenerationTest.m Ensure test can be run from any current working directory, not just the matnwb repo folder * Update getMatnwbDir.m Simplyfy function by using mfilename instead of dbstack * Delete file which was introduced with issue #585 * Change nwbtest: Add selector options as input; Add cleanup routine * Add test for constructing Anon with name, value input * Add specific testing of types.untyped.Set When writing test, also discovered a but in types.untyped.Set which is fixed * Remove function call used for debugging --------- Co-authored-by: Ben Dichter <[email protected]>
- Loading branch information
1 parent
9d1caa3
commit fd34d3d
Showing
8 changed files
with
187 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,7 @@ | ||
function [matnwbDir] = getMatnwbDir(varargin) | ||
|
||
try | ||
% Get the actual location of the matnwb directory. This assumes "getMatnwbDir" is | ||
% within the +misc matnwb package folder. | ||
fnLoc = dbstack('-completenames'); | ||
fnLoc = fnLoc(1).file; | ||
[fnDir,~,~] = fileparts(fnLoc); | ||
[matnwbDir,~,~] = fileparts(fnDir); | ||
|
||
if 7 ~= exist(matnwbDir, 'dir') | ||
warning('NWB:GetMatnwbDir:NotFound',... | ||
'Did not find "matnwb" root directory at %s. Using defaults.',... | ||
matnwbDir); | ||
end | ||
catch err | ||
atLine = repmat('@', 1, 7); | ||
fprintf('%s\n%s\n%s\n',... | ||
atLine,... | ||
getReport(err, 'extended', 'hyperlinks', 'on'),... | ||
atLine); | ||
end | ||
function matnwbDir = getMatnwbDir(varargin) | ||
% Get the absolute path for the matnwb directory. | ||
|
||
% This assumes "getMatnwbDir" is within the +misc matnwb package folder. | ||
miscFolder = fileparts(mfilename('fullpath')); | ||
matnwbDir = fileparts(miscFolder); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
function tests = untypedSetTest() | ||
tests = functiontests(localfunctions); | ||
end | ||
|
||
function setupOnce(testCase) | ||
rootPath = fullfile(fileparts(mfilename('fullpath')), '..', '..'); | ||
testCase.applyFixture(matlab.unittest.fixtures.PathFixture(rootPath)); | ||
end | ||
|
||
function setup(testCase) | ||
testCase.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture); | ||
end | ||
|
||
function testCreateSetWithFunctionInput(testCase) | ||
set = types.untyped.Set(@(key, value) true); | ||
testCase.verifyNotEmpty(set.ValidationFcn) | ||
end | ||
|
||
function testCreateSetFromStruct(testCase) | ||
untypedSet = types.untyped.Set( struct('a',1, 'b', 2) ); | ||
testCase.verifyEqual(untypedSet.get('a'), 1) | ||
end | ||
|
||
function testCreateSetFromNvPairs(testCase) | ||
untypedSet = types.untyped.Set( 'a',1, 'b', 2 ); | ||
testCase.verifyEqual(untypedSet.get('a'), 1) | ||
end | ||
|
||
function testCreateSetFromNvPairsPlusFunctionHandle(testCase) | ||
untypedSet = types.untyped.Set( 'a',1, 'b', 2, @(key, value) disp('Hello World')); | ||
testCase.verifyEqual(untypedSet.get('a'), 1) | ||
end | ||
|
||
function testDisplayEmptyObject(testCase) | ||
emptyUntypedSet = types.untyped.Set(); | ||
disp(emptyUntypedSet) | ||
end | ||
|
||
function testDisplayScalarObject(testCase) | ||
scalarSet = types.untyped.Set('a',1) | ||
disp(scalarSet) | ||
end | ||
|
||
function testGetSetSize(testCase) | ||
untypedSet = types.untyped.Set( 'a',1, 'b', 2 ); | ||
|
||
[nRowsA, nColsA] = size(untypedSet); | ||
|
||
nRowsB = size(untypedSet, 1); | ||
nColsB = size(untypedSet, 2); | ||
|
||
testCase.verifyEqual(nRowsA, nRowsB); | ||
testCase.verifyEqual(nColsA, nColsB); | ||
end | ||
|
||
function testHorizontalConcatenation(testCase) | ||
untypedSetA = types.untyped.Set( struct('a',1, 'b', 2) ); | ||
untypedSetB = types.untyped.Set( struct('c',3, 'd', 3) ); | ||
|
||
testCase.verifyError(@() [untypedSetA, untypedSetB], 'NWB:Set:Unsupported') | ||
end | ||
|
||
function testVerticalConcatenation(testCase) | ||
untypedSetA = types.untyped.Set( struct('a',1, 'b', 2) ); | ||
untypedSetB = types.untyped.Set( struct('c',3, 'd', 3) ); | ||
|
||
testCase.verifyError(@() [untypedSetA; untypedSetB], 'NWB:Set:Unsupported') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters