diff options
author | Rohit Goswami <rgoswami@quansight.com> | 2022-03-31 14:51:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-31 11:51:57 -0300 |
commit | 04bf4057d565f3d47e984fa0f21929bbb8d9ab7c (patch) | |
tree | f28f654e4c8373cf9a0b60fc8a174139a9935405 /numpy/f2py/tests/test_regression.py | |
parent | a8fd84da447a5af7434cbff1e7e84a2e7a0cfb5a (diff) | |
download | numpy-04bf4057d565f3d47e984fa0f21929bbb8d9ab7c.tar.gz |
BUG,ENH: Fix negative bounds for F2PY (#21256)
Co-authored-by: Pearu Peterson <pearu.peterson@gmail.com>
Diffstat (limited to 'numpy/f2py/tests/test_regression.py')
-rw-r--r-- | numpy/f2py/tests/test_regression.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/numpy/f2py/tests/test_regression.py b/numpy/f2py/tests/test_regression.py index 40b9d4327..044f952f2 100644 --- a/numpy/f2py/tests/test_regression.py +++ b/numpy/f2py/tests/test_regression.py @@ -22,6 +22,25 @@ class TestIntentInOut(util.F2PyTest): assert np.allclose(x, [3, 1, 2]) +class TestNegativeBounds(util.F2PyTest): + # Check that negative bounds work correctly + sources = [util.getpath("tests", "src", "negative_bounds", "issue_20853.f90")] + + @pytest.mark.slow + def test_negbound(self): + xvec = np.arange(12) + xlow = -6 + xhigh = 4 + # Calculate the upper bound, + # Keeping the 1 index in mind + def ubound(xl, xh): + return xh - xl + 1 + rval = self.module.foo(is_=xlow, ie_=xhigh, + arr=xvec[:ubound(xlow, xhigh)]) + expval = np.arange(11, dtype = np.float32) + assert np.allclose(rval, expval) + + class TestNumpyVersionAttribute(util.F2PyTest): # Check that th attribute __f2py_numpy_version__ is present # in the compiled module and that has the value np.__version__. |