Skip to content

Commit

Permalink
bicas.tools.batch, solo.adm: Fix indentation
Browse files Browse the repository at this point in the history
Note: Changes many files without changing functionality.
  • Loading branch information
ErikPGJ committed Feb 26, 2024
1 parent 6826ecf commit 07b9993
Show file tree
Hide file tree
Showing 29 changed files with 2,443 additions and 2,443 deletions.
60 changes: 30 additions & 30 deletions mission/solar_orbiter/+solo/+adm/get_directory_DSMDs.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,40 @@
%
function [DsmdArray, OiArray] = get_directory_DSMDs(dirPathsCa)

t = tic();
t = tic();

% Create empty struct array of the right size.
% IMPLEMENTATION NOTE: Calling dir() just to make sure that the code uses
% the exact struct which it produces. This should make the code more
% future-proof.
OiArray = dir('~');
OiArray = OiArray([], 1); % Column array.
% Create empty struct array of the right size.
% IMPLEMENTATION NOTE: Calling dir() just to make sure that the code uses
% the exact struct which it produces. This should make the code more
% future-proof.
OiArray = dir('~');
OiArray = OiArray([], 1); % Column array.

DsmdArray = solo.adm.DSMD.empty(0, 1);
for i = 1:numel(dirPathsCa)
% Assert that directory exists.
% IMPLEMENTATION NOTE: dir(fullfile(dirPathsCa{i}, '**')) will NOT raise
% error for non-existing directory.
irf.assert.dir_exists(dirPathsCa{i})
DsmdArray = solo.adm.DSMD.empty(0, 1);
for i = 1:numel(dirPathsCa)
% Assert that directory exists.
% IMPLEMENTATION NOTE: dir(fullfile(dirPathsCa{i}, '**')) will NOT raise
% error for non-existing directory.
irf.assert.dir_exists(dirPathsCa{i})

DirOiArray = dir(fullfile(dirPathsCa{i}, '**'));
DirOiArray = DirOiArray(~[DirOiArray.isdir]);
DirOiArray = DirOiArray(:);
% CASE: DirOiArray is a column array.
dirFilesPathsCa = arrayfun(@(Oi) (fullfile(Oi.folder, Oi.name)), DirOiArray, 'UniformOutput', false);
DirOiArray = dir(fullfile(dirPathsCa{i}, '**'));
DirOiArray = DirOiArray(~[DirOiArray.isdir]);
DirOiArray = DirOiArray(:);
% CASE: DirOiArray is a column array.
dirFilesPathsCa = arrayfun(@(Oi) (fullfile(Oi.folder, Oi.name)), DirOiArray, 'UniformOutput', false);

[DirDsmdArray, bIsDataSetArray] = solo.adm.paths_to_DSMD_array(dirFilesPathsCa);
DirOiArray = DirOiArray(bIsDataSetArray);
[DirDsmdArray, bIsDataSetArray] = solo.adm.paths_to_DSMD_array(dirFilesPathsCa);
DirOiArray = DirOiArray(bIsDataSetArray);

OiArray = [...
OiArray; ...
DirOiArray];
DsmdArray = [...
DsmdArray; ...
DirDsmdArray];
end
OiArray = [...
OiArray; ...
DirOiArray];
DsmdArray = [...
DsmdArray; ...
DirDsmdArray];
end

wallTimeSec = toc(t);
fprintf('SPEED: Wall time to obtain DSMDs for %g paths: %.1f [s]\n', ...
numel(dirPathsCa), wallTimeSec);
wallTimeSec = toc(t);
fprintf('SPEED: Wall time to obtain DSMDs for %g paths: %.1f [s]\n', ...
numel(dirPathsCa), wallTimeSec);
end
142 changes: 71 additions & 71 deletions mission/solar_orbiter/+solo/+adm/get_directory_DSMDs___UTEST.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,87 +9,87 @@



%##############
%##############
% TEST METHODS
%##############
%##############
methods(Test)
%##############
%##############
% TEST METHODS
%##############
%##############
methods(Test)



function test_zero_direcctories(testCase)
[ActDsmdArray, ActOiArray] = solo.adm.get_directory_DSMDs({});
function test_zero_direcctories(testCase)
[ActDsmdArray, ActOiArray] = solo.adm.get_directory_DSMDs({});

