Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
BigDataProject/ClusterProjectest.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
263 lines (251 sloc)
11.5 KB
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
classdef ClusterProjectest < matlab.unittest.TestCase | |
properties (TestParameter) | |
Data = struct( 'M1', ncread("Model_Individual/W_fr-meteofrance,MODEL,CHIMERE+FORECAST+SURFACE+O3+0H24H_C_LFPW_20180701000000.nc", "unknown"),... | |
'M2', ncread("Model_Individual/W_fr-meteofrance,MODEL,EMEP+FORECAST+SURFACE+O3+0H24H_C_LFPW_20180701000000.nc", "unknown"),... | |
'M3', ncread("Model_Individual/W_fr-meteofrance,MODEL,ENSEMBLE+FORECAST+SURFACE+O3+0H24H_C_LFPW_20180701000000.nc", "unknown"),... | |
'M4', ncread("Model_Individual/W_fr-meteofrance,MODEL,EURAD+FORECAST+SURFACE+O3+0H24H_C_LFPW_20180701000000.nc", "unknown"),... | |
'M5', ncread("Model_Individual/W_fr-meteofrance,MODEL,MATCH+FORECAST+SURFACE+O3+0H24H_C_LFPW_20180701000000.nc", "unknown"),... | |
'M6', ncread("Model_Individual/W_fr-meteofrance,MODEL,MOCAGE+FORECAST+SURFACE+O3+0H24H_C_LFPW_20180701000000.nc", "unknown"),... | |
'M7', ncread("Model_Individual/W_fr-meteofrance,MODEL,SILAM+FORECAST+SURFACE+O3+0H24H_C_LFPW_20180701000000.nc", "unknown")); | |
end | |
methods (Test) | |
% This test function should be fixed | |
% function Test_If_files_are_saved(testCase) | |
% % import matlab.unittest.TestCase; | |
% % import matlab.unittest.constraints.IsFile; | |
% data(1,:,:,:) = testCase.Data.M1; | |
% data(2,:,:,:) = testCase.Data.M2; | |
% data(3,:,:,:) = testCase.Data.M3; | |
% data(4,:,:,:) = testCase.Data.M4; | |
% data(5,:,:,:) = testCase.Data.M5; | |
% data(6,:,:,:) = testCase.Data.M6; | |
% data(7,:,:,:) = testCase.Data.M7; | |
% | |
% X = 1; | |
% Y = 1; | |
% T = 1; | |
% Rangee = 3; | |
% [~, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+1, 1, 0); | |
% % source link for future work. y x t | |
% % https://www.mathworks.com/help/matlab/ref/matlab.unittest.constraints.isfile-class.html | |
% act = ['results' filesep '1Hour.csv']; | |
% testCase.verifyThat(act,IsFile) | |
% end | |
% clockwise order | |
% ___________________________________________________________________ | |
function Test_Zero_Corner1(testCase) | |
data(1,:,:,:) = testCase.Data.M1; | |
data(2,:,:,:) = testCase.Data.M2; | |
data(3,:,:,:) = testCase.Data.M3; | |
data(4,:,:,:) = testCase.Data.M4; | |
data(5,:,:,:) = testCase.Data.M5; | |
data(6,:,:,:) = testCase.Data.M6; | |
data(7,:,:,:) = testCase.Data.M7; | |
X = 1; | |
Y = 1; | |
T = 1; | |
Rangee = 3; | |
[FinalResultofWholeData, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+1, 0, 0); | |
% y x t | |
actSolution = FinalResultofWholeData(Y,X,T); % the x 1 y 1 corner | |
expSolution = 0; | |
testCase.verifyEqual(actSolution, expSolution) | |
end | |
function Test_Zero_Corner2(testCase) | |
data(1,:,:,:) = testCase.Data.M1; | |
data(2,:,:,:) = testCase.Data.M2; | |
data(3,:,:,:) = testCase.Data.M3; | |
data(4,:,:,:) = testCase.Data.M4; | |
data(5,:,:,:) = testCase.Data.M5; | |
data(6,:,:,:) = testCase.Data.M6; | |
data(7,:,:,:) = testCase.Data.M7; | |
X = 1; | |
Y = 1; | |
T = 1; | |
Rangee = 3; | |
[FinalResultofWholeData, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+1, 0, 0); | |
% y x t | |
actSolution = FinalResultofWholeData(Y,X+Rangee,T); % the x 1 y 1 corner | |
expSolution = 0; | |
testCase.verifyEqual(actSolution, expSolution) | |
end | |
function Test_Zero_Corner3(testCase) | |
data(1,:,:,:) = testCase.Data.M1; | |
data(2,:,:,:) = testCase.Data.M2; | |
data(3,:,:,:) = testCase.Data.M3; | |
data(4,:,:,:) = testCase.Data.M4; | |
data(5,:,:,:) = testCase.Data.M5; | |
data(6,:,:,:) = testCase.Data.M6; | |
data(7,:,:,:) = testCase.Data.M7; | |
X = 1; | |
Y = 1; | |
T = 1; | |
Rangee = 3; | |
[FinalResultofWholeData, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+1, 0, 0); | |
% y x t | |
actSolution = FinalResultofWholeData(Y+Rangee,X+Rangee,T); % the x 1 y 1 corner | |
expSolution = 0; | |
testCase.verifyEqual(actSolution, expSolution) | |
end | |
function Test_Zero_Corner4(testCase) | |
data(1,:,:,:) = testCase.Data.M1; | |
data(2,:,:,:) = testCase.Data.M2; | |
data(3,:,:,:) = testCase.Data.M3; | |
data(4,:,:,:) = testCase.Data.M4; | |
data(5,:,:,:) = testCase.Data.M5; | |
data(6,:,:,:) = testCase.Data.M6; | |
data(7,:,:,:) = testCase.Data.M7; | |
X = 1; | |
Y = 1; | |
T = 1; | |
Rangee = 3; | |
[FinalResultofWholeData, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+1, 0, 0); | |
% y x t | |
actSolution = FinalResultofWholeData(Y+Rangee,X,T); % the x 1 y 1 corner | |
expSolution = 0; | |
testCase.verifyEqual(actSolution, expSolution) | |
end | |
% ___________________________________________________________________ | |
function Test_Zero_Edge1(testCase) | |
data(1,:,:,:) = testCase.Data.M1; | |
data(2,:,:,:) = testCase.Data.M2; | |
data(3,:,:,:) = testCase.Data.M3; | |
data(4,:,:,:) = testCase.Data.M4; | |
data(5,:,:,:) = testCase.Data.M5; | |
data(6,:,:,:) = testCase.Data.M6; | |
data(7,:,:,:) = testCase.Data.M7; | |
X = 1; | |
Y = 1; | |
T = 1; | |
Rangee = 3; | |
[FinalResultofWholeData, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+1, 0, 0); | |
actSolution = FinalResultofWholeData(Y,X+1,T); % edge | |
expSolution = 0; | |
testCase.verifyEqual(actSolution, expSolution) | |
end | |
function Test_Zero_Edge2(testCase) | |
data(1,:,:,:) = testCase.Data.M1; | |
data(2,:,:,:) = testCase.Data.M2; | |
data(3,:,:,:) = testCase.Data.M3; | |
data(4,:,:,:) = testCase.Data.M4; | |
data(5,:,:,:) = testCase.Data.M5; | |
data(6,:,:,:) = testCase.Data.M6; | |
data(7,:,:,:) = testCase.Data.M7; | |
X = 1; | |
Y = 1; | |
T = 1; | |
Rangee = 3; | |
[FinalResultofWholeData, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+1, 0, 0); | |
actSolution = FinalResultofWholeData(Y+1,X+Rangee,T); % edge | |
expSolution = 0; | |
testCase.verifyEqual(actSolution, expSolution) | |
end | |
function Test_Zero_Edge3(testCase) | |
data(1,:,:,:) = testCase.Data.M1; | |
data(2,:,:,:) = testCase.Data.M2; | |
data(3,:,:,:) = testCase.Data.M3; | |
data(4,:,:,:) = testCase.Data.M4; | |
data(5,:,:,:) = testCase.Data.M5; | |
data(6,:,:,:) = testCase.Data.M6; | |
data(7,:,:,:) = testCase.Data.M7; | |
X = 1; | |
Y = 1; | |
T = 1; | |
Rangee = 3; | |
[FinalResultofWholeData, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+1, 0, 0); | |
actSolution = FinalResultofWholeData(Y+Rangee,X+1,T); % edge | |
expSolution = 0; | |
testCase.verifyEqual(actSolution, expSolution) | |
end | |
function Test_Zero_Edge4(testCase) | |
data(1,:,:,:) = testCase.Data.M1; | |
data(2,:,:,:) = testCase.Data.M2; | |
data(3,:,:,:) = testCase.Data.M3; | |
data(4,:,:,:) = testCase.Data.M4; | |
data(5,:,:,:) = testCase.Data.M5; | |
data(6,:,:,:) = testCase.Data.M6; | |
data(7,:,:,:) = testCase.Data.M7; | |
X = 1; | |
Y = 1; | |
T = 1; | |
Rangee = 3; | |
[FinalResultofWholeData, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+1, 0, 0); | |
actSolution = FinalResultofWholeData(Y+1,X,T); % edge | |
expSolution = 0; | |
testCase.verifyEqual(actSolution, expSolution) | |
end | |
% ___________________________________________________________________ | |
function Test_NotZero_Centre(testCase) | |
data(1,:,:,:) = testCase.Data.M1; | |
data(2,:,:,:) = testCase.Data.M2; | |
data(3,:,:,:) = testCase.Data.M3; | |
data(4,:,:,:) = testCase.Data.M4; | |
data(5,:,:,:) = testCase.Data.M5; | |
data(6,:,:,:) = testCase.Data.M6; | |
data(7,:,:,:) = testCase.Data.M7; | |
X = 1; | |
Y = 1; | |
T = 1; | |
Rangee = 3; | |
[FinalResultofWholeData, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+1, 0, 0); | |
actSolution = FinalResultofWholeData(Y+1,X+1,T); % edge | |
expSolution = 0; | |
testCase.verifyNotEqual(actSolution, expSolution) | |
end | |
function Test_NotPositiveInfinity(testCase) | |
data(1,:,:,:) = testCase.Data.M1; | |
data(2,:,:,:) = testCase.Data.M2; | |
data(3,:,:,:) = testCase.Data.M3; | |
data(4,:,:,:) = testCase.Data.M4; | |
data(5,:,:,:) = testCase.Data.M5; | |
data(6,:,:,:) = testCase.Data.M6; | |
data(7,:,:,:) = testCase.Data.M7; | |
X = 1; | |
Y = 1; | |
T = 1; | |
Rangee = 3; | |
[FinalResultofWholeData, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+1, 0, 0); | |
actSolution = FinalResultofWholeData(Y+1,X+1,T); % edge | |
expSolution = 1/0; | |
testCase.verifyNotEqual(actSolution, expSolution) | |
end | |
function Test_NotNegativeInfinity(testCase) | |
data(1,:,:,:) = testCase.Data.M1; | |
data(2,:,:,:) = testCase.Data.M2; | |
data(3,:,:,:) = testCase.Data.M3; | |
data(4,:,:,:) = testCase.Data.M4; | |
data(5,:,:,:) = testCase.Data.M5; | |
data(6,:,:,:) = testCase.Data.M6; | |
data(7,:,:,:) = testCase.Data.M7; | |
X = 1; | |
Y = 1; | |
T = 1; | |
Rangee = 3; | |
[FinalResultofWholeData, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+1, 0, 0); | |
actSolution = FinalResultofWholeData(Y+1,X+1,T); % edge | |
expSolution = -1/0; | |
testCase.verifyNotEqual(actSolution, expSolution) | |
end | |
function Test_Nan(testCase) | |
% to test the nan value code | |
% function does not pass this test , code fails | |
data(1,:,:,:) = testCase.Data.M1; | |
data(2,:,:,:) = testCase.Data.M2; | |
data(3,:,:,:) = testCase.Data.M3; | |
data(4,:,:,:) = testCase.Data.M4; | |
data(5,:,:,:) = testCase.Data.M5; | |
data(6,:,:,:) = testCase.Data.M6; | |
data(7,:,:,:) = testCase.Data.M7; | |
X = 1; | |
Y = 1; | |
T = 1; | |
Rangee = 3; | |
data(2,2,2,2) = nan; | |
[FinalResultofWholeData, ~] = ClusterProject(data,1 , 1, Y, Y+Rangee, X, X+Rangee, T, T+3, 0, 0); | |
actSolution = FinalResultofWholeData(Y+1,X+1,T+1); % edge | |
% expSolution = zeros(size(FinalResultofWholeData)); | |
expSolution = -99999; | |
testCase.verifyEqual(actSolution, expSolution) | |
end | |
end | |
end |