NumPy clip limits array values to chosen bounds without removing positions
Limiting values to an interval is different from selecting only the values already inside it. NumPy clip replaces entries outside chosen bounds with the corresponding endpoints. Academia Master Trader presents this English lesson for readers in Libya, using constructed arrays to explain clipping, one sided limits and the effect of writing the result into the original array.
Values outside the interval become endpoints
After import numpy as np, define v = np.array([-4,2,6,13]). The call np.clip(v,0,10) returns [0,2,6,10]. Negative four becomes zero because it lies below the lower bound. Thirteen becomes ten because it exceeds the upper bound.
Two and six stay unchanged because they already lie inside the interval. A value exactly equal to either bound also remains unchanged. Clipping does not remove positions, reorder entries or shorten this vector. It changes the values that cross the supplied limits.

Clipping is not filtering or rescaling
The output still has four entries, one for every input position. Selecting only entries within the interval would instead return [2,6] for this example. That selection answers a different question because it excludes positions rather than replacing their values.
Clipping also does not proportionally rescale the entire input range into the target interval. Two stays two and six stays six. Several different values above ten would all become ten, so the clipped output alone would not reveal their original magnitudes.
Keep the source alongside the transformed result when the original values matter. Stating both bounds makes the transformation easier to interpret and avoids confusing a limit with a selection condition.
None leaves one boundary unrestricted
The call np.clip(v,0,None) returns [0,2,6,13]. Only the lower limit is applied, so thirteen remains thirteen. The call np.clip(v,None,10) returns [-4,2,6,10], applying only the upper limit.
These calls use None to indicate that no clipping should occur on that side. None is not another numeric endpoint and does not mean zero. Check which argument holds None before describing the direction of the limit.
A matrix keeps its shape with scalar bounds
For m = np.array([[-3,4],[12,7]]), the call np.clip(m,0,9) returns [[0,4],[9,7]], with shape (2,2). The same scalar bounds apply independently at every position.
By default, this call returns a result without changing m. The optional output argument can change that behaviour. Using np.clip(m,0,9,out=m) writes the clipped values into m itself. Make that choice explicit whenever later calculations will reuse the source array.
For this matrix, two entries change and two entries remain the same. Compare corresponding input and output positions rather than comparing sorted value lists. This keeps the explanation tied to the original arrangement of rows and columns.
Bound order is part of the calculation
NumPy does not check that the lower bound is smaller than the upper bound. The call np.clip(v,10,0) returns [0,0,0,0]; it does not exchange the bounds. Confirm their intended order before interpreting the output.
Continue learning with Academia Master Trader at academiamastertrader.com.br and in Aprenda. Record the bounds and whether the source is preserved beside every clipping operation.