Commit 598d8fc1 authored by Jakob Gabriel's avatar Jakob Gabriel
Browse files

quantity.Discrete: fixed assertion to verify that discrete values suite to grid

parent 451a8d40
......@@ -99,9 +99,12 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
% the case if all values are empty. This is required for
% the initialization of quantity.Function and
% quantity.Symbolic objects
assert( all( cellfun(@isempty, valueOriginal ), 'all' ) || ...
numGridElements(myDomain) == numel(valueOriginal{1}), ...
'grids do not fit to valueOriginal');
assert(isempty(myDomain) ... % constant case
|| all( cellfun(@isempty, valueOriginal ), 'all' ) ... % empty case
|| isequal([myDomain.n], size(valueOriginal{1}, 1 : max(1, numel(myDomain)))) ... % usual case
|| (isrow(valueOriginal{1}) && ... % row-vector case (including next line)
isequal([1, myDomain.n], size(valueOriginal{1}, 1 : max(1, numel(myDomain)+1)))), ...
'grids do not fit to valueOriginal');
% allow initialization of empty objects
valueOriginalSize = size(valueOriginal);
......@@ -2610,13 +2613,15 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
parameters = struct(A);
gridSize = A.domain.gridLength();
end
end
end % innerInputNormalizer()
q = innerInputNormalizer(b, a);
p = innerInputNormalizer(a, b);
end
end % inputNormalizer()
end %% (Static)
methods(Access = protected)
function [valDiscrete] = expandValueDiscrete(obj, newDomain)
......
......@@ -191,7 +191,7 @@ classdef (InferiorClasses = {?quantity.EquidistantDomain}) Domain < ...
function n = numGridElements(obj)
% NUMGRIDLEMENTS returns the number of the elements of the grid
n = prod([obj.n]);
end
end % numGridElements()
function s = gridLength(obj)
%GRIDLENGTH number of discretization points for each grid in the
......
......@@ -1333,7 +1333,7 @@ testCase.verifyEqual( on( TZX + XTZ ), on( 2 * TZX ), 'AbsTol', eps )
end
function testInit(testCase)
function testInit(tc)
%%
z = linspace(0,1).';
t = linspace(0,1,101);
......@@ -1347,7 +1347,7 @@ a = quantity.Discrete(v, [Z, T]);
b = quantity.Discrete(V, [Z, T]);
%
verifyTrue(testCase, all(a.on() == b.on(), 'all'));
verifyTrue(tc, all(a.on() == b.on(), 'all'));
%%
zeta = T.grid;
......@@ -1355,9 +1355,10 @@ zeta = T.grid;
Z = quantity.Domain("z", z);
Zeta = quantity.Domain("zeta", zeta);
c = quantity.Discrete(zGrid, [Z, Zeta], 'name', 'a');
d = quantity.Discrete(zetaGrid', [Z, Zeta], 'name', 'b');
%TODO write test case, the last line should not work
c = quantity.Discrete(zGrid, [Z, Zeta], 'name', 'a'); % this should work
tc.verifyError(...
@() quantity.Discrete(zetaGrid.', [Z, Zeta], 'name', 'd'), ...% this should not work
'');
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment