foamlib 0.9.4__tar.gz → 0.9.5__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.
Files changed (65) hide show
  1. {foamlib-0.9.4 → foamlib-0.9.5}/PKG-INFO +1 -1
  2. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/__init__.py +1 -1
  3. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_files/_parsing.py +5 -2
  4. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_files/_serialization.py +9 -6
  5. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_files/_types.py +20 -7
  6. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/test_dumps.py +4 -0
  7. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/test_parsing/test_loads.py +3 -0
  8. {foamlib-0.9.4 → foamlib-0.9.5}/.devcontainer.json +0 -0
  9. {foamlib-0.9.4 → foamlib-0.9.5}/.dockerignore +0 -0
  10. {foamlib-0.9.4 → foamlib-0.9.5}/.git-blame-ignore-revs +0 -0
  11. {foamlib-0.9.4 → foamlib-0.9.5}/.github/dependabot.yml +0 -0
  12. {foamlib-0.9.4 → foamlib-0.9.5}/.github/workflows/ci.yml +0 -0
  13. {foamlib-0.9.4 → foamlib-0.9.5}/.github/workflows/docker.yml +0 -0
  14. {foamlib-0.9.4 → foamlib-0.9.5}/.github/workflows/dockerhub-description.yml +0 -0
  15. {foamlib-0.9.4 → foamlib-0.9.5}/.github/workflows/pypi-publish.yml +0 -0
  16. {foamlib-0.9.4 → foamlib-0.9.5}/.gitignore +0 -0
  17. {foamlib-0.9.4 → foamlib-0.9.5}/.readthedocs.yaml +0 -0
  18. {foamlib-0.9.4 → foamlib-0.9.5}/CONTRIBUTING.md +0 -0
  19. {foamlib-0.9.4 → foamlib-0.9.5}/Dockerfile +0 -0
  20. {foamlib-0.9.4 → foamlib-0.9.5}/LICENSE.txt +0 -0
  21. {foamlib-0.9.4 → foamlib-0.9.5}/README.md +0 -0
  22. {foamlib-0.9.4 → foamlib-0.9.5}/benchmark/benchmark.png +0 -0
  23. {foamlib-0.9.4 → foamlib-0.9.5}/benchmark/benchmark.py +0 -0
  24. {foamlib-0.9.4 → foamlib-0.9.5}/benchmark/requirements.txt +0 -0
  25. {foamlib-0.9.4 → foamlib-0.9.5}/benchmark/ruff.toml +0 -0
  26. {foamlib-0.9.4 → foamlib-0.9.5}/docs/Makefile +0 -0
  27. {foamlib-0.9.4 → foamlib-0.9.5}/docs/cases.rst +0 -0
  28. {foamlib-0.9.4 → foamlib-0.9.5}/docs/conf.py +0 -0
  29. {foamlib-0.9.4 → foamlib-0.9.5}/docs/files.rst +0 -0
  30. {foamlib-0.9.4 → foamlib-0.9.5}/docs/index.rst +0 -0
  31. {foamlib-0.9.4 → foamlib-0.9.5}/docs/make.bat +0 -0
  32. {foamlib-0.9.4 → foamlib-0.9.5}/docs/ruff.toml +0 -0
  33. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_cases/__init__.py +0 -0
  34. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_cases/_async.py +0 -0
  35. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_cases/_base.py +0 -0
  36. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_cases/_run.py +0 -0
  37. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_cases/_slurm.py +0 -0
  38. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_cases/_subprocess.py +0 -0
  39. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_cases/_sync.py +0 -0
  40. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_cases/_util.py +0 -0
  41. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_files/__init__.py +0 -0
  42. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_files/_files.py +0 -0
  43. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/_files/_io.py +0 -0
  44. {foamlib-0.9.4 → foamlib-0.9.5}/foamlib/py.typed +0 -0
  45. {foamlib-0.9.4 → foamlib-0.9.5}/logo.png +0 -0
  46. {foamlib-0.9.4 → foamlib-0.9.5}/pyproject.toml +0 -0
  47. {foamlib-0.9.4 → foamlib-0.9.5}/tests/__init__.py +0 -0
  48. {foamlib-0.9.4 → foamlib-0.9.5}/tests/ruff.toml +0 -0
  49. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_cases/__init__.py +0 -0
  50. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_cases/test_cavity.py +0 -0
  51. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_cases/test_cavity_async.py +0 -0
  52. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_cases/test_flange.py +0 -0
  53. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_cases/test_flange_async.py +0 -0
  54. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_example.py +0 -0
  55. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/__init__.py +0 -0
  56. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/test_files.py +0 -0
  57. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/test_parsing/__init__.py +0 -0
  58. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/test_parsing/test_advanced.py +0 -0
  59. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/test_parsing/test_basic.py +0 -0
  60. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/test_parsing/test_decompose_par.py +0 -0
  61. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/test_parsing/test_fields.py +0 -0
  62. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/test_parsing/test_fv_schemes.py +0 -0
  63. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/test_parsing/test_intermediate.py +0 -0
  64. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/test_parsing/test_poly_mesh.py +0 -0
  65. {foamlib-0.9.4 → foamlib-0.9.5}/tests/test_files/test_types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: foamlib
