|
1 | 1 | import dataclasses |
2 | | -from typing import Optional |
| 2 | +from typing import Optional, Callable |
3 | 3 |
|
4 | 4 | import numpy as np |
| 5 | +from pydantic import Field |
5 | 6 |
|
6 | | -from gempy_engine.core.data.transforms import Transform |
| 7 | +from ..encoders.converters import short_array_type |
| 8 | +from ..transforms import Transform |
7 | 9 |
|
8 | 10 |
|
9 | 11 | @dataclasses.dataclass |
10 | 12 | class FiniteFaultData: |
11 | | - implicit_function: callable |
12 | | - implicit_function_transform: Transform |
13 | | - pivot: np.ndarray |
14 | | - |
| 13 | + implicit_function: Callable | None = Field(exclude=True, default=None)#, default=None) |
| 14 | + implicit_function_transform: Transform = Field() |
| 15 | + pivot: short_array_type = Field() |
| 16 | + |
15 | 17 | def apply(self, points: np.ndarray) -> np.ndarray: |
16 | 18 | transformed_points = self.implicit_function_transform.apply_inverse_with_pivot( |
17 | 19 | points=points, |
18 | 20 | pivot=self.pivot |
19 | 21 | ) |
| 22 | + if self.implicit_function is None: |
| 23 | + raise ValueError("No implicit function defined. This can happen after deserializing (loading).") |
| 24 | + |
20 | 25 | scalar_block = self.implicit_function(transformed_points) |
21 | 26 | return scalar_block |
22 | 27 |
|
23 | 28 |
|
24 | 29 |
|
25 | 30 | @dataclasses.dataclass |
26 | 31 | class FaultsData: |
27 | | - fault_values_everywhere: np.ndarray = None |
28 | | - fault_values_on_sp: np.ndarray = None |
| 32 | + fault_values_everywhere: short_array_type | None = None |
| 33 | + fault_values_on_sp: short_array_type | None = None |
29 | 34 |
|
30 | | - fault_values_ref: np.ndarray = None |
31 | | - fault_values_rest: np.ndarray = None |
| 35 | + fault_values_ref: short_array_type | None = None |
| 36 | + fault_values_rest: short_array_type | None = None |
32 | 37 |
|
33 | 38 | # User given data: |
34 | 39 | thickness: Optional[float] = None |
|
0 commit comments