Skip to content

Commit

Permalink
[Doc&Fix] Fix compatibility with isort and black and refine install_s…
Browse files Browse the repository at this point in the history
…etup and graphcast doc (PaddlePaddle#934)

* update develop mkdocs

* allow alias for mike

* add pymesh test notation for py310 and fix isort conflict with black

* use warning instead of assert for duplicated metric name

* fix amgnet for precision promotion is deprecated between int32/64
  • Loading branch information
HydrogenSulfate authored Jun 27, 2024
1 parent 2eb2639 commit 45fcb52
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: 5.11.5
hooks:
- id: isort
args: ["--multi-line=7", "--sl"]
args: ["--multi-line=7", "--sl", "--profile", "black", "--filter-files"]

- repo: https://github.com/psf/black
rev: 22.3.0
Expand Down
3 changes: 1 addition & 2 deletions docs/zh/examples/graphcast.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
=== "模型评估命令"

``` sh

# linux
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/graphcast/dataset.zip
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/graphcast/dataset-step12.zip
Expand Down Expand Up @@ -266,4 +265,4 @@ examples/graphcast/graphcast.py

## 6. 参考文献

- [GraphCast: Learning skillful medium-range global weather forecasting](https://doi.org/10.1080/09540091.2022.2131737)
- [GraphCast: Learning skillful medium-range global weather forecasting](https://arxiv.org/abs/2212.12794)
2 changes: 2 additions & 0 deletions docs/zh/install_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ pybind11、pysdf、PyMesh 四个依赖库(上述**1.1 从 docker 镜像启动*
手动找到并删除这些空文件夹,再执行 `git submodule update --init --recursive --progress`
令即可恢复这些空文件夹至正常含有文件的状态,此时再继续执行剩余安装命令即可。

3. 由于自测工具 nose 未适配 Python>=3.10,因此执行 `pymesh.test()` 会报错,**不影响 pymesh 正常使用**
## 2. 验证安装
- 执行以下代码,验证安装的 PaddleScience 基础功能是否正常。
Expand Down
2 changes: 1 addition & 1 deletion examples/pipe/poiseuille_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def forward(self, output_dict, label_dict):
eval_cfg,
ppsci.loss.MSELoss("mean"),
{"u": lambda out: out["u"]},
{"Cross_section_velocity_profile_MAE": KL_divergence()},
{"KL_divergence": KL_divergence()},
name="KL_divergence",
)
validator = {
Expand Down
4 changes: 2 additions & 2 deletions ppsci/arch/amgnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def StAS(
index_E = sp_x.indices()
value_E = sp_x.values()

return index_E, value_E
return index_E.astype("int64"), value_E


def FillZeros(
Expand Down Expand Up @@ -194,7 +194,7 @@ def FillZeros(
index_E = sp_x.indices()
value_E = sp_x.values()

return index_E, value_E
return index_E.astype("int64"), value_E


def remove_self_loops(
Expand Down
19 changes: 11 additions & 8 deletions ppsci/solver/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from paddle import io

from ppsci.solver import printer
from ppsci.utils import logger
from ppsci.utils import misc

if TYPE_CHECKING:
Expand Down Expand Up @@ -167,10 +168,11 @@ def _eval_by_dataset(
for metric_name, metric_func in _validator.metric.items():
# NOTE: compute metric with entire output and label
metric_dict = metric_func(all_output, all_label)
assert metric_name not in metric_dict_group, (
f"Metric name({metric_name}) already exists, please ensure all metric "
"names are unique over all validators."
)
if metric_name in metric_dict_group:
logger.warning(
f"Metric name({metric_name}) already exists, please ensure "
"all metric names are unique over all validators."
)
metric_dict_group[metric_name] = {
k: float(v) for k, v in metric_dict.items()
}
Expand Down Expand Up @@ -254,10 +256,11 @@ def _eval_by_batch(

# collect batch metric
for metric_name, metric_func in _validator.metric.items():
assert metric_name not in metric_dict_group, (
f"Metric name({metric_name}) already exists, please ensure all metric "
"names are unique over all validators."
)
if metric_name in metric_dict_group:
logger.warning(
f"Metric name({metric_name}) already exists, please ensure "
"all metric names are unique over all validators."
)
metric_dict_group[metric_name] = misc.Prettydefaultdict(list)
metric_dict = metric_func(output_dict, label_dict)
for var_name, metric_value in metric_dict.items():
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ version_scheme = "post-release"

[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }

[tool.isort]
profile = "black"

0 comments on commit 45fcb52

Please sign in to comment.