climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r1506801 - /incubator/climate/branches/RefactorInput/ocw/tests/test_evaluation.py
Date Thu, 25 Jul 2013 02:24:52 GMT
Author: joyce
Date: Thu Jul 25 02:24:51 2013
New Revision: 1506801

URL: http://svn.apache.org/r1506801
Log:
CLIMATE-218 - Fix add_metric(s) tests for Evaluation

- Update add_metric and add_metrics test now that a metric must inherit
  from the base Metric class.

Modified:
    incubator/climate/branches/RefactorInput/ocw/tests/test_evaluation.py

Modified: incubator/climate/branches/RefactorInput/ocw/tests/test_evaluation.py
URL: http://svn.apache.org/viewvc/incubator/climate/branches/RefactorInput/ocw/tests/test_evaluation.py?rev=1506801&r1=1506800&r2=1506801&view=diff
==============================================================================
--- incubator/climate/branches/RefactorInput/ocw/tests/test_evaluation.py (original)
+++ incubator/climate/branches/RefactorInput/ocw/tests/test_evaluation.py Thu Jul 25 02:24:51
2013
@@ -22,6 +22,7 @@ import numpy as np
 import datetime as dt
 from dataset import Dataset
 from evaluation import Evaluation
+from metrics import Bias, TemporalStdDev
 
 class TestEvaluation(unittest.TestCase):
     def setUp(self):
@@ -64,18 +65,14 @@ class TestEvaluation(unittest.TestCase):
                 self.other_var)
 
     def test_add_metric(self):
-        test_func = lambda x: x + 1
-        self.eval.add_metric(test_func)
-
-        self.assertEqual(self.eval.metrics[0](2), 3)
+        self.assertEqual(len(self.eval.metrics), 0)
+        self.eval.add_metric(Bias())
+        self.assertEqual(len(self.eval.metrics), 1)
 
     def test_add_metrics(self):
-        test_func = lambda x: x + 1
-        another_test_func = lambda x: x * 5
-        self.eval.add_metrics([test_func, another_test_func])
-
-        self.assertEqual(self.eval.metrics[0](2), 3)
-        self.assertEqual(self.eval.metrics[1](2), 10)
+        self.assertEqual(len(self.eval.metrics), 0)
+        self.eval.add_metrics([Bias(), Bias()])
+        self.assertEqual(len(self.eval.metrics), 2)
 
 if __name__  == '__main__':
     unittest.main()



Mime
View raw message