error_solver.solvers.ErrorSolver¶
-
class
error_solver.solvers.
ErrorSolver
(equations, names={}, combos={}, tol=0.01)[source]¶ A class for solving systems of equations for their propagation errors based on their equation strings.
Parameters: - equations : list
A list of equation strings or string convertible objects.
- names : dict
A dictionary of variable name replacements.
- combos : dict
A dictionary of equation combinations.
- tol : float
The tolerance used for verifying that values satisfy equations.
Examples
# error_solver_ex1.py from error_solver import ErrorSolver # Define the equations EQUATIONS = [ 'A = pi * r**2', 'V = A * h' ] # Solve the equations by some means and assemble the values in a dictionary values = { 'h': 12, 'r': 5, 'A': 78.54, 'V': 942.48 } # Define the known error tolerances errors = { 'h': 0.05, 'r': 0.05 } solver = ErrorSolver(EQUATIONS) solver.solve(values, errors) # value error pct_error is_calc # var # A 78.539816 1.570796 2.000000 True # V 942.477796 22.776547 2.416667 True # h 12.000000 0.050000 0.416667 False # r 5.000000 0.050000 1.000000 False
Methods
check
(self, values, errors[, combo])Checks that the input parameters are correct to carry out a solution. equation_vars
(self[, combo])Returns a set of all variables in the equations. from_file
(path, \*\*kwargs)Creates a new object from a specified Error Solver file. get_equations
(self[, combo])Returns a list of equations for the specified combination. get_partials
(self[, combo])Returns a list of partial derivatives for the specified combination. jacobian
(self, values, errors[, combo])Returns the Jacobian matrix for the system of equations. python_str
(self)Returns a Python module string for the equations and partial derivatives assigned to the object. set_equations
(self, equations)Parses the input equations to sympy expressions and sets them to the object. set_partials
(self)Calculates the partial derivatives for the equations assigned to the object. solve
(self, values, errors[, const, combo, …])Solves for the propagation errors of the system of equations and returns a Data Frame of the results. used_vars
(self, values, errors[, combo])Returns a lists of (1) variables present in both the equations and input values dictionary and (2) variables present in both the equations and input errors dictionary. write_python
(self, path)Writes a Python module with the equations and partial derivatives assigned to the object.