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