Mercurial > repos > public > sbplib
diff +scheme/Schrodinger.m @ 1042:8d73fcdb07a5 feature/getBoundaryOp
Add asserts to boundary identifier inputs
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 22 Jan 2019 16:47:34 +0100 |
parents | 337c4d1dcef5 |
children | 5afc774fb7c4 |
line wrap: on
line diff
--- a/+scheme/Schrodinger.m Wed Jan 16 11:31:04 2019 -0800 +++ b/+scheme/Schrodinger.m Tue Jan 22 16:47:34 2019 +0100 @@ -114,6 +114,7 @@ % op -- string or a cell array of strings % boundary -- string function varargout = getBoundaryOperator(obj, op, boundary) + assertIsMember(boundary, {'l', 'r'}) if ~iscell(op) op = {op}; @@ -127,8 +128,6 @@ e = obj.e_l; case 'r' e = obj.e_r; - otherwise - error('No such boundary: boundary = %s',boundary); end varargout{i} = e; @@ -138,8 +137,6 @@ d = obj.d1_l; case 'r' d = obj.d1_r; - otherwise - error('No such boundary: boundary = %s',boundary); end varargout{i} = d; end @@ -149,13 +146,13 @@ % Returns the boundary sign. The right boundary is considered the positive boundary % boundary -- string function s = getBoundarySign(obj, boundary) + assertIsMember(boundary, {'l', 'r'}) + switch boundary case {'r'} s = 1; case {'l'} s = -1; - otherwise - error('No such boundary: boundary = %s',boundary); end end