Skip to content

Commit

Permalink
Merge pull request #9 from atsoroka/master
Browse files Browse the repository at this point in the history
Value Error Check (from Yamini)
  • Loading branch information
atsoroka committed Oct 31, 2016
2 parents d1da56a + 4b3f463 commit ce48486
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 28 deletions.
31 changes: 31 additions & 0 deletions timeseries/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,37 @@ def test_bool_false():
assert bool(ts) == False


'''
Functions Being Tested: add
Summary: Value Error on Add
'''
def test_add_valueError():
ts = TimeSeries([1,2,3,4],[100,101,102,103])
ts2 = TimeSeries([1,2,3,4,5],[200,202,204,206,207])
with raises(ValueError):
ts + ts2

'''
Functions Being Tested: sub
Summary: Value Error on Sub
'''
def test_sub_valueError():
ts = TimeSeries([1,2,3,4],[100,101,102,103])
ts2 = TimeSeries([1,2,3,4,5],[200,202,204,206,207])
with raises(ValueError):
ts - ts2

'''
Functions Being Tested: mult
Summary: Value Error on Mult
'''
def test_mult_valueError():
ts = TimeSeries([1,2,3,4],[100,101,102,103])
ts2 = TimeSeries([1,2,3,4,5],[200,202,204,206,207])
with raises(ValueError):
ts * ts2


### Start of ArrayTimeSeries Tests###

'''
Expand Down
29 changes: 2 additions & 27 deletions timeseries/testmore_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,8 @@
import random


'''
Functions Being Tested: add
Summary: Value Error on Add
'''
def test_add_valueError():
ts = TimeSeries([1,2,3,4],[100,101,102,103])
ts2 = TimeSeries([1,2,3,4,5],[200,202,204,206,207])
with raises(ValueError):
ts + ts2

'''
Functions Being Tested: sub
Summary: Value Error on Sub
'''
def test_sub_valueError():
ts = TimeSeries([1,2,3,4],[100,101,102,103])
ts2 = TimeSeries([1,2,3,4,5],[200,202,204,206,207])
with raises(ValueError):
ts - ts2

'''
Functions Being Tested: mult
Summary: Value Error on Mult
'''
def test_mult_valueError():
ts = TimeSeries([1,2,3,4],[100,101,102,103])
ts2 = TimeSeries([1,2,3,4,5],[200,202,204,206,207])
with raises(ValueError):
ts * ts2

##### ArrayTimeSeries Tests ####

2 changes: 1 addition & 1 deletion timeseries/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def __bool__(self):
def _check_time_values(function):
def _check_time_values_helper(self , rhs):
try:
if not all(t1 == t2 for t1, t2 in zip(self._times, rhs._times)):
if len(self._times)!=len(rhs._times) or not all(t1 == t2 for t1, t2 in zip(self._times, rhs._times)):
raise ValueError(str(self)+' and '+str(rhs)+' must have the same points')
return function(self,rhs)
except AttributeError:
Expand Down

0 comments on commit ce48486

Please sign in to comment.