diff options
author | Stephan Hoyer <shoyer@climate.com> | 2016-01-12 20:44:34 -0800 |
---|---|---|
committer | Stephan Hoyer <shoyer@climate.com> | 2016-01-14 13:44:43 -0800 |
commit | 53ad26a84ac2aa6f5a37f09aa9feae5afed44f79 (patch) | |
tree | 856886f3b9d65fb6305f21f9d692cb0861b861cb /numpy/core/arrayprint.py | |
parent | 8fa6e3bef26a6d4a2c92f2824129aa4409be2590 (diff) | |
download | numpy-53ad26a84ac2aa6f5a37f09aa9feae5afed44f79.tar.gz |
TST, ENH: make all comparisons with NaT false
Now, NaT compares like NaN:
- NaT != NaT -> True
- NaT == NaT (and all other comparisons) -> False
We discussed this on the mailing list back in October:
https://mail.scipy.org/pipermail/numpy-discussion/2015-October/073968.html
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r-- | numpy/core/arrayprint.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index fefcb6493..c5b5b5a8f 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -739,8 +739,8 @@ class DatetimeFormat(object): 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') + # select non-NaT elements + v = data[data == data].view('i8') if len(v) > 0: # Max str length of non-NaT elements max_str_len = max(len(str(maximum.reduce(v))), @@ -754,7 +754,7 @@ class TimedeltaFormat(object): self._nat = "'NaT'".rjust(max_str_len) def __call__(self, x): - if x + 1 == x: + if x != x: return self._nat else: return self.format % x.astype('i8') |