10
10
from gempy_engine .core .data .input_data_descriptor import InputDataDescriptor
11
11
from gempy_engine .core .data .kernel_classes .faults import FaultsData
12
12
from gempy_engine .core .data .stack_relation_type import StackRelationType
13
+
14
+ from .encoders .binary_encoder import deserialize_input_data_tables
13
15
from .encoders .converters import loading_model_context
14
16
from .orientations import OrientationsTable
15
17
from .structural_element import StructuralElement
@@ -469,29 +471,15 @@ def deserialize_binary(cls, data: Union["StructuralFrame", dict], constructor: M
469
471
case dict ():
470
472
instance : StructuralFrame = constructor (data )
471
473
metadata = data .get ('binary_meta_data' , {})
472
-
473
474
context = loading_model_context .get ()
474
475
475
476
if 'binary_body' not in context :
476
477
return instance
477
478
478
- binary_array = context ['binary_body' ]
479
-
480
- sp_binary = binary_array [:metadata ["sp_binary_length" ]]
481
- ori_binary = binary_array [metadata ["sp_binary_length" ]:]
482
-
483
- # Reconstruct arrays
484
- sp_data : np .ndarray = np .frombuffer (sp_binary , dtype = SurfacePointsTable .dt )
485
- ori_data : np .ndarray = np .frombuffer (ori_binary , dtype = OrientationsTable .dt )
486
-
487
- instance .surface_points = SurfacePointsTable (
488
- data = sp_data ,
489
- name_id_map = instance .surface_points_copy .name_id_map
490
- )
491
-
492
- instance .orientations = OrientationsTable (
493
- data = ori_data ,
494
- name_id_map = instance .orientations_copy .name_id_map
479
+ instance .orientations , instance .surface_points = deserialize_input_data_tables (
480
+ binary_array = context ['binary_body' ],
481
+ name_id_map = instance .surface_points_copy .name_id_map ,
482
+ sp_binary_length_ = metadata ["sp_binary_length" ]
495
483
)
496
484
497
485
return instance
@@ -500,6 +488,7 @@ def deserialize_binary(cls, data: Union["StructuralFrame", dict], constructor: M
500
488
501
489
# Access the context variable to get injected data
502
490
491
+
503
492
@model_validator (mode = "after" )
504
493
def deserialize_surface_points (self : "StructuralFrame" ):
505
494
# Access the context variable to get injected data
@@ -545,27 +534,11 @@ def deserialize_orientations(self: "StructuralFrame"):
545
534
546
535
@computed_field
547
536
def binary_meta_data (self ) -> dict :
548
- sp_data = self .surface_points_copy .data
549
- ori_data = self .orientations_copy .data
550
537
return {
551
- 'sp_shape' : sp_data .shape ,
552
- 'sp_dtype' : str (sp_data .dtype ),
553
- 'sp_binary_length' : len (sp_data .tobytes ()),
554
- 'ori_shape' : ori_data .shape ,
555
- 'ori_dtype' : str (ori_data .dtype ),
556
- 'ori_binary_length' : len (ori_data .tobytes ())
538
+ 'sp_binary_length' : len (self .surface_points_copy .data .tobytes ()),
539
+ # 'ori_binary_length': len(self.orientations_copy.data.tobytes()) * (miguel May 2025) This is not necessary at the moment
557
540
}
558
541
559
- @computed_field
560
- @property
561
- def serialize_sp (self ) -> int :
562
- return int (hashlib .md5 (self .surface_points_copy .data .tobytes ()).hexdigest ()[:8 ], 16 )
563
-
564
- @computed_field
565
- @property
566
- def serialize_orientations (self ) -> int :
567
- return int (hashlib .md5 (self .orientations_copy .data .tobytes ()).hexdigest ()[:8 ], 16 )
568
-
569
542
# endregion
570
543
571
544
def _validate_faults_relations (self ):
0 commit comments