From a11794e54b83ff7b6a5562feb8d2a24632a746e3 Mon Sep 17 00:00:00 2001 From: Ryuichi Arafune Date: Wed, 22 Nov 2023 12:45:22 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20=20remove=20function:=20propagat?= =?UTF-8?q?e=5Fstatistical=5Ferror=20&=20derivative?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arpes/plotting/spin.py | 4 ---- arpes/utilities/math.py | 35 +---------------------------------- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/arpes/plotting/spin.py b/arpes/plotting/spin.py index 7e21bbd5..e9451045 100644 --- a/arpes/plotting/spin.py +++ b/arpes/plotting/spin.py @@ -16,7 +16,6 @@ from arpes.analysis.statistics import mean_and_deviation from arpes.bootstrap import bootstrap from arpes.provenance import save_plot_provenance -from arpes.utilities.math import polarization, propagate_statistical_error from .tof import scatter_with_std from .utils import label_for_dim, path_for_plot, polarization_colorbar, savefig @@ -35,9 +34,6 @@ ) -test_polarization = propagate_statistical_error(polarization) - - @save_plot_provenance def spin_colored_spectrum( spin_dr: xr.Dataset, diff --git a/arpes/utilities/math.py b/arpes/utilities/math.py index 73fb808e..97e16d20 100644 --- a/arpes/utilities/math.py +++ b/arpes/utilities/math.py @@ -2,7 +2,7 @@ from __future__ import annotations import itertools -from collections.abc import Callable, Iterable +from collections.abc import Iterable from typing import TYPE_CHECKING import numpy as np @@ -16,44 +16,11 @@ from numpy.typing import NDArray -def derivative(f: Callable[..., float], arg_idx: int = 0) -> float: - """Defines a simple midpoint derivative.""" - - def d(*args: Incomplete): - args = list(args) - ref_arg = args[arg_idx] - d = ref_arg / 100 - args[arg_idx] = ref_arg + d - high = f(*args) - args[arg_idx] = ref_arg - d - low = f(*args) - return (high - low) / (2 * d) - - return d - - def polarization(up: NDArray[np.float_], down: NDArray[np.float_]) -> NDArray[np.float_]: """The equivalent normalized difference for a two component signal.""" return (up - down) / (up + down) -def propagate_statistical_error(f): - """To compute a function which propagates statistical error. - - It Uses numerical derivatives and sampling. - """ - - def compute_propagated_error(*args): - running_sum = 0 - for i, arg in enumerate(args): - df_darg_i = derivative(f, i) - running_sum += df_darg_i(*args) ** 2 * arg - - return np.sqrt(running_sum) - - return compute_propagated_error - - def shift_by( arr: NDArray[np.float_], value: xr.DataArray | NDArray[np.float_],