|
4 | 4 | from collections import namedtuple |
5 | 5 | from contextlib import contextmanager |
6 | 6 | from pathlib import Path |
7 | | -from typing import Any, Type |
| 7 | +from typing import Any, Type, TypeVar |
8 | 8 | from typing import Callable |
9 | 9 | from typing import DefaultDict |
10 | 10 | from typing import Dict |
@@ -110,6 +110,7 @@ class ResultsNeedFullReloadError(RuntimeError): |
110 | 110 | class BaseUQMetaData: |
111 | 111 | """ |
112 | 112 | Base class for UQ metadata analysis. |
| 113 | +
|
113 | 114 | :ivar property_id: |
114 | 115 | The property name (holdup, total mass flow rate). |
115 | 116 | :ivar trend_id: |
@@ -151,6 +152,7 @@ class UncertaintyPropagationAnalysesMetaData: |
151 | 152 | class UPItem(BaseUQMetaData): |
152 | 153 | """ |
153 | 154 | A class that hold each uncertainty propagation analyses metadata. |
| 155 | +
|
154 | 156 | :ivar samples: |
155 | 157 | The total samples generate to construct the result. |
156 | 158 | :ivar result_index: |
@@ -280,10 +282,18 @@ class UPResult: |
280 | 282 | """ |
281 | 283 | category: str = attr.ib(validator=attr.validators.optional(attr.validators.instance_of(str))) |
282 | 284 | unit: str = attr.ib(validator=attr.validators.optional(attr.validators.instance_of(str))) |
283 | | - realization_output: List = attr.ib(default=attr.Factory(List)) |
| 285 | + realization_output: List[np.ndarray] = attr.ib(default=attr.Factory(List)) |
284 | 286 | std_result: np.ndarray = attr.ib(default=attr.Factory(lambda: np.array([]))) |
285 | 287 | mean_result: np.ndarray = attr.ib(default=attr.Factory(lambda: np.array([]))) |
286 | | -def read_results_file(result_directory: Path, metadata_class: Type[UQMetadataClass], map_data: Callable, meta_data_attrs: str) -> UQMetadataClass: |
| 288 | + |
| 289 | + |
| 290 | +MetadataClassType = TypeVar("MetadataClassType", bound=UQMetadataClass) |
| 291 | +def read_results_file( |
| 292 | + result_directory: Path, |
| 293 | + metadata_class: Type[MetadataClassType], |
| 294 | + map_data: Callable, |
| 295 | + meta_data_attrs: str) -> MetadataClassType: |
| 296 | + |
287 | 297 | with open_result_file( |
288 | 298 | result_directory, result_filename="result" |
289 | 299 | ) as result_file: |
|
0 commit comments