From e05ae7a12dceea01c5d9f745c1dce1ca9cb3b394 Mon Sep 17 00:00:00 2001 From: Jakob Gabriel <jakob.gabriel@fau.de> Date: Wed, 15 Apr 2020 23:12:45 +0200 Subject: [PATCH] quantity.Discrete.isnan --- +quantity/Discrete.m | 22 ++++++++++++++++++++++ +unittests/+quantity/testDomain.m | 6 +++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/+quantity/Discrete.m b/+quantity/Discrete.m index 826e34a..ba6d07c 100644 --- a/+quantity/Discrete.m +++ b/+quantity/Discrete.m @@ -1869,6 +1869,28 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ... end end % isdiag() + function result = isnan(obj, anyNan) + % isnan True for Not-a-Number. + % isnan(X) returns an array that contains true's where + % the elements of X are NaN's and false's where they are not. + % + % isnan(X, true) returns the same as any(isnan(X), 'all') + + arguments + obj + anyNan = false; + end + + if anyNan + result = any(isnan(obj.on()), 'all'); + else + result = true(size(obj)); + for it = 1 : numel(obj) + result(it) = any(isnan(obj(it).on()), 'all'); + end + end + end % isnan() + function P = ztzTimes(a, b) assert(size(a,2) == size(b,1)) diff --git a/+unittests/+quantity/testDomain.m b/+unittests/+quantity/testDomain.m index b92c4ff..11ee196 100644 --- a/+unittests/+quantity/testDomain.m +++ b/+unittests/+quantity/testDomain.m @@ -20,13 +20,13 @@ end function testParser(testCase) -profile on +%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 +%profile off +%profile viewer testCase.verifyEqual(d, a); -- GitLab