def test_calc_total_error(): stat = numpy.array([1, 2]) sys = numpy.array([3, 4]) assert utils.calc_total_error(None, None) is None assert (utils.calc_total_error(stat, None) == stat).all() assert (utils.calc_total_error(None, sys) == sys).all() # Unlike the above tests, only look for equivalence within # a tolerance, since the numbers are manipulated rather than # copied in this case (although the equation should be the same # so the old approach of using equality should actually be okay # here). ans = numpy.sqrt(stat * stat + sys * sys) assert utils.calc_total_error(stat, sys) == pytest.approx(ans)
def test_calc_total_error(self): stat = numpy.array([1, 2]) sys = numpy.array([3, 4]) self.assertEqual(utils.calc_total_error(None, None), None) assert_equal(utils.calc_total_error(stat, None), stat) assert_equal(utils.calc_total_error(None, sys), sys) # Unlike the above tests, only look for equivalence within # a tolerance, since the numbers are manipulated rather than # copied in this case (although the equation should be the same # so the old approach of using equality should actually be okay # here). ans = numpy.sqrt(stat * stat + sys * sys) assert_allclose(utils.calc_total_error(stat, sys), ans)
def get_error(self, filter=False, staterrfunc=None): """Return the total error on the dependent variable. Parameters ---------- filter : bool, optional Should the filter attached to the data set be applied to the return value or not. The default is `False`. staterrfunc : function If no statistical error has been set, the errors will be calculated by applying this function to the dependent axis of the data set. Returns ------- axis : array or `None` The error for each data point, formed by adding the statistical and systematic errors in quadrature. See Also -------- get_dep : Return the independent axis of a data set. get_staterror : Return the statistical errors on the dependent axis of a data set. get_syserror : Return the systematic errors on the dependent axis of a data set. """ return calc_total_error(self.get_staterror(filter, staterrfunc), self.get_syserror(filter))
def get_error(self, filter=False, staterrfunc=None): "Return total error in dependent variable" return calc_total_error(self.get_staterror(filter, staterrfunc), self.get_syserror(filter))