diff options
author | Matti Picus <matti.picus@gmail.com> | 2023-02-12 09:12:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-12 09:12:36 +0200 |
commit | 5c7fde654c7cc9d9f32f29f82f5cb034c3c3ccaa (patch) | |
tree | 9d21c3e3f62276dbd35303d49203ca4834ee1e09 /numpy/lib | |
parent | 9dde0a930aa568bbdd3ba176b12d1d46c72d3d4e (diff) | |
parent | 9d5eafe596e75e30a85c01ed62bb5bea9389adc8 (diff) | |
download | numpy-5c7fde654c7cc9d9f32f29f82f5cb034c3c3ccaa.tar.gz |
Merge pull request #23089 from seberg/numpy2-flag
API: Add environment variable for behavior planned in a 2.0
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/function_base.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 0ca3c21c1..f5af314b5 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1311,6 +1311,8 @@ def gradient(f, *varargs, axis=None, edge_order=1): if len_axes == 1: return outvals[0] + elif np._using_numpy2_behavior(): + return tuple(outvals) else: return outvals diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index ecba35f2d..cc8003f61 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1217,6 +1217,13 @@ class TestGradient: dfdx = gradient(f, x) assert_array_equal(dfdx, [0.5, 0.5]) + def test_return_type(self): + res = np.gradient(([1, 2], [2, 3])) + if np._using_numpy2_behavior(): + assert type(res) is tuple + else: + assert type(res) is list + class TestAngle: |