| 1 | /* -*- mode: C++ -*- */ |
|---|
| 2 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 3 | // FILE : test.tol |
|---|
| 4 | // PURPOSE: Package MatQuery test |
|---|
| 5 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 6 | |
|---|
| 7 | Text email_ = "vdebuen@tol-project.org"; |
|---|
| 8 | Text link_ = ""; |
|---|
| 9 | Text summary_ = "checking matrix row selection of unknown values"; |
|---|
| 10 | |
|---|
| 11 | //#Require MatQuery; |
|---|
| 12 | //#Embed "../../../_embed_all.tol"; |
|---|
| 13 | |
|---|
| 14 | //Write here the initial test TOL code if needed |
|---|
| 15 | Real numErr0 = Copy(NError); |
|---|
| 16 | Real numWar0 = Copy(NWarning); |
|---|
| 17 | |
|---|
| 18 | Real t1 = Copy(Time); |
|---|
| 19 | Real rndSeed = 0; |
|---|
| 20 | Real m = 300; |
|---|
| 21 | Real n = 10; |
|---|
| 22 | |
|---|
| 23 | VMatrix unk.match = LE(Rand(m,n,0,1),Rand(m,n,1,1)*.20); |
|---|
| 24 | VMatrix M = IfVMat(unk.match, Rand(m,n,1,1)*?, Rand(m,n,-10,10)); |
|---|
| 25 | |
|---|
| 26 | VMatrix M.unk = Min(IsUnknown(M)*Rand(n,1,1,1), Rand(m,1,1,1)); |
|---|
| 27 | |
|---|
| 28 | VMatrix M.rows.known = Pack(Not(IsUnknown(M)*Rand(n,1,1,1))); |
|---|
| 29 | VMatrix M.rows.unknown = Pack(Not(M.rows.known)); |
|---|
| 30 | VMatrix M.rows.known_= MatQuery::MatchRowsFullKnown(M); |
|---|
| 31 | |
|---|
| 32 | VMatrix unk.match.1 = LE(Rand(m,1,0,1),Rand(m,1,1,1)*.20); |
|---|
| 33 | VMatrix M1 = IfVMat(unk.match.1, Rand(m,1,1,1)*?, Rand(m,1,-10,10)); |
|---|
| 34 | |
|---|
| 35 | VMatrix unk.match.1_ = MatQuery::MatchRowsWithValue(M1,?); |
|---|
| 36 | Real ok.1 = VMatMax(Abs(unk.match.1-unk.match.1))==0; |
|---|
| 37 | |
|---|
| 38 | Set sel.known = MatQuery::SelectMatch(Not(unk.match.1_)); |
|---|
| 39 | |
|---|
| 40 | VMatrix extract.known = SubRow(M1, sel.known); |
|---|
| 41 | |
|---|
| 42 | Real ok.2 = VMatSum(IsUnknown(extract.known))==0; |
|---|
| 43 | Real ok.3 = VRows(extract.known)==m-VMatSum(unk.match.1); |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | Real numErr1 = Copy(NError); |
|---|
| 47 | Real numWar1 = Copy(NWarning); |
|---|
| 48 | |
|---|
| 49 | Set partialResults_ = [[numErr0, numErr1, |
|---|
| 50 | ok.1, ok.2, ok.3]]; |
|---|
| 51 | |
|---|
| 52 | //This is a messure of the success of the test |
|---|
| 53 | Real quality_ = And(numErr1 == numErr0, |
|---|
| 54 | numWar1 <= numWar0, |
|---|
| 55 | ok.1, ok.2, ok.3); |
|---|
| 56 | |
|---|
| 57 | //Return the results |
|---|
| 58 | Set resultStr_ = @strTestStatus(summary_, link_, quality_, |
|---|
| 59 | "Partial results = "<<partialResults_, |
|---|
| 60 | "NO DBServerType", "NO DBServerHost", "NO DBAlias", |
|---|
| 61 | email_); |
|---|
| 62 | WriteLn(""<<resultStr_); |
|---|
| 63 | resultStr_; |
|---|
| 64 | |
|---|
| 65 | /* */ |
|---|
| 66 | |
|---|