Give a more useful error if cvxopt is not found
authorDebian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org>
Tue, 4 Feb 2020 00:34:03 +0000 (00:34 +0000)
committerPeter Michael Green <plugwash@raspbian.org>
Tue, 4 Feb 2020 00:34:03 +0000 (00:34 +0000)
message wasn't actually passed to anything, so it previously failed at
statsmodels/base/optimizer.py:13 (_check_method) with
"Unknown fit method l1_cvxopt_cp"

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Forwarded: accepted https://github.com/statsmodels/statsmodels/pull/6163

Gbp-Pq: Name show_cvxopt_error.patch

statsmodels/discrete/discrete_model.py

index 4b4675da07a06d597e8b9f04ef8a6ff9fa4f1cc7..561c1a4fe7ce5ba75d90a85c24ef1e2e26e51aec 100644 (file)
@@ -353,8 +353,8 @@ class DiscreteModel(base.LikelihoodModel):
             from statsmodels.base.l1_cvxopt import fit_l1_cvxopt_cp
             extra_fit_funcs['l1_cvxopt_cp'] = fit_l1_cvxopt_cp
         elif method.lower() == 'l1_cvxopt_cp':
-            message = ("Attempt to use l1_cvxopt_cp failed since cvxopt "
-                        "could not be imported")
+            raise ValueError("Cannot use l1_cvxopt_cp as cvxopt "
+                "was not found (install it, or use method='l1' instead)")
 
         if callback is None:
             callback = self._check_perfect_pred