From 1104032e019af01da2a2251dff655addaf5b3448 Mon Sep 17 00:00:00 2001 From: Tom Teasdale Date: Sun, 21 Jan 2024 15:02:23 +0100 Subject: [PATCH] added range checks Input arguments are checked for being within valid range as defined per parameters or loose fallbacks if ranges are undefined. --- +tests/FunctionSignatures.mlx | Bin 3664 -> 3661 bytes src/+magicformula/InputParser.m | 40 +++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/+tests/FunctionSignatures.mlx b/+tests/FunctionSignatures.mlx index 4e286d7487fb2a901056db57ae1be4c7f8a626d5..80e645e1f1f5f4a645c8b440bf238f7e61000db0 100644 GIT binary patch delta 1251 zcmV<91RVR&9L*fC#R3XDV!)?S0ssI32b0eNC4WK*QksOWt18|qv<-<$+t9)gYSjZH!p{wEI$FP1SiYpf{Km_F$ivY+VR4+M!_S{Ht&s84$vKO z1*Bi33~((Zh-WE2ZV9gp-~RCQ`Acuqdx~O2cYlb5JLU0Ln&g5j4}f{uG%6IMz(W^eX|)U^ z=piuVvujC1`(wRj1QRq|`R+~Acl`zqH!WkZ5AqQ-7^1;<@4kL&8U06`H*h~&##nP3 zI5A))bq3#bCHm_^jL>9Ti`#~U0%eId6|yzh2_{a^tG`3tH;mV()J3(+#4hEbPk*~y zkOT&+I`p7Xfh-uU?=|9FCd9%nFg2B#Fy_B-Rr84$-m2XwTNvOtEp4@8a$&>p0-2LlaSDe96 z?p^Qy)}|hUAKyvYDi}@4loN?M|4FxclBLqXRhYufkI@lRK|wY8=OO%qK4H&&cb; z{nPZ+M47{1Nx=02q4H?w(t!xjqUhk?yPcAk{PwO{<2s{Ro=}$1Ws^}}FiwlNl3dLH zav$ng(MJ6zEe_I*H7w`FGM+Q(Nf4_ff4Zy}UrmJc@n5a1BZV3JQ~P4I7i!4ILbi2n)5r0000t0RR9f0000000001000000Qd@%aSa=j ND-It9{|f*B0060$Hc)F32 z!_!Oqx_`Co#5pTdo&iC8raQ}?JqIW{L7>^3r&RlS!87zFxk@SEubKtRT*ZaT8P^)+ zQhynoh2cezQjyt4@*$5`=37+5SXG}0R+5utXF+Ap1_6@WfpI*twNdf}j4gN}RRi=V zTmu=F83SAkiNq|UP%5qs5-Pl^S#JlOb81$9aM&qVB3Y4?&IBW7`K6=;m;OhSrGPo1 zQj%nyl|D8r+!Edx{_4Zs=P!fF;4Tq}?tc*ncPijdG%Y080RRi~hosbu0*`$V%IR8G zG(cd?XJ?AW?#EWwif+(w8v5s*&=1=3C+Hp^mbXB ztefoK@OBRaJ>F=aT-s@w~jB7l$&CtEa^!~p8?nT#} z!B}nG?f=%JzC}NOkg88Gnvn-i6j18?^G0++o?B5;N@=F9qZM;J;;h@?rZ@YKI?qgz zPcRovdn1!MvQFZEHrlfMTkf6+?AFcgOG`xGJfZIW(`8QShb*_DD|Me#1AXIrpILlW)w z_GWdhn-07T|93u4&R?wdx<#Mhyy{GeSw=AeBfCbKZHb@jb-KjJ2Vok~b_Pm(0FTkC zN(yPY>>ND0&VmaHJc=gcxwIwTgumFs49tXKmV|cY08;Df;@T&DFw=1uQ(l zPByZz5-=V%CpZ6G$=$y20Qd(87W&K&d^V2~nk1Y+e7Vb*u}h5AoP1~JRnnG5-P|K0 zyH!OmA>!nhzEcAiTm1kQgDV*ljyS8VWqGytR>Vs>r(sMNoJ`E)R000{R000000003100000um_XL2OX1* z4G@!34H^LilWh%30u2h2ZVelg)D0aRldygr!2kdNHUR(tC;$Ke000000RR91008?6 WlWq+glP?PolQ#|!1_BHK0001)Ts)}& diff --git a/src/+magicformula/InputParser.m b/src/+magicformula/InputParser.m index e143ac4..598ad66 100644 --- a/src/+magicformula/InputParser.m +++ b/src/+magicformula/InputParser.m @@ -3,9 +3,10 @@ methods (Static) function [p,SX,SA,FZ,IP,IA,VX,side,ver] = parse(p,SX,SA,varargin) versions = enumeration('MagicFormulaVersion'); - isValidVersion = @(x) mustBeMember(x, versions); - isValidNumericVector = @(x) isnumeric(x) && isvector(x); - isValidTyreSide = @(x) mustBeMember(x, [0, 1]); + isVersion = @(x) mustBeMember(x, versions); + isVector = @(x) isnumeric(x) && isvector(x); + isTyreSide = @(x) mustBeMember(x, [0, 1]); + isWithinBounds = @(x,lb,ub) isVector(x) && all(x>lb & x