removed type call from pulp.py in response to http://code.google.com/p/pulp-or/issues/detail?id=54

This commit is contained in:
Stuart Mitchell
2014-02-24 10:38:46 +13:00
parent fbf73918bf
commit 26ac7d342f
2 changed files with 4 additions and 4 deletions

View File

@@ -1311,7 +1311,7 @@ class LpProblem(object):
elif isinstance(other, LpAffineExpression):
self.objective = other
self.objective.name = name
elif isinstance(other, LpVariable) or type(other) in [int, float]:
elif isinstance(other, LpVariable) or isinstance(other, (int, float)):
self.objective = LpAffineExpression(other)
self.objective.name = name
else:
@@ -1957,8 +1957,8 @@ def lpDot(v1, v2):
return lpSum([lpDot(e1,e2) for e1,e2 in zip(v1,v2)])
def isNumber(x):
"""Returns true if x is an int of a float"""
return type(x) in [int, float]
"""Returns true if x is an int or a float"""
return isinstance(x, (int, float))
def value(x):
"""Returns the value of the variable/expression x, or x if it is a number"""

View File

@@ -2495,7 +2495,7 @@ class GurobiFormulation(object):
elif isinstance(other, LpAffineExpression):
self.objective = other
self.objective.name = name
elif isinstance(other, LpVariable) or type(other) in [int, float]:
elif isinstance(other, LpVariable) or isinstance(other, (int, float)):
self.objective = LpAffineExpression(other)
self.objective.name = name
else: