1
- from pydantic import Field , model_validator
2
- from typing import Tuple , Dict , List , Optional
3
-
4
1
import dataclasses
5
2
import numpy as np
3
+ from pydantic import Field
4
+ from typing import Tuple , Dict , List , Optional
6
5
7
6
from ..core_utils import calculate_line_coordinates_2points
8
7
from ..encoders .converters import short_array_type
@@ -42,7 +41,7 @@ class Sections:
42
41
]
43
42
44
43
# computed/internal (will be serialized too unless excluded)
45
- names : List [ str ] = Field (default_factory = list , exclude = True )
44
+ names : short_array_type = Field (default = np . array ([]) , exclude = True )
46
45
points : List [List [Tuple [float , float ]]] = Field (default_factory = list , exclude = True )
47
46
resolution : List [Tuple [int , int ]] = Field (default_factory = list , exclude = True )
48
47
length : np .ndarray = Field (default_factory = lambda : np .array ([0 ]), exclude = True )
@@ -51,38 +50,13 @@ class Sections:
51
50
values : np .ndarray = Field (default_factory = lambda : np .empty ((0 , 3 )), exclude = True )
52
51
extent : Optional [np .ndarray ] = Field (default = None , exclude = True )
53
52
54
- # def __init__(self, regular_grid=None, z_ext=None, section_dict=None):
55
- # pd = require_pandas()
56
- # if regular_grid is not None:
57
- # self.z_ext = regular_grid.extent[4:]
58
- # else:
59
- # self.z_ext = z_ext
60
- #
61
- # self.section_dict = section_dict
62
- # self.names = []
63
- # self.points = []
64
- # self.resolution = []
65
- # self.length = [0]
66
- # self.dist = []
67
- # self.df = pd.DataFrame()
68
- # self.df['dist'] = self.dist
69
- # self.values = np.empty((0, 3))
70
- # self.extent = None
71
- #
72
- # if section_dict is not None:
73
- # self.set_sections(section_dict)
74
53
def __post_init__ (self ):
75
54
self .initialize_computations ()
76
55
pass
77
56
78
- # @model_validator(mode="after")
79
- # def init_class(self):
80
- # self.initialize_computations()
81
- # return self
82
- #
83
57
def initialize_computations (self ):
84
58
# copy names
85
- self .names = list (self .section_dict .keys ())
59
+ self .names = np . array ( list (self .section_dict .keys () ))
86
60
87
61
# build points/resolution/length
88
62
self ._get_section_params ()
0 commit comments