NumPy | spacing method
Start your free 7-days trial now!
spacing(~) method returns the difference between the next representable adjacent number.
The input array.
Numpy array |
Instead of creating a new array, you can place the computed result into the array specified by out.
Values that are flagged as False will be ignored, that is, their original value will be uninitialized. If you specified the out parameter, the behavior is slightly different - the original value will be kept intact. Since this is a source of confusion for many, check examples below.
a is a scalar, then a scalar is returned. Otherwise, a Numpy array of float is returned.
Here's an example:
5 + np.spacing(5)5.000000000000001
Here, the next smallest number that can be represented in Numpy is what is shown in as the output.