summaryrefslogtreecommitdiff
path: root/numpy/testing/utils.py
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2016-06-19 13:39:46 +0200
committerSebastian Berg <sebastian@sipsolutions.net>2016-09-02 10:10:55 +0200
commit86b0a5e9c58160bad818ba3a0a6faf38f5ac4d09 (patch)
tree928ce2677bcdf6735ebac42955859f5d522200b1 /numpy/testing/utils.py
parent968507bdfb4467d5ec6e3b6999a5717100782c3c (diff)
downloadnumpy-86b0a5e9c58160bad818ba3a0a6faf38f5ac4d09.tar.gz
BUG: Suppress common NaT warnings
Printing of datetime arrays used to cause warning due to comparison warnings in NaT. This is circumvented by using views to integer values. Part of this should be simplified when the deprecation is over. Also fixes a bug with non-native byteorder.
Diffstat (limited to 'numpy/testing/utils.py')
-rw-r--r--numpy/testing/utils.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py
index 8789dd13c..682b032b4 100644
--- a/numpy/testing/utils.py
+++ b/numpy/testing/utils.py
@@ -396,8 +396,12 @@ def assert_equal(actual,desired,err_msg='',verbose=True):
pass
# Explicitly use __eq__ for comparison, ticket #2552
- if not (desired == actual):
- raise AssertionError(msg)
+ with suppress_warnings() as sup:
+ # TODO: Better handling will to needed when change happens!
+ sup.filter(DeprecationWarning, ".*NAT ==")
+ sup.filter(FutureWarning, ".*NAT ==")
+ if not (desired == actual):
+ raise AssertionError(msg)
def print_assert_equal(test_string, actual, desired):
@@ -687,8 +691,9 @@ def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
# pass (or maybe eventually catch the errors and return False, I
# dunno, that's a little trickier and we can figure that out when the
# time comes).
- with warnings.catch_warnings():
- warnings.filterwarnings("ignore", category=DeprecationWarning)
+ with suppress_warnings() as sup:
+ sup.filter(DeprecationWarning, ".*==")
+ sup.filter(FutureWarning, ".*==")
return comparison(*args, **kwargs)
def isnumber(x):