jcmsuite 7.4.2__py3-none-any.whl

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.

Potentially problematic release.


This version of jcmsuite might be problematic. Click here for more details.

Files changed (119) hide show
  1. jcmsuite/__init__.py +22 -0
  2. jcmsuite/_build_info.py +4 -0
  3. jcmsuite/context/__init__.py +44 -0
  4. jcmsuite/context/interface_metadata.py +158 -0
  5. jcmsuite/context/models.py +213 -0
  6. jcmsuite/context/scope.py +210 -0
  7. jcmsuite/context/solver_context.py +569 -0
  8. jcmsuite/context/subprocess_tools.py +172 -0
  9. jcmsuite/contract.py +47 -0
  10. jcmsuite/daemon/__init__.py +19 -0
  11. jcmsuite/daemon/handler.py +925 -0
  12. jcmsuite/daemon/internal/__init__.py +4 -0
  13. jcmsuite/daemon/internal/bundle_protocol.py +64 -0
  14. jcmsuite/daemon/internal/handler_helpers.py +368 -0
  15. jcmsuite/daemon/internal/handler_resource_jobs.py +227 -0
  16. jcmsuite/daemon/internal/handler_wait.py +564 -0
  17. jcmsuite/daemon/models.py +349 -0
  18. jcmsuite/daemon/namespaces.py +250 -0
  19. jcmsuite/daemon/protocol.py +801 -0
  20. jcmsuite/daemon/resources.py +407 -0
  21. jcmsuite/daemon/scope.py +53 -0
  22. jcmsuite/daemon/transport.py +223 -0
  23. jcmsuite/editing/__init__.py +10 -0
  24. jcmsuite/editing/editor.py +274 -0
  25. jcmsuite/exceptions/__init__.py +32 -0
  26. jcmsuite/exceptions/errors.py +173 -0
  27. jcmsuite/geo/__init__.py +10 -0
  28. jcmsuite/geo/mesh.py +302 -0
  29. jcmsuite/info/__init__.py +10 -0
  30. jcmsuite/info/runtime_info.py +45 -0
  31. jcmsuite/internal/__init__.py +2 -0
  32. jcmsuite/internal/diagnostics.py +74 -0
  33. jcmsuite/internal/progress.py +80 -0
  34. jcmsuite/loaders/__init__.py +18 -0
  35. jcmsuite/loaders/blob_header.py +315 -0
  36. jcmsuite/loaders/cartesian_field_reader.py +249 -0
  37. jcmsuite/loaders/cartesian_fields.py +324 -0
  38. jcmsuite/loaders/nested_mapping.py +69 -0
  39. jcmsuite/loaders/powerflux.py +136 -0
  40. jcmsuite/loaders/table.py +637 -0
  41. jcmsuite/logging/__init__.py +22 -0
  42. jcmsuite/logging/runtime.py +210 -0
  43. jcmsuite/results/__init__.py +126 -0
  44. jcmsuite/results/artifacts.py +806 -0
  45. jcmsuite/results/discovery.py +82 -0
  46. jcmsuite/results/field_exports.py +1062 -0
  47. jcmsuite/results/field_payloads.py +453 -0
  48. jcmsuite/results/internal/__init__.py +4 -0
  49. jcmsuite/results/internal/export/__init__.py +4 -0
  50. jcmsuite/results/internal/export/common.py +56 -0
  51. jcmsuite/results/internal/export/pandas/__init__.py +4 -0
  52. jcmsuite/results/internal/export/pandas/common.py +165 -0
  53. jcmsuite/results/internal/export/pandas/payload.py +480 -0
  54. jcmsuite/results/internal/export/pandas/rows.py +484 -0
  55. jcmsuite/results/internal/export/preview.py +178 -0
  56. jcmsuite/results/internal/export/xarray/__init__.py +4 -0
  57. jcmsuite/results/internal/export/xarray/export.py +688 -0
  58. jcmsuite/results/internal/export/xarray/grouped.py +608 -0
  59. jcmsuite/results/internal/export/xarray/headers.py +290 -0
  60. jcmsuite/results/internal/export/xarray/runtime.py +99 -0
  61. jcmsuite/results/internal/export/xarray/shared.py +246 -0
  62. jcmsuite/results/internal/export/xarray/tabular.py +304 -0
  63. jcmsuite/results/internal/export/xarray/types.py +28 -0
  64. jcmsuite/results/internal/models/__init__.py +4 -0
  65. jcmsuite/results/internal/models/batch.py +1081 -0
  66. jcmsuite/results/internal/models/batch_postprocess.py +1728 -0
  67. jcmsuite/results/internal/models/bundle.py +343 -0
  68. jcmsuite/results/internal/models/core.py +556 -0
  69. jcmsuite/results/internal/models/submission.py +1157 -0
  70. jcmsuite/results/internal/resultbag/__init__.py +4 -0
  71. jcmsuite/results/internal/resultbag/access.py +489 -0
  72. jcmsuite/results/internal/resultbag/iteration.py +199 -0
  73. jcmsuite/results/internal/resultbag/query.py +226 -0
  74. jcmsuite/results/internal/resultbag/raw.py +407 -0
  75. jcmsuite/results/internal/resultbag/source_files.py +142 -0
  76. jcmsuite/results/internal/resultbag/store.py +881 -0
  77. jcmsuite/results/internal/resultbag/utils.py +258 -0
  78. jcmsuite/results/models.py +76 -0
  79. jcmsuite/results/opening.py +55 -0
  80. jcmsuite/results/pandas_export.py +325 -0
  81. jcmsuite/results/payloads.py +478 -0
  82. jcmsuite/results/postprocess.py +97 -0
  83. jcmsuite/results/postprocess_payloads.py +757 -0
  84. jcmsuite/results/postprocess_record.py +418 -0
  85. jcmsuite/results/resultbag.py +279 -0
  86. jcmsuite/results/resultbag_management.py +433 -0
  87. jcmsuite/results/structured_derivatives.py +387 -0
  88. jcmsuite/solve/__init__.py +10 -0
  89. jcmsuite/solve/daemon_bundle_staging.py +100 -0
  90. jcmsuite/solve/daemon_bundle_wait.py +89 -0
  91. jcmsuite/solve/orchestration.py +1576 -0
  92. jcmsuite/solve/orchestration_execution.py +180 -0
  93. jcmsuite/solve/orchestration_routing.py +128 -0
  94. jcmsuite/solve/orchestration_support.py +323 -0
  95. jcmsuite/solve/path_resolution.py +98 -0
  96. jcmsuite/solve/progress.py +20 -0
  97. jcmsuite/solve/solver.py +709 -0
  98. jcmsuite/solve/staging.py +264 -0
  99. jcmsuite/solve/types.py +25 -0
  100. jcmsuite/solve/working_dirs.py +227 -0
  101. jcmsuite/templates/__init__.py +11 -0
  102. jcmsuite/templates/converter.py +71 -0
  103. jcmsuite/templates/formatting.py +335 -0
  104. jcmsuite/templates/formatting_cli.py +47 -0
  105. jcmsuite/templates/rendering.py +666 -0
  106. jcmsuite/torch/__init__.py +25 -0
  107. jcmsuite/torch/autograd.py +488 -0
  108. jcmsuite/torch/coordinate_policy.py +82 -0
  109. jcmsuite/torch/core.py +312 -0
  110. jcmsuite/torch/results/__init__.py +51 -0
  111. jcmsuite/torch/types.py +84 -0
  112. jcmsuite/torch/validation.py +208 -0
  113. jcmsuite/torch/wrappers.py +4332 -0
  114. jcmsuite/view/__init__.py +10 -0
  115. jcmsuite/view/viewer.py +122 -0
  116. jcmsuite-7.4.2.dist-info/METADATA +180 -0
  117. jcmsuite-7.4.2.dist-info/RECORD +119 -0
  118. jcmsuite-7.4.2.dist-info/WHEEL +4 -0
  119. jcmsuite-7.4.2.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,478 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2001-2026 JCMwave GmbH
