Repository: kb-press/ndsplines

Issue:
`set_impl` should have a default
The `set_impl` function should handle a `name` that is not `"cython"` or `"numpy"` by raising an exception.

Discussion:

Patch:
diff --git a/ndsplines/__init__.py b/ndsplines/__init__.py
index 86d81e0..08cacac 100644
--- a/ndsplines/__init__.py
+++ b/ndsplines/__init__.py
@@ -3,34 +3,41 @@ from .version import __version__
 
 evaluate_spline = None
 
+
 def set_impl(name):
     """Set bspl implementation to either cython or numpy.
 
     Parameters
     ----------
-    name : 'cython' or 'numpy'
-        Name of implementation to set to.
-
+    name : "cython" or "numpy"
+        Name of implementation to use.
     """
     global evaluate_spline
-    if name == 'cython':
+    name = name.lower()
+    if name == "cython":
         try:
             from . import _bspl
+
             ndsplines.impl = _bspl
             evaluate_spline = _bspl.evaluate_spline
         except ImportError:
-            raise ImportError("Can't use cython implementation. Install "
-                              "cython then reinstall ndsplines.")
-    elif name == 'numpy':
+            raise ImportError(
+                "Can't use cython implementation. Install cython then reinstall "
+                "ndsplines."
+            )
+    elif name == "numpy":
         from . import _npy_bspl
+
         ndsplines.impl = _npy_bspl
         evaluate_spline = _npy_bspl.evaluate_spline
+    else:
+        raise ValueError("Implementation must be one of {'cython', 'numpy'}")
 
 
 try:
-    set_impl('cython')
+    set_impl("cython")
 except ImportError:
-    set_impl('numpy')
+    set_impl("numpy")
 
 
-__all__ = [d for d in dir() if not d.startswith('_')]
+__all__ = [d for d in dir() if not d.startswith("_")]


Test patch:
diff --git a/tests/test_ndsplines.py b/tests/test_ndsplines.py
index 010c045..3823249 100644
--- a/tests/test_ndsplines.py
+++ b/tests/test_ndsplines.py
@@ -7,6 +7,7 @@ from scipy.stats import norm
 import itertools
 from utils import get_query_points, assert_equal_splines, _make_random_spline
 
+
 #
 # Integration/Miscellaneous tests
 #
@@ -22,6 +23,11 @@ def test_evaluate_spline_different_impls():
     assert f_numpy is not f_cython
 
 
+def test_invalid_impl():
+    with pytest.raises(ValueError):
+        ndsplines.set_impl('notimplemented')
+
+
 #
 # Scipy compatibility tests
 #