3
- Version: 0.9.4
3
+ Version: 0.9.5
4
4
  Summary: A Python interface for interacting with OpenFOAM
5
5
  Project-URL: Homepage, https://github.com/gerlero/foamlib
6
6
  Project-URL: Repository, https://github.com/gerlero/foamlib
@@ -1,6 +1,6 @@
1
1
  """A Python interface for interacting with OpenFOAM."""
2
2
 
3
- __version__ = "0.9.4"
3
+ __version__ = "0.9.5"
4
4
 
5
5
  from ._cases import (
6
6
  AsyncFoamCase,
@@ -363,11 +363,14 @@ _FIELD = (Keyword("uniform", _IDENTBODYCHARS).suppress() + _TENSOR) | (
363
363
  _DIRECTIVE = Word("#", _IDENTBODYCHARS)
364
364
  _TOKEN = dbl_quoted_string | _DIRECTIVE | _IDENTIFIER
365
365
  _DATA = Forward()
366
+ _DATA_ENTRY = Forward()
366
367
  _KEYWORD_ENTRY = _keyword_entry_of(
367
- _TOKEN | _list_of(_IDENTIFIER), Opt(_DATA, default="")
368
+ _TOKEN | _list_of(_IDENTIFIER),
369
+ Opt(_DATA, default=""),
370
+ directive=_DIRECTIVE,
371
+ data_entry=_DATA_ENTRY,
368
372
  )
369
373
  _DICT = _dict_of(_TOKEN, _DATA)
370
- _DATA_ENTRY = Forward()
371
374
  _LIST_ENTRY = _DICT | _KEYWORD_ENTRY | _DATA_ENTRY
372
375
  _LIST = _list_of(_LIST_ENTRY)
373
376
  _NUMBER = (
@@ -87,7 +87,7 @@ def normalize_data(
87
87
  if arr.ndim == 1 or (arr.ndim == 2 and arr.shape[1] in (3, 6, 9)):
88
88
  return arr # type: ignore [return-value]
89
89
 
90
- return [normalize_data(d) for d in data] # type: ignore [arg-type]
90
+ return [normalize_data(d) for d in data] # type: ignore [arg-type, misc]
91
91
 
92
92
  if isinstance(data, int):
93
93
  return float(data)
@@ -112,7 +112,7 @@ def normalize_data(
112
112
  if keywords is None and isinstance(data, tuple) and len(data) == 2:
113
113
  k, v = data
114
114
  assert not isinstance(k, Mapping)
115
- return (
115
+ return ( # type: ignore [return-value]
116
116
  normalize_keyword(k), # type: ignore [arg-type]
117
117
  normalize_data(v) if not isinstance(v, Mapping) else v, # type: ignore [arg-type, misc]
118
118
  )
@@ -122,10 +122,10 @@ def normalize_data(
122
122
  and not isinstance(data, DimensionSet)
123
123
  and not isinstance(data, tuple)
124
124
  ):
125
- return [normalize_data(d) for d in data] # type: ignore [arg-type]
125
+ return [normalize_data(d) for d in data] # type: ignore [arg-type, misc]
126
126
 
127
127
  if isinstance(data, tuple) and not isinstance(data, DimensionSet):
128
- return tuple(normalize_data(d) for d in data)
128
+ return tuple(normalize_data(d) for d in data) # type: ignore [misc]
129
129
 
130
130
  if isinstance(data, str):
131
131
  s = loads(data)
@@ -247,7 +247,8 @@ def dumps(
247
247
  if isinstance(data, tuple):
248
248
  if tuple_is_entry:
249
249
  k, v = data
250
- ret = dumps(k)
250
+ ret = b"\n" if isinstance(k, str) and k[0] == "#" else b""
251
+ ret += dumps(k)
251
252
  val = dumps(
252
253
  v,
253
254
  keywords=(*keywords, k)
@@ -256,7 +257,9 @@ def dumps(
256
257
  )
257
258
  if val:
258
259
  ret += b" " + val
259
- if not isinstance(v, Mapping):
260
+ if isinstance(k, str) and k[0] == "#":
261
+ ret += b"\n"
262
+ elif not isinstance(v, Mapping):
260
263
  ret += b";"
261
264
  return ret
262
265
 
@@ -199,25 +199,38 @@ FieldLike = Union[
199
199
  ]
200
200
 
201
201
 
202
- Data = Union[
202
+ DataEntry = Union[
203
203
  str,
204
204
  int,
205
205
  float,
206
206
  bool,
207
207
  Dimensioned,
208
208
  DimensionSet,
209
- Tuple["Data", ...],
210
- List[Union["Data", Tuple["Data", Union["Data", "SubDict"]]]],
209
+ List[Union["DataEntry", Tuple["DataEntry", Union["DataEntry", "SubDict"]]]],
211
210
  Field,
212
211
  ]
213
212
 
214
- DataLike = Union[
215
- Data,
216
- Tuple["DataLike", ...],
217
- Sequence[Union["DataLike", Tuple["DataLike", Union["DataLike", "SubDictLike"]]]],
213
+ DataEntryLike = Union[
214
+ DataEntry,
215
+ Sequence[
216
+ Union[
217
+ "DataEntryLike",
218
+ Tuple["DataEntryLike", Union["DataEntryLike", "SubDictLike"]],
219
+ ]
220
+ ],
218
221
  FieldLike,
219
222
  ]
220
223
 
224
+ Data = Union[
225
+ DataEntry,
226
+ Tuple[DataEntry, ...],
227
+ ]
228
+
229
+ DataLike = Union[
230
+ DataEntryLike,
231
+ Tuple["DataEntryLike", ...],
232
+ ]
233
+
221
234
  StandaloneData = Union[
222
235
  Data,
223
236
  "np.ndarray[tuple[int], np.dtype[np.int64 | np.int32]]",
@@ -125,3 +125,7 @@ def test_serialize_file() -> None:
125
125
  )
126
126
  == b"FoamFile {format binary;} 3(\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00)"
127
127
  )
128
+ assert (
129
+ FoamFile.dumps({"#include": "$FOAM_CASE/simControls"}, ensure_header=False)
130
+ == b"\n#include $FOAM_CASE/simControls\n"
131
+ )
@@ -71,3 +71,6 @@ def test_loads() -> None:
71
71
  assert FoamFile.loads("a {b c; d e;}") == {"a": {"b": "c", "d": "e"}}
72
72
  assert FoamFile.loads("(a b; c d;)") == [("a", "b"), ("c", "d")]
73
73
  assert FoamFile.loads("keyword;") == {"keyword": ""}
74
+ assert FoamFile.loads("#include $FOAM_CASE/simControls") == {
75
+ "#include": "$FOAM_CASE/simControls"
76
+ }
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