#NEWLINE# def test_getitem( self ) : #NEWLINE# #INDENT# orig = pd . Series ( [ 1 , np . nan , np . nan , 3 , np . nan ] ) #NEWLINE# sparse = orig . to_sparse ( ) #NEWLINE# self . assertEqual ( sparse [ 0 ] , 1 ) #NEWLINE# self . assertTrue ( np . isnan ( sparse [ 1 ] ) ) #NEWLINE# self . assertEqual ( sparse [ 3 ] , 3 ) #NEWLINE# result = sparse [ [ 1 , 3 , 4 ] ] #NEWLINE# exp = orig [ [ 1 , 3 , 4 ] ] . to_sparse ( ) #NEWLINE# tm . assert_sp_series_equal ( result , exp ) #NEWLINE# result = sparse [ ( ( orig % 2 ) == 1 ) ] #NEWLINE# exp = orig [ ( ( orig % 2 ) == 1 ) ] . to_sparse ( ) #NEWLINE# tm . assert_sp_series_equal ( result , exp ) #NEWLINE# result = sparse [ ( ( sparse % 2 ) == 1 ) ] #NEWLINE# exp = orig [ ( ( orig % 2 ) == 1 ) ] . to_sparse ( ) #NEWLINE# tm . assert_sp_series_equal ( result , exp )