diff --git a/errorcalc.py b/errorcalc.py index 52c6d11..db25774 100644 --- a/errorcalc.py +++ b/errorcalc.py @@ -3,7 +3,24 @@ class Error: - def __init__(self, func): + """ Perform a error estimation of given function + and corresponding errors for the variables. """ + + def __init__(self, func: callable): + """ Constructer for the Error instance. + Parameters + ---------- + func: callable + Func (e.g. a physical Law) is the function, + to which the error estimation is to be calculated. + The Arguments used in func are automatticlay extraced using + the inspect library. + + Returns + ------ + Error Instance + + """ # Get the arguments of the function arg_names = inspect.getfullargspec(func).args # Define the variables as regular Python variables @@ -21,7 +38,7 @@ def __init__(self, func): f_prime = self.f.diff(variable) self.derivatives[str(variable)] = f_prime - def substitute(self, values): + def substitute(self, values: dict): derivatives_sub = [] for variable in self.variables: # Get the variable name as a string @@ -36,7 +53,7 @@ def substitute(self, values): derivatives_sub.append(derivative_str) return " + ".join(derivatives_sub) - def latex_out(self, values): + def latex_out(self, values: dict): latex_str = "\\begin{align*}\n" latex_str += ( " &= \\Delta " @@ -72,7 +89,7 @@ def latex_out(self, values): latex_str += f" &= \\SI{{{float(result)}}}{{}}\n" latex_str += "\\end{align*}\n\n" return latex_str - def result(self, values): + def result(self, values: dict): result = sum( [ values[delta_name][0]