Skip to content

Commit

Permalink
Check is_indexed before calling as_numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
gseastream committed Aug 9, 2018
1 parent b54c5ef commit f21c152
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyomo/network/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ def add(self, var, name=None, rule=None, **kwds):
**kwds Keyword arguments that will be passed to rule
"""
if var is not None:
var = as_numeric(var)
try:
# indexed components are ok, but as_numeric will error on them
# make sure they have this attribute
var.is_indexed()
except AttributeError:
var = as_numeric(var)
if name is None:
name = var.local_name
if name in self.vars and self.vars[name] is not None:
Expand Down

0 comments on commit f21c152

Please sign in to comment.