reverse clipping in numpy

This is the place for queries that don't fit in any of the other categories.

reverse clipping in numpy

Postby soul » Thu Sep 15, 2016 7:52 pm


I have a numpy float matrix and I want to set all values within this matrix to zero which absolute value is lower than a given threshold.

set x = 0 if -threshold < x < threshold.

An easy solution would be to do a loop over all elements in this matrix, but this is time consuming. numpy.clip is very fast, but clipping values higher than a max threshold or lower than a min threshold. Are there any better ways than looping over all values?

Last edited by micseydel on Thu Sep 15, 2016 7:53 pm, edited 1 time in total.
Reason: Initial post lock.
Posts: 1
Joined: Thu Sep 15, 2016 7:45 pm

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 10 guests