Skip to content

Commit 45fcb52

Browse files
[Doc&Fix] Fix compatibility with isort and black and refine install_setup and graphcast doc (#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
1 parent 2eb2639 commit 45fcb52

File tree

7 files changed

+21
-14
lines changed

7 files changed

+21
-14
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
rev: 5.11.5
44
hooks:
55
- id: isort
6-
args: ["--multi-line=7", "--sl"]
6+
args: ["--multi-line=7", "--sl", "--profile", "black", "--filter-files"]
77

88
- repo: https://github.com/psf/black
99
rev: 22.3.0

docs/zh/examples/graphcast.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
=== "模型评估命令"
44

55
``` sh
6-
76
# linux
87
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/graphcast/dataset.zip
98
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/datasets/graphcast/dataset-step12.zip
@@ -266,4 +265,4 @@ examples/graphcast/graphcast.py
266265

267266
## 6. 参考文献
268267

269-
- [GraphCast: Learning skillful medium-range global weather forecasting](https://doi.org/10.1080/09540091.2022.2131737)
268+
- [GraphCast: Learning skillful medium-range global weather forecasting](https://arxiv.org/abs/2212.12794)

docs/zh/install_setup.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ pybind11、pysdf、PyMesh 四个依赖库(上述**1.1 从 docker 镜像启动*
189189
手动找到并删除这些空文件夹,再执行 `git submodule update --init --recursive --progress`
190190
令即可恢复这些空文件夹至正常含有文件的状态,此时再继续执行剩余安装命令即可。
191191

192+
3. 由于自测工具 nose 未适配 Python>=3.10,因此执行 `pymesh.test()` 会报错,**不影响 pymesh 正常使用**
193+
192194
## 2. 验证安装
193195
194196
- 执行以下代码,验证安装的 PaddleScience 基础功能是否正常。

examples/pipe/poiseuille_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def forward(self, output_dict, label_dict):
324324
eval_cfg,
325325
ppsci.loss.MSELoss("mean"),
326326
{"u": lambda out: out["u"]},
327-
{"Cross_section_velocity_profile_MAE": KL_divergence()},
327+
{"KL_divergence": KL_divergence()},
328328
name="KL_divergence",
329329
)
330330
validator = {

ppsci/arch/amgnet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def StAS(
161161
index_E = sp_x.indices()
162162
value_E = sp_x.values()
163163

164-
return index_E, value_E
164+
return index_E.astype("int64"), value_E
165165

166166

167167
def FillZeros(
@@ -194,7 +194,7 @@ def FillZeros(
194194
index_E = sp_x.indices()
195195
value_E = sp_x.values()
196196

197-
return index_E, value_E
197+
return index_E.astype("int64"), value_E
198198

199199

200200
def remove_self_loops(

ppsci/solver/eval.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from paddle import io
2626

2727
from ppsci.solver import printer
28+
from ppsci.utils import logger
2829
from ppsci.utils import misc
2930

3031
if TYPE_CHECKING:
@@ -167,10 +168,11 @@ def _eval_by_dataset(
167168
for metric_name, metric_func in _validator.metric.items():
168169
# NOTE: compute metric with entire output and label
169170
metric_dict = metric_func(all_output, all_label)
170-
assert metric_name not in metric_dict_group, (
171-
f"Metric name({metric_name}) already exists, please ensure all metric "
172-
"names are unique over all validators."
173-
)
171+
if metric_name in metric_dict_group:
172+
logger.warning(
173+
f"Metric name({metric_name}) already exists, please ensure "
174+
"all metric names are unique over all validators."
175+
)
174176
metric_dict_group[metric_name] = {
175177
k: float(v) for k, v in metric_dict.items()
176178
}
@@ -254,10 +256,11 @@ def _eval_by_batch(
254256

255257
# collect batch metric
256258
for metric_name, metric_func in _validator.metric.items():
257-
assert metric_name not in metric_dict_group, (
258-
f"Metric name({metric_name}) already exists, please ensure all metric "
259-
"names are unique over all validators."
260-
)
259+
if metric_name in metric_dict_group:
260+
logger.warning(
261+
f"Metric name({metric_name}) already exists, please ensure "
262+
"all metric names are unique over all validators."
263+
)
261264
metric_dict_group[metric_name] = misc.Prettydefaultdict(list)
262265
metric_dict = metric_func(output_dict, label_dict)
263266
for var_name, metric_value in metric_dict.items():

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ version_scheme = "post-release"
6464

6565
[tool.setuptools.dynamic]
6666
dependencies = { file = ["requirements.txt"] }
67+
68+
[tool.isort]
69+
profile = "black"

0 commit comments

Comments
 (0)