#NEWLINE# def test_measure( ) : #NEWLINE# #INDENT# a = Symbol ( 'a' , real = True ) #NEWLINE# assert ( Interval ( 1 , 3 ) . measure == 2 ) #NEWLINE# assert ( Interval ( 0 , a ) . measure == a ) #NEWLINE# assert ( Interval ( 1 , a ) . measure == ( a - 1 ) ) #NEWLINE# assert ( Union ( Interval ( 1 , 2 ) , Interval ( 3 , 4 ) ) . measure == 2 ) #NEWLINE# assert ( Union ( Interval ( 1 , 2 ) , Interval ( 3 , 4 ) , FiniteSet ( 5 , 6 , 7 ) ) . measure == 2 ) #NEWLINE# assert ( FiniteSet ( 1 , 2 , oo , a , ( - oo ) , ( - 5 ) ) . measure == 0 ) #NEWLINE# assert ( S . EmptySet . measure == 0 ) #NEWLINE# square = ( Interval ( 0 , 10 ) * Interval ( 0 , 10 ) ) #NEWLINE# offsetsquare = ( Interval ( 5 , 15 ) * Interval ( 5 , 15 ) ) #NEWLINE# band = ( Interval ( ( - oo ) , oo ) * Interval ( 2 , 4 ) ) #NEWLINE# assert ( square . measure == offsetsquare . measure == 100 ) #NEWLINE# assert ( ( square + offsetsquare ) . measure == 175 ) #NEWLINE# assert ( ( square - offsetsquare ) . measure == 75 ) #NEWLINE# assert ( ( square * FiniteSet ( 1 , 2 , 3 ) ) . measure == 0 ) #NEWLINE# assert ( square . intersect ( band ) . measure == 20 ) #NEWLINE# assert ( ( square + band ) . measure == oo ) #NEWLINE# assert ( ( a * FiniteSet ( 1 , 2 , 3 ) ) . measure == nan )