Solved by ptrblck in post #2 
              
              
                It shouldn’t matter, if some values are positive and others zero, since the result tensor would also contain zeros. So even if the top 10% includes zeros (if not enough positive values were found), you wouldn’t change the output, would you? 
If that’s the case, this code should work: 
# Setup
x = to…