Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: TestClip.test_NaT_propagation xfails unexpectedly #15320

Open
Kai-Striega opened this issue Jan 12, 2020 · 2 comments
Open

TST: TestClip.test_NaT_propagation xfails unexpectedly #15320

Kai-Striega opened this issue Jan 12, 2020 · 2 comments

Comments

@Kai-Striega
Copy link
Member

Kai-Striega commented Jan 12, 2020

The test TestClip.test_NaT_propagation xfails due to errors in the test, rather than the test conditions not being met. This is similar to #15319, where the parameter arr is expected then a is used by the test. However there are several more reasons for the test to fail prematurely:

  1. Passing nat to np.clip is deprecated and raises a DepcrecationWarning
  2. Cannot cast ufunc 'clip' input 1 from dtype('float64') to dtype('<m8') with casting rule 'same_kind'

I believe that these were changed previously and missed due to the test being expected to fail.

Reproducing code example:

$ python runtests.py -v -t numpy/core/tests/test_numeric.py::TestClip::test_NaT_propagation -- --runxfail
Building, see build.log...
Build OK
NumPy version 1.19.0.dev0+b757fb3
NumPy relaxed strides checking option: True
============================= test session starts ==============================
platform linux -- Python 3.7.5, pytest-5.3.2, py-1.8.1, pluggy-0.13.1
rootdir: /mnt/c/Users/Kai/Develop/numpy-git, inifile: pytest.ini
plugins: forked-1.1.3, xdist-1.31.0
collected 1 item

numpy/core/tests/test_numeric.py F                                       [100%]

=================================== FAILURES ===================================
_______________ TestClip.test_NaT_propagation[arr0-amin0-amax0] ________________

self = <numpy.core.tests.test_numeric.TestClip object at 0x7f9b0cfde840>
arr = array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=timedelta64)
amin = numpy.timedelta64('NaT')
amax = array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=int32)

    @pytest.mark.xfail(reason="propagation doesn't match spec")
    @pytest.mark.parametrize("arr, amin, amax", [
        (np.array([1] * 10, dtype='m8'),
         np.timedelta64('NaT'),
         np.zeros(10, dtype=np.int32)),
    ])
    def test_NaT_propagation(self, arr, amin, amax):
        # NOTE: the expected function spec doesn't
        # propagate NaT, but clip() now does
>       expected = np.minimum(np.maximum(a, amin), amax)
E       NameError: name 'a' is not defined

amax       = array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=int32)
amin       = numpy.timedelta64('NaT')
arr        = array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=timedelta64)
self       = <numpy.core.tests.test_numeric.TestClip object at 0x7f9b0cfde840>

numpy/core/tests/test_numeric.py:2018: NameError
============================== 1 failed in 0.82s ===============================

Numpy/Python version information:

>>> import sys, numpy
>>> numpy.__version__, sys.version
(1.19.0.dev0+b757fb3, 3.7.5 (default, Nov  7 2019, 10:50:52) [GCC 8.3.0])
@mattip
Copy link
Member

mattip commented Jan 12, 2020

Can you add a fix to gh-15319?

@Kai-Striega
Copy link
Member Author

Kai-Striega commented Jan 12, 2020

The problem I have is that I'm not sure how it's supposed to behave. The generic NaN fails as expected after the fixes. This one does not, it runs into additional problems with casting the float to a datetime. So even if I did the changes as in #15319 they would still fail (incorrectly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants