File tree Expand file tree Collapse file tree 4 files changed +90
-2
lines changed Expand file tree Collapse file tree 4 files changed +90
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,6 @@ copyright_entity: "CPP_BIDS developers"
66
77# metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html)
88metric " cnest" : limit 4
9- metric " file_length" : limit 550
9+ metric " file_length" : limit 500
1010metric " cyc" : limit 15
1111metric " parameters" : limit 6
Original file line number Diff line number Diff line change 11% (C) Copyright 2020 CPP_BIDS developers
22
33function data = nanPadding(cfg , data , expectedLength )
4-
4+ %
55 % For numeric data that don't have the expected length, it will be padded
66 % with NaNs. If the vector is too long it will be truncated
7+ %
8+ % USAGE::
9+ %
10+ % data = nanPadding(cfg, data, expectedLength)
11+ %
12+ %
713
814 if nargin < 2
915 expectedLength = [];
Original file line number Diff line number Diff line change 1+ % (C) Copyright 2020 CPP_BIDS developers
2+
3+ function test_suite = test_checkInput % #ok<*STOUT>
4+ try % assignment of 'localfunctions' is necessary in Matlab >= 2016
5+ test_functions = localfunctions(); % #ok<*NASGU>
6+ catch % no problem; early Matlab versions can use initTestSuite fine
7+ end
8+ initTestSuite ;
9+ end
10+
11+ function test_checkInputBasic()
12+
13+ data = checkInput(1 );
14+ assertEqual(data , 1 );
15+
16+ data = checkInput(' test' );
17+ assertEqual(data , ' test' );
18+
19+ data = checkInput(' ' );
20+ assertEqual(data , ' n/a' );
21+
22+ data = checkInput(' ' );
23+ assertEqual(data , ' n/a' );
24+
25+ data = checkInput([]);
26+ assertEqual(data , nan );
27+
28+ data = checkInput(true());
29+ assertEqual(data , ' true' );
30+
31+ data = checkInput(false());
32+ assertEqual(data , ' false' );
33+
34+ end
Original file line number Diff line number Diff line change 1+ % (C) Copyright 2020 CPP_BIDS developers
2+
3+ function test_suite = test_nanPadding % #ok<*STOUT>
4+ try % assignment of 'localfunctions' is necessary in Matlab >= 2016
5+ test_functions = localfunctions(); % #ok<*NASGU>
6+ catch % no problem; early Matlab versions can use initTestSuite fine
7+ end
8+ initTestSuite ;
9+ end
10+
11+ function test_nanPaddingBasic()
12+
13+ cfg.verbose = 1 ;
14+
15+ %%
16+ data = ' test' ;
17+ expectedLength = 2 ;
18+
19+ data = nanPadding(cfg , data , expectedLength );
20+
21+ assertEqual(data , ' test' );
22+
23+ %%
24+ data = [1 0 ];
25+ expectedLength = 2 ;
26+
27+ data = nanPadding(cfg , data , expectedLength );
28+
29+ assertEqual(data , [1 0 ]);
30+
31+ %%
32+ data = [1 0 ];
33+ expectedLength = 3 ;
34+
35+ data = nanPadding(cfg , data , expectedLength );
36+
37+ assertEqual(data , [1 0 NaN ]);
38+
39+ %%
40+ %%
41+ data = [1 0 1 ];
42+ expectedLength = 2 ;
43+
44+ data = nanPadding(cfg , data , expectedLength );
45+
46+ assertEqual(data , [1 0 ]);
47+
48+ end
You can’t perform that action at this time.
0 commit comments