Repository: lmfit/lmfit-py

Issue:
ValueError when using scipy development version
# Description

When a `scipy` development version is installed, determining its version fails in lmfit/minimizer.py

```python
major, minor, micro = np.array(scipy_version.split('.'), dtype='int')
```

Generates the following error

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bfmaier/.local/lib/python3.6/site-packages/lmfit/__init__.py", line 42, in <module>
    from .confidence import conf_interval, conf_interval2d
  File "/home/bfmaier/.local/lib/python3.6/site-packages/lmfit/confidence.py", line 12, in <module>
    from .minimizer import MinimizerException
  File "/home/bfmaier/.local/lib/python3.6/site-packages/lmfit/minimizer.py", line 134, in <module>
    major, minor, micro = np.array(scipy_version.split('.'), dtype='int')
ValueError: invalid literal for int() with base 10: 'dev0+dfb0cc2'
```

# Versions

* lmfit: 0.9.11
* scipy: 1.2.0.dev0+dfb0cc2

# Minimal example

This works only when a scipy dev version is installed.

```python
import lmfit
```


Discussion:
suggested solution:

replace both occurences of

```python
major, minor, micro = np.array(scipy_version.split('.'), dtype='int')
```

in `minimizer.py` with

```python
major, minor, micro = np.array((scipy_version.split('.dev')[0]).split('.'), dtype='int')
```

Resolving patch:
diff --git a/lmfit/minimizer.py b/lmfit/minimizer.py
--- a/lmfit/minimizer.py
+++ b/lmfit/minimizer.py
@@ -130,10 +130,10 @@ class AbortFitException(MinimizerException):
                   'differential_evolution': 'differential_evolution'}
 
 # FIXME: update this when incresing the minimum scipy version
-major, minor, micro = np.array(scipy_version.split('.'), dtype='int')
-if (major >= 1 and minor >= 1):
+major, minor, micro = scipy_version.split('.', 2)
+if (int(major) >= 1 and int(minor) >= 1):
     SCALAR_METHODS.update({'trust-constr': 'trust-constr'})
-if major >= 1:
+if int(major) >= 1:
     SCALAR_METHODS.update({'trust-exact': 'trust-exact',
                            'trust-krylov': 'trust-krylov'})
 
@@ -1438,8 +1438,8 @@ def basinhopping(self, params=None, **kws):
         basinhopping_kws.update(kws)
 
         # FIXME - remove after requirement for scipy >= 0.19
-        major, minor, micro = np.array(scipy_version.split('.'), dtype='int')
-        if major < 1 and minor < 19:
+        major, minor, micro = scipy_version.split('.', 2)
+        if int(major) < 1 and int(minor) < 19:
             _ = basinhopping_kws.pop('seed')
             print("Warning: basinhopping doesn't support argument 'seed' for "
                   "scipy versions below 0.19!")


Test patch:
diff --git a/tests/test_basinhopping.py b/tests/test_basinhopping.py
--- a/tests/test_basinhopping.py
+++ b/tests/test_basinhopping.py
@@ -18,8 +18,8 @@ def func(x):
     x0 = [1.]
 
     # FIXME - remove after requirement for scipy >= 0.19
-    major, minor, micro = np.array(scipy_version.split('.'), dtype='int')
-    if major < 1 and minor < 19:
+    major, minor, micro = scipy_version.split('.', 2)
+    if int(major) < 1 and int(minor) < 19:
         ret = basinhopping(func, x0, minimizer_kwargs=minimizer_kwargs)
     else:
         ret = basinhopping(func, x0, minimizer_kwargs=minimizer_kwargs, seed=7)
@@ -50,8 +50,8 @@ def func2d(x):
     x0 = [1.0, 1.0]
 
     # FIXME - remove after requirement for scipy >= 0.19
-    major, minor, micro = np.array(scipy_version.split('.'), dtype='int')
-    if major < 1 and minor < 19:
+    major, minor, micro = scipy_version.split('.', 2)
+    if int(major) < 1 and int(minor) < 19:
         ret = basinhopping(func2d, x0, minimizer_kwargs=minimizer_kwargs)
     else:
         ret = basinhopping(func2d, x0, minimizer_kwargs=minimizer_kwargs, seed=7)
@@ -106,8 +106,8 @@ def basinhopping_accept(f_new, f_old, x_new, x_old):
     x0 = [1.0, 1.0]
 
     # FIXME - remove after requirement for scipy >= 0.19
-    major, minor, micro = np.array(scipy_version.split('.'), dtype='int')
-    if major < 1 and minor < 19:
+    major, minor, micro = scipy_version.split('.', 2)
+    if int(major) < 1 and int(minor) < 19:
         ret = basinhopping(Alpine02, x0, minimizer_kwargs=minimizer_kwargs,
                            accept_test=basinhopping_accept)
     else: