auto_uncertainties.jittable_function_wrapper ============================================ .. py:module:: auto_uncertainties.jittable_function_wrapper Attributes ---------- .. autoapisummary:: auto_uncertainties.jittable_function_wrapper.P auto_uncertainties.jittable_function_wrapper.R Functions --------- .. autoapisummary:: auto_uncertainties.jittable_function_wrapper.elementwise_value_and_grad auto_uncertainties.jittable_function_wrapper.propagate_uncertainties Module Contents --------------- .. py:data:: P .. py:data:: R .. py:function:: elementwise_value_and_grad(g) .. py:function:: propagate_uncertainties(func, implement_mode = 'same_shape') A decorator to propagate uncertainties through a given function using first-order Taylor expansion. :param func: The function through which to propagate uncertainties. This function should be compatible with JAX for automatic differentiation. :type func: callable :returns: A new function that propagates uncertainties when called with `Uncertainty` objects. :rtype: callable .. rubric:: Notes This decorator uses JAX's automatic differentiation to compute gradients, which are then used to propagate uncertainties. The function being decorated should be compatible with JAX, meaning it should use JAX-compatible operations. .. rubric:: Examples >>> import numpy as np >>> import jax.numpy as jnp >>> from auto_uncertainties import Uncertainty, propagate_uncertainties >>> @propagate_uncertainties ... def my_function(x, y): ... return x * jnp.sin(y) >>> x = Uncertainty(2.0, 0.1) # Value 2.0 with uncertainty 0.1 >>> y = Uncertainty(np.pi / 4, 0.01) # Value pi/4 with uncertainty 0.01 >>> result = my_function(x, y)