ExpOiArray = dir('~');
ExpOiArray = ExpOiArray([], 1);

testCase.assertEqual(ActDsmdArray, solo.adm.DSMD.empty(0, 1))
testCase.assertEqual(ActOiArray, ExpOiArray)
end
ExpOiArray = dir('~');
ExpOiArray = ExpOiArray([], 1);

testCase.assertEqual(ActDsmdArray, solo.adm.DSMD.empty(0, 1))
testCase.assertEqual(ActOiArray, ExpOiArray)
end


function test_subdirectories(testCase)
function subdirPath = create_subdir(parentDir, varargin)
% PROPOSAL: Make into generic function.

for i = 1:numel(varargin)
mkdir(parentDir, varargin{i})
parentDir = fullfile(parentDir, varargin{i});
end

subdirPath = parentDir;
end

function test(dirPathsCa, expDatasetPathsCa)
[ActDsmdArray, ActOiArray] = solo.adm.get_directory_DSMDs(dirPathsCa);
actPathCa = {ActDsmdArray.path}';

testCase.assertEqual(...
sort(actPathCa(:)), ...
sort(expDatasetPathsCa(:)))
testCase.assertEqual(...
size(ActOiArray), size(ActDsmdArray))
end

testCase.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture)
testDir = pwd;
cd('~') % Move to any OTHER unrelated directory.

junk = create_subdir(testDir, 'subdir1', 'subdir11');
dir2 = create_subdir(testDir, 'subdir2', 'subdir21');
dir3 = create_subdir(testDir, 'subdir3', 'subdir31');

% NOTE: No file in subdir1.
file2 = fullfile(dir2, 'solo_L1R_rpw-lfr-surv-cwf-e_20240101_V02.cdf');
file3a = fullfile(dir3, 'solo_L1R_rpw-lfr-surv-cwf-e_20240102_V03.cdf');
file3b = fullfile(dir3, 'solo_L1R_rpw-lfr-surv-cwf-e_20240103_V04.cdf');
file3c = fullfile(dir3, 'NOT_DATASET.DAT');
irf.fs.create_empty_file(file2)
irf.fs.create_empty_file(file3a)
irf.fs.create_empty_file(file3b)
irf.fs.create_empty_file(file3c)

test(...
{testDir}, ...
{file2, file3a, file3b})

test(...
{fullfile(testDir, 'subdir1')}, ...
{})
test(...
{fullfile(testDir, 'subdir2')}, ...
{file2})

test(...
{fullfile(testDir, 'subdir3')}, ...
{file3a, file3b})
end

function test_subdirectories(testCase)
function subdirPath = create_subdir(parentDir, varargin)
% PROPOSAL: Make into generic function.

for i = 1:numel(varargin)
mkdir(parentDir, varargin{i})
parentDir = fullfile(parentDir, varargin{i});
end

end % methods(Test)
subdirPath = parentDir;
end

function test(dirPathsCa, expDatasetPathsCa)
[ActDsmdArray, ActOiArray] = solo.adm.get_directory_DSMDs(dirPathsCa);
actPathCa = {ActDsmdArray.path}';

testCase.assertEqual(...
sort(actPathCa(:)), ...
sort(expDatasetPathsCa(:)))
testCase.assertEqual(...
size(ActOiArray), size(ActDsmdArray))
end

testCase.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture)
testDir = pwd;
cd('~') % Move to any OTHER unrelated directory.

junk = create_subdir(testDir, 'subdir1', 'subdir11');
dir2 = create_subdir(testDir, 'subdir2', 'subdir21');
dir3 = create_subdir(testDir, 'subdir3', 'subdir31');

% NOTE: No file in subdir1.
file2 = fullfile(dir2, 'solo_L1R_rpw-lfr-surv-cwf-e_20240101_V02.cdf');
file3a = fullfile(dir3, 'solo_L1R_rpw-lfr-surv-cwf-e_20240102_V03.cdf');
file3b = fullfile(dir3, 'solo_L1R_rpw-lfr-surv-cwf-e_20240103_V04.cdf');
file3c = fullfile(dir3, 'NOT_DATASET.DAT');
irf.fs.create_empty_file(file2)
irf.fs.create_empty_file(file3a)
irf.fs.create_empty_file(file3b)
irf.fs.create_empty_file(file3c)

