Skip to content

Commit 5fbd0fb

Browse files
Add IDs to validation warnings
1 parent c31a7a2 commit 5fbd0fb

File tree

6 files changed

+31
-10
lines changed

6 files changed

+31
-10
lines changed

src/+otp/+allencahn/AllenCahnProblem.m

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99

1010
methods (Access = protected)
1111
function validateNewState(obj, newTimeSpan, newY0, newParameters)
12+
[email protected](obj, newTimeSpan, newY0, ...
13+
newParameters);
14+
1215
y0Len = length(newY0);
1316
gridPts = newParameters.Size^2;
1417

1518
if y0Len ~= gridPts
16-
warning('Y0 has size %d, but there are %d grid points', ...
19+
warning('OTP:inconsistentNumVars', ...
20+
'NumVars is %d, but there are %d grid points', ...
1721
y0Len, gridPts);
1822
end
1923
end

src/+otp/+cusp/CUSPProblem.m

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@
2020

2121
methods (Access = protected)
2222
function validateNewState(obj, newTimeSpan, newY0, newParameters)
23+
[email protected](obj, newTimeSpan, newY0, ...
24+
newParameters);
25+
2326
y0Len = length(newY0);
2427
gridPts = 3 * newParameters.Size;
2528

2629
if y0Len ~= gridPts
27-
warning('Y0 has size %d, but there are %d grid points', ...
30+
warning('OTP:inconsistentNumVars', ...
31+
'NumVars is %d, but there are %d grid points', ...
2832
y0Len, gridPts);
2933
end
3034
end

src/+otp/+nbody/NBodyProblem.m

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77

88
methods (Access = protected)
99
function validateNewState(obj, newTimeSpan, newY0, newParameters)
10+
[email protected](obj, newTimeSpan, newY0, ...
11+
newParameters);
12+
1013
numMasses = length(newParameters.Masses);
1114
expectedLen = numMasses * 2^newParameters.SpatialDim;
1215
actualLen = length(newY0);
1316

1417
if expectedLen ~= actualLen
15-
warning( ...
16-
'With %d masses, Y0 should have length %d but has %d', ...
18+
warning('OTP:inconsistentNumVars', ...
19+
'With %d masses, NumVars should be %d but is %d', ...
1720
numMasses, expectedLen, actualLen);
1821
end
1922
end

src/+otp/+pendulum/PendulumProblem.m

+9-5
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,21 @@
2525

2626
methods (Access = protected)
2727
function validateNewState(obj, newTimeSpan, newY0, newParameters)
28+
[email protected](obj, newTimeSpan, newY0, ...
29+
newParameters);
30+
2831
y0Len = length(newY0);
2932
numMasses = length(newParameters.Masses);
3033
numLens = length(newParameters.Lengths);
3134

3235
if y0Len ~= 2 * numMasses
33-
warning( ...
34-
'With %d masses, Y0 should have length %d but has %d', ...
36+
warning('OTP:inconsistentNumVars', ...
37+
'With %d masses, NumVars should be %d but is %d', ...
3538
numMasses, 2 * numMasses, y0Len);
36-
elseif numMasses ~= numLens
37-
warning('Masses has length %d, but Lengths has length %d', ...
38-
numMasses, numLens);
39+
elseif y0Len ~= 2 * numLens
40+
warning('OTP:inconsistentNumVars', ...
41+
'With %d lengths, NumVars should be %d but is %d', ...
42+
numLens, 2 * numLens, y0Len);
3943
end
4044
end
4145

src/+otp/+qg/QuasiGeostrophicProblem.m

+5-1
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,15 @@
101101

102102
methods (Access = protected)
103103
function validateNewState(obj, newTimeSpan, newY0, newParameters)
104+
[email protected](obj, newTimeSpan, newY0, ...
105+
newParameters);
106+
104107
y0Len = length(newY0);
105108
gridPts = newParameters.Nx * newParameters.Ny;
106109

107110
if y0Len ~= gridPts
108-
warning('Y0 has size %d, but there are %d grid points', ...
111+
warning('OTP:inconsistentNumVars', ...
112+
'NumVars is %d, but there are %d grid points', ...
109113
y0Len, gridPts);
110114
end
111115
end

src/+otp/Problem.m

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
end
3030
obj.Name = name;
3131
obj.ExpectedNumVars = expectedNumVars;
32+
33+
% IDEA: Make Settings a class with property validation
3234
obj.Settings = struct('timeSpan', timeSpan(:), 'y0', y0, 'parameters', parameters);
3335
end
3436

0 commit comments

Comments
 (0)