3
+
4
+ """Class-based export payload foundations for single solve results."""
5
+
6
+ from __future__ import annotations
7
+
8
+ import warnings
9
+ from abc import ABC, abstractmethod
10
+ from collections.abc import Iterator, Mapping
11
+ from pathlib import Path
12
+ from typing import TYPE_CHECKING, TypeAlias, cast
13
+
14
+ from ..exceptions import UnsupportedExportError
15
+ from .internal.export.common import materialize_rows, rows_to_dataframe
16
+
17
+ if TYPE_CHECKING:
18
+ import pandas as pd
19
+
20
+ from .internal.export.xarray.types import XarrayDataTree
21
+ from .postprocess_payloads import (
22
+ TableCollectionDerivativeCollection,
23
+ TableDerivativeCollection,
24
+ )
25
+
26
+ Source: TypeAlias = str | Path | None
27
+
28
+
29
+ class ExportablePayload(ABC):
30
+ """Common provenance state for a single-result export payload."""
31
+
32
+ @property
33
+ @abstractmethod
34
+ def source(self) -> Source:
35
+ """Return the source path or storage origin for the payload."""
36
+
37
+
38
+ class DictionaryExportMixin(ABC):
39
+ """Capability for schema-faithful mapping export."""
40
+
41
+ @abstractmethod
42
+ def to_dict(self) -> Mapping[object, object]:
43
+ """Return the result data as a dictionary.
44
+
45
+ Returns
46
+ -------
47
+ Mapping[object, object]
48
+ Result data as a dictionary that keeps the original field names.
49
+ """
50
+
51
+ def to_mapping(self) -> Mapping[object, object]:
52
+ """Return result data using the deprecated mapping export name.
53
+
54
+ .. deprecated:: 7.2
55
+ Use :meth:`to_dict` instead.
56
+
57
+ Returns
58
+ -------
59
+ Mapping[object, object]
60
+ Result data as a dictionary that keeps the original field names.
61
+ """
62
+
63
+ warnings.warn(
64
+ "to_mapping() is deprecated; use to_dict() instead.",
65
+ DeprecationWarning,
66
+ stacklevel=2,
67
+ )
68
+ return self.to_dict()
69
+
70
+
71
+ class DataFrameWideExportMixin(ABC):
72
+ """Capability for rectangular, wide DataFrame export."""
73
+
74
+ @abstractmethod
75
+ def _to_df_wide(self) -> "pd.DataFrame":
76
+ """Return a DataFrame with one column for each value name."""
77
+
78
+
79
+ class DataFrameLongExportMixin(ABC):
80
+ """Capability for normalized, long DataFrame export."""
81
+
82
+ @abstractmethod
83
+ def _to_df_long(self) -> "pd.DataFrame":
84
+ """Return a DataFrame with one row for each named value."""
85
+
86
+
87
+ class XarrayExportMixin(ABC):
88
+ """Capability for xarray tree export."""
89
+
90
+ @abstractmethod
91
+ def to_xarray(self) -> "XarrayDataTree":
92
+ """Return the result data as an xarray `DataTree`.
93
+
94
+ Returns
95
+ -------
96
+ xarray.DataTree
97
+ Result data in an xarray tree. See the user documentation for xarray
98
+ export details.
99
+ """
100
+
101
+
102
+ class MetadataPayload(
103
+ ExportablePayload,
104
+ DictionaryExportMixin,
105
+ DataFrameWideExportMixin,
106
+ DataFrameLongExportMixin,
107
+ XarrayExportMixin,
108
+ ABC,
109
+ ):
110
+ """Base class for metadata mappings."""
111
+
112
+ def _preview(self) -> str:
113
+ """Return internal bounded one-row metadata preview text.
114
+
115
+ Returns
116
+ -------
117
+ str
118
+ A text table containing at most six metadata fields.
119
+ """
120
+
121
+ from .internal.export.preview import format_mapping_preview
122
+
123
+ return format_mapping_preview(self.to_dict())
124
+
125
+ def to_df(self, orient: str | None = None) -> "pd.DataFrame":
126
+ """Return metadata in the requested DataFrame orientation.
127
+
128
+ Metadata uses long form by default. Subclasses may support wide form when
129
+ their schema has a meaningful rectangular representation.
130
+ """
131
+
132
+ if orient is None or orient == "long":
133
+ return self._to_df_long()
134
+ if orient == "wide":
135
+ return self._to_df_wide()
136
+ raise ValueError("orient must be None, 'wide', or 'long'")
137
+
138
+ def __repr__(self) -> str:
139
+ """Return the payload class name with its bounded data preview."""
140
+
141
+ return f"{type(self).__name__}(\n preview=\n{self._preview()}\n)"
142
+
143
+
144
+ class SolveKeys(MetadataPayload, Mapping[str, object]):
145
+ """Store and export the project keys for one solve.
146
+
147
+ A list used as a project key remains one value. It does not create Batched
148
+ project keys.
149
+
150
+ Parameters
151
+ ----------
152
+ values : Mapping[str, object] | None, optional
153
+ project keys. If omitted, use an empty dictionary.
154
+ source : Path | None, optional
155
+ project file associated with the project keys.
156
+ """
157
+
158
+ def __init__(
159
+ self,
160
+ values: Mapping[str, object] | None = None,
161
+ *,
162
+ source: Path | None = None,
163
+ ) -> None:
164
+ self._values: dict[str, object] = {} if values is None else dict(values)
165
+ self._source: Path | None = source
166
+
167
+ @property
168
+ def source(self) -> Path | None:
169
+ """Return the project path associated with these keys, if available."""
170
+
171
+ return self._source
172
+
173
+ def __getitem__(self, key: str) -> object:
174
+ return self._values[key]
175
+
176
+ def __iter__(self) -> Iterator[str]:
177
+ return iter(self._values)
178
+
179
+ def __len__(self) -> int:
180
+ return len(self._values)
181
+
182
+ def to_dict(self) -> Mapping[object, object]:
183
+ """Return a new dictionary that contains the project keys.
184
+
185
+ Returns
186
+ -------
187
+ Mapping[object, object]
188
+ Copy of the project keys.
189
+ """
190
+
191
+ return cast(Mapping[object, object], dict(self._values))
192
+
193
+ def _preview(self) -> str:
194
+ """Return internal bounded text preview with one value per project key.
195
+
196
+ Returns
197
+ -------
198
+ str
199
+ A one-row text table containing at most six project keys.
200
+ """
201
+
202
+ from .internal.export.preview import format_mapping_preview
203
+
204
+ return format_mapping_preview(self._values)
205
+
206
+ def __repr__(self) -> str:
207
+ """Return the payload class name with its bounded data preview."""
208
+
209
+ return f"SolveKeys(\n preview=\n{self._preview()}\n)"
210
+
211
+ def _to_df_wide(self) -> "pd.DataFrame":
212
+ """Return one DataFrame row with one column for each project key.
213
+
214
+ Returns
215
+ -------
216
+ pandas.DataFrame
217
+ One-row table of project keys.
218
+ """
219
+
220
+ return rows_to_dataframe(materialize_rows([self._values]))
221
+
222
+ def _to_df_long(self) -> "pd.DataFrame":
223
+ """Return one DataFrame row for each project key.
224
+
225
+ The DataFrame has `key` and `value` columns.
226
+
227
+ Returns
228
+ -------
229
+ pandas.DataFrame
230
+ Long-form table of project keys.
231
+ """
232
+
233
+ rows: list[dict[str, object]] = [
234
+ {"key": key, "value": value} for key, value in self._values.items()
235
+ ]
236
+ return rows_to_dataframe(rows)
237
+
238
+ def to_df(self, orient: str | None = None) -> "pd.DataFrame":
239
+ """Return the project keys as a DataFrame.
240
+
241
+ Parameters
242
+ ----------
243
+ orient : {"wide", "long"} | None, optional
244
+ Table layout. `"wide"` gives one row with one column for each
245
+ project key. `"long"` gives one row for each project key. If
246
+ omitted, use `"wide"`.
247
+
248
+ Returns
249
+ -------
250
+ pandas.DataFrame
251
+ project keys in the selected layout.
252
+
253
+ Raises
254
+ ------
255
+ ValueError
256
+ If `orient` is not `"wide"`, `"long"`, or `None`.
257
+ """
258
+
259
+ if orient is None or orient == "wide":
260
+ return self._to_df_wide()
261
+ if orient == "long":
262
+ return self._to_df_long()
263
+ raise ValueError("orient must be None, 'wide', or 'long'")
264
+
265
+ def to_xarray(self) -> "XarrayDataTree":
266
+ """Return the project keys as an xarray `DataTree`.
267
+
268
+ The root node stores project key values that xarray can represent.
269
+
270
+ Returns
271
+ -------
272
+ xarray.DataTree
273
+ project keys stored as attributes on the root node.
274
+
275
+ Raises
276
+ ------
277
+ ValueError
278
+ If a project key value cannot be stored by xarray.
279
+ """
280
+
281
+ from .internal.export.xarray.runtime import (
282
+ _create_data_tree,
283
+ _load_datatree_module,
284
+ _load_xarray_module,
285
+ )
286
+
287
+ xarray_module = _load_xarray_module()
288
+ data: dict[str, object] = {}
289
+ key: str
290
+ value: object
291
+ for key, value in self._values.items():
292
+ if isinstance(value, (str, int, float, bool)) or value is None:
293
+ data[key] = value
294
+ elif isinstance(value, (list, tuple)) and all(
295
+ isinstance(item, (str, int, float, bool)) or item is None
296
+ for item in value
297
+ ):
298
+ data[key] = value
299
+ else:
300
+ raise ValueError(
301
+ f"Solve key {key!r} has a value that cannot be represented honestly in xarray."
302
+ )
303
+ dataset = xarray_module.Dataset(
304
+ data_vars={},
305
+ attrs={"source": str(self._source) if self._source else ""},
306
+ )
307
+ for key, value in data.items():
308
+ dataset.attrs[key] = value
309
+ return _create_data_tree(
310
+ datatree_module=_load_datatree_module(),
311
+ dataset=dataset,
312
+ )
313
+
314
+
315
+ class PostprocessRecordPayload(ExportablePayload, ABC):
316
+ """Payload family permitted inside a postprocess record façade."""
317
+
318
+
319
+ class TablePayload(
320
+ PostprocessRecordPayload,
321
+ DictionaryExportMixin,
322
+ DataFrameWideExportMixin,
323
+ DataFrameLongExportMixin,
324
+ XarrayExportMixin,
325
+ ABC,
326
+ ):
327
+ """Result data stored as one table."""
328
+
329
+ @property
330
+ def derivatives(self) -> "TableDerivativeCollection":
331
+ """Return name-based derivative navigation for numeric table values.
332
+
333
+ Derivative names are solver parameter names. The selected values keep
334
+ the table's quantity names and export conventions.
335
+ """
336
+
337
+ from .postprocess_payloads import TableDerivativeCollection
338
+
339
+ return TableDerivativeCollection(self)
340
+
341
+ def _preview(self) -> str:
342
+ """Return internal bounded text preview of the table values.
343
+
344
+ Returns
345
+ -------
346
+ str
347
+ A text table containing at most five rows and six columns.
348
+ """
349
+
350
+ from .internal.export.preview import format_table_preview
351
+
352
+ preview_values: dict[object, object] = dict(self.to_dict())
353
+ preview_values.pop("header", None)
354
+ return format_table_preview(preview_values)
355
+
356
+ def __repr__(self) -> str:
357
+ """Return the payload class name with its bounded data preview."""
358
+
359
+ return f"{type(self).__name__}(\n preview=\n{self._preview()}\n)"
360
+
361
+ def to_df(self, orient: str | None = None) -> "pd.DataFrame":
362
+ """Return table data in the requested DataFrame orientation.
363
+
364
+ Parameters
365
+ ----------
366
+ orient : {"wide", "long"} | None, optional
367
+ Table layout. If omitted, use the natural wide form.
368
+
369
+ Returns
370
+ -------
371
+ pandas.DataFrame
372
+ Table data in the selected layout.
373
+
374
+ Raises
375
+ ------
376
+ ValueError
377
+ If `orient` is not `None`, `"wide"`, or `"long"`.
378
+ """
379
+
380
+ if orient is None or orient == "wide":
381
+ return self._to_df_wide()
382
+ if orient == "long":
383
+ return self._to_df_long()
384
+ raise ValueError("orient must be None, 'wide', or 'long'")
385
+
386
+
387
+ class TableCollectionPayload(
388
+ PostprocessRecordPayload,
389
+ DictionaryExportMixin,
390
+ DataFrameLongExportMixin,
391
+ XarrayExportMixin,
392
+ ABC,
393
+ ):
394
+ """Result data stored as multiple tables with different shapes."""
395
+
396
+ @property
397
+ def derivatives(self) -> "TableCollectionDerivativeCollection":
398
+ """Return solver-parameter derivative navigation for collection members.
399
+
400
+ Each selected view retains the original table names. Members without the
401
+ requested derivative are omitted; they are never replaced or zero-filled.
402
+ """
403
+
404
+ from .postprocess_payloads import TableCollectionDerivativeCollection
405
+
406
+ return TableCollectionDerivativeCollection(self)
407
+
408
+ def to_df(self, orient: str | None = None) -> "pd.DataFrame":
409
+ """Return the table collection in its supported long form.
410
+
411
+ Parameters
412
+ ----------
413
+ orient : {None, "long"}, optional
414
+ Select the table layout. The collection supports only long form.
415
+
416
+ Returns
417
+ -------
418
+ pandas.DataFrame
419
+ Table rows in long form.
420
+
421
+ Raises
422
+ ------
423
+ UnsupportedExportError
424
+ If `orient` is `"wide"`.
425
+ ValueError
426
+ If `orient` is not `None` or `"long"`.
427
+ """
428
+
429
+ if orient is None or orient == "long":
430
+ return self._to_df_long()
431
+ if orient == "wide":
432
+ raise UnsupportedExportError(
433
+ "to_df is not supported for wide `TableCollectionPayload`."
434
+ )
435
+ raise ValueError("orient must be None, 'wide', or 'long'")
436
+
437
+
438
+ class StructuredPayload(
439
+ PostprocessRecordPayload,
440
+ DictionaryExportMixin,
441
+ DataFrameLongExportMixin,
442
+ XarrayExportMixin,
443
+ ABC,
444
+ ):
445
+ """Deprecated base class for nested scientific payloads.
446
+
447
+ No supported file-backed loader produces this family. It remains only for
448
+ in-memory mappings and restored state and is marked for removal.
449
+ """
450
+
451
+ def to_df(self, orient: str | None = None) -> "pd.DataFrame":
452
+ """Return structured data as path/value rows.
453
+
454
+ Parameters
455
+ ----------
456
+ orient : str | None, optional
457
+ DataFrame orientation. Use `None` or `"long"`; `"wide"` is not
458
+ supported for structured data.
459
+
460
+ Returns
461
+ -------
462
+ pandas.DataFrame
463
+ Structured data in path/value rows.
464
+ """
465
+
466
+ if orient is None or orient == "long":
467
+ return self._to_df_long()
468
+ if orient == "wide":
469
+ raise UnsupportedExportError(
470
+ "to_df is not supported for wide `StructuredPayload`."
471
+ )
472
+ raise ValueError("orient must be None, 'wide', or 'long'")
473
+
474
+
475
+ class FieldExportPayload(
476
+ PostprocessRecordPayload, DictionaryExportMixin, XarrayExportMixin, ABC
477
+ ):
478
+ """Base class for non-tabular field payloads."""
@@ -0,0 +1,97 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2001-2026 JCMwave GmbH
3
+
4
+ """Postprocess result collection models."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from collections.abc import Iterator
9
+ from dataclasses import dataclass
10
+ from typing import TYPE_CHECKING
11
+
12
+ if TYPE_CHECKING:
13
+ from .postprocess_record import PostprocessRecord
14
+
15
+
16
+ @dataclass(slots=True, frozen=True, repr=False)
17
+ class PostprocessCollection:
18
+ """Store postprocess records in project file order."""
19
+
20
+ records: tuple[PostprocessRecord, ...]
21
+
22
+ def __repr__(self) -> str:
23
+ """Return indexed postprocess titles and availability states."""
24
+
25
+ from .internal.export.preview import format_table_preview
26
+
27
+ values: dict[object, object] = {
28
+ "index": tuple(range(len(self.records))),
29
+ "title": tuple(
30
+ "<untitled>" if record.title is None else record.title
31
+ for record in self.records
32
+ ),
33
+ "status": tuple(
34
+ (
35
+ "available"
36
+ if record.available
37
+ else (
38
+ "unavailable"
39
+ if record.failure_message is None
40
+ else f"unavailable: {record.failure_message}"
41
+ )
42
+ )
43
+ for record in self.records
44
+ ),
45
+ }
46
+ return f"PostprocessCollection(\n{format_table_preview(values, include_row_index=False, quote_strings=False)}\n)"
47
+
48
+ def __len__(self) -> int:
49
+ """Return the number of postprocess records.
50
+
51
+ Returns
52
+ -------
53
+ int
54
+ Number of postprocess records.
55
+ """
56
+
57
+ return len(self.records)
58
+
59
+ def __iter__(self) -> Iterator[PostprocessRecord]:
60
+ """Iterate over records in project file order.
61
+
62
+ Returns
63
+ -------
64
+ Iterator[PostprocessRecord]
65
+ Postprocess records in project file order.
66
+ """
67
+
68
+ return iter(self.records)
69
+
70
+ def __getitem__(self, index: int) -> PostprocessRecord:
71
+ """Return one postprocess record by position.
72
+
73
+ Parameters
74
+ ----------
75
+ index : int
76
+ Record position. Position `0` selects the first record.
77
+
78
+ Returns
79
+ -------
80
+ PostprocessRecord
81
+ Selected postprocess record.
82
+ """
83
+
84
+ return self.records[index]
85
+
86
+ def titles(self) -> tuple[str, ...]:
87
+ """Return non-empty postprocess titles in project file order.
88
+
89
+ Returns
90
+ -------
91
+ tuple[str, ...]
92
+ Titles for records that define a title.
93
+ """
94
+
95
+ return tuple(
96
+ record.title for record in self.records if record.title is not None
97
+ )