rospy: #3667 bug fix for truediv in Duration instance

This commit is contained in:
Ken Conley 2011-09-12 20:09:18 +00:00
parent de2d4cb17f
commit 960d21deda
1 changed files with 3 additions and 5 deletions

View File

@ -426,7 +426,8 @@ class Duration(TVal):
@return: Duration multiplied by val
@rtype: L{Duration}
"""
# unlike __floordiv__, this uses true div for float arg
# unlike __floordiv__, this uses true div for float arg.
# PEP 238
t = type(val)
if t in (int, long):
return Duration(self.secs // val, self.nsecs // val)
@ -443,10 +444,7 @@ class Duration(TVal):
@return: Duration multiplied by val
@rtype: L{Duration}
"""
t = type(val)
if t in (int, long):
return Duration(self.secs / val, self.nsecs / val)
elif t == float:
if type(val) in (int, long, float):
return Duration.from_sec(self.to_sec() / val)
else:
return NotImplemented