@@ -21,6 +21,9 @@ def test_getMissing(self):
2121 def test_get (self ):
2222 assert_true (array_equal (self .ary2 , self .images .get (1 )))
2323
24+ # keys are integers, ask for sequence
25+ assert_raises (ValueError , self .images .get , (1 , 2 ))
26+
2427 def test_getMany (self ):
2528 vals = self .images .getMany ([0 , - 1 , 1 , 0 ])
2629 assert_equals (4 , len (vals ))
@@ -29,6 +32,10 @@ def test_getMany(self):
2932 assert_true (array_equal (self .ary2 , vals [2 ]))
3033 assert_true (array_equal (self .ary1 , vals [3 ]))
3134
35+ # keys are integers, ask for sequences:
36+ assert_raises (ValueError , self .images .get , [(0 , 0 )])
37+ assert_raises (ValueError , self .images .get , [0 , (0 , 0 ), 1 , 0 ])
38+
3239 def test_getRanges (self ):
3340 vals = self .images .getRange (slice (None ))
3441 assert_equals (2 , len (vals ))
@@ -55,6 +62,9 @@ def test_getRanges(self):
5562 vals = self .images .getRange (slice (2 , 3 ))
5663 assert_equals (0 , len (vals ))
5764
65+ # keys are integers, ask for sequence
66+ assert_raises (ValueError , self .images .getRange , [slice (1 ), slice (1 )])
67+
5868 # raise exception if 'step' specified:
5969 assert_raises (ValueError , self .images .getRange , slice (1 , 2 , 2 ))
6070
@@ -108,12 +118,15 @@ def setUp(self):
108118 self .series = Data (self .sc .parallelize (self .dataLocal ), dtype = 'float32' )
109119
110120 def test_getMissing (self ):
111- assert_is_none (self .series .get (- 1 ))
121+ assert_is_none (self .series .get (( - 1 , - 1 ) ))
112122
113123 def test_get (self ):
114124 expected = self .dataLocal [1 ][1 ]
115125 assert_true (array_equal (expected , self .series .get ((0 , 1 ))))
116126
127+ assert_raises (ValueError , self .series .get , 1 ) # keys are sequences, ask for integer
128+ assert_raises (ValueError , self .series .get , (1 , 2 , 3 )) # key length mismatch
129+
117130 def test_getMany (self ):
118131 vals = self .series .getMany ([(0 , 0 ), (17 , 256 ), (1 , 0 ), (0 , 0 )])
119132 assert_equals (4 , len (vals ))
@@ -122,6 +135,9 @@ def test_getMany(self):
122135 assert_true (array_equal (self .dataLocal [2 ][1 ], vals [2 ]))
123136 assert_true (array_equal (self .dataLocal [0 ][1 ], vals [3 ]))
124137
138+ assert_raises (ValueError , self .series .getMany , [1 ]) # keys are sequences, ask for integer
139+ assert_raises (ValueError , self .series .getMany , [(0 , 0 ), 1 , (1 , 0 ), (0 , 0 )]) # asking for integer again
140+
125141 def test_getRanges (self ):
126142 vals = self .series .getRange ([slice (2 ), slice (2 )])
127143 assert_equals (4 , len (vals ))
@@ -174,6 +190,12 @@ def test_getRanges(self):
174190 vals = self .series .getRange ([slice (2 , 3 ), slice (None )])
175191 assert_equals (0 , len (vals ))
176192
193+ # keys are sequences, ask for single slice
194+ assert_raises (ValueError , self .series .getRange , slice (2 , 3 ))
195+
196+ # ask for wrong number of slices
197+ assert_raises (ValueError , self .series .getRange , [slice (2 , 3 ), slice (2 , 3 ), slice (2 , 3 )])
198+
177199 # raise exception if 'step' specified:
178200 assert_raises (ValueError , self .series .getRange , [slice (0 , 4 , 2 ), slice (2 , 3 )])
179201
0 commit comments