Commit 083e1871 authored by Jakob Gabriel's avatar Jakob Gabriel
Browse files

bugfix 4 isConstant of quantity.Symbolic: Previously, isConstant behaved...

bugfix 4 isConstant of quantity.Symbolic: Previously, isConstant behaved differently for Discrete and Symbolic. Furthermore, this caused errors, in on() of Symbolic.
parent 718eaff8
......@@ -100,17 +100,7 @@ classdef Symbolic < quantity.Function
'quantity:Symbolic:Initialisation', ...
'If a quantity.Symbolic is initialized with a symbolic variable, a domain is required.');
end
end
function itIs = isConstant(obj)
itIs = true;
for k = 1:numel(obj)
itIs = itIs && isempty( obj(k).variable );
if ~itIs
break
end
end
end
end % Symbolic-Constructor
function i = eq(A, B)
%== Equal.
......
......@@ -4,6 +4,13 @@ function [tests ] = testSymbolic()
tests = functiontests(localfunctions());
end
function testZeroOn(tc)
% unittest to fix a bug related with isConstant usage in on() of symbolic
z = quantity.Domain("z", linspace(0, 1, 11));
quan = 0 * quantity.Symbolic(1-0.5*sym("z"), z, 'name', "Gamma");
tc.verifyEqual(quan.on({linspace(0, 1, 5)}), zeros(5, 1));
tc.verifyEqual(quan.on(linspace(0, 1, 5)), zeros(5, 1));
end % testZeroOn()
function testOnes(tc)
myDomain = [quantity.Domain("z", linspace(0, 1, 11)), quantity.Domain("zeta", linspace(0, 1, 5))];
......@@ -886,7 +893,6 @@ end
%%
testCase.verifyEqual(magic700, q.on());
testCase.verifyTrue(q.isConstant());
p = quantity.Symbolic([0 0 0 0 z], myDomain);
testCase.verifyFalse(p.isConstant());
......@@ -902,7 +908,7 @@ for k = 1:numel(magic2)
testCase.verifyTrue( all( Qon(:,:,k) == magic2(k), 'all') )
end
end
end % testConstantValues()
function testIsConstant(testCase)
syms z
......
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