@@ -216,16 +216,25 @@ class TextRegions:
216216 source : Source | None = None
217217 is_extracted_array : np .ndarray = field (default_factory = lambda : np .array ([]))
218218 is_extracted : bool | None = None
219- _optional_array_attributes : list [str ] = field (init = False , default_factory = lambda : ["texts" , "sources" , "is_extracted_array" ])
220- _scalar_to_array_mappings : dict [str , str ] = field (init = False , default_factory = lambda : {
221- "source" : "sources" ,
222- "is_extracted" : "is_extracted_array" ,
223- })
219+ _optional_array_attributes : list [str ] = field (
220+ init = False , default_factory = lambda : ["texts" , "sources" , "is_extracted_array" ]
221+ )
222+ _scalar_to_array_mappings : dict [str , str ] = field (
223+ init = False ,
224+ default_factory = lambda : {
225+ "source" : "sources" ,
226+ "is_extracted" : "is_extracted_array" ,
227+ },
228+ )
224229
225230 def __post_init__ (self ):
226231 element_size = self .element_coords .shape [0 ]
227232 for scalar , array in self ._scalar_to_array_mappings .items ():
228- if getattr (self , scalar ) is not None and getattr (self , array ).size == 0 and element_size :
233+ if (
234+ getattr (self , scalar ) is not None
235+ and getattr (self , array ).size == 0
236+ and element_size
237+ ):
229238 setattr (self , array , np .array ([getattr (self , scalar )] * element_size ))
230239 elif getattr (self , scalar ) is None and getattr (self , array ).size > 0 :
231240 setattr (self , scalar , getattr (self , array )[0 ])
0 commit comments