Mercurial Hosting > traffic-intelligence
changeset 96:9928c2fa72cc
added equal method to intervals
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 13 Jun 2011 16:50:40 -0400 |
parents | 857bcd41e9a2 |
children | b3a1c26e2f22 |
files | python/moving.py python/tests/moving.txt |
diffstat | 2 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/python/moving.py Mon Jun 13 16:46:16 2011 -0400 +++ b/python/moving.py Mon Jun 13 16:50:40 2011 -0400 @@ -32,6 +32,9 @@ '''Returns the length of the interval''' return float(max(0,self.last-self.first)) + def equal(self, i2): + return self.first==i2.first and self.last == i2.last + def getList(self): return [self.first, self.last]
--- a/python/tests/moving.txt Mon Jun 13 16:46:16 2011 -0400 +++ b/python/tests/moving.txt Mon Jun 13 16:50:40 2011 -0400 @@ -17,6 +17,13 @@ >>> TimeInterval(10,8).length() 0.0 +>>> TimeInterval(2,5).equal(TimeInterval(2,5)) +True +>>> TimeInterval(2,5).equal(TimeInterval(2,4)) +False +>>> TimeInterval(2,5).equal(TimeInterval(5,2)) +False + >>> Point(3,4)-Point(1,7) (2.000000,-3.000000)