test(...
{testDir}, ...
{file2, file3a, file3b})

test(...
{fullfile(testDir, 'subdir1')}, ...
{})
test(...
{fullfile(testDir, 'subdir2')}, ...
{file2})

test(...
{fullfile(testDir, 'subdir3')}, ...
{file3a, file3b})
end



end % methods(Test)



Expand Down
18 changes: 9 additions & 9 deletions mission/solar_orbiter/+solo/+adm/paths_to_DSMD_array___UTEST.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ function test(filePathList, expDsmdArray, expBIsDatasetArray)

% Empty argument (no files)
test(...
{}, ...
solo.adm.DSMD.empty(0,1), ...
false(0,1));
{}, ...
solo.adm.DSMD.empty(0,1), ...
false(0,1));

test(...
{FILE_CDF_IGNORE}, ...
solo.adm.DSMD.empty(0,1), ...
false(1,1));
{FILE_CDF_IGNORE}, ...
solo.adm.DSMD.empty(0,1), ...
false(1,1));
test(...
{FILE_NONCDF_IGNORE}, ...
solo.adm.DSMD.empty(0,1), ...
false(1,1));
{FILE_NONCDF_IGNORE}, ...
solo.adm.DSMD.empty(0,1), ...
false(1,1));

test(...
{DSMD_1.path}, ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
% PROPOSAL: CLI_OPTION_PREFIX as argument.
% PROPOSAL: CLI_OPTION_PREFIX using BICAS constant.

CLI_OPTION_PREFIX = '--';
CLI_OPTION_PREFIX = '--';

assert(isa(Bpci, 'bicas.tools.batch.BicasProcessingCallInfo'))
assert(isa(Bpci, 'bicas.tools.batch.BicasProcessingCallInfo'))

argsCa = {Bpci.swmCliOption};
argsCa = {Bpci.swmCliOption};

for i = 1:numel(Bpci.inputsArray)
In = Bpci.inputsArray(i);
argsCa{end+1} = [CLI_OPTION_PREFIX, In.cohb];
argsCa{end+1} = In.path;
end
for i = 1:numel(Bpci.inputsArray)
In = Bpci.inputsArray(i);
argsCa{end+1} = [CLI_OPTION_PREFIX, In.cohb];
argsCa{end+1} = In.path;
end

for i = 1:numel(Bpci.outputsArray)
Out = Bpci.outputsArray(i);
argsCa{end+1} = [CLI_OPTION_PREFIX, Out.cohb];
argsCa{end+1} = Out.path;
end
for i = 1:numel(Bpci.outputsArray)
Out = Bpci.outputsArray(i);
argsCa{end+1} = [CLI_OPTION_PREFIX, Out.cohb];
argsCa{end+1} = Out.path;
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@



%#########################
%#########################
% PUBLIC INSTANCE METHODS
%#########################
%#########################
methods(Abstract)
%#########################
%#########################
% PUBLIC INSTANCE METHODS
%#########################
%#########################
methods(Abstract)



% Call bicas.main() with the exact same arguments and return value(s).
[varargout] = bicas_main(obj, varargin);
% Call bicas.main() with the exact same arguments and return value(s).
[varargout] = bicas_main(obj, varargin);



end % methods(Access=public)
end % methods(Access=public)



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@



%#########################
%#########################
% PUBLIC INSTANCE METHODS
%#########################
%#########################
methods(Access=public)
%#########################
%#########################
% PUBLIC INSTANCE METHODS
%#########################
%#########################
methods(Access=public)



% OVERRIDE
function [varargout] = bicas_main(obj, varargin)
for i = 1:numel(varargin)
assert(ischar(varargin{i}))
end
% OVERRIDE
function [varargout] = bicas_main(obj, varargin)
for i = 1:numel(varargin)
assert(ischar(varargin{i}))
end

[varargout{1:nargout}] = bicas.main(varargin{:});
end
[varargout{1:nargout}] = bicas.main(varargin{:});
end



end % methods(Access=public)
end % methods(Access=public)



Expand Down
Loading

0 comments on commit 07b9993

Please sign in to comment.