Skip to content

Commit

Permalink
Added some try/except clauses since MIP backends are an optional extra.
Browse files Browse the repository at this point in the history
  • Loading branch information
tBuLi committed Sep 25, 2023
1 parent 8881b65 commit 9c66409
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ universal=1
[extras]
contrib =
matplotlib >= 2.0
symmip =
pyscipopt
# all should be a complete list of all dependencies of all other extras. How to
# automate this?
all =
matplotlib >= 2.0
pyscipopt
2 changes: 1 addition & 1 deletion symfit/symmip/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .gurobi import GurobiBackend
from .scipopt import SCIPOptBackend
from .scipopt import SCIPOptBackend
10 changes: 8 additions & 2 deletions symfit/symmip/backend/gurobi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from dataclasses import dataclass, field

import gurobipy as gp
import importlib
import warnings

try:
gp = importlib.import_module('gurobipy')
except ImportError as e:
warnings.warn('Install gurobipy to use this feature.')
gp = {}

from sympy.printing.pycode import PythonCodePrinter

Expand Down
10 changes: 8 additions & 2 deletions symfit/symmip/backend/scipopt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from dataclasses import dataclass, field

import pyscipopt as scip
import importlib
import warnings

try:
scip = importlib.import_module('pyscipopt')
except ImportError as e:
warnings.warn('Install pyscipopt to use this feature.')
scip = {}

from sympy.printing.pycode import PythonCodePrinter

Expand Down

0 comments on commit 9c66409

Please sign in to comment.