@@ -14,7 +14,18 @@ class ValuePoints:
1414 values : np .ndarray = field (default_factory = lambda : np .array ([0 ]))
1515 name : str = "unnamed"
1616 properties : Optional [dict ] = None
17-
17+ def __post_init__ (self ):
18+
19+ self .values = np .asarray (self .values )
20+ self .locations = np .asarray (self .locations )
21+ if self .locations .shape [1 ] != 3 :
22+ raise ValueError ('locations must be of shape (n, 3)' )
23+ if len (self .values ) != len (self .locations ):
24+ raise ValueError ('values must be the same length as locations' )
25+ for k , v in (self .properties or {}).items ():
26+ if len (v ) != len (self .locations ):
27+ raise ValueError (f'Property { k } must be the same length as locations' )
28+ self .properties [k ] = np .asarray (v )
1829 def to_dict (self ):
1930 return {
2031 "locations" : self .locations ,
@@ -112,7 +123,17 @@ class VectorPoints:
112123 vectors : np .ndarray = field (default_factory = lambda : np .array ([[0 , 0 , 0 ]]))
113124 name : str = "unnamed"
114125 properties : Optional [dict ] = None
115-
126+ def __post_init__ (self ):
127+ self .vectors = np .asarray (self .vectors )
128+ self .locations = np .asarray (self .locations )
129+ if self .locations .shape [1 ] != 3 :
130+ raise ValueError ('locations must be of shape (n, 3)' )
131+ if len (self .vectors ) != len (self .locations ):
132+ raise ValueError ('vectors must be the same length as locations' )
133+ for k , v in (self .properties or {}).items ():
134+ if len (v ) != len (self .locations ):
135+ raise ValueError (f'Property { k } must be the same length as locations' )
136+ self .properties [k ] = np .asarray (v )
116137 def to_dict (self ):
117138 return {
118139 "locations" : self .locations ,
0 commit comments