#NEWLINE# def test_list_of_dicts_with_missing_to_numpy( ) : #NEWLINE# #INDENT# data = [ { #NEWLINE# #INDENT# 'name' : 'Alice' , #NEWLINE# 'amount' : 100 , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'Bob' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'amount' : 200 , #NEWLINE# #UNINDENT# } ] #NEWLINE# result = convert ( np . ndarray , data ) #NEWLINE# assert ( result . dtype . names == ( 'amount' , 'name' ) ) #NEWLINE# expected = np . array ( [ ( 100.0 , 'Alice' ) , ( np . nan , 'Bob' ) , ( 200.0 , None ) ] , dtype = [ ( 'amount' , 'float64' ) , ( 'name' , 'O' ) ] ) #NEWLINE# assert np . all ( ( ( result == expected ) | ( ( result != result ) & ( expected != expected ) ) ) )