Skip to content

Commit 5ef8e3f

Browse files
authored
Merge pull request #510 from gerlero/names
Switch preprocessing.system functions to PEP 8/`FoamCase`-like names
2 parents e04c66c + ff3e973 commit 5ef8e3f

File tree

3 files changed

+51
-8
lines changed

3 files changed

+51
-8
lines changed

foamlib/preprocessing/system.py

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,81 @@
1-
# ruff: noqa: N802, D100
1+
# ruff: noqa: D100
22
from __future__ import annotations
33

4+
import sys
45
from pathlib import Path
56

7+
if sys.version_info >= (3, 13):
8+
from warnings import deprecated
9+
else:
10+
from typing_extensions import deprecated
11+
612
from foamlib.preprocessing.of_dict import FoamDictInstruction
713

814

9-
def simulationParameters(keys: list[str]) -> FoamDictInstruction:
15+
def simulation_parameters(keys: list[str]) -> FoamDictInstruction:
1016
"""Return the FoamDictInstruction for simulationParameters."""
1117
return FoamDictInstruction(
1218
file_name=Path("system/simulationParameters"),
1319
keys=keys,
1420
)
1521

22+
"""
23+
Alias for :func:`simulation_parameters`.
24+
25+
Deprecated since version 1.3.0: use :func:`simulation_parameters` instead.
26+
"""
27+
return simulation_parameters(keys)
28+
1629

17-
def controlDict(keys: list[str]) -> FoamDictInstruction:
30+
def control_dict(keys: list[str]) -> FoamDictInstruction:
1831
"""Return the FoamDictInstruction for controlDict."""
1932
return FoamDictInstruction(
2033
file_name=Path("system/controlDict"),
2134
keys=keys,
2235
)
2336

2437

25-
def fvSchemes(keys: list[str]) -> FoamDictInstruction:
38+
@deprecated("Use 'control_dict' instead")
39+
def controlDict(keys: list[str]) -> FoamDictInstruction: # noqa: N802
40+
"""
41+
Alias for :func:`control_dict`.
42+
43+
Deprecated since version 1.3.0: use :func:`control_dict` instead.
44+
"""
45+
return control_dict(keys)
46+
47+
48+
def fv_schemes(keys: list[str]) -> FoamDictInstruction:
2649
"""Return the FoamDictInstruction for fvSchemes."""
2750
return FoamDictInstruction(
2851
file_name=Path("system/fvSchemes"),
2952
keys=keys,
3053
)
3154

3255

33-
def fvSolution(keys: list[str]) -> FoamDictInstruction:
56+
@deprecated("Use 'fv_schemes' instead")
57+
def fvSchemes(keys: list[str]) -> FoamDictInstruction: # noqa: N802
58+
"""
59+
Alias for :func:`fv_schemes`.
60+
61+
Deprecated since version 1.3.0: use :func:`fv_schemes` instead.
62+
"""
63+
return fv_schemes(keys)
64+
65+
66+
def fv_solution(keys: list[str]) -> FoamDictInstruction:
3467
"""Return the FoamDictInstruction for fvSolution."""
3568
return FoamDictInstruction(
3669
file_name=Path("system/fvSolution"),
3770
keys=keys,
3871
)
72+
73+
74+
@deprecated("Use 'fv_solution' instead")
75+
def fvSolution(keys: list[str]) -> FoamDictInstruction: # noqa: N802
76+
"""
77+
Alias for :func:`fv_solution`.
78+
79+
Deprecated since version 1.3.0: use :func:`fv_solution` instead.
80+
"""
81+
return fv_solution(keys)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies = [
3535
"numpy>=1,<3",
3636
"pyparsing>=3.1.2,<4",
3737
"rich>=13,<15",
38-
"typing-extensions>=4.4,<5; python_version<'3.12'",
38+
"typing-extensions>=4.5,<5; python_version<'3.13'",
3939
]
4040

4141
[project.optional-dependencies]

tests/test_preprocessing/test_grid_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from foamlib.preprocessing.grid_parameter_sweep import CaseParameter, GridParameter
1515
from foamlib.preprocessing.of_dict import FoamDictInstruction
1616
from foamlib.preprocessing.parameter_study import grid_generator
17-
from foamlib.preprocessing.system import simulationParameters
17+
from foamlib.preprocessing.system import simulation_parameters
1818

1919
CSV_FILE = "tests/test_preprocessing/test_parastudy.csv"
2020
OUTPUT_FOLDER = "tests/test_preprocessing/Cases/"
@@ -49,7 +49,7 @@ def test_grid_parameter() -> None:
4949
# file_name=Path("system/simulationParameters"),
5050
# keys=[f"res{i}"],
5151
# )
52-
modify_dict=[simulationParameters(keys=[f"res{i}"]) for i in range(1, 6)],
52+
modify_dict=[simulation_parameters(keys=[f"res{i}"]) for i in range(1, 6)],
5353
parameters=[
5454
CaseParameter(name="coarse", values=grid_parameters(1)),
5555
CaseParameter(name="mid", values=grid_parameters(2)),

0 commit comments

Comments
 (0)