@@ -821,10 +821,11 @@ def __str__(self):
821821 def to_binary (self ):
822822 b = []
823823 encoding = self .VariantType .value & 0b111111
824- if type (self .Value ) in (list , tuple ):
824+ if self .is_array or type (self .Value ) in (list , tuple ):
825+ self .is_array = True
826+ encoding = uabin .set_bit (encoding , 7 )
825827 if self .Dimensions is not None :
826828 encoding = uabin .set_bit (encoding , 6 )
827- encoding = uabin .set_bit (encoding , 7 )
828829 b .append (uabin .Primitives .UInt8 .pack (encoding ))
829830 b .append (uabin .pack_uatype_array (self .VariantType , flatten (self .Value )))
830831 if self .Dimensions is not None :
@@ -842,8 +843,6 @@ def from_binary(data):
842843 encoding = ord (data .read (1 ))
843844 int_type = encoding & 0b00111111
844845 vtype = datatype_to_varianttype (int_type )
845- if vtype == VariantType .Null :
846- return Variant (None , vtype , encoding )
847846 if uabin .test_bit (encoding , 7 ):
848847 value = uabin .unpack_uatype_array (vtype , data )
849848 array = True
@@ -886,7 +885,9 @@ def flatten_and_get_shape(mylist):
886885
887886
888887def flatten (mylist ):
889- if len (mylist ) == 0 :
888+ if mylist is None :
889+ return None
890+ elif len (mylist ) == 0 :
890891 return mylist
891892 while isinstance (mylist [0 ], (list , tuple )):
892893 mylist = [item for sublist in mylist for item in sublist ]
0 commit comments