projects
/
linpy.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
49fa0d5
)
Do not cast values returned by LinExpr accessors to Rational
author
Vivien Maisonneuve
<v.maisonneuve@gmail.com>
Tue, 19 Aug 2014 09:21:50 +0000
(11:21 +0200)
committer
Vivien Maisonneuve
<v.maisonneuve@gmail.com>
Tue, 19 Aug 2014 09:21:50 +0000
(11:21 +0200)
linpy/linexprs.py
patch
|
blob
|
history
diff --git
a/linpy/linexprs.py
b/linpy/linexprs.py
index
38fa7a1
..
b2cec53
100644
(file)
--- a/
linpy/linexprs.py
+++ b/
linpy/linexprs.py
@@
-122,7
+122,7
@@
class LinExpr:
"""
if not isinstance(symbol, Symbol):
raise TypeError('symbol must be a Symbol instance')
"""
if not isinstance(symbol, Symbol):
raise TypeError('symbol must be a Symbol instance')
- return
Rational(self._coefficients.get(symbol, 0)
)
+ return
self._coefficients.get(symbol, 0
)
__getitem__ = coefficient
__getitem__ = coefficient
@@
-132,14
+132,14
@@
class LinExpr:
expression. The constant term is ignored.
"""
for symbol, coefficient in self._coefficients.items():
expression. The constant term is ignored.
"""
for symbol, coefficient in self._coefficients.items():
- yield symbol,
Rational(coefficient)
+ yield symbol,
coefficient
@property
def constant(self):
"""
The constant term of the expression.
"""
@property
def constant(self):
"""
The constant term of the expression.
"""
- return
Rational(self._constant)
+ return
self._constant
@property
def symbols(self):
@property
def symbols(self):
@@
-180,8
+180,8
@@
class LinExpr:
term.
"""
for coefficient in self._coefficients.values():
term.
"""
for coefficient in self._coefficients.values():
- yield
Rational(coefficient)
- yield
Rational(self._constant)
+ yield
coefficient
+ yield
self._constant
def __bool__(self):
return True
def __bool__(self):
return True