foamlib 0.8.4__tar.gz → 0.8.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {foamlib-0.8.4 → foamlib-0.8.6}/.github/workflows/ci.yml +2 -2
- {foamlib-0.8.4 → foamlib-0.8.6}/.github/workflows/docker.yml +1 -1
- {foamlib-0.8.4 → foamlib-0.8.6}/Dockerfile +1 -1
- {foamlib-0.8.4 → foamlib-0.8.6}/PKG-INFO +1 -1
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/__init__.py +1 -1
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_files/_files.py +5 -5
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_files/_parsing.py +32 -11
- {foamlib-0.8.4 → foamlib-0.8.6}/tests/test_files/test_files.py +2 -2
- {foamlib-0.8.4 → foamlib-0.8.6}/tests/test_files/test_parsing.py +5 -1
- {foamlib-0.8.4 → foamlib-0.8.6}/.devcontainer.json +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/.dockerignore +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/.git-blame-ignore-revs +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/.github/dependabot.yml +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/.github/workflows/dockerhub-description.yml +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/.github/workflows/pypi-publish.yml +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/.gitignore +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/.readthedocs.yaml +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/LICENSE.txt +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/README.md +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/benchmark.png +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/docs/Makefile +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/docs/cases.rst +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/docs/conf.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/docs/files.rst +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/docs/index.rst +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/docs/make.bat +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/docs/ruff.toml +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_cases/__init__.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_cases/_async.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_cases/_base.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_cases/_run.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_cases/_slurm.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_cases/_subprocess.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_cases/_sync.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_cases/_util.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_files/__init__.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_files/_io.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_files/_serialization.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/_files/_types.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/foamlib/py.typed +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/logo.png +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/pyproject.toml +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/tests/__init__.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/tests/ruff.toml +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/tests/test_cases/__init__.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/tests/test_cases/test_cavity.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/tests/test_cases/test_cavity_async.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/tests/test_cases/test_flange.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/tests/test_cases/test_flange_async.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/tests/test_files/__init__.py +0 -0
- {foamlib-0.8.4 → foamlib-0.8.6}/tests/test_files/test_dumps.py +0 -0
@@ -49,11 +49,11 @@ jobs:
|
|
49
49
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
50
50
|
strategy:
|
51
51
|
matrix:
|
52
|
-
openfoam-version: [
|
52
|
+
openfoam-version: [2412, 2006, 12, 9]
|
53
53
|
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
|
54
54
|
slurm: [false]
|
55
55
|
include:
|
56
|
-
- openfoam-version:
|
56
|
+
- openfoam-version: 2412
|
57
57
|
python-version: '3.13'
|
58
58
|
slurm: true
|
59
59
|
- openfoam-version: 12
|
@@ -100,9 +100,9 @@ class FoamFile(
|
|
100
100
|
assert isinstance(ret, dict)
|
101
101
|
v = ret[k]
|
102
102
|
assert isinstance(v, dict)
|
103
|
-
ret = cast(File, v)
|
103
|
+
ret = cast("File", v)
|
104
104
|
|
105
|
-
return cast(Dict_, ret)
|
105
|
+
return cast("Dict_", ret)
|
106
106
|
|
107
107
|
@property
|
108
108
|
def version(self) -> float:
|
@@ -127,7 +127,7 @@ class FoamFile(
|
|
127
127
|
if ret not in ("ascii", "binary"):
|
128
128
|
msg = "format is not 'ascii' or 'binary'"
|
129
129
|
raise ValueError(msg)
|
130
|
-
return cast(Literal[
|
130
|
+
return cast("Literal['ascii', 'binary']", ret)
|
131
131
|
|
132
132
|
@format.setter
|
133
133
|
def format(self, value: Literal["ascii", "binary"]) -> None:
|
@@ -412,7 +412,7 @@ class FoamFieldFile(FoamFile):
|
|
412
412
|
) -> Field:
|
413
413
|
"""Alias of `self["value"]`."""
|
414
414
|
return cast(
|
415
|
-
Field,
|
415
|
+
"Field",
|
416
416
|
self["value"],
|
417
417
|
)
|
418
418
|
|
@@ -461,7 +461,7 @@ class FoamFieldFile(FoamFile):
|
|
461
461
|
self,
|
462
462
|
) -> Field:
|
463
463
|
"""Alias of `self["internalField"]`."""
|
464
|
-
return cast(Field, self["internalField"])
|
464
|
+
return cast("Field", self["internalField"])
|
465
465
|
|
466
466
|
@internal_field.setter
|
467
467
|
def internal_field(
|
@@ -16,6 +16,7 @@ else:
|
|
16
16
|
|
17
17
|
import numpy as np
|
18
18
|
from pyparsing import (
|
19
|
+
CaselessKeyword,
|
19
20
|
Combine,
|
20
21
|
Dict,
|
21
22
|
Forward,
|
@@ -157,6 +158,7 @@ def _dict_of(
|
|
157
158
|
data: ParserElement,
|
158
159
|
*,
|
159
160
|
directive: ParserElement | None = None,
|
161
|
+
data_entry: ParserElement | None = None,
|
160
162
|
located: bool = False,
|
161
163
|
) -> ParserElement:
|
162
164
|
dict_ = Forward()
|
@@ -164,7 +166,8 @@ def _dict_of(
|
|
164
166
|
keyword_entry = keyword + (dict_ | (data + Literal(";").suppress()))
|
165
167
|
|
166
168
|
if directive is not None:
|
167
|
-
|
169
|
+
assert data_entry is not None
|
170
|
+
keyword_entry |= directive + data_entry + LineEnd().suppress() # type: ignore [no-untyped-call]
|
168
171
|
|
169
172
|
if located:
|
170
173
|
keyword_entry = Located(keyword_entry)
|
@@ -183,15 +186,19 @@ def _keyword_entry_of(
|
|
183
186
|
data: ParserElement,
|
184
187
|
*,
|
185
188
|
directive: ParserElement | None = None,
|
189
|
+
data_entry: ParserElement | None = None,
|
186
190
|
located: bool = False,
|
187
191
|
) -> ParserElement:
|
188
192
|
keyword_entry = keyword + (
|
189
|
-
_dict_of(
|
193
|
+
_dict_of(
|
194
|
+
keyword, data, directive=directive, data_entry=data_entry, located=located
|
195
|
+
)
|
190
196
|
| (data + Literal(";").suppress())
|
191
197
|
)
|
192
198
|
|
193
199
|
if directive is not None:
|
194
|
-
|
200
|
+
assert data_entry is not None
|
201
|
+
keyword_entry |= directive + data_entry + LineEnd().suppress() # type: ignore [no-untyped-call]
|
195
202
|
|
196
203
|
if located:
|
197
204
|
keyword_entry = Located(keyword_entry)
|
@@ -235,11 +242,12 @@ _TENSOR = (
|
|
235
242
|
| _tensor(TensorKind.SYMM_TENSOR)
|
236
243
|
| _tensor(TensorKind.TENSOR)
|
237
244
|
)
|
238
|
-
|
239
|
-
_IDENTIFIER
|
240
|
-
Word(_IDENTCHARS, _IDENTBODYCHARS, exclude_chars="()")
|
241
|
-
+ Opt(Literal("(") + _IDENTIFIER + Literal(")"))
|
245
|
+
_PARENTHESIZED = Forward()
|
246
|
+
_IDENTIFIER = Combine(
|
247
|
+
Word(_IDENTCHARS, _IDENTBODYCHARS, exclude_chars="()") + Opt(_PARENTHESIZED)
|
242
248
|
)
|
249
|
+
_PARENTHESIZED <<= Combine(Literal("(") + (_PARENTHESIZED | _IDENTIFIER) + Literal(")"))
|
250
|
+
|
243
251
|
_DIMENSIONED = (Opt(_IDENTIFIER) + _DIMENSIONS + _TENSOR).set_parse_action(
|
244
252
|
lambda tks: Dimensioned(*reversed(tks.as_list()))
|
245
253
|
)
|
@@ -260,7 +268,16 @@ _DICT = _dict_of(_TOKEN, _DATA)
|
|
260
268
|
_DATA_ENTRY = Forward()
|
261
269
|
_LIST_ENTRY = _DICT | _KEYWORD_ENTRY | _DATA_ENTRY
|
262
270
|
_LIST = _list_of(_LIST_ENTRY)
|
263
|
-
_NUMBER =
|
271
|
+
_NUMBER = (
|
272
|
+
common.number
|
273
|
+
| CaselessKeyword("nan").set_parse_action(lambda: np.nan)
|
274
|
+
| (CaselessKeyword("inf") | CaselessKeyword("infinity")).set_parse_action(
|
275
|
+
lambda: np.inf
|
276
|
+
)
|
277
|
+
| (CaselessKeyword("-inf") | CaselessKeyword("-infinity")).set_parse_action(
|
278
|
+
lambda: -np.inf
|
279
|
+
)
|
280
|
+
)
|
264
281
|
_DATA_ENTRY <<= _FIELD | _LIST | _DIMENSIONED | _DIMENSIONS | _NUMBER | _SWITCH | _TOKEN
|
265
282
|
|
266
283
|
_DATA <<= (
|
@@ -274,12 +291,16 @@ _DATA <<= (
|
|
274
291
|
def parse_data(s: str) -> Data:
|
275
292
|
if not s.strip():
|
276
293
|
return ""
|
277
|
-
return cast(Data, _DATA.parse_string(s, parse_all=True)[0])
|
294
|
+
return cast("Data", _DATA.parse_string(s, parse_all=True)[0])
|
278
295
|
|
279
296
|
|
280
297
|
_LOCATED_DICTIONARY = Group(
|
281
298
|
_keyword_entry_of(
|
282
|
-
_TOKEN,
|
299
|
+
_TOKEN,
|
300
|
+
Opt(_DATA, default=""),
|
301
|
+
directive=_DIRECTIVE,
|
302
|
+
data_entry=_DATA_ENTRY,
|
303
|
+
located=True,
|
283
304
|
)
|
284
305
|
)[...]
|
285
306
|
_LOCATED_DATA = Group(Located(_DATA.copy().add_parse_action(lambda tks: ["", tks[0]])))
|
@@ -420,7 +441,7 @@ class Parsed(Mapping[Tuple[str, ...], Union[Data, EllipsisType]]):
|
|
420
441
|
for k in keywords[:-1]:
|
421
442
|
v = r[k]
|
422
443
|
assert isinstance(v, dict)
|
423
|
-
r = cast(File, v)
|
444
|
+
r = cast("File", v)
|
424
445
|
|
425
446
|
assert isinstance(r, dict)
|
426
447
|
if keywords:
|
@@ -163,7 +163,7 @@ def test_internal_field(cavity: FoamCase) -> None:
|
|
163
163
|
p_arr = np.zeros(size)
|
164
164
|
U_arr = np.zeros((size, 3))
|
165
165
|
|
166
|
-
cavity[0]["p"].internal_field = p_arr
|
166
|
+
cavity[0]["p"].internal_field = p_arr
|
167
167
|
cavity[0]["U"].internal_field = U_arr # type: ignore [assignment]
|
168
168
|
|
169
169
|
assert cavity[0]["p"].internal_field == pytest.approx(p_arr)
|
@@ -174,7 +174,7 @@ def test_internal_field(cavity: FoamCase) -> None:
|
|
174
174
|
p_arr = np.arange(size) * 1e-6 # type: ignore [assignment]
|
175
175
|
U_arr = np.full((size, 3), [-1e-6, 1e-6, 0]) * np.arange(size)[:, np.newaxis]
|
176
176
|
|
177
|
-
cavity[0]["p"].internal_field = p_arr
|
177
|
+
cavity[0]["p"].internal_field = p_arr
|
178
178
|
cavity[0]["U"].internal_field = U_arr # type: ignore [assignment]
|
179
179
|
|
180
180
|
assert cavity[0]["p"].internal_field == pytest.approx(p_arr)
|
@@ -10,6 +10,7 @@ def test_parse_value() -> None:
|
|
10
10
|
assert Parsed(b"yes")[()] is True
|
11
11
|
assert Parsed(b"no")[()] is False
|
12
12
|
assert Parsed(b"word")[()] == "word"
|
13
|
+
assert Parsed(b"inference")[()] == "inference"
|
13
14
|
assert Parsed(b"word word")[()] == ("word", "word")
|
14
15
|
assert Parsed(b'"a string"')[()] == '"a string"'
|
15
16
|
assert Parsed(b"uniform 1")[()] == 1
|
@@ -93,6 +94,7 @@ def test_parse_value() -> None:
|
|
93
94
|
assert Parsed(b"(water oil mercury air)")[()] == ["water", "oil", "mercury", "air"]
|
94
95
|
assert Parsed(b"div(phi,U)")[()] == "div(phi,U)"
|
95
96
|
assert Parsed(b"div(nuEff*dev(T(grad(U))))")[()] == "div(nuEff*dev(T(grad(U))))"
|
97
|
+
assert Parsed(b"div((nuEff*dev(T(grad(U)))))")[()] == "div((nuEff*dev(T(grad(U)))))"
|
96
98
|
assert Parsed(b"((air and water) { type constant; sigma 0.07; })")[()] == [
|
97
99
|
(["air", "and", "water"], {"type": "constant", "sigma": 0.07})
|
98
100
|
]
|
@@ -103,6 +105,8 @@ def test_parse_value() -> None:
|
|
103
105
|
def test_parse_directive() -> None:
|
104
106
|
assert Parsed(b'#include "filename"')[("#include",)] == '"filename"'
|
105
107
|
assert (
|
106
|
-
Parsed(b"functions\n{\n#includeFunc funcName\
|
108
|
+
Parsed(b"functions\n{\n#includeFunc funcName\nsubdict{}}")[
|
109
|
+
("functions", "#includeFunc")
|
110
|
+
]
|
107
111
|
== "funcName"
|
108
112
|
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|