1
1
import re
2
2
3
3
__package__ = 'python-intervals'
4
- __version__ = '1.4 .0'
4
+ __version__ = '1.5 .0'
5
5
__licence__ = 'LGPL3'
6
6
__author__ = 'Alexandre Decan'
7
7
__url__ = 'https://github.com/AlexandreDecan/python-intervals'
@@ -488,7 +488,7 @@ class Interval:
488
488
This class represents an interval.
489
489
490
490
An interval is an (automatically simplified) union of atomic intervals.
491
- It can be created either by passing atomic intervals, or by using one of the helpers
491
+ It can be created either by passing ( atomic) intervals, or by using one of the helpers
492
492
provided in this module (open(..), closed(..), etc).
493
493
494
494
Unless explicitly specified, all operations on an Interval instance return Interval instances.
@@ -498,15 +498,20 @@ class Interval:
498
498
499
499
def __init__ (self , * intervals ):
500
500
"""
501
- Create an interval from a list of atomic intervals.
501
+ Create an interval from a list of ( atomic or not) intervals.
502
502
503
- :param intervals: a list of atomic intervals.
503
+ :param intervals: a list of ( atomic or not) intervals.
504
504
"""
505
505
self ._intervals = list ()
506
506
507
507
for interval in intervals :
508
- if not interval .is_empty ():
509
- self ._intervals .append (interval )
508
+ if isinstance (interval , Interval ):
509
+ self ._intervals .extend (interval )
510
+ elif isinstance (interval , AtomicInterval ):
511
+ if not interval .is_empty ():
512
+ self ._intervals .append (interval )
513
+ else :
514
+ raise TypeError ('Parameters must be Interval or AtomicInterval instances' )
510
515
511
516
if len (self ._intervals ) == 0 :
512
517
# So we have at least one (empty) interval
0 commit comments