From ea015abac69395211704291af419a411d528b08f Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 15 Oct 2024 07:44:19 +0200 Subject: [PATCH] More informative `NumpyIsCloseDerivativeCheck.__call__.df` (#51) * Fixes different dtypes for expected and actual values, closes #38 * Adds extra columns for relative and absolute error --- fiddy/derivative_check.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fiddy/derivative_check.py b/fiddy/derivative_check.py index 7f96d59..579f924 100644 --- a/fiddy/derivative_check.py +++ b/fiddy/derivative_check.py @@ -47,6 +47,8 @@ def df(self): df = pd.DataFrame(self.directional_derivative_check_results) # FIXME string literal df.set_index("direction_id", inplace=True) + df["abs_diff"] = np.abs(df["expectation"] - df["test"]) + df["rel_diff"] = df["abs_diff"] / np.abs(df["expectation"]) return df @@ -98,7 +100,7 @@ def method(self, *args, **kwargs): for direction_index, directional_derivative in enumerate( self.derivative.directional_derivatives ): - test_value = directional_derivative.value + test_value = np.asarray(directional_derivative.value) expected_value = [] for output_index in np.ndindex(self.output_indices): @@ -112,7 +114,6 @@ def method(self, *args, **kwargs): *args, **kwargs, ) - directional_derivative_check_result = ( DirectionalDerivativeCheckResult( direction_id=directional_derivative.id,