1 Feb 2004 18:05
question/request with Numeric compress and putmask
Vineet Jain <vineet <at> eswap.com>
2004-02-01 17:05:59 GMT
2004-02-01 17:05:59 GMT
I'm using the Numeric arrays for financial data elements. I'm interfacing with an external c library which does not support invalid elements. To get around this I maintain a separate mask array in my python class which denotes which elements are valid. I then use the compress function with the mask array to get an array with valid elements which I pass to the c function. I was then going to use the putmask to assign the returned values to their corresponding place in the original array. This obviously (after reading the documentation) is not going to work. Example: financial_data = [10, 11, 22, 33, INVALID, INVALID, 44, 55] full_return_value = INVALID+zeros(lenfinancial_data) my_mask = [1, 1, 1, 1, 0, 0, 1, 1] compressed_data = compress(financiali_data, my_mask) [10, 11, 22, 33, 44, 55] return_value = some_c_function(compressed_data) Now the problem I have is copying the values in return_value to their original place in the financial_data. I was happily going to use putmask till about an hour back when I found out that this is not going to work. What I would like to do is: putmask(full_return_value, my_mask, return_value)(Continue reading)
RSS Feed