Skip to content

Commit

Permalink
Merge pull request #1 from cropsinsilico/add_tests
Browse files Browse the repository at this point in the history
Add tests & CI
  • Loading branch information
langmm authored Dec 12, 2024
2 parents 632c0a3 + ff968e0 commit a962828
Show file tree
Hide file tree
Showing 22 changed files with 712 additions and 94 deletions.
28 changes: 28 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
* text=auto

*.fig binary
*.mat binary
*.mdl binary diff merge=mlAutoMerge
*.mdlp binary
*.mex* binary
*.mlapp binary
*.mldatx binary
*.mlproj binary
*.mlx binary
*.p binary
*.sfx binary
*.sldd binary
*.slreqx binary merge=mlAutoMerge
*.slmx binary merge=mlAutoMerge
*.sltx binary
*.slxc binary
*.slx binary merge=mlAutoMerge
*.slxp binary

## Other common binary file types
*.docx binary
*.exe binary
*.jpg binary
*.pdf binary
*.png binary
*.xlsx binary
30 changes: 30 additions & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Verify that MATLAB & C++ versions return the same answers
'on':
push:
branches-ignore:
- gh-pages
tags:
- '*'
schedule:
- cron: 0 10 * * 1
jobs:
build_cxx:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: true
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
# - name: Run tests command
# uses: matlab-actions/run-command@v2
# with:
# command: runtests('tests'); exit;
# startup-options: -nodisplay -nosplash -nodesktop -nojvm -logfile matlab_log.txt
# - name: Display MATLAB log
# run: cat matlab_log.txt
- name: Run tests
uses: matlab-actions/run-tests@v2
with:
select-by-folder: tests
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*~
*.asv
14 changes: 11 additions & 3 deletions CM_Drive.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



clear all;
global dontClear;
if (~dontClear)
clear all;
end
InitRatios(1, 1);

Begin = 1;
fin = SYSInitial(Begin);
Expand Down Expand Up @@ -93,8 +96,13 @@
% output step %
%%%%%%%%%%%%%%%%%%%%%%%%

global dontGraph;
if (~dontGraph)
success = CM_OUT(Tt, d);
else
success = 1;
end

% Reinitialize some values of global variables.
PSPR_SUCS_com = 0;
IniModelCom;
IniModelCom;
4 changes: 3 additions & 1 deletion CM_Drive2.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

function CO2AR = CM_Drive2(pop, currentPop)

InitRatios(1, 1);

Begin = 1;
fin = SysInitial(Begin);
global options1;
Expand Down Expand Up @@ -107,4 +109,4 @@
PSPR_SUCS_com = 0;
IniModelCom;

CO2AR = TargetFunVal
CO2AR = TargetFunVal
4 changes: 2 additions & 2 deletions CM_OUT.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

PSPR(:,24) = d(:,36);

out1 = PSPR_OUT(Tt,PSPR);
out1 = PSPR_Out(Tt,PSPR);
out2 = SUCS_Graph(Tt,SUCS);

OUTSUC = 1;
OUTSUC = 1;
11 changes: 10 additions & 1 deletion Condition.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
% second part contains the detailed conditions for different time period.

function fini = Condition (t)
% Allow early abort if environmental inputs handled via ePhotosynthesis
% function
global dontCondition;
if (dontCondition)
global NumInter_draw;
NumInter_draw = 10;
fini = 1;
return;
end
global TestCa;
global TestLi;
global RUBISCOMETHOD; % The method for calculation of Rubisco catalyzed reaction
Expand Down Expand Up @@ -142,4 +151,4 @@
% end

GLight = light;
fini = 1;
fini = 1;
41 changes: 1 addition & 40 deletions DynaPS_Drive.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,7 @@
% This part include the function to begin the simulation.

% The time information is set in a global variable called tglobal in SYSInitial.
global PSRatio;
PSRatio=ones(103,1);
if ParaNum <= 103
PSRatio(ParaNum)=Ratio;
end
global SUCRatio;
SUCRatio=ones(66,1);
if ParaNum > 103&&ParaNum<=169
SUCRatio(ParaNum-103)=Ratio;
end
global PRRatio;
PRRatio=ones(48,1);
if ParaNum > 169&&ParaNum<=217
PRRatio(ParaNum-169)=Ratio;
end

global RacRatio;
RacRatio=ones(16,1);
if ParaNum > 217&&ParaNum<=233
RacRatio(ParaNum-217)=Ratio;
end

global FIRatio;
FIRatio=ones(23,1);
if ParaNum > 233&&ParaNum<=256
FIRatio(ParaNum-233)=Ratio;
end

global BFRatio;
BFRatio=ones(49,1);
if ParaNum > 256&&ParaNum<=305
BFRatio(ParaNum-256)=Ratio;
end


global XanRatio;
XanRatio=ones(4,1);
if ParaNum > 305&&ParaNum<=309
XanRatio(ParaNum-305)=Ratio;
end
InitRatios(ParaNum, Ratio);

% DynaPS_Drive.m
% This part include the function to begin the simulation.
Expand Down
14 changes: 10 additions & 4 deletions EPS_Drive.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



clear;
global dontClear;
if (~dontClear)
clear;
end
InitRatios(1, 1);

Begin = 1;
fin = SYSInitial(Begin);
Expand Down Expand Up @@ -91,7 +94,10 @@
[Tt,d] = ode15s(@EPS_mb,[0,time],EPS_Con,options1,BF_Param, FI_Param, PS_PR_Param, Sucs_Param);

% The following section deals with the data output of the program.
GraphSuc = EPS_Graph(Tt,d);
global dontGraph;
if (~dontGraph)
GraphSuc = EPS_Graph(Tt,d);
end
% Here is the place to recover the status of the regulatory variables.

% ATPActive = 0;
Expand All @@ -107,4 +113,4 @@
global FI_VEL;
global FI_CON;
global BF_VEL;
global BF_CON;
global BF_CON;
48 changes: 48 additions & 0 deletions InitRatios.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
function InitRatios(ParaNum, Ratio)
if ParaNum <= 0
return;
end

global PSRatio;
PSRatio=ones(103,1);
if ParaNum <= 103
PSRatio(ParaNum)=Ratio;
end

global SUCRatio;
SUCRatio=ones(66,1);
if ParaNum > 103&&ParaNum<=169
SUCRatio(ParaNum-103)=Ratio;
end

global PRRatio;
PRRatio=ones(48,1);
if ParaNum > 169&&ParaNum<=217
PRRatio(ParaNum-169)=Ratio;
end

global RacRatio;
RacRatio=ones(16,1);
if ParaNum > 217&&ParaNum<=233
RacRatio(ParaNum-217)=Ratio;
end

global FIRatio;
FIRatio=ones(23,1);
if ParaNum > 233&&ParaNum<=256
FIRatio(ParaNum-233)=Ratio;
end

global BFRatio;
BFRatio=ones(49,1);
if ParaNum > 256&&ParaNum<=305
BFRatio(ParaNum-256)=Ratio;
end

global XanRatio;
XanRatio=ones(4,1);
if ParaNum > 305&&ParaNum<=309
XanRatio(ParaNum-305)=Ratio;
end

end
Loading

0 comments on commit a962828

Please sign in to comment.