Skip to content

Commit

Permalink
Merge branch 'develop' into update/subrepos
Browse files Browse the repository at this point in the history
  • Loading branch information
fmalatino authored Sep 13, 2024
2 parents b87b0cb + 4ff66a9 commit 3a9852c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions ndsl/stencils/corners.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ def fill_corners_dgrid_defn(
with computation(PARALLEL), interval(...):
# this line of code is used to fix the missing symbol crash due to the node visitor depth limitation
acoef = mysign
x_out = x_out
# sw corner
with horizontal(region[i_start - 1, j_start - 1]):
x_out = mysign * y_in[0, 1, 0]
Expand Down
2 changes: 2 additions & 0 deletions ndsl/stencils/testing/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ def make_storage_data_input_vars(self, inputs, storage_vars=None):
for p in self.in_vars["parameters"]:
if type(inputs_in[p]) in [np.int64, np.int32]:
inputs_out[p] = int(inputs_in[p])
elif type(inputs_in[p]) is bool:
inputs_out[p] == inputs_in[p]
else:
inputs_out[p] = Float(inputs_in[p])
for d, info in storage_vars.items():
Expand Down
11 changes: 6 additions & 5 deletions ndsl/testing/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,23 @@ def __init__(
):
super().__init__(reference_values, computed_values)
self.eps = eps
self._calculated_metric = np.empty_like(self.references)
self.success = self._compute_errors(
ignore_near_zero_errors,
near_zero,
)
self.check = np.all(self.success)
self._calculated_metric = np.empty_like(self.references)

def _compute_errors(
self,
ignore_near_zero_errors,
near_zero,
) -> npt.NDArray[np.bool_]:
if self.references.dtype in (np.float64, np.int64, np.float32, np.int32):
denom = np.abs(self.references) + np.abs(self.computed)
denom = self.references
denom[self.references == 0] = self.computed[self.references == 0]
self._calculated_metric = np.asarray(
2.0 * np.abs(self.computed - self.references) / denom
np.abs((self.computed - self.references) / denom)
)
self._calculated_metric[denom == 0] = 0.0
elif self.references.dtype in (np.bool_, bool):
Expand Down Expand Up @@ -123,7 +124,7 @@ def __repr__(self) -> str:
f"{reference_failures[b]} {abs_errs[-1]:.3e} {metric_err:.3e}"
)

if np.isnan(metric_err) or (metric_err > worst_metric_err):
if np.isnan(metric_err) or (abs(metric_err) > abs(worst_metric_err)):
worst_metric_err = metric_err
worst_full_idx = full_index
worst_abs_err = abs_errs[-1]
Expand Down Expand Up @@ -249,7 +250,7 @@ def __repr__(self) -> str:
f"All failures ({bad_indices_count}/{full_count}) ({failures_pct}%),\n",
f"Index Computed Reference "
f"Absolute E(<{self.absolute_eps:.2e}) "
f"Relative E(<{self.relative_fraction*100:.2e}%) "
f"Relative E(<{self.relative_fraction * 100:.2e}%) "
f"ULP E(<{self.ulp_threshold})",
]
# Summary and worst result
Expand Down

0 comments on commit 3a9852c

Please sign in to comment.