Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Fix doctest #821

Merged
merged 11 commits into from
Mar 26, 2024
Prev Previous commit
Next Next commit
Revert "Merge branch 'pretty_eval_output' into develop"
This reverts commit 66cded1, reversing
changes made to da865dd.
  • Loading branch information
HydrogenSulfate committed Mar 25, 2024
commit 0e6dcba7231c8dbb0de40810a258acdac64bd1de
2 changes: 1 addition & 1 deletion examples/darcy/darcy2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def poisson_ref_compute_func(_in):
cfg.NPOINT_PDE + cfg.NPOINT_BC, evenly=True
)
visualizer = {
"visualize_p_ux_uy": ppsci.visualize.VisualizerVtu(
"visualize_p": ppsci.visualize.VisualizerVtu(
vis_points,
{
"p": lambda d: d["p"],
Expand Down
18 changes: 3 additions & 15 deletions ppsci/solver/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import numpy as np
import paddle
import paddle.distributed as dist
import prettytable
import sympy as sp
import visualdl as vdl
from packaging import version
Expand Down Expand Up @@ -546,21 +545,10 @@ def eval(self, epoch_id: int = 0) -> Tuple[float, Dict[str, Dict[str, float]]]:
self.eval_func = ppsci.solver.eval.eval_func

result = self.eval_func(self, epoch_id, self.log_freq)
metric_table = prettytable.PrettyTable(
["Name", "Value"],
title=f"Evaluation Metric(s){'' if epoch_id == 0 else f' at epoch {epoch_id}'}",
align="l",
metric_msg = ", ".join(
[self.eval_output_info[key].avg_info for key in self.eval_output_info]
)

loss_msg = []
for name, value in self.eval_output_info.items():
if name.startswith("loss"):
loss_msg.append(f"{name}: {value.avg_fmt}")
else:
metric_table.add_row([name, value.avg_fmt])
loss_msg = ", ".join(loss_msg)

logger.info(f"[Eval][Epoch {epoch_id}][Avg] {loss_msg}\n{metric_table}")
logger.info(f"[Eval][Epoch {epoch_id}][Avg] {metric_msg}")
self.eval_output_info.clear()

return result
Expand Down
6 changes: 0 additions & 6 deletions ppsci/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ def avg_info(self):
self.avg = float(self.avg)
return f"{self.name}: {self.avg:.5f}"

@property
def avg_fmt(self):
if isinstance(self.avg, paddle.Tensor):
self.avg = float(self.avg)
return f"{self.avg:.5e}"

@property
def total(self):
return f"{self.name}_sum: {self.sum:{self.fmt}}{self.postfix}"
Expand Down