@@ -199,19 +199,20 @@ def test_invert_ranges(self):
199199 self .assertEqual (list (ihm .util ._invert_ranges (inrng , 4 , start = 1 )),
200200 [(1 , 4 )])
201201
202- def test_pred_ranges (self ):
203- """Test _pred_ranges function"""
204- inrng = [(2 , 3 )]
205- self .assertEqual (list (ihm .util ._pred_ranges (inrng , 4 )),
206- [(1 , 1 , False ), (2 , 3 , True ), (4 , 4 , False )])
207- inrng = [(1 , 1 ), (4 , 7 )]
208- self .assertEqual (list (ihm .util ._pred_ranges (inrng , 8 )),
209- [(1 , 1 , True ), (2 , 3 , False ), (4 , 7 , True ),
210- (8 , 8 , False )])
211- inrng = [(2 , 2 ), (4 , 7 )]
212- self .assertEqual (list (ihm .util ._pred_ranges (inrng , 7 )),
213- [(1 , 1 , False ), (2 , 2 , True ), (3 , 3 , False ),
214- (4 , 7 , True )])
202+ def test_pred_id_ranges (self ):
203+ """Test _pred_id_ranges function"""
204+ inrng = [(2 , 3 , 'a' )]
205+ self .assertEqual (list (ihm .util ._pred_id_ranges (inrng , 4 )),
206+ [(1 , 1 , False , None ), (2 , 3 , True , 'a' ),
207+ (4 , 4 , False , None )])
208+ inrng = [(1 , 1 , 'a' ), (4 , 7 , 'b' )]
209+ self .assertEqual (list (ihm .util ._pred_id_ranges (inrng , 8 )),
210+ [(1 , 1 , True , 'a' ), (2 , 3 , False , None ),
211+ (4 , 7 , True , 'b' ), (8 , 8 , False , None )])
212+ inrng = [(2 , 2 , 'a' ), (4 , 7 , 'b' )]
213+ self .assertEqual (list (ihm .util ._pred_id_ranges (inrng , 7 )),
214+ [(1 , 1 , False , None ), (2 , 2 , True , 'a' ),
215+ (3 , 3 , False , None ), (4 , 7 , True , 'b' )])
215216
216217 def test_combine_ranges (self ):
217218 """Test _combine_ranges function"""
@@ -227,6 +228,36 @@ def test_combine_ranges(self):
227228 [(1 , 2 ), (4 , 4 )])
228229 self .assertEqual (list (ihm .util ._combine_ranges ([])), [])
229230
231+ def test_sorted_nonoverlap_id_ranges (self ):
232+ """Test _sorted_nonoverlap_id_ranges function"""
233+ inrng = [(8 , 10 , 'a' ), (1 , 2 , 'a' ), (3 , 4 , 'a' )]
234+ self .assertEqual (list (ihm .util ._sorted_nonoverlap_id_ranges (inrng )),
235+ [(1 , 4 , 'a' ), (8 , 10 , 'a' )])
236+ inrng = [(8 , 10 , 'a' ), (1 , 2 , 'a' ), (3 , 4 , 'b' )]
237+ self .assertEqual (list (ihm .util ._sorted_nonoverlap_id_ranges (inrng )),
238+ [(1 , 2 , 'a' ), (3 , 4 , 'b' ), (8 , 10 , 'a' )])
239+ inrng = [(1 , 10 , 'a' ), (3 , 4 , 'a' )]
240+ self .assertEqual (list (ihm .util ._sorted_nonoverlap_id_ranges (inrng )),
241+ [(1 , 10 , 'a' )])
242+ inrng = [(1 , 10 , 'a' ), (3 , 4 , 'b' )]
243+ self .assertEqual (list (ihm .util ._sorted_nonoverlap_id_ranges (inrng )),
244+ [(1 , 10 , 'a' ), (3 , 4 , 'b' )])
245+ self .assertEqual (list (ihm .util ._sorted_nonoverlap_id_ranges ([])), [])
246+
247+ def test_combine_id_ranges (self ):
248+ """Test _combine_id_ranges function"""
249+ inrng = [(1 , 30 , 'd' ), (1 , 50 , 'a' ), (1 , 60 , 'c' ), (2 , 40 , 'b' ),
250+ (80 , 100 , 'e' )]
251+ self .assertEqual (list (ihm .util ._combine_id_ranges (inrng )),
252+ [(1 , 1 , 'a,c,d' ), (2 , 30 , 'a,b,c,d' ),
253+ (31 , 40 , 'a,b,c' ), (41 , 50 , 'a,c' ),
254+ (51 , 60 , 'c' ), (80 , 100 , 'e' )])
255+ inrng = [(8 , 10 , 'x' ), (1 , 2 , 'y' ), (3 , 4 , 'z' ), (2 , 3 , 'z' )]
256+ self .assertEqual (list (ihm .util ._combine_id_ranges (inrng )),
257+ [(1 , 1 , 'y' ), (2 , 2 , 'y,z' ),
258+ (3 , 4 , 'z' ), (8 , 10 , 'x' )])
259+ self .assertEqual (list (ihm .util ._combine_id_ranges ([])), [])
260+
230261 def test_make_range_from_list (self ):
231262 """Test _make_range_from_list function"""
232263 rr = []
0 commit comments