foamlib 0.6.8__tar.gz → 0.6.9__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.6.8 → foamlib-0.6.9}/PKG-INFO +1 -1
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/__init__.py +1 -1
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_files/_files.py +10 -6
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_files/_serialization.py +18 -18
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib.egg-info/PKG-INFO +1 -1
- {foamlib-0.6.8 → foamlib-0.6.9}/LICENSE.txt +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/README.md +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_cases/__init__.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_cases/_async.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_cases/_base.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_cases/_run.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_cases/_slurm.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_cases/_subprocess.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_cases/_sync.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_cases/_util.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_files/__init__.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_files/_base.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_files/_io.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_files/_parsing.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/_files/_util.py +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib/py.typed +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib.egg-info/SOURCES.txt +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib.egg-info/dependency_links.txt +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib.egg-info/requires.txt +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/foamlib.egg-info/top_level.txt +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/pyproject.toml +0 -0
- {foamlib-0.6.8 → foamlib-0.6.9}/setup.cfg +0 -0
@@ -13,7 +13,7 @@ else:
|
|
13
13
|
|
14
14
|
from ._base import FoamFileBase
|
15
15
|
from ._io import FoamFileIO
|
16
|
-
from ._serialization import Kind,
|
16
|
+
from ._serialization import Kind, dumps
|
17
17
|
from ._util import is_sequence
|
18
18
|
|
19
19
|
if TYPE_CHECKING:
|
@@ -202,7 +202,11 @@ class FoamFile(
|
|
202
202
|
if keywords == ("internalField",) or (
|
203
203
|
len(keywords) == 3
|
204
204
|
and keywords[0] == "boundaryField"
|
205
|
-
and
|
205
|
+
and (
|
206
|
+
keywords[2] in ("value", "gradient")
|
207
|
+
or keywords[2].endswith("Value")
|
208
|
+
or keywords[2].endswith("Gradient")
|
209
|
+
)
|
206
210
|
):
|
207
211
|
kind = Kind.BINARY_FIELD if self.format == "binary" else Kind.FIELD
|
208
212
|
elif keywords == ("dimensions",):
|
@@ -251,7 +255,7 @@ class FoamFile(
|
|
251
255
|
self._write(
|
252
256
|
before
|
253
257
|
+ indentation
|
254
|
-
+
|
258
|
+
+ dumps(keywords[-1])
|
255
259
|
+ b"\n"
|
256
260
|
+ indentation
|
257
261
|
+ b"{\n"
|
@@ -267,15 +271,15 @@ class FoamFile(
|
|
267
271
|
self._write(
|
268
272
|
before
|
269
273
|
+ indentation
|
270
|
-
+
|
274
|
+
+ dumps(keywords[-1])
|
271
275
|
+ b" "
|
272
|
-
+
|
276
|
+
+ dumps(data, kind=kind)
|
273
277
|
+ b";"
|
274
278
|
+ after
|
275
279
|
)
|
276
280
|
|
277
281
|
else:
|
278
|
-
self._write(before +
|
282
|
+
self._write(before + dumps(data, kind=kind) + after)
|
279
283
|
|
280
284
|
def __delitem__(self, keywords: Optional[Union[str, Tuple[str, ...]]]) -> None:
|
281
285
|
if not keywords:
|
@@ -27,31 +27,31 @@ class Kind(Enum):
|
|
27
27
|
DIMENSIONS = auto()
|
28
28
|
|
29
29
|
|
30
|
-
def
|
30
|
+
def dumps(
|
31
31
|
data: FoamFileBase._SetData,
|
32
32
|
*,
|
33
33
|
kind: Kind = Kind.DEFAULT,
|
34
34
|
) -> bytes:
|
35
35
|
if numpy and isinstance(data, np.ndarray):
|
36
|
-
return
|
36
|
+
return dumps(data.tolist(), kind=kind)
|
37
37
|
|
38
38
|
if isinstance(data, Mapping):
|
39
39
|
entries = []
|
40
40
|
for k, v in data.items():
|
41
|
-
b =
|
41
|
+
b = dumps(v, kind=kind)
|
42
42
|
if isinstance(v, Mapping):
|
43
|
-
entries.append(
|
43
|
+
entries.append(dumps(k) + b" {" + b + b"}")
|
44
44
|
elif not b:
|
45
|
-
entries.append(
|
45
|
+
entries.append(dumps(k) + b";")
|
46
46
|
else:
|
47
|
-
entries.append(
|
47
|
+
entries.append(dumps(k) + b" " + b + b";")
|
48
48
|
|
49
49
|
return b" ".join(entries)
|
50
50
|
|
51
51
|
if isinstance(data, FoamFileBase.DimensionSet) or (
|
52
52
|
kind == Kind.DIMENSIONS and is_sequence(data) and len(data) == 7
|
53
53
|
):
|
54
|
-
return b"[" + b" ".join(
|
54
|
+
return b"[" + b" ".join(dumps(v) for v in data) + b"]"
|
55
55
|
|
56
56
|
if (kind == Kind.FIELD or kind == Kind.BINARY_FIELD) and (
|
57
57
|
isinstance(data, (int, float))
|
@@ -60,7 +60,7 @@ def dumpb(
|
|
60
60
|
and isinstance(data[0], (int, float))
|
61
61
|
and len(data) in (3, 6, 9)
|
62
62
|
):
|
63
|
-
return b"uniform " +
|
63
|
+
return b"uniform " + dumps(data, kind=Kind.SINGLE_ENTRY)
|
64
64
|
|
65
65
|
if (kind == Kind.FIELD or kind == Kind.BINARY_FIELD) and is_sequence(data):
|
66
66
|
if isinstance(data[0], (int, float)):
|
@@ -72,7 +72,7 @@ def dumpb(
|
|
72
72
|
elif len(data[0]) == 9:
|
73
73
|
tensor_kind = b"tensor"
|
74
74
|
else:
|
75
|
-
return
|
75
|
+
return dumps(data)
|
76
76
|
|
77
77
|
if kind == Kind.BINARY_FIELD:
|
78
78
|
if tensor_kind == b"scalar":
|
@@ -84,30 +84,30 @@ def dumpb(
|
|
84
84
|
+ b")"
|
85
85
|
)
|
86
86
|
else:
|
87
|
-
contents =
|
87
|
+
contents = dumps(data, kind=Kind.SINGLE_ENTRY)
|
88
88
|
|
89
|
-
return b"nonuniform List<" + tensor_kind + b"> " +
|
89
|
+
return b"nonuniform List<" + tensor_kind + b"> " + dumps(len(data)) + contents
|
90
90
|
|
91
91
|
if kind != Kind.SINGLE_ENTRY and isinstance(data, tuple):
|
92
|
-
return b" ".join(
|
92
|
+
return b" ".join(dumps(v) for v in data)
|
93
93
|
|
94
94
|
if isinstance(data, FoamFileBase.Dimensioned):
|
95
95
|
if data.name is not None:
|
96
96
|
return (
|
97
|
-
|
97
|
+
dumps(data.name)
|
98
98
|
+ b" "
|
99
|
-
+
|
99
|
+
+ dumps(data.dimensions, kind=Kind.DIMENSIONS)
|
100
100
|
+ b" "
|
101
|
-
+
|
101
|
+
+ dumps(data.value, kind=Kind.SINGLE_ENTRY)
|
102
102
|
)
|
103
103
|
return (
|
104
|
-
|
104
|
+
dumps(data.dimensions, kind=Kind.DIMENSIONS)
|
105
105
|
+ b" "
|
106
|
-
+
|
106
|
+
+ dumps(data.value, kind=Kind.SINGLE_ENTRY)
|
107
107
|
)
|
108
108
|
|
109
109
|
if is_sequence(data):
|
110
|
-
return b"(" + b" ".join(
|
110
|
+
return b"(" + b" ".join(dumps(v, kind=Kind.SINGLE_ENTRY) for v in data) + b")"
|
111
111
|
|
112
112
|
if data is True:
|
113
113
|
return b"yes"
|
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
|