[yt-svn] commit/yt: 3 new changesets
Bitbucket
commits-noreply at bitbucket.org
Sun Nov 11 07:08:45 PST 2012
3 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/81e081f65311/
changeset: 81e081f65311
branch: yt
user: brittonsmith
date: 2012-11-10 23:52:49
summary: Adding error messages and optional relative comparison for some tests.
affected #: 2 files
diff -r 5e3967177d655534958bfd15f7c2762111c60141 -r 81e081f653117710b1b1653e24387ac229adbd8d 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 5e3967177d655534958bfd15f7c2762111c60141 -r 81e081f653117710b1b1653e24387ac229adbd8d yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -280,10 +280,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 +295,26 @@
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 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 +331,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 +409,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/1050f4f6d8ea/
changeset: 1050f4f6d8ea
branch: yt
user: brittonsmith
date: 2012-11-10 23:54:18
summary: Merged.
affected #: 1 file
diff -r 81e081f653117710b1b1653e24387ac229adbd8d -r 1050f4f6d8ea85aaecfbb56fc931a7c97f188719 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)
https://bitbucket.org/yt_analysis/yt/changeset/87c2a8e4af57/
changeset: 87c2a8e4af57
branch: yt
user: brittonsmith
date: 2012-11-11 01:12:50
summary: Adding test for all values of a field in a dataset.
affected #: 1 file
diff -r 1050f4f6d8ea85aaecfbb56fc931a7c97f188719 -r 87c2a8e4af57ee467f65296f8c922e26d7246446 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -307,6 +307,30 @@
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")
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