Function to determine if two numbers are nearly equal when rounded to n significant decimal digits

前端 未结 11 1891

I have been asked to test a library provided by a 3rd party. The library is known to be accurate to n significant figures. Any less-significant errors can safely be

11条回答
  •  忘掉有多难
    2020-12-03 02:52

    I have been asked to test a library provided by a 3rd party

    If you are using the default Python unittest framework, you can use assertAlmostEqual

    self.assertAlmostEqual(a, b, places=5)
    

提交回复
热议问题