@@ -432,7 +432,7 @@ def from_vector(
432
432
raise NotImplementedError ("%s not yet supported" % dtype )
433
433
434
434
metadata = struct .pack ("<sB" , dtype .value , padding )
435
- data = struct .pack (f"{ len (vector )} { format_str } " , * vector )
435
+ data = struct .pack (f"< { len (vector )} { format_str } " , * vector )
436
436
return cls (metadata + data , subtype = VECTOR_SUBTYPE )
437
437
438
438
def as_vector (self ) -> BinaryVector :
@@ -454,7 +454,7 @@ def as_vector(self) -> BinaryVector:
454
454
455
455
if dtype == BinaryVectorDtype .INT8 :
456
456
dtype_format = "b"
457
- format_string = f"{ n_values } { dtype_format } "
457
+ format_string = f"< { n_values } { dtype_format } "
458
458
vector = list (struct .unpack_from (format_string , self , position ))
459
459
return BinaryVector (vector , dtype , padding )
460
460
@@ -465,13 +465,16 @@ def as_vector(self) -> BinaryVector:
465
465
raise ValueError (
466
466
"Corrupt data. N bytes for a float32 vector must be a multiple of 4."
467
467
)
468
- vector = list (struct .unpack_from (f"{ n_values } f" , self , position ))
468
+ dtype_format = "f"
469
+ format_string = f"<{ n_values } { dtype_format } "
470
+ vector = list (struct .unpack_from (format_string , self , position ))
469
471
return BinaryVector (vector , dtype , padding )
470
472
471
473
elif dtype == BinaryVectorDtype .PACKED_BIT :
472
474
# data packed as uint8
473
475
dtype_format = "B"
474
- unpacked_uint8s = list (struct .unpack_from (f"{ n_values } { dtype_format } " , self , position ))
476
+ format_string = f"<{ n_values } { dtype_format } "
477
+ unpacked_uint8s = list (struct .unpack_from (format_string , self , position ))
475
478
return BinaryVector (unpacked_uint8s , dtype , padding )
476
479
477
480
else :
0 commit comments