# HG changeset patch # User Nicolas Saunier # Date 1310678109 14400 # Node ID 13187af8622d31847ab3766e3992e1633c76de1a # Parent 1621b46a15238d1aaf8c8e57e4483a62e7468047 finally added the representation of intervals diff -r 1621b46a1523 -r 13187af8622d python/moving.py --- a/python/moving.py Wed Jul 13 19:14:17 2011 -0400 +++ b/python/moving.py Thu Jul 14 17:15:09 2011 -0400 @@ -24,7 +24,10 @@ self.last=last def __str__(self): - return '%d %d'%(self.first, self.last) + return '[{0}, {1}]'.format(self.first, self.last) + + def __repr__(self): + return self.__str__() def empty(self): return self.first > self.last @@ -51,7 +54,7 @@ return TimeInterval(min(self.first, interval2.first), max(self.last, interval2.last)) def intersection(self, interval2): - '''Largest interval comprising self and interval2''' + '''Largest interval comprised in both self and interval2''' return TimeInterval(max(self.first, interval2.first), min(self.last, interval2.last)) diff -r 1621b46a1523 -r 13187af8622d python/tests/moving.txt --- a/python/tests/moving.txt Wed Jul 13 19:14:17 2011 -0400 +++ b/python/tests/moving.txt Thu Jul 14 17:15:09 2011 -0400 @@ -5,6 +5,8 @@ True >>> Interval(0,1).empty() False +>>> Interval(0,1) +[0, 1] >>> Interval(0,1).length() 1.0 >>> Interval(23.2,24.9).length()