[python-dtcwt] 222/497: tests/util.py: add a percentile-based 'nearly equal' test
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:07 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.
commit 576b8855f308a85584572985aeb9e66f0da9f6f8
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date: Wed Dec 4 15:28:40 2013 +0000
tests/util.py: add a percentile-based 'nearly equal' test
---
tests/util.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tests/util.py b/tests/util.py
index 1999603..0c86b49 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -15,6 +15,15 @@ def assert_almost_equal(a, b, tolerance=TOLERANCE):
'Arrays differ by a maximum of {0} which is greater than the tolerance of {1}'.
format(md, tolerance))
+def assert_percentile_almost_equal(a, b, percentile=90, tolerance=TOLERANCE):
+ md = np.percentile(np.abs(a-b), percentile)
+ if md <= tolerance:
+ return
+
+ raise AssertionError(
+ 'Arrays differ by a maximum of {0} in the {2}th percentile which is greater than the tolerance of {1}'.
+ format(md, tolerance, percentile))
+
def _mean(a, axis=None, *args, **kwargs):
"""Equivalent to numpy.mean except that the axis along which the mean is taken is not removed."""
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git
More information about the debian-science-commits
mailing list