Repository: scipy/scipy

Issue:
DEP: deal with deprecation of ndim >1 in bspline
Since https://github.com/scipy/scipy/commit/0131d72f0f7a5c13f00961aea054094b2b78f071 from https://github.com/scipy/scipy/pull/3174, there's a warning that says
```
Calling splev() with BSpline objects with c.ndim > 1 is not recommended. Use BSpline.__call__(x) instead.
```

It _does_ raise a `DeprecationWarning` (and for over 5 years, at that), but the message text is a bit soft. Either we should sharpen the deprecation warning to schedule removal in 1.10 / 1.11, or simply remove it for 1.9.

CC @ev-br


Discussion:
Since there was not a single complaint about this, we can even raise an error. If anybody feels stong enough about it --- not sure whether it's of any use. It won't be less code, so as far as I'm concerned it can just be left as-is. 

Resolving patch:
diff --git a/scipy/interpolate/_fitpack_py.py b/scipy/interpolate/_fitpack_py.py
--- a/scipy/interpolate/_fitpack_py.py
+++ b/scipy/interpolate/_fitpack_py.py
@@ -359,8 +359,8 @@ def splev(x, tck, der=0, ext=0):
     if isinstance(tck, BSpline):
         if tck.c.ndim > 1:
             mesg = ("Calling splev() with BSpline objects with c.ndim > 1 is "
-                   "not recommended. Use BSpline.__call__(x) instead.")
-            warnings.warn(mesg, DeprecationWarning)
+                    "not allowed. Use BSpline.__call__(x) instead.")
+            raise ValueError(mesg)
 
         # remap the out-of-bounds behavior
         try:
@@ -427,8 +427,8 @@ def splint(a, b, tck, full_output=0):
     if isinstance(tck, BSpline):
         if tck.c.ndim > 1:
             mesg = ("Calling splint() with BSpline objects with c.ndim > 1 is "
-                   "not recommended. Use BSpline.integrate() instead.")
-            warnings.warn(mesg, DeprecationWarning)
+                    "not allowed. Use BSpline.integrate() instead.")
+            raise ValueError(mesg)
 
         if full_output != 0:
             mesg = ("full_output = %s is not supported. Proceeding as if "
@@ -491,8 +491,8 @@ def sproot(tck, mest=10):
     if isinstance(tck, BSpline):
         if tck.c.ndim > 1:
             mesg = ("Calling sproot() with BSpline objects with c.ndim > 1 is "
-                    "not recommended.")
-            warnings.warn(mesg, DeprecationWarning)
+                    "not allowed.")
+            raise ValueError(mesg)
 
         t, c, k = tck.tck
 


Test patch:
diff --git a/scipy/interpolate/tests/test_bsplines.py b/scipy/interpolate/tests/test_bsplines.py
--- a/scipy/interpolate/tests/test_bsplines.py
+++ b/scipy/interpolate/tests/test_bsplines.py
@@ -726,10 +726,8 @@ def test_splev(self):
 
         # With N-D coefficients, there's a quirck:
         # splev(x, BSpline) is equivalent to BSpline(x)
-        with suppress_warnings() as sup:
-            sup.filter(DeprecationWarning,
-                       "Calling splev.. with BSpline objects with c.ndim > 1 is not recommended.")
-            assert_allclose(splev(xnew, b2), b2(xnew), atol=1e-15, rtol=1e-15)
+        with assert_raises(ValueError, match="Calling splev.. with BSpline"):
+            splev(xnew, b2)
 
         # However, splev(x, BSpline.tck) needs some transposes. This is because
         # BSpline interpolates along the first axis, while the legacy FITPACK
@@ -835,14 +833,8 @@ def test_sproot(self):
         assert_allclose(sproot((b.t, b.c, b.k)), roots, atol=1e-7, rtol=1e-7)
 
         # ... and deals with trailing dimensions if coef array is N-D
-        with suppress_warnings() as sup:
-            sup.filter(DeprecationWarning,
-                       "Calling sproot.. with BSpline objects with c.ndim > 1 is not recommended.")
-            r = sproot(b2, mest=50)
-        r = np.asarray(r)
-
-        assert_equal(r.shape, (3, 2, 4))
-        assert_allclose(r - roots, 0, atol=1e-12)
+        with assert_raises(ValueError, match="Calling sproot.. with BSpline"):
+            sproot(b2, mest=50)
 
         # and legacy behavior is preserved for a tck tuple w/ N-D coef
         c2r = b2.c.transpose(1, 2, 0)
@@ -859,10 +851,8 @@ def test_splint(self):
                         b.integrate(0, 1), atol=1e-14)
 
         # ... and deals with N-D arrays of coefficients
-        with suppress_warnings() as sup:
-            sup.filter(DeprecationWarning,
-                       "Calling splint.. with BSpline objects with c.ndim > 1 is not recommended.")
-            assert_allclose(splint(0, 1, b2), b2.integrate(0, 1), atol=1e-14)
+        with assert_raises(ValueError, match="Calling splint.. with BSpline"):
+            splint(0, 1, b2)
 
         # and the legacy behavior is preserved for a tck tuple w/ N-D coef
         c2r = b2.c.transpose(1, 2, 0)