diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2016-06-19 13:39:46 +0200 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2016-09-02 10:10:55 +0200 |
commit | 86b0a5e9c58160bad818ba3a0a6faf38f5ac4d09 (patch) | |
tree | 928ce2677bcdf6735ebac42955859f5d522200b1 /numpy/core/arrayprint.py | |
parent | 968507bdfb4467d5ec6e3b6999a5717100782c3c (diff) | |
download | numpy-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/core/arrayprint.py')
-rw-r--r-- | numpy/core/arrayprint.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 282fbd1cf..b05082e9d 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -20,7 +20,7 @@ from functools import reduce from . import numerictypes as _nt from .umath import maximum, minimum, absolute, not_equal, isnan, isinf from .multiarray import (array, format_longfloat, datetime_as_string, - datetime_data) + datetime_data, dtype) from .fromnumeric import ravel from .numeric import asarray @@ -734,7 +734,9 @@ class TimedeltaFormat(object): def __init__(self, data): if data.dtype.kind == 'm': nat_value = array(['NaT'], dtype=data.dtype)[0] - v = data[not_equal(data, nat_value)].view('i8') + int_dtype = dtype(data.dtype.byteorder + 'i8') + int_view = data.view(int_dtype) + v = int_view[not_equal(int_view, nat_value.view(int_dtype))] if len(v) > 0: # Max str length of non-NaT elements max_str_len = max(len(str(maximum.reduce(v))), @@ -748,7 +750,8 @@ class TimedeltaFormat(object): self._nat = "'NaT'".rjust(max_str_len) def __call__(self, x): - if x + 1 == x: + # TODO: After NAT == NAT deprecation should be simplified: + if (x + 1).view('i8') == x.view('i8'): return self._nat else: return self.format % x.astype('i8') |