Search code examples
pythonarraysnumpyrounding

Difference between numpy.round and numpy.around


So, I was searching for ways to round off all the numbers in a numpy array. I found 2 similar functions, numpy.round and numpy.around. Both take seemingly same arguments for a beginner like me.

So what is the difference between these two in terms of:

  • General difference
  • Speed
  • Accuracy
  • Being used in practice

Solution

  • They are the exact same function:

    def round_(a, decimals=0, out=None):
        """
        Round an array to the given number of decimals.
        Refer to `around` for full documentation.
        See Also
        --------
        around : equivalent function
        """
        return around(a, decimals=decimals, out=out)