Skip to content

Commit

Permalink
More informative NumpyIsCloseDerivativeCheck.__call__.df
Browse files Browse the repository at this point in the history
* Fixes different dtypes for expected and actual values, closes #38
* Adds extra columns for relative and absolute error
  • Loading branch information
dweindl committed Oct 8, 2024
1 parent 6aea82e commit d409dc9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fiddy/derivative_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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):
Expand All @@ -112,7 +114,6 @@ def method(self, *args, **kwargs):
*args,
**kwargs,
)

directional_derivative_check_result = (
DirectionalDerivativeCheckResult(
direction_id=directional_derivative.id,
Expand Down

0 comments on commit d409dc9

Please sign in to comment.