pybird.utils module
- pybird.utils.diff_all(f, x, max_order=4, epsilon=0.002)[source]
Computes all derivatives of a function f: ℝⁿ → ℝᵐ at point x up to
max_order
using central finite differences with memoized evaluation reuse.- Parameters:
f – callable, ℝⁿ → ℝᵐ
x – 1D array of shape (n,)
max_order – int, in [0, 4]; highest derivative order to compute
epsilon – scalar or array of shape (n,); finite difference step size
- Returns:
- [0] → f(x) of shape (m,)
[1] → Jacobian of shape (m, n) [2] → Hessian of shape (m, n, n) [3] → 3rd-order tensor of shape (m, n, n, n) [4] → 4th-order tensor of shape (m, n, n, n, n)
- For example, if max_order = 2, the return value is:
[f(x), Jacobian, Hessian]
- Return type:
List of derivatives up to
max_order
, where each element is
- pybird.utils.get_data_path()[source]
Get the path to the emulator data directory, works for both development and PyPI installation.
- Returns:
Path to the emulator data directory
- Return type:
Path
- pybird.utils.reshape_bird(array, L)[source]
Reshape 1D concatenated array back to the original arrays (P11l, Pctl, Ploopl).
- Parameters:
array (-) – The input array (1D for original, higher dimensions for derivatives)
L (-) – The object that contains correlator_sky objects and original shapes
- Returns:
A list of reshaped tuples (P11l, Pctl, Ploopl) for each correlator_sky