Commit b903a122 authored by Ferdinand Fischer's avatar Ferdinand Fischer
Browse files

simplifcation of quantity.Domain/parser

parent 004a5513
......@@ -12,9 +12,7 @@ classdef Parser < inputParser
% set default properties
obj.KeepUnmatched = true;
obj.CaseSensitive = true;
obj.PartialMatching = false;
obj.PartialMatching = false;
end % Parser()
function i = isDefault(obj, name)
......
......@@ -520,14 +520,9 @@ classdef (InferiorClasses = {?quantity.EquidistantDomain}) Domain < ...
domainParser.addParameter('gridName', '');
domainParser.addParameter('grid', [], @(g) isnumeric(g) || iscell(g));
domainParser.parse(varargin{:});
if domainParser.isDefault('domain') && ...
( domainParser.isDefault('grid') || ...
domainParser.isDefault('gridName') )
% case 1: nothing about the grid is defined
error('No domain is specified! A domain is obligatory for the initialization of a quantity.')
elseif domainParser.isDefault('domain')
% case 3: the gridNames and the gridValues are defined:
if domainParser.isDefault('domain')
% case: the gridNames and the gridValues are defined:
% -> initialize quantity.Domain objects with the
% specified values
......@@ -542,10 +537,13 @@ classdef (InferiorClasses = {?quantity.EquidistantDomain}) Domain < ...
for k = 1:numel(myGrid)
myDomain(k) = quantity.Domain(myGridName(k), myGrid{k});
end
else
% else case: the domains are specified as domain
elseif ( domainParser.isDefault('grid') || ...
domainParser.isDefault('gridName') )
% case: the domains are specified as domain
% objects.
myDomain = domainParser.Results.domain;
myDomain = domainParser.Results.domain;
else
error('No domain is specified! A domain is obligatory for the initialization of a quantity.')
end
assert(misc.isunique([myDomain.name]), ...
......
......@@ -18,6 +18,22 @@ tc.TestData.d = d;
end
function testParser(testCase)
profile on
d = quantity.Domain.parser('blub', 1, 'grid', 1:3, 'gridName', 'test');
a = quantity.Domain.parser('domain', d);
b = quantity.Domain.parser('blabla', 0, 'domain', a);
b = quantity.Domain.parser('blabla', 0, 'domain', a, 'blub', 'a');
profile off
profile viewer
testCase.verifyEqual(d, a);
testCase.verifyEqual(b, a);
end
function testSplit(testCase)
a = quantity.Domain('a', -5:15 );
......
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