I have an NxM array in numpy that I would like to take the log of, and ignore entries that were negative prior to taking the log. When I take the log of negative entries, it
Use a filter():
filter()
>>> array array([ 1., 2., 3., -Inf]) >>> sum(filter(lambda x: x != float('-inf'), array)) 6.0