Changeset 1867


Ignore:
Timestamp:
Aug 24, 2010, 9:38:06 PM (11 years ago)
Author:
malischewski
Message:

Tolerance problems with double comparison cleared up, has to be done this way, because of floating point arithmetic (e.g. exact comparison of two floating point values is not possible), therefore these deltas have to be used.
In my opinion this tolerance level is acceptable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DevTestMethods/CostFunctionTest.cs

    r1863 r1867  
    3232            System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); // String to Byte Conversion
    3333            CostFunction cf = new CostFunction();
    34 
    35 
     34           
    3635            //Index of Conincidence
    3736            cf.Initialize();
    38 
    3937            cf.InputText = enc.GetBytes(input);
    4038           
     
    4341            cf.PreExecution(); // important, wont work without this
    4442            cf.Execute();
    45 
    46             Assert.AreEqual(target, cf.Value, 0.00000000000001); // Uhm. Close enough? Oo
     43           
     44            Assert.AreEqual(target, cf.Value, 0.00000000000001); // This _is_ close enough. => Floating point arithmetic!
    4745
    4846            //Entropy
     
    5452            cf.Execute();
    5553
    56             Assert.AreEqual(target, cf.Value, 0.00000000000001); // Uhm. Close enough? Oo
    57 
     54            Assert.AreEqual(target, cf.Value, 0.00000000000001);
    5855           
    5956            //Bigrams: log 2
     
    7572            cf.Execute();
    7673            testContextInstance.WriteLine(cf.Value.ToString());
    77             Assert.AreEqual(target, cf.Value, 0.000000000001); // Seriously what's whats up with the tolerances?
    78            
     74            Assert.AreEqual(target, cf.Value, 0.000000000001);
     75
    7976            //Bigrams: Sinkov
    8077            target = -548.360297827531;
     
    8582            cf.Execute();
    8683            testContextInstance.WriteLine(cf.Value.ToString());
    87             Assert.AreEqual(target, cf.Value, 0.000000000001); // Uhm. Close enough? Oo
    88            
     84            Assert.AreEqual(target, cf.Value, 0.000000000001);
     85
    8986            //Bigrams: Percentaged
    9087            target = 0.20132645541636;
     
    9592            cf.Execute();
    9693            testContextInstance.WriteLine(cf.Value.ToString());
    97             Assert.AreEqual(target, cf.Value, 0.00000000000001); // Uhm. Close enough? Oo
    98            
     94            Assert.AreEqual(target, cf.Value, 0.00000000000001);
     95
    9996            //RegEx - Match
    10097            target = 1.0;
     
    106103            cf.Execute();
    107104            testContextInstance.WriteLine(cf.Value.ToString());
    108             Assert.AreEqual(target, cf.Value, 0.00000000000001); // Uhm. Close enough? Oo
     105            Assert.AreEqual(target, cf.Value, 0.00000000000001);
    109106
    110             //RegEx - Match
     107            //RegEx - Not a Match
    111108            target = -1.0;
    112109            cf.Initialize();
     
    117114            cf.Execute();
    118115            testContextInstance.WriteLine(cf.Value.ToString());
    119             Assert.AreEqual(target, cf.Value, 0.00000000000001); // Uhm. Close enough? Oo
     116            Assert.AreEqual(target, cf.Value, 0.00000000000001);
    120117
    121118            //Weighted Bigrams/Trigrams
     
    127124            cf.Execute();
    128125            testContextInstance.WriteLine(cf.Value.ToString());
    129             Assert.AreEqual(target, cf.Value, 0.000000000001); // Uhm. Close enough? Oo
     126            Assert.AreEqual(target, cf.Value, 0.000000000001);
    130127        }
    131128
Note: See TracChangeset for help on using the changeset viewer.