Skip to content

Commit

Permalink
adding a conditional wrapper to the pynumero import
Browse files Browse the repository at this point in the history
  • Loading branch information
Cody Karcher committed Aug 8, 2023
1 parent 2acc63e commit fd0c45b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pyomo/contrib/edi/formulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@
from pyomo.environ import Var, Param, Objective, Constraint, Set
from pyomo.environ import maximize, minimize
from pyomo.environ import units as pyomo_units
from pyomo.contrib.pynumero.interfaces.external_grey_box import (
ExternalGreyBoxModel,
ExternalGreyBoxBlock,

egb, egb_available = attempt_import(
"pyomo.contrib.pynumero.interfaces.external_grey_box"
)
if egb_available:
from pyomo.contrib.pynumero.interfaces.external_grey_box import (
ExternalGreyBoxModel,
ExternalGreyBoxBlock,
)
else:
raise ImportError(
"pyomo.contrib.edi requires pyomo.contrib.pynumero to be installed to enable black box capability, this should have installed with base pyomo"
)

from pyomo.environ import (
Reals,
PositiveReals,
Expand Down

0 comments on commit fd0c45b

Please sign in to comment.