Skip to content

Commit efaf5e4

Browse files
change list to tuple
1 parent a319e99 commit efaf5e4

File tree

8 files changed

+14
-16
lines changed

8 files changed

+14
-16
lines changed

ppsci/constraint/boundary_constraint.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ def __init__(
8585
weight_dict: Optional[Dict[str, Union[float, Callable]]] = None,
8686
name: str = "BC",
8787
):
88-
self.output_expr = output_expr
8988
self.label_dict = label_dict
9089
self.input_keys = geom.dim_keys
91-
self.output_keys = list(label_dict.keys())
90+
self.output_keys = tuple(label_dict.keys())
9291
self.output_expr = {
9392
k: v for k, v in output_expr.items() if k in self.output_keys
9493
}

ppsci/constraint/initial_constraint.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@ def __init__(
8888
weight_dict: Optional[Dict[str, Callable]] = None,
8989
name: str = "IC",
9090
):
91-
self.output_expr = output_expr
9291
self.label_dict = label_dict
9392
self.input_keys = geom.dim_keys
94-
self.output_keys = list(label_dict.keys())
93+
self.output_keys = tuple(label_dict.keys())
9594
self.output_expr = {
9695
k: v for k, v in output_expr.items() if k in self.output_keys
9796
}

ppsci/constraint/integral_constraint.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ def __init__(
8585
weight_dict: Optional[Dict[str, Callable]] = None,
8686
name: str = "IgC",
8787
):
88-
self.output_expr = output_expr
8988
self.label_dict = label_dict
9089
self.input_keys = geom.dim_keys
91-
self.output_keys = list(label_dict.keys())
90+
self.output_keys = tuple(label_dict.keys())
9291
self.output_expr = {
9392
k: v for k, v in output_expr.items() if k in self.output_keys
9493
}

ppsci/constraint/interior_constraint.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ def __init__(
8585
weight_dict: Optional[Dict[str, Union[Callable, float]]] = None,
8686
name: str = "EQ",
8787
):
88-
self.output_expr = output_expr
8988
self.label_dict = label_dict
9089
self.input_keys = geom.dim_keys
91-
self.output_keys = list(label_dict.keys())
90+
self.output_keys = tuple(label_dict.keys())
9291
self.output_expr = {
9392
k: v for k, v in output_expr.items() if k in self.output_keys
9493
}

ppsci/constraint/periodic_constraint.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ def __init__(
7272
weight_dict: Optional[Dict[str, Callable]] = None,
7373
name: str = "PeriodicBC",
7474
):
75-
self.output_expr = output_expr
7675
self.input_keys = geom.dim_keys
77-
self.output_keys = list(output_expr.keys())
76+
self.output_keys = tuple(output_expr.keys())
7877
self.output_expr = {
7978
k: v for k, v in output_expr.items() if k in self.output_keys
8079
}

ppsci/constraint/supervised_constraint.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,20 @@ def __init__(
6060
output_expr: Optional[Dict[str, Callable]] = None,
6161
name: str = "Sup",
6262
):
63-
self.output_expr = output_expr
64-
6563
# build dataset
6664
_dataset = dataset.build_dataset(dataloader_cfg["dataset"])
6765

6866
self.input_keys = _dataset.input_keys
6967
self.output_keys = (
70-
list(output_expr.keys()) if output_expr is not None else _dataset.label_keys
68+
tuple(output_expr.keys())
69+
if output_expr is not None
70+
else _dataset.label_keys
7171
)
7272

73+
self.output_expr = output_expr
7374
if self.output_expr is None:
7475
self.output_expr = {
75-
key: lambda out, k=key: out[k] for key in self.output_keys
76+
key: (lambda out, k=key: out[k]) for key in self.output_keys
7677
}
7778

7879
# construct dataloader with dataset and dataloader_cfg

ppsci/validate/geo_validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __init__(
8686
self.output_expr = output_expr
8787
self.label_dict = label_dict
8888
self.input_keys = geom.dim_keys
89-
self.output_keys = list(label_dict.keys())
89+
self.output_keys = tuple(label_dict.keys())
9090

9191
nx = dataloader_cfg["total_size"]
9292
self.num_timestamps = 1

ppsci/validate/sup_validator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ def __init__(
7575

7676
self.input_keys = _dataset.input_keys
7777
self.output_keys = (
78-
list(output_expr.keys()) if output_expr is not None else _dataset.label_keys
78+
tuple(output_expr.keys())
79+
if output_expr is not None
80+
else _dataset.label_keys
7981
)
8082

8183
if self.output_expr is None:

0 commit comments

Comments
 (0)