[yt-svn] commit/yt: 3 new changesets

Bitbucket commits-noreply at bitbucket.org
Mon Nov 12 10:58:23 PST 2012


3 new commits in yt:


https://bitbucket.org/yt_analysis/yt/changeset/be44666c67ee/
changeset:   be44666c67ee
branch:      yt
user:        samskillman
date:        2012-11-12 18:13:09
summary:     Make the store-local a flag with no arguments, adding a help for it.
affected #:  1 file

diff -r 5e3967177d655534958bfd15f7c2762111c60141 -r be44666c67ee90f43e2fd7bbda3ed0645316b591 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -63,7 +63,7 @@
         parser.add_option("--answer-store", dest="store_results",
             default=False, action="store_true")
         parser.add_option("--local-store", dest="store_local_results",
-            default=False)
+            default=False, action="store_true", help="Store/Load local results?")
 
     def configure(self, options, conf):
         super(AnswerTesting, self).configure(options, conf)
@@ -85,7 +85,7 @@
             options.compare_name = _latest
 
         # We only either store or test.
-        if options.store_local_results == 'True':
+        if options.store_local_results:
             AnswerTestingTest.reference_storage = \
                 self.storage = \
                     AnswerTestLocalStorage("%s/%s" % \



https://bitbucket.org/yt_analysis/yt/changeset/1555c64e1bd7/
changeset:   1555c64e1bd7
branch:      yt
user:        samskillman
date:        2012-11-12 18:13:20
summary:     Merging
affected #:  2 files

diff -r be44666c67ee90f43e2fd7bbda3ed0645316b591 -r 1555c64e1bd743b17a0d4a8d9f03411e90e14d8e yt/testing.py
--- a/yt/testing.py
+++ b/yt/testing.py
@@ -29,7 +29,7 @@
     assert_array_less, assert_string_equal, assert_array_almost_equal_nulp,\
     assert_allclose
 
-def assert_rel_equal(a1, a2, decimals):
+def assert_rel_equal(a1, a2, decimals, err_msg=''):
     # We have nan checks in here because occasionally we have fields that get
     # weighted without non-zero weights.  I'm looking at you, particle fields!
     if isinstance(a1, np.ndarray):
@@ -39,7 +39,7 @@
         a2[np.isnan(a2)] = 1.0
     elif np.isnan(a1) and np.isnan(a2):
         return True
-    return assert_almost_equal(a1/a2, 1.0, decimals)
+    return assert_almost_equal(a1/a2, 1.0, decimals, err_msg=err_msg)
 
 def amrspace(extent, levels=7, cells=8):
     """Creates two numpy arrays representing the left and right bounds of 


diff -r be44666c67ee90f43e2fd7bbda3ed0645316b591 -r 1555c64e1bd743b17a0d4a8d9f03411e90e14d8e yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -180,6 +180,8 @@
 
 def can_run_pf(pf_fn):
     path = ytcfg.get("yt", "test_data_dir")
+    if not os.path.isdir(path):
+        return False
     if isinstance(pf_fn, StaticOutput):
         return AnswerTestingTest.result_storage is not None
     with temp_cwd(path):
@@ -191,6 +193,8 @@
 
 def data_dir_load(pf_fn):
     path = ytcfg.get("yt", "test_data_dir")
+    if not os.path.isdir(path):
+        return False
     if isinstance(pf_fn, StaticOutput): return pf_fn
     with temp_cwd(path):
         pf = load(pf_fn)
@@ -280,10 +284,12 @@
     _type_name = "FieldValues"
     _attrs = ("field", )
 
-    def __init__(self, pf_fn, field, obj_type = None):
+    def __init__(self, pf_fn, field, obj_type = None,
+                 decimals = None):
         super(FieldValuesTest, self).__init__(pf_fn)
         self.obj_type = obj_type
         self.field = field
+        self.decimals = decimals
 
     def run(self):
         obj = self.create_obj(self.pf, self.obj_type)
@@ -293,19 +299,50 @@
         return np.array([avg, mi, ma])
 
     def compare(self, new_result, old_result):
-        assert_equal(new_result, old_result)
+        err_msg = "Field values for %s not equal." % self.field
+        if self.decimals is None:
+            assert_equal(new_result, old_result, 
+                         err_msg=err_msg, verbose=True)
+        else:
+            assert_rel_equal(new_result, old_result, self.decimals,
+                             err_msg=err_msg, verbose=True)
 
+class AllFieldValuesTest(AnswerTestingTest):
+    _type_name = "AllFieldValues"
+    _attrs = ("field", )
+
+    def __init__(self, pf_fn, field, obj_type = None,
+                 decimals = None):
+        super(AllFieldValuesTest, self).__init__(pf_fn)
+        self.obj_type = obj_type
+        self.field = field
+        self.decimals = decimals
+
+    def run(self):
+        obj = self.create_obj(self.pf, self.obj_type)
+        return obj[self.field]
+
+    def compare(self, new_result, old_result):
+        err_msg = "All field values for %s not equal." % self.field
+        if self.decimals is None:
+            assert_equal(new_result, old_result, 
+                         err_msg=err_msg, verbose=True)
+        else:
+            assert_rel_equal(new_result, old_result, self.decimals,
+                             err_msg=err_msg, verbose=True)
+            
 class ProjectionValuesTest(AnswerTestingTest):
     _type_name = "ProjectionValues"
     _attrs = ("field", "axis", "weight_field")
 
     def __init__(self, pf_fn, axis, field, weight_field = None,
-                 obj_type = None):
+                 obj_type = None, decimals = None):
         super(ProjectionValuesTest, self).__init__(pf_fn)
         self.axis = axis
         self.field = field
         self.weight_field = field
         self.obj_type = obj_type
+        self.decimals = decimals
 
     def run(self):
         if self.obj_type is not None:
@@ -322,7 +359,14 @@
         for k in new_result:
             assert (k in old_result)
         for k in new_result:
-            assert_equal(new_result[k], old_result[k])
+            err_msg = "%s values of %s (%s weighted) projection (axis %s) not equal." % \
+              (k, self.field, self.weight_field, self.axis)
+            if self.decimals is None:
+                assert_equal(new_result[k], old_result[k],
+                             err_msg=err_msg)
+            else:
+                assert_rel_equal(new_result[k], old_result[k], 
+                                 self.decimals, err_msg=err_msg)
 
 class PixelizedProjectionValuesTest(AnswerTestingTest):
     _type_name = "PixelizedProjectionValues"
@@ -393,9 +437,13 @@
         return result
 
     def compare(self, new_result, old_result):
-        assert_equal(len(new_result), len(old_result))
+        assert_equal(len(new_result), len(old_result),
+                     err_msg="Number of outputs not equal.",
+                     verbose=True)
         for i in range(len(new_result)):
-            assert_equal(new_result[i], old_result[i])
+            assert_equal(new_result[i], old_result[i],
+                         err_msg="Output times not equal.",
+                         verbose=True)
         
 class GridHierarchyTest(AnswerTestingTest):
     _type_name = "GridHierarchy"



https://bitbucket.org/yt_analysis/yt/changeset/5e1ba28cc582/
changeset:   5e1ba28cc582
branch:      yt
user:        samskillman
date:        2012-11-12 19:57:09
summary:     --answer-compare=SKIP now works.  Local and cloud storage seems to now be working.
affected #:  1 file

diff -r 1555c64e1bd743b17a0d4a8d9f03411e90e14d8e -r 5e1ba28cc582d1f7dc9de6f0c73695722d1f32bd yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -86,10 +86,14 @@
 
         # We only either store or test.
         if options.store_local_results:
+            if options.compare_name is not None:
+                options.compare_name = "%s/%s" % \
+                        (os.path.realpath(options.output_dir), 
+                         options.compare_name)
             AnswerTestingTest.reference_storage = \
                 self.storage = \
-                    AnswerTestLocalStorage("%s/%s" % \
-                        (os.path.realpath(options.output_dir), options.compare_name), not options.store_results)
+                    AnswerTestLocalStorage(options.compare_name, 
+                                           not options.store_results)
         else:
             AnswerTestingTest.reference_storage = \
                 self.storage = AnswerTestCloudStorage(options.compare_name, not options.store_results)
@@ -109,9 +113,9 @@
         self.cache = {}
         self.read = read
     def dump(self, result_storage, result):
-        pass
+        raise NotImplementedError 
     def get(self, pf_name, default=None):
-        pass
+        raise NotImplementedError 
 
 class AnswerTestCloudStorage(AnswerTestStorage):
     def get(self, pf_name, default = None):
@@ -220,7 +224,8 @@
 
     def __call__(self):
         nv = self.run()
-        if self.reference_storage is not None and self.reference_storage.read:
+        if self.reference_storage.read and \
+           self.reference_storage.reference_name is not None:
             dd = self.reference_storage.get(self.storage_name)
             if dd is None: raise YTNoOldAnswer(self.storage_name)
             ov = dd[self.description